Replacing STRING terminal/skip inserting closing terminal [message #1386648] |
Thu, 19 June 2014 01:59  |
Eclipse User |
|
|
|
In a simple DSL example that uses the STRING terminal defined in Terminals, there is a nice feature that skips the closing terminal, e.g. typing
" => "" // two quotes and the cursor in between
a => "a"
b => "ab"
c => "abc"
" => "abc" // the closing quote is not inserted
In my DSL we aren't using STRING. Instead we have defined two terminals, one for single quoted strings and one for double quoted strings, SINGLE_STRING and DOUBLE_STRING.
The problem is that we have lost the nice closing terminal skipping feature - using the same example as above, the result is instead:
"abc"""
If I name one of my terminal rules STRING then I get the closing terminal skipping behavior for that rule, but not for the other. It seems that the terminal name STRING is treated special?
I've looked into extending DefaultAutoEditStrategyProvider and PartitionEndSkippingEditStrategy as they seem related/involved, but haven't come up with a solution.
Is there a way to do this?
Thanks!
dan
|
|
|
|
Re: Replacing STRING terminal/skip inserting closing terminal [message #1386717 is a reply to message #1386662] |
Thu, 19 June 2014 15:29  |
Eclipse User |
|
|
|
Hi,
Ok, I see - I extended TerminalsTokenTypeToPartitionMapper to override calculateId to additionally check for my RULE_SINGLE_STRING and RULE_DOUBLE_STRING returning STRING_LITERAL_PARITION.
The only piece left that gave me some trouble was to know where to bind my MyTerminalsTokenTypeToParitionMapper ... I ended up using this in class MyDSLUiModule:
public Class<? extends TerminalsTokenTypeToPartitionMapper> bindTerminalsTokenTypeToPartitionMapper() {
return MyDSLTerminalsTokenTypeToPartitionMapper.class ;
}
@Override
public Class<? extends AbstractEditStrategyProvider> bindAbstractEditStrategyProvider() {
return MyDSLAutoEditStrategyProvider.class;
}
Good news is that it's working - thanks Christian!
|
|
|
Powered by
FUDForum. Page generated in 3.04140 seconds