Search in sources :

Example 6 with AbstractNode

use of org.eclipse.xtext.nodemodel.impl.AbstractNode in project xtext-core by eclipse.

the class AbstractNodeTest method testGetNextSibling_FirstChild.

@Test
public void testGetNextSibling_FirstChild() {
    ICompositeNode rootNode = builder.newRootNode("input");
    AbstractNode first = createNode();
    AbstractNode second = createNode();
    builder.addChild(rootNode, first);
    builder.addChild(rootNode, second);
    assertTrue(first.hasNextSibling());
    assertSame(second, first.getNextSibling());
}
Also used : AbstractNode(org.eclipse.xtext.nodemodel.impl.AbstractNode) Test(org.junit.Test)

Example 7 with AbstractNode

use of org.eclipse.xtext.nodemodel.impl.AbstractNode in project xtext-core by eclipse.

the class AbstractNodeTest method testGetRootNode.

@Test
public void testGetRootNode() {
    AbstractNode node = createNode();
    ICompositeNode rootNode = builder.newRootNode("My input");
    builder.addChild(rootNode, node);
    assertSame(rootNode, node.getRootNode());
}
Also used : AbstractNode(org.eclipse.xtext.nodemodel.impl.AbstractNode) Test(org.junit.Test)

Example 8 with AbstractNode

use of org.eclipse.xtext.nodemodel.impl.AbstractNode in project xtext-core by eclipse.

the class AbstractNodeTest method testGetNextSibling_SingleChild.

@Test
public void testGetNextSibling_SingleChild() {
    ICompositeNode rootNode = builder.newRootNode("input");
    AbstractNode node = createNode();
    builder.addChild(rootNode, node);
    assertFalse(node.hasNextSibling());
    assertNull(node.getNextSibling());
}
Also used : AbstractNode(org.eclipse.xtext.nodemodel.impl.AbstractNode) Test(org.junit.Test)

Example 9 with AbstractNode

use of org.eclipse.xtext.nodemodel.impl.AbstractNode in project xtext-core by eclipse.

the class AbstractNodeTest method testIterator_Next.

@Test
public void testIterator_Next() {
    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
    }
}
Also used : AbstractNode(org.eclipse.xtext.nodemodel.impl.AbstractNode) NoSuchElementException(java.util.NoSuchElementException) Test(org.junit.Test)

Example 10 with AbstractNode

use of org.eclipse.xtext.nodemodel.impl.AbstractNode in project xtext-core by eclipse.

the class AbstractNodeTest method testGetParent.

@Test
public void testGetParent() {
    AbstractNode node = createNode();
    ICompositeNode parent = builder.newRootNode("input");
    builder.addChild(parent, node);
    assertSame(parent, node.getParent());
}
Also used : AbstractNode(org.eclipse.xtext.nodemodel.impl.AbstractNode) Test(org.junit.Test)

Aggregations

AbstractNode (org.eclipse.xtext.nodemodel.impl.AbstractNode)25 Test (org.junit.Test)22 NoSuchElementException (java.util.NoSuchElementException)6 ILeafNode (org.eclipse.xtext.nodemodel.ILeafNode)3 ICompositeNode (org.eclipse.xtext.nodemodel.ICompositeNode)2 CompositeNode (org.eclipse.xtext.nodemodel.impl.CompositeNode)2 SyntheticCompositeNode (org.eclipse.xtext.nodemodel.impl.SyntheticCompositeNode)2 INode (org.eclipse.xtext.nodemodel.INode)1