|
|
|
|
Re: Terminal rule keywords highlighting [message #1733252 is a reply to message #1733229] |
Wed, 25 May 2016 17:32 |
|
Looks like you have 2 missunderstandings at one
- how the node model grammar elements look like
- how the api of the accept method looks like
class JPLSemanticHighlightingCalculator implements
ISemanticHighlightingCalculator {
override provideHighlightingFor(XtextResource resource,
IHighlightedPositionAcceptor acceptor,
CancelIndicator cancelIndicator) {
val ICompositeNode rootNode = resource.getParseResult().getRootNode();
val BidiTreeIterator<INode> it = rootNode.getAsTreeIterable().iterator();
while (it.hasNext) {
val INode node = it.next();
if (node.getGrammarElement() instanceof RuleCall) {
val rc = node.getGrammarElement() as RuleCall
val rule = rc.getRule()
if (rule instanceof TerminalRule) {
val s = node.text
println("Node ######################### " + s)
acceptor.addPosition(node.getOffset(), node.getLength(),
DefaultHighlightingConfiguration.KEYWORD_ID);
}
}
}
}
}
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
Powered by
FUDForum. Page generated in 0.80488 seconds