|
|
|
|
|
|
|
|
|
|
Re: Handling older files which contain unescaped keywords [message #1731767 is a reply to message #1731766] |
Tue, 10 May 2016 05:47 |
|
what about letting the computer do that job for you
import org.eclipse.xtext.GrammarUtil;
import org.eclipse.xtext.IGrammarAccess;
import com.google.inject.Injector;
public class Main {
public static void main(String[] args) {
Injector injector = new MyDslStandaloneSetup().createInjectorAndDoEMFRegistration();
IGrammarAccess ga = injector.getInstance(IGrammarAccess.class);
System.out.println(GrammarUtil.getAllKeywords(ga.getGrammar()));
}
}
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
|
|
|
|
|
|
|
|
|
|
Re: Handling older files which contain unescaped keywords [message #1731843 is a reply to message #1731832] |
Tue, 10 May 2016 12:51 |
Jason Pell Messages: 55 Registered: February 2011 |
Member |
|
|
Am I right that the carets actually do remain in the Node model, but are removed from the emf one. So that is why the carets are re-serialized by default.
What would be the recommended interface to override in order to remove the caret from the node before serializing? I can see I have several choices.
I can implement a IValueSerializer, but when I extend org.eclipse.xtext.serializer.tokens.ValueSerializer, eclipse warns me that this is not a good idea, so should I re-implement the entirety of the IValueSerializer?
Or should I override the TokenUtil class which is used by the org.eclipse.xtext.serializer.tokens.ValueSerializer
Any others I have missed.
[Updated on: Tue, 10 May 2016 12:57] Report message to a moderator
|
|
|
|
Re: Handling older files which contain unescaped keywords [message #1731848 is a reply to message #1731846] |
Tue, 10 May 2016 13:10 |
Jason Pell Messages: 55 Registered: February 2011 |
Member |
|
|
I am not sure if this is a good idea or not, would appreciate your opinion.
@SuppressWarnings("restriction")
public class MyDslValueSerializer extends ValueSerializer {
public String serializeAssignedValue(EObject context, RuleCall ruleCall, Object value, INode node, Acceptor errors) {
String name = ruleCall.getRule().getName();
if ("MyID".equals(name)) {
// passing 'null' node, to force use of value converter
return super.serializeAssignedValue(context, ruleCall, value, null, errors);
} else {
return super.serializeAssignedValue(context, ruleCall, value, node, errors);
}
}
}
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.06512 seconds