Search in sources :

Example 6 with PRFNamed

use of org.eclipse.xtext.parser.fragments.fragmentTestLanguage.PRFNamed in project xtext-core by eclipse.

the class AbstractFragmentsTest method testActionInFragmentAndReference_02.

@Test
@Ignore("Actions are currently not supported in fragments")
public void testActionInFragmentAndReference_02() {
    final ParserRuleFragments fragments = this.parseAndValidate("#6 prev current current - prev");
    Assert.assertNotNull(fragments);
    final PRFNamed element = fragments.getElement();
    Assert.assertEquals("current", element.getName());
    final PRFNamed prev = ((PRFNamedWithAction) element).getPrev();
    Assert.assertEquals("prev", prev.getName());
    Assert.assertEquals(prev, element.getRef());
    Assert.assertEquals(element, ((PRFNamedWithAction) element).getRef2());
}
Also used : ParserRuleFragments(org.eclipse.xtext.parser.fragments.fragmentTestLanguage.ParserRuleFragments) PRFNamedWithAction(org.eclipse.xtext.parser.fragments.fragmentTestLanguage.PRFNamedWithAction) PRFNamed(org.eclipse.xtext.parser.fragments.fragmentTestLanguage.PRFNamed) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 7 with PRFNamed

use of org.eclipse.xtext.parser.fragments.fragmentTestLanguage.PRFNamed in project xtext-core by eclipse.

the class AbstractFragmentsTest method testFragmentRecursive_04.

@Test
public void testFragmentRecursive_04() {
    final ParserRuleFragments fragments = this.parseAndValidate("#11 myName ((myPrev))");
    Assert.assertNotNull(fragments);
    Assert.assertEquals("myName", fragments.getElement().getName());
    PRFNamed _element = fragments.getElement();
    final PRFNamed prev = ((PRFNamedWithAction) _element).getPrev();
    Assert.assertEquals("myPrev", prev.getName());
    final ICompositeNode node = NodeModelUtils.findActualNodeFor(prev);
    Assert.assertEquals("myPrev", node.getText());
    final EObject lookup = NodeModelUtils.findActualSemanticObjectFor(node);
    Assert.assertSame(prev, lookup);
}
Also used : ParserRuleFragments(org.eclipse.xtext.parser.fragments.fragmentTestLanguage.ParserRuleFragments) PRFNamedWithAction(org.eclipse.xtext.parser.fragments.fragmentTestLanguage.PRFNamedWithAction) EObject(org.eclipse.emf.ecore.EObject) ICompositeNode(org.eclipse.xtext.nodemodel.ICompositeNode) PRFNamed(org.eclipse.xtext.parser.fragments.fragmentTestLanguage.PRFNamed) Test(org.junit.Test)

Example 8 with PRFNamed

use of org.eclipse.xtext.parser.fragments.fragmentTestLanguage.PRFNamed in project xtext-core by eclipse.

the class AbstractFragmentsTest method testActionInFragmentAndReferenceLoop.

@Test
@Ignore("Actions are currently not supported in fragments")
public void testActionInFragmentAndReferenceLoop() {
    final ParserRuleFragments fragments = this.parseAndValidate("#7 root -> a a -> b b -> c c - root");
    Assert.assertNotNull(fragments);
    PRFNamed element = fragments.getElement();
    while ((element instanceof PRFNamedWithAction)) {
        {
            Assert.assertEquals(element, ((PRFNamedWithAction) element).getRef2());
            element = ((PRFNamedWithAction) element).getPrev();
        }
    }
    Assert.assertEquals(element, element.getRef());
}
Also used : ParserRuleFragments(org.eclipse.xtext.parser.fragments.fragmentTestLanguage.ParserRuleFragments) PRFNamedWithAction(org.eclipse.xtext.parser.fragments.fragmentTestLanguage.PRFNamedWithAction) PRFNamed(org.eclipse.xtext.parser.fragments.fragmentTestLanguage.PRFNamed) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 9 with PRFNamed

use of org.eclipse.xtext.parser.fragments.fragmentTestLanguage.PRFNamed in project xtext-core by eclipse.

the class AbstractFragmentsTest method testActionAndReference.

@Test
public void testActionAndReference() {
    final ParserRuleFragments fragments = this.parseAndValidate("#4 prev current prev current");
    Assert.assertNotNull(fragments);
    final PRFNamed element = fragments.getElement();
    Assert.assertEquals("current", element.getName());
    final PRFNamed prev = ((PRFNamedWithAction) element).getPrev();
    Assert.assertEquals("prev", prev.getName());
    Assert.assertEquals(prev, element.getRef());
    Assert.assertEquals(element, ((PRFNamedWithAction) element).getRef2());
}
Also used : ParserRuleFragments(org.eclipse.xtext.parser.fragments.fragmentTestLanguage.ParserRuleFragments) PRFNamedWithAction(org.eclipse.xtext.parser.fragments.fragmentTestLanguage.PRFNamedWithAction) PRFNamed(org.eclipse.xtext.parser.fragments.fragmentTestLanguage.PRFNamed) Test(org.junit.Test)

Example 10 with PRFNamed

use of org.eclipse.xtext.parser.fragments.fragmentTestLanguage.PRFNamed in project xtext-core by eclipse.

the class AbstractFragmentsTest method testFragmentRecursive_01.

@Test
public void testFragmentRecursive_01() {
    final ParserRuleFragments fragments = this.parseAndValidate("#10 myName myPrev");
    Assert.assertNotNull(fragments);
    Assert.assertEquals("myName", fragments.getElement().getName());
    PRFNamed _element = fragments.getElement();
    final PRFNamed prev = ((PRFNamedWithAction) _element).getPrev();
    Assert.assertEquals("myPrev", prev.getName());
    final ICompositeNode node = NodeModelUtils.findActualNodeFor(prev);
    Assert.assertEquals(" myPrev", node.getText());
    final EObject lookup = NodeModelUtils.findActualSemanticObjectFor(node);
    Assert.assertSame(prev, lookup);
}
Also used : ParserRuleFragments(org.eclipse.xtext.parser.fragments.fragmentTestLanguage.ParserRuleFragments) PRFNamedWithAction(org.eclipse.xtext.parser.fragments.fragmentTestLanguage.PRFNamedWithAction) EObject(org.eclipse.emf.ecore.EObject) ICompositeNode(org.eclipse.xtext.nodemodel.ICompositeNode) PRFNamed(org.eclipse.xtext.parser.fragments.fragmentTestLanguage.PRFNamed) Test(org.junit.Test)

Aggregations

PRFNamed (org.eclipse.xtext.parser.fragments.fragmentTestLanguage.PRFNamed)21 ParserRuleFragments (org.eclipse.xtext.parser.fragments.fragmentTestLanguage.ParserRuleFragments)16 Test (org.junit.Test)14 PRFNamedWithAction (org.eclipse.xtext.parser.fragments.fragmentTestLanguage.PRFNamedWithAction)13 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)5 Ignore (org.junit.Ignore)5 EObject (org.eclipse.emf.ecore.EObject)4 ICompositeNode (org.eclipse.xtext.nodemodel.ICompositeNode)4 EPackage (org.eclipse.emf.ecore.EPackage)2 Action (org.eclipse.xtext.Action)2 Parameter (org.eclipse.xtext.Parameter)2 ParserRule (org.eclipse.xtext.ParserRule)2