use of org.eclipse.xtext.nodemodel.impl.AbstractNode in project xtext-core by eclipse.
the class AbstractNodeTest method testGetPreviousSibling_LastChild.
@Test
public void testGetPreviousSibling_LastChild() {
ICompositeNode rootNode = builder.newRootNode("input");
AbstractNode first = createNode();
AbstractNode second = createNode();
builder.addChild(rootNode, first);
builder.addChild(rootNode, second);
assertTrue(second.hasPreviousSibling());
assertSame(first, second.getPreviousSibling());
assertTrue(second.hasSiblings());
}
use of org.eclipse.xtext.nodemodel.impl.AbstractNode in project xtext-core by eclipse.
the class AbstractNodeTest method testTreeIterator_Bidi_NoParent.
@Test
public void testTreeIterator_Bidi_NoParent() {
AbstractNode node = createNode();
BidiIterator<INode> iterator = node.iterator();
assertSame(node, iterator.next());
assertTrue(iterator.hasPrevious());
assertSame(node, iterator.previous());
assertTrue(iterator.hasNext());
}
use of org.eclipse.xtext.nodemodel.impl.AbstractNode in project xtext-core by eclipse.
the class AbstractNodeTest method testTreeIterator_Next.
@Test
public void testTreeIterator_Next() {
ICompositeNode rootNode = builder.newRootNode("input");
AbstractNode node = createNode();
builder.addChild(rootNode, node);
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
}
}
use of org.eclipse.xtext.nodemodel.impl.AbstractNode in project xtext-core by eclipse.
the class AbstractNodeTest method testGetNextSibling_LastChild.
@Test
public void testGetNextSibling_LastChild() {
ICompositeNode rootNode = builder.newRootNode("input");
AbstractNode first = createNode();
AbstractNode second = createNode();
builder.addChild(rootNode, first);
builder.addChild(rootNode, second);
assertFalse(second.hasNextSibling());
assertNull(second.getNextSibling());
}
use of org.eclipse.xtext.nodemodel.impl.AbstractNode in project dsl-devkit by dsldevkit.
the class FixedPartialParsingHelper method isRangePartOfExceedingLookAhead.
private boolean isRangePartOfExceedingLookAhead(final CompositeNode node, final 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;
}
Aggregations