Search in sources :

Example 96 with ICompositeNode

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

the class NodeModelTest method testWeirdTree.

@Test
public void testWeirdTree() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("root");
    _builder.newLine();
    _builder.append("    ");
    _builder.append("s4");
    _builder.newLine();
    _builder.append("        ");
    _builder.append("s8");
    _builder.newLine();
    _builder.append("      ");
    _builder.append("s6");
    _builder.newLine();
    final ICompositeNode tree = this.getRootNode(_builder);
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("[ID:root][-WS:");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("][INDENT:][ID:s4][-WS:");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("][INDENT:][ID:s8][-WS:");
    _builder_1.newLine();
    _builder_1.append("][DEDENT:][-WS:      ][INDENT:][ID:s6][-WS:");
    _builder_1.newLine();
    _builder_1.append("][DEDENT:][DEDENT:]");
    _builder_1.newLine();
    NodeModelTest.assertEquals(_builder_1.toString().trim(), this.asText(tree));
}
Also used : StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) ICompositeNode(org.eclipse.xtext.nodemodel.ICompositeNode) Test(org.junit.Test)

Example 97 with ICompositeNode

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

the class NodeModelTest method testParentChildren.

@Test
public void testParentChildren() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("parent");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("child");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("child");
    _builder.newLine();
    final ICompositeNode tree = this.getRootNode(_builder);
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("[ID:parent][-WS:");
    _builder_1.newLine();
    _builder_1.append("\\t][INDENT:][ID:child][-WS:");
    _builder_1.newLine();
    _builder_1.append("\\t][ID:child][-WS:");
    _builder_1.newLine();
    _builder_1.append("][DEDENT:]");
    _builder_1.newLine();
    NodeModelTest.assertEquals(_builder_1.toString().trim(), this.asText(tree));
}
Also used : StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) ICompositeNode(org.eclipse.xtext.nodemodel.ICompositeNode) Test(org.junit.Test)

Example 98 with ICompositeNode

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

the class NodeModelTest method testParentChildWithEof.

@Test
public void testParentChildWithEof() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("parent");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("child");
    _builder.newLine();
    final ICompositeNode tree = this.getRootNode(_builder.toString().trim());
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("[ID:parent][-WS:");
    _builder_1.newLine();
    _builder_1.append("\\t][INDENT:][ID:child][DEDENT:]");
    _builder_1.newLine();
    NodeModelTest.assertEquals(_builder_1.toString().trim(), this.asText(tree));
}
Also used : StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) ICompositeNode(org.eclipse.xtext.nodemodel.ICompositeNode) Test(org.junit.Test)

Example 99 with ICompositeNode

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

the class UnassignedRuleCallTest method testNodeModel_02.

@Test
public void testNodeModel_02() throws Exception {
    String modelAsText = "model 7 13 137 feature Foo 1 keyword 1 'bar';";
    Model model = (Model) getModel(modelAsText);
    ICompositeNode node = NodeModelUtils.getNode(model);
    assertEquals(8, Iterables.size(node.getChildren()));
    ModelFeatures modelFeatures = model.getModelFeatures();
    ICompositeNode featuresNode = NodeModelUtils.getNode(modelFeatures);
    assertSame(featuresNode, Iterables.get(node.getChildren(), 7));
    assertEquals(6, Iterables.size(featuresNode.getChildren()));
    ICompositeNode dataTypeNode = (ICompositeNode) Iterables.get(featuresNode.getChildren(), 4);
    assertEquals(8, Iterables.size(dataTypeNode.getChildren()));
}
Also used : ModelFeatures(org.eclipse.xtext.xtext.ecoreInference.unassignedRuleCallTestLanguage.ModelFeatures) Model(org.eclipse.xtext.xtext.ecoreInference.unassignedRuleCallTestLanguage.Model) ICompositeNode(org.eclipse.xtext.nodemodel.ICompositeNode) Test(org.junit.Test)

Example 100 with ICompositeNode

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

the class SequenceFeeder method accept.

public void accept(Action action, EObject child) {
    assertAction(action);
    EStructuralFeature ref = getFeature(action.getFeature());
    ICompositeNode node = ref.isMany() ? getCompositeNode(ref, 0, 0, child) : getCompositeNode(ref, child);
    acceptAction(action, child, node);
}
Also used : EStructuralFeature(org.eclipse.emf.ecore.EStructuralFeature) ICompositeNode(org.eclipse.xtext.nodemodel.ICompositeNode)

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