Search in sources :

Example 16 with AbstractNode

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

the class AbstractNodeTest method testTreeIterator_Previous.

@Test
public void testTreeIterator_Previous() {
    ICompositeNode rootNode = builder.newRootNode("input");
    AbstractNode node = createNode();
    builder.addChild(rootNode, node);
    BidiIterator<INode> iterator = node.iterator();
    assertTrue(iterator.hasPrevious());
    assertSame(node, iterator.previous());
    assertFalse(iterator.hasPrevious());
    try {
        iterator.previous();
        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 17 with AbstractNode

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

the class AbstractNodeTest method testTreeIterator_Bidi.

@Test
public void testTreeIterator_Bidi() {
    ICompositeNode rootNode = builder.newRootNode("input");
    AbstractNode node = createNode();
    builder.addChild(rootNode, node);
    BidiIterator<INode> iterator = node.iterator();
    assertSame(node, iterator.next());
    assertTrue(iterator.hasPrevious());
    assertSame(node, iterator.previous());
    assertTrue(iterator.hasNext());
}
Also used : AbstractNode(org.eclipse.xtext.nodemodel.impl.AbstractNode) Test(org.junit.Test)

Example 18 with AbstractNode

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

the class AbstractNodeTest method testGetRootNode_Parent.

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

Example 19 with AbstractNode

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

the class AbstractNodeTest method testTreeIterator_Previous_NoParent.

@Test
public void testTreeIterator_Previous_NoParent() {
    AbstractNode node = createNode();
    BidiIterator<INode> iterator = node.iterator();
    assertTrue(iterator.hasPrevious());
    assertSame(node, iterator.previous());
    assertFalse(iterator.hasPrevious());
    try {
        iterator.previous();
        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 20 with AbstractNode

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

the class AbstractNodeTest method testGetText_NoParent.

@Test
public void testGetText_NoParent() {
    AbstractNode node = createNode();
    assertNull(node.getText());
}
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