use of org.eclipse.xtext.parser.indentation.indentationAwareTestLanguage.TreeNode 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));
}
use of org.eclipse.xtext.parser.indentation.indentationAwareTestLanguage.TreeNode in project xtext-core by eclipse.
the class IndentationAwareLanguageTest method testIgnoreEmptyLines_1.
@Test
public void testIgnoreEmptyLines_1() {
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.getNodes().size());
Assert.assertEquals("first", IterableExtensions.<TreeNode>head(tree.getNodes()).getName());
Assert.assertEquals(0, IterableExtensions.<TreeNode>head(tree.getNodes()).getChildren().size());
Assert.assertEquals("second", IterableExtensions.<TreeNode>last(tree.getNodes()).getName());
}
use of org.eclipse.xtext.parser.indentation.indentationAwareTestLanguage.TreeNode in project xtext-core by eclipse.
the class IndentationAwareLanguageTest method testSingleRootNode.
@Test
public void testSingleRootNode() {
final Tree tree = this.parse("root");
Assert.assertNotNull(tree);
Assert.assertEquals(1, tree.getNodes().size());
Assert.assertEquals("root", IterableExtensions.<TreeNode>head(tree.getNodes()).getName());
}
use of org.eclipse.xtext.parser.indentation.indentationAwareTestLanguage.TreeNode 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));
}
use of org.eclipse.xtext.parser.indentation.indentationAwareTestLanguage.TreeNode in project xtext-core by eclipse.
the class IndentationAwareLanguageTest method asText.
private StringConcatenation asText(final TreeNode treeNode) {
StringConcatenation _builder = new StringConcatenation();
String _name = treeNode.getName();
_builder.append(_name);
_builder.newLineIfNotEmpty();
{
EList<TreeNode> _children = treeNode.getChildren();
for (final TreeNode node : _children) {
_builder.append("\t");
StringConcatenation _asText = this.asText(node);
_builder.append(_asText, "\t");
_builder.newLineIfNotEmpty();
}
}
return _builder;
}
Aggregations