use of org.eclipse.xtext.parsetree.reconstr.impl.NodeIterator in project xtext-core by eclipse.
the class NodeIteratorTest method checkDescending.
protected void checkDescending(int index) {
int i = index;
NodeIterator nodeIterator = new NodeIterator(nodes[i]);
while (nodeIterator.hasPrevious()) {
assertEquals(nodes[--i], nodeIterator.previous());
}
}
use of org.eclipse.xtext.parsetree.reconstr.impl.NodeIterator in project xtext-core by eclipse.
the class NodeIteratorTest method checkAscending.
protected void checkAscending(int index) {
int i = index;
NodeIterator nodeIterator = new NodeIterator(nodes[i]);
while (nodeIterator.hasNext()) {
assertEquals("Ascending " + i, nodes[++i], nodeIterator.next());
}
}
use of org.eclipse.xtext.parsetree.reconstr.impl.NodeIterator in project xtext-core by eclipse.
the class EmitterNodeIterator method next.
@Override
public INode next() {
INode result;
if (!next.isEmpty()) {
result = next.get(0);
next.remove(0);
} else
result = null;
if (next.isEmpty())
while (iterator.hasNext()) {
INode next = iterator.next();
if (next.getOffset() >= end)
break;
if (include(next)) {
if (!passAbsorber && isAbsorber(next))
break;
if (allowHidden && next instanceof ICompositeNode && (GrammarUtil.isDatatypeRuleCall(next.getGrammarElement()) || GrammarUtil.isEnumRuleCall(next.getGrammarElement()) || next.getGrammarElement() instanceof CrossReference)) {
NodeIterator ni = new NodeIterator(next);
while (ni.hasNext()) {
INode next2 = ni.next();
if (next2 instanceof ILeafNode && ((ILeafNode) next2).isHidden())
this.next.add(next2);
else
break;
}
}
iterator.prune();
this.next.add(next);
return result;
}
}
return result;
}
use of org.eclipse.xtext.parsetree.reconstr.impl.NodeIterator in project xtext-core by eclipse.
the class HiddenTokenSequencer method getTrailingCommentsIncludingWhitespace.
protected Set<INode> getTrailingCommentsIncludingWhitespace(ILeafNode node) {
Set<INode> associatedNodes = Sets.newHashSet();
Set<INode> pendingWhitespace = Sets.newHashSet();
INode lastLink = node;
NodeIterator ni = new NodeIterator(lastLink);
while (ni.hasNext()) {
INode next = ni.next();
if (tokenUtil.isCommentNode(next)) {
if (isTrailingCommentFor(next, lastLink)) {
lastLink = next;
associatedNodes.addAll(pendingWhitespace);
associatedNodes.add(next);
} else {
break;
}
} else if (tokenUtil.isWhitespaceNode(next)) {
pendingWhitespace.add(next);
} else if (next instanceof ILeafNode) {
break;
}
}
return associatedNodes;
}
use of org.eclipse.xtext.parsetree.reconstr.impl.NodeIterator in project xtext-core by eclipse.
the class HiddenTokenSequencer method getRemainingHiddenNodesInContainer.
protected List<INode> getRemainingHiddenNodesInContainer(INode from, INode root) {
if (from == null || root == null)
return Collections.emptyList();
List<INode> out = Lists.newArrayList();
NodeIterator ni = new NodeIterator(from);
while (ni.hasNext()) {
INode next = ni.next();
if (next.getTotalOffset() > root.getTotalEndOffset())
return out;
else if (tokenUtil.isWhitespaceOrCommentNode(next)) {
out.add(next);
} else if (tokenUtil.isToken(next))
return Collections.emptyList();
}
return out;
}
Aggregations