Text: Adjacent partitions of same content type not merged? [message #331738] |
Thu, 18 September 2008 19:58 ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Eclipse User![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=) |
|
|
|
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 message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Eclipse User![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=) |
|
|
|
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
|
|
|
|
Powered by
FUDForum. Page generated in 0.03165 seconds