use of org.eclipse.xtext.nodemodel.BidiTreeIterator in project xtext-core by eclipse.
the class Range method mergeAllSyntaxErrors.
public void mergeAllSyntaxErrors(INode node) {
if (node.getSyntaxErrorMessage() != null)
merge(node);
else {
// first syntax error
boolean errorSeen = false;
{
BidiTreeIterator<INode> iterator = node.getAsTreeIterable().iterator();
while (!errorSeen && iterator.hasNext()) {
INode next = iterator.next();
if (next.getSyntaxErrorMessage() != null) {
merge(next);
errorSeen = true;
}
}
}
// last syntax error
if (errorSeen) {
BidiTreeIterator<INode> iterator = node.getAsTreeIterable().iterator();
errorSeen = false;
while (!errorSeen && iterator.hasPrevious()) {
INode prev = iterator.previous();
if (prev.getSyntaxErrorMessage() != null) {
merge(prev);
errorSeen = true;
} else if (prev instanceof ILeafNode) {
// do not have a grammar element assigned
if (prev.getGrammarElement() == null) {
merge(prev);
errorSeen = true;
}
}
}
}
}
}
Aggregations