use of org.eclipse.xtext.nodemodel.impl.AbstractNode in project xtext-core by eclipse.
the class PartialParsingHelper method isRangePartOfExceedingLookAhead.
private boolean isRangePartOfExceedingLookAhead(CompositeNode node, ReplaceRegion replaceRegion) {
TreeIterator<AbstractNode> iterator = node.basicIterator();
int lookAhead = node.getLookAhead();
if (lookAhead == 0) {
return false;
}
while (iterator.hasNext()) {
AbstractNode child = iterator.next();
if (child instanceof CompositeNode) {
if (child.getTotalOffset() < replaceRegion.getEndOffset())
lookAhead = Math.max(((CompositeNode) child).getLookAhead(), lookAhead);
} else if (!((ILeafNode) child).isHidden()) {
lookAhead--;
if (lookAhead == 0) {
if (child.getTotalOffset() >= replaceRegion.getEndOffset())
return false;
}
}
}
return lookAhead > 0;
}
use of org.eclipse.xtext.nodemodel.impl.AbstractNode in project xtext-core by eclipse.
the class AbstractNodeTest method testGetRootNode_NoRoot.
@Test
public void testGetRootNode_NoRoot() {
AbstractNode node = createNode();
ICompositeNode parent = new CompositeNode();
builder.addChild(parent, node);
assertNull(node.getRootNode());
}
use of org.eclipse.xtext.nodemodel.impl.AbstractNode in project xtext-core by eclipse.
the class AbstractNodeTest method testGetPreviousSibling_SingleChild.
@Test
public void testGetPreviousSibling_SingleChild() {
ICompositeNode rootNode = builder.newRootNode("input");
AbstractNode node = createNode();
builder.addChild(rootNode, node);
assertFalse(node.hasPreviousSibling());
assertNull(node.getPreviousSibling());
assertFalse(node.hasSiblings());
}
use of org.eclipse.xtext.nodemodel.impl.AbstractNode in project xtext-core by eclipse.
the class AbstractNodeTest method testGetParent_NoParent.
@Test
public void testGetParent_NoParent() {
AbstractNode node = createNode();
assertNull(node.getParent());
}
use of org.eclipse.xtext.nodemodel.impl.AbstractNode in project xtext-core by eclipse.
the class AbstractNodeTest method testTreeIterator_Next_NoParent.
@Test
public void testTreeIterator_Next_NoParent() {
AbstractNode node = createNode();
BidiIterator<INode> iterator = node.iterator();
assertTrue(iterator.hasNext());
assertSame(node, iterator.next());
assertFalse(iterator.hasNext());
try {
iterator.next();
fail("Expected NoSuchElementException");
} catch (NoSuchElementException e) {
// ok
}
}
Aggregations