How to deal with partitions when partition is not terminal [message #652311] |
Thu, 03 February 2011 14:38  |
Eclipse User |
|
|
|
Hi,
The implementation of ITokenTypeToPartitionTypeMapper
creates text partitions based on lexer tokens (i.e. for comments or
strings). My strings are not a single terminal and are instead handled
as data type rules.
I created my own implementation of ITokenTypeToPartitionTypeMapper and
by marking all parts included in strings (except WS) auto edits work a
lot better. I would however like to protect against insertion of ML
comments when seeing /* in a string even if caret is after a WS in the
string.
I am wondering if I can assume that the #getPartitionType(int
antlrToken) will be called with *all* tokens thus making it possible to
detect the start and end of strings. However since the default
implementation of ITokenTypeToPartitionTypeMapper is marked as
@Singleton it makes me wonder if it is possible to maintain state.
If I mark it as a non singleton, will it be recreated lots and lots of
times? etc.
Any other suggestions how to handle non terminal string partitions?
Regards
- henrik
|
|
|
Re: How to deal with partitions when partition is not terminal [message #652413 is a reply to message #652311] |
Thu, 03 February 2011 19:06  |
Eclipse User |
|
|
|
Sorry, obviously sent to the wrong forum :)
Now reposted where it was supposed to be sent... (tmf).
Sorry for the noise...
- henrik
On 2/3/11 3:38 PM, Henrik Lindberg wrote:
> Hi,
> The implementation of ITokenTypeToPartitionTypeMapper
> creates text partitions based on lexer tokens (i.e. for comments or
> strings). My strings are not a single terminal and are instead handled
> as data type rules.
>
> I created my own implementation of ITokenTypeToPartitionTypeMapper and
> by marking all parts included in strings (except WS) auto edits work a
> lot better. I would however like to protect against insertion of ML
> comments when seeing /* in a string even if caret is after a WS in the
> string.
>
> I am wondering if I can assume that the #getPartitionType(int
> antlrToken) will be called with *all* tokens thus making it possible to
> detect the start and end of strings. However since the default
> implementation of ITokenTypeToPartitionTypeMapper is marked as
> @Singleton it makes me wonder if it is possible to maintain state.
> If I mark it as a non singleton, will it be recreated lots and lots of
> times? etc.
>
> Any other suggestions how to handle non terminal string partitions?
>
> Regards
> - henrik
|
|
|
Powered by
FUDForum. Page generated in 0.05826 seconds