|
|
|
|
Re: Syntax Highlighting in Xtext [message #1092758 is a reply to message #1092752] |
Fri, 23 August 2013 06:56 |
|
Hi,
Yes they are already colored.. But in this case i want to color only the keywords which comes inside "{" and "}" braces.. So default color for "start" and different color for details1, details2, details3.. What is the best way to do it. Thanks in advance
Arshad
|
|
|
Re: Syntax Highlighting in Xtext [message #1092759 is a reply to message #1092706] |
Fri, 23 August 2013 06:58 |
|
Hi,
Yes they are already colored.. But in this case i want to color only the keywords which comes inside "{" and "}" braces.. So default color for "start" and different color for details1, details2, details3.. What is the best way to do it. Thanks in advance
Arshad
|
|
|
Re: Syntax Highlighting in Xtext [message #1092760 is a reply to message #1092706] |
Fri, 23 August 2013 06:59 |
|
Hi,
Yes they are already colored.. But in this case i want to color only the keywords which comes inside "{" and "}" braces.. So default color for "start" and different color for details1, details2, details3.. What is the best way to do it. Thanks in advance
Arshad
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Re: Syntax Highlighting in Xtext [message #1093547 is a reply to message #1093159] |
Sat, 24 August 2013 08:13 |
|
Hi Christian,
I have overridden the:
protected String calculateId(final String tokenName, final int tokenType) {} method from DefaultAntlrTokenToAttributeIdMapper class and now I am able to get all my tokens.
I removed invalid tokens for me like "RULE_STRING", "RULE_INT", all punctuation etc. But still how do I avoid "start" in:
start Sample{
details1 "Some details"
details2 20
details3 "Some data"
}
Do I have any other way than hardcoding this value ?? Because I will have a problem if a string literal is changed in the grammar.
Thanks in advance !! :)
Regards,
Arshad
Arshad
[Updated on: Sat, 24 August 2013 08:14] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
Re: Syntax Highlighting in Xtext [message #1730287 is a reply to message #1730286] |
Sat, 23 April 2016 14:38 |
|
yes you can
class MyDslUiModule extends AbstractMyDslUiModule {
def Class<? extends ISemanticHighlightingCalculator> bindISemanticHighlightingCalculator() {
MyDslSemanticHighlightingCalculator
}
}
public class MyDslSemanticHighlightingCalculator extends DefaultSemanticHighlightingCalculator{
@Inject
MyDslGrammarAccess ga;
@Override
public void provideHighlightingFor(XtextResource resource, IHighlightedPositionAcceptor acceptor,
CancelIndicator cancelIndicator) {
ICompositeNode rootNode = resource.getParseResult().getRootNode();
for (INode node : rootNode.getAsTreeIterable()) {
if (node.getGrammarElement() == ga.getGreetingAccess().getNameIDTerminalRuleCall_1_0()) {
acceptor.addPosition(node.getOffset(), node.getLength(), DefaultHighlightingConfiguration.KEYWORD_ID);
}
}
super.provideHighlightingFor(resource, acceptor, cancelIndicator);
}
}
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
|
Powered by
FUDForum. Page generated in 0.09577 seconds