Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Text: Adjacent partitions of same content type not merged?
Text: Adjacent partitions of same content type not merged? [message #331738] Thu, 18 September 2008 19:58 Go to next message
Eclipse UserFriend
Originally posted by: bsv.datatel.com

I'm writing a SourceViewer for a language similar to Java. I'd like to
partition the document into 4 buckets:

#1 Single line comments
#2 Multi line comments
#3 String literals
#4 Everything else

I'm running into trouble on #4. What I've got is a subclass of
RuleBasedPartitionScanner that looks something like this:

List<IPredicateRule> rules = new ArrayList<IPredicateRule>();

// Single line comments
rules.add(new EndOfLineRule("//", TokenType.COMMENT_SINGLE));

// Multi line comments
rules.add(new MultiLineRule("/*", "*/", TokenType.COMMENT_MULTI));

// String literals
rules.add(new SingleLineRule("\"", "\"", TokenType.LITERAL_STR));

setDefaultReturnToken(DEFAULT);
setPredicateRules(rules.toArray(new IPredicateRule [rules.size()]));

The FastPartitioner is working fine for the first 3 types. But
"everything else" is getting detected as a bunch of 1-character tokens
of the same default type.

So I guess my question is two-part:

1) Is there a reason that adjacent tokens of the same content type are
not merged into a single partition?

2) What is the best way to get a big block of "everything else" code
detected as a single block with the default content type?

Thanks,
Ben
Re: Text: Adjacent partitions of same content type not merged? [message #331820 is a reply to message #331738] Tue, 23 September 2008 21:04 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: bsv.datatel.com

<<ping>>

Anyone? :)

Ben Vitale wrote:
> I'm writing a SourceViewer for a language similar to Java. I'd like to
> partition the document into 4 buckets:
>
> #1 Single line comments
> #2 Multi line comments
> #3 String literals
> #4 Everything else
>
> I'm running into trouble on #4. What I've got is a subclass of
> RuleBasedPartitionScanner that looks something like this:
>
> List<IPredicateRule> rules = new ArrayList<IPredicateRule>();
>
> // Single line comments
> rules.add(new EndOfLineRule("//", TokenType.COMMENT_SINGLE));
>
> // Multi line comments
> rules.add(new MultiLineRule("/*", "*/", TokenType.COMMENT_MULTI));
>
> // String literals
> rules.add(new SingleLineRule("\"", "\"", TokenType.LITERAL_STR));
>
> setDefaultReturnToken(DEFAULT);
> setPredicateRules(rules.toArray(new IPredicateRule [rules.size()]));
>
> The FastPartitioner is working fine for the first 3 types. But
> "everything else" is getting detected as a bunch of 1-character tokens
> of the same default type.
>
> So I guess my question is two-part:
>
> 1) Is there a reason that adjacent tokens of the same content type are
> not merged into a single partition?
>
> 2) What is the best way to get a big block of "everything else" code
> detected as a single block with the default content type?
>
> Thanks,
> Ben
Re: Text: Adjacent partitions of same content type not merged? [message #331837 is a reply to message #331820] Wed, 24 September 2008 16:31 Go to previous message
Eclipse UserFriend
Originally posted by: bsv.datatel.com

I believe I have this sorted out. The key was the content types. I left
my partition scanner alone, but made sure that the 3 content types it
was returning in its tokens were specified as legal types in the
FastPartitioner constructor.
Previous Topic:FilteredResourcesSelectionDialog pattern and behavior for derived resources
Next Topic:Eclipse 3.4/3.5 M2 build issue
Goto Forum:
  


Current Time: Fri Nov 08 23:37:18 GMT 2024

Powered by FUDForum. Page generated in 0.02725 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top