Search in sources :

Example 1 with OtherTreeNode

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

the class AbstractIndentationAwareTestLanguageSemanticSequencer method sequence.

@Override
public void sequence(ISerializationContext context, EObject semanticObject) {
    EPackage epackage = semanticObject.eClass().getEPackage();
    ParserRule rule = context.getParserRule();
    Action action = context.getAssignedAction();
    Set<Parameter> parameters = context.getEnabledBooleanParameters();
    if (epackage == IndentationAwareTestLanguagePackage.eINSTANCE)
        switch(semanticObject.eClass().getClassifierID()) {
            case IndentationAwareTestLanguagePackage.CHILD_LIST:
                sequence_ChildList(context, (ChildList) semanticObject);
                return;
            case IndentationAwareTestLanguagePackage.OTHER_TREE_NODE:
                sequence_OtherTreeNode(context, (OtherTreeNode) semanticObject);
                return;
            case IndentationAwareTestLanguagePackage.TREE:
                sequence_Tree(context, (Tree) semanticObject);
                return;
            case IndentationAwareTestLanguagePackage.TREE_NODE:
                sequence_TreeNode(context, (TreeNode) semanticObject);
                return;
        }
    if (errorAcceptor != null)
        errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
Also used : OtherTreeNode(org.eclipse.xtext.parser.indentation.indentationAwareTestLanguage.OtherTreeNode) ParserRule(org.eclipse.xtext.ParserRule) Action(org.eclipse.xtext.Action) OtherTreeNode(org.eclipse.xtext.parser.indentation.indentationAwareTestLanguage.OtherTreeNode) TreeNode(org.eclipse.xtext.parser.indentation.indentationAwareTestLanguage.TreeNode) ChildList(org.eclipse.xtext.parser.indentation.indentationAwareTestLanguage.ChildList) Parameter(org.eclipse.xtext.Parameter) Tree(org.eclipse.xtext.parser.indentation.indentationAwareTestLanguage.Tree) EPackage(org.eclipse.emf.ecore.EPackage)

Example 2 with OtherTreeNode

use of org.eclipse.xtext.parser.indentation.indentationAwareTestLanguage.OtherTreeNode 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 3 with OtherTreeNode

use of org.eclipse.xtext.parser.indentation.indentationAwareTestLanguage.OtherTreeNode 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 4 with OtherTreeNode

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

the class IndentationAwareLanguageTest method asText.

private StringConcatenation asText(final OtherTreeNode treeNode) {
    StringConcatenation _builder = new StringConcatenation();
    String _name = treeNode.getName();
    _builder.append(_name);
    _builder.newLineIfNotEmpty();
    {
        ChildList _childList = treeNode.getChildList();
        boolean _tripleNotEquals = (_childList != null);
        if (_tripleNotEquals) {
            _builder.append("\t");
            _builder.append(">");
            _builder.newLine();
            {
                EList<OtherTreeNode> _children = treeNode.getChildList().getChildren();
                for (final OtherTreeNode node : _children) {
                    _builder.append("\t");
                    _builder.append("\t");
                    StringConcatenation _asText = this.asText(node);
                    _builder.append(_asText, "\t\t");
                    _builder.newLineIfNotEmpty();
                }
            }
        }
    }
    return _builder;
}
Also used : OtherTreeNode(org.eclipse.xtext.parser.indentation.indentationAwareTestLanguage.OtherTreeNode) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) ChildList(org.eclipse.xtext.parser.indentation.indentationAwareTestLanguage.ChildList)

Example 5 with OtherTreeNode

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

the class IndentationAwareLanguageTest method testIgnoreEmptyLines_4.

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

Aggregations

OtherTreeNode (org.eclipse.xtext.parser.indentation.indentationAwareTestLanguage.OtherTreeNode)5 Tree (org.eclipse.xtext.parser.indentation.indentationAwareTestLanguage.Tree)4 Test (org.junit.Test)3 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)2 ChildList (org.eclipse.xtext.parser.indentation.indentationAwareTestLanguage.ChildList)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 TreeNode (org.eclipse.xtext.parser.indentation.indentationAwareTestLanguage.TreeNode)1