Search in sources :

Example 16 with ParserRuleFragments

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

the class AbstractFragmentsTest method testReferenceBeforeFragment.

@Test
public void testReferenceBeforeFragment() {
    final ParserRuleFragments fragments = this.parseAndValidate("#3 myName <- myName");
    Assert.assertNotNull(fragments);
    Assert.assertEquals("myName", fragments.getElement().getName());
    Assert.assertEquals(fragments.getElement(), fragments.getElement().getRef());
}
Also used : ParserRuleFragments(org.eclipse.xtext.parser.fragments.fragmentTestLanguage.ParserRuleFragments) Test(org.junit.Test)

Example 17 with ParserRuleFragments

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

the class AbstractFragmentsTest method testActionInFragment_01.

@Test
@Ignore("Actions are currently not supported in fragments")
public void testActionInFragment_01() {
    final ParserRuleFragments fragments = this.parseAndValidate("#5 prev current");
    Assert.assertNotNull(fragments);
    Assert.assertEquals("current", fragments.getElement().getName());
    PRFNamed _element = fragments.getElement();
    Assert.assertEquals("prev", ((PRFNamedWithAction) _element).getPrev().getName());
}
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 18 with ParserRuleFragments

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

the class AbstractFragmentsTest method testFragmentWithPredicate.

@Test
public void testFragmentWithPredicate() {
    final ParserRuleFragments fragments = this.parseAndValidate("#9 myName - myName");
    Assert.assertNotNull(fragments);
    Assert.assertEquals("myName", fragments.getElement().getName());
    Assert.assertEquals(fragments.getElement(), fragments.getElement().getRef());
}
Also used : ParserRuleFragments(org.eclipse.xtext.parser.fragments.fragmentTestLanguage.ParserRuleFragments) Test(org.junit.Test)

Example 19 with ParserRuleFragments

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

the class AbstractFragmentsTest method testDatatypeRule_03.

@Test
public void testDatatypeRule_03() {
    final ParserRuleFragments fragments = this.parseAndValidate("#8 a.b.c.d - a.b.c.d");
    Assert.assertNotNull(fragments);
    PRFNamed element = fragments.getElement();
    Assert.assertEquals(element, element.getRef());
}
Also used : ParserRuleFragments(org.eclipse.xtext.parser.fragments.fragmentTestLanguage.ParserRuleFragments) PRFNamed(org.eclipse.xtext.parser.fragments.fragmentTestLanguage.PRFNamed) Test(org.junit.Test)

Example 20 with ParserRuleFragments

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

the class AbstractFragmentsTest method testFragmentRecursive_02.

@Test
public void testFragmentRecursive_02() {
    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

ParserRuleFragments (org.eclipse.xtext.parser.fragments.fragmentTestLanguage.ParserRuleFragments)23 Test (org.junit.Test)20 PRFNamed (org.eclipse.xtext.parser.fragments.fragmentTestLanguage.PRFNamed)16 PRFNamedWithAction (org.eclipse.xtext.parser.fragments.fragmentTestLanguage.PRFNamedWithAction)13 ICompositeNode (org.eclipse.xtext.nodemodel.ICompositeNode)5 Ignore (org.junit.Ignore)5 EObject (org.eclipse.emf.ecore.EObject)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 Resource (org.eclipse.emf.ecore.resource.Resource)1 XtextResource (org.eclipse.xtext.resource.XtextResource)1