Search in sources :

Example 86 with ICompositeNode

use of org.eclipse.xtext.nodemodel.ICompositeNode 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 87 with ICompositeNode

use of org.eclipse.xtext.nodemodel.ICompositeNode 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);
    }
}
Also used : ParserRuleFragments(org.eclipse.xtext.parser.fragments.fragmentTestLanguage.ParserRuleFragments) XtextResource(org.eclipse.xtext.resource.XtextResource) Resource(org.eclipse.emf.ecore.resource.Resource) ICompositeNode(org.eclipse.xtext.nodemodel.ICompositeNode) XtextResource(org.eclipse.xtext.resource.XtextResource)

Example 88 with ICompositeNode

use of org.eclipse.xtext.nodemodel.ICompositeNode 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)

Example 89 with ICompositeNode

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

the class IndentationAwareLanguageTest method parseAndValidate.

private Tree parseAndValidate(final CharSequence s) {
    final Tree result = this.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;
}
Also used : XtextResource(org.eclipse.xtext.resource.XtextResource) Resource(org.eclipse.emf.ecore.resource.Resource) Tree(org.eclipse.xtext.parser.indentation.indentationAwareTestLanguage.Tree) ICompositeNode(org.eclipse.xtext.nodemodel.ICompositeNode) XtextResource(org.eclipse.xtext.resource.XtextResource)

Example 90 with ICompositeNode

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

the class NodeModelTest method testEmptyTree.

@Test
public void testEmptyTree() {
    final ICompositeNode tree = this.getRootNode("");
    NodeModelTest.assertEquals("", this.asText(tree));
}
Also used : ICompositeNode(org.eclipse.xtext.nodemodel.ICompositeNode) Test(org.junit.Test)

Aggregations

ICompositeNode (org.eclipse.xtext.nodemodel.ICompositeNode)263 Test (org.junit.Test)87 INode (org.eclipse.xtext.nodemodel.INode)79 EObject (org.eclipse.emf.ecore.EObject)70 ILeafNode (org.eclipse.xtext.nodemodel.ILeafNode)57 XtextResource (org.eclipse.xtext.resource.XtextResource)41 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)24 ReplaceRegion (org.eclipse.xtext.util.ReplaceRegion)20 Resource (org.eclipse.emf.ecore.resource.Resource)19 Model (org.eclipse.xtext.valueconverter.bug250313.Model)15 IParseResult (org.eclipse.xtext.parser.IParseResult)14 ParserRule (org.eclipse.xtext.ParserRule)12 ITextRegion (org.eclipse.xtext.util.ITextRegion)12 RuleCall (org.eclipse.xtext.RuleCall)11 CrossReference (org.eclipse.xtext.CrossReference)10 ArrayList (java.util.ArrayList)8 List (java.util.List)8 EStructuralFeature (org.eclipse.emf.ecore.EStructuralFeature)8 AbstractRule (org.eclipse.xtext.AbstractRule)8 Keyword (org.eclipse.xtext.Keyword)8