Search in sources :

Example 6 with Tree

use of org.eclipse.xtext.parser.indentation.indentationAwareTestLanguage.Tree in project xtext-core by eclipse.

the class IndentationAwareLanguageTest method testTree_05.

@Test
public void testTree_05() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("a");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("x");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("b // two tabs");
    _builder.newLine();
    _builder.append("\t        ");
    _builder.append("c // tab and 8 spaces (eq 2 tabs)");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("y");
    _builder.newLine();
    final Tree tree = this.parseAndValidate(_builder);
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("a");
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.append("x");
    _builder_1.newLine();
    _builder_1.append("\t\t");
    _builder_1.append("b");
    _builder_1.newLine();
    _builder_1.append("\t\t");
    _builder_1.append("c");
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.append("y");
    _builder_1.newLine();
    Assert.assertEquals(_builder_1.toString(), this.asText(tree));
}
Also used : StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) Tree(org.eclipse.xtext.parser.indentation.indentationAwareTestLanguage.Tree) Test(org.junit.Test)

Example 7 with Tree

use of org.eclipse.xtext.parser.indentation.indentationAwareTestLanguage.Tree in project xtext-core by eclipse.

the class IndentationAwareLanguageTest method testIgnoreEmptyLines_6.

@Test
public void testIgnoreEmptyLines_6() {
    final Tree tree = this.parse("\"first\"\n\t\t\"abc\"\n\t");
    Assert.assertNotNull(tree);
    Assert.assertEquals(1, tree.getMoreNodes().size());
    Assert.assertEquals("first", IterableExtensions.<OtherTreeNode>head(tree.getMoreNodes()).getName());
    Assert.assertNotNull(IterableExtensions.<OtherTreeNode>head(tree.getMoreNodes()).getChildList());
    Assert.assertEquals(1, IterableExtensions.<OtherTreeNode>head(tree.getMoreNodes()).getChildList().getChildren().size());
}
Also used : OtherTreeNode(org.eclipse.xtext.parser.indentation.indentationAwareTestLanguage.OtherTreeNode) Tree(org.eclipse.xtext.parser.indentation.indentationAwareTestLanguage.Tree) Test(org.junit.Test)

Example 8 with Tree

use of org.eclipse.xtext.parser.indentation.indentationAwareTestLanguage.Tree in project xtext-core by eclipse.

the class IndentationAwareLanguageTest method testIgnoreEmptyLines_2.

@Test
public void testIgnoreEmptyLines_2() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("\"first\"");
    _builder.newLine();
    _builder.append("\t");
    _builder.newLine();
    _builder.append("\"second\"");
    _builder.newLine();
    final Tree tree = this.parse(_builder);
    Assert.assertNotNull(tree);
    Assert.assertEquals(2, tree.getMoreNodes().size());
    Assert.assertEquals("first", IterableExtensions.<OtherTreeNode>head(tree.getMoreNodes()).getName());
    Assert.assertNull(IterableExtensions.<OtherTreeNode>head(tree.getMoreNodes()).getChildList());
    Assert.assertEquals("second", IterableExtensions.<OtherTreeNode>last(tree.getMoreNodes()).getName());
}
Also used : OtherTreeNode(org.eclipse.xtext.parser.indentation.indentationAwareTestLanguage.OtherTreeNode) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) Tree(org.eclipse.xtext.parser.indentation.indentationAwareTestLanguage.Tree) Test(org.junit.Test)

Example 9 with Tree

use of org.eclipse.xtext.parser.indentation.indentationAwareTestLanguage.Tree in project xtext-core by eclipse.

the class IndentationAwareLanguageTest method testTree_03.

@Test
public void testTree_03() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("a");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("b // single tab");
    _builder.newLine();
    _builder.append("        ");
    _builder.append("c // 8 spaces eq 1 tab");
    _builder.newLine();
    _builder.append("d");
    _builder.newLine();
    final Tree tree = this.parseAndValidate(_builder);
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("a");
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.append("b");
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.append("c");
    _builder_1.newLine();
    _builder_1.append("d");
    _builder_1.newLine();
    Assert.assertEquals(_builder_1.toString(), this.asText(tree));
}
Also used : StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) Tree(org.eclipse.xtext.parser.indentation.indentationAwareTestLanguage.Tree) Test(org.junit.Test)

Example 10 with Tree

use of org.eclipse.xtext.parser.indentation.indentationAwareTestLanguage.Tree in project xtext-core by eclipse.

the class IndentationAwareLanguageTest method testParentChild.

@Test
public void testParentChild() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("parent");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("child");
    _builder.newLine();
    final Tree tree = this.parse(_builder);
    Assert.assertNotNull(tree);
    Assert.assertEquals(1, tree.getNodes().size());
    Assert.assertEquals("parent", IterableExtensions.<TreeNode>head(tree.getNodes()).getName());
    Assert.assertEquals("child", IterableExtensions.<TreeNode>head(IterableExtensions.<TreeNode>head(tree.getNodes()).getChildren()).getName());
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("parent");
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.append("child");
    _builder_1.newLine();
    Assert.assertEquals(_builder_1.toString(), this.asText(tree));
}
Also used : OtherTreeNode(org.eclipse.xtext.parser.indentation.indentationAwareTestLanguage.OtherTreeNode) TreeNode(org.eclipse.xtext.parser.indentation.indentationAwareTestLanguage.TreeNode) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) Tree(org.eclipse.xtext.parser.indentation.indentationAwareTestLanguage.Tree) Test(org.junit.Test)

Aggregations

Tree (org.eclipse.xtext.parser.indentation.indentationAwareTestLanguage.Tree)24 Test (org.junit.Test)21 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)15 OtherTreeNode (org.eclipse.xtext.parser.indentation.indentationAwareTestLanguage.OtherTreeNode)10 TreeNode (org.eclipse.xtext.parser.indentation.indentationAwareTestLanguage.TreeNode)7 Resource (org.eclipse.emf.ecore.resource.Resource)3 XtextResource (org.eclipse.xtext.resource.XtextResource)3 EObject (org.eclipse.emf.ecore.EObject)2 ICompositeNode (org.eclipse.xtext.nodemodel.ICompositeNode)2 EPackage (org.eclipse.emf.ecore.EPackage)1 Action (org.eclipse.xtext.Action)1 Parameter (org.eclipse.xtext.Parameter)1 ParserRule (org.eclipse.xtext.ParserRule)1 ChildList (org.eclipse.xtext.parser.indentation.indentationAwareTestLanguage.ChildList)1