use of org.eclipse.xtext.parser.fragments.fragmentTestLanguage.ParserRuleFragments in project xtext-core by eclipse.
the class AbstractFragmentsTest method testReferenceInFragment.
@Test
public void testReferenceInFragment() {
final ParserRuleFragments fragments = this.parseAndValidate("#1 myName - myName");
Assert.assertNotNull(fragments);
Assert.assertEquals("myName", fragments.getElement().getName());
Assert.assertEquals(fragments.getElement(), fragments.getElement().getRef());
}
use of org.eclipse.xtext.parser.fragments.fragmentTestLanguage.ParserRuleFragments 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);
}
use of org.eclipse.xtext.parser.fragments.fragmentTestLanguage.ParserRuleFragments 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());
}
use of org.eclipse.xtext.parser.fragments.fragmentTestLanguage.ParserRuleFragments 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());
}
use of org.eclipse.xtext.parser.fragments.fragmentTestLanguage.ParserRuleFragments in project xtext-core by eclipse.
the class AbstractFragmentsTest method parseAndValidate.
protected ParserRuleFragments parseAndValidate(final CharSequence s) {
try {
final ParserRuleFragments result = this.parseHelper.parse(s);
this.validationTestHelper.assertNoIssues(result);
Resource _eResource = result.eResource();
final XtextResource resource = ((XtextResource) _eResource);
final ICompositeNode node = resource.getParseResult().getRootNode();
this.invariantChecker.checkInvariant(node);
return result;
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
Aggregations