Search in sources :

Example 21 with Tree

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

the class IndentationAwareLanguageTest method testTree_06.

@Test
public void testTree_06() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("\"a\"");
    _builder.newLine();
    _builder.append("\"b\"");
    _builder.newLine();
    final Tree tree = this.parseAndValidate(_builder);
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("a");
    _builder_1.newLine();
    _builder_1.append("b");
    _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 22 with Tree

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

the class IndentationAwareLanguageTest method testEmptyTree.

@Test
public void testEmptyTree() {
    final Tree tree = this.parse("");
    Assert.assertNotNull(tree);
    Assert.assertTrue(tree.getNodes().isEmpty());
}
Also used : Tree(org.eclipse.xtext.parser.indentation.indentationAwareTestLanguage.Tree) Test(org.junit.Test)

Example 23 with Tree

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

the class IndentationAwarePartialParsingErrorTest method testResourceUpdate.

@Test
public void testResourceUpdate() {
    try {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("a");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("b // single tab");
        _builder.newLine();
        _builder.append("         ");
        _builder.append("// 8 spaces eq 1 tab");
        _builder.newLine();
        _builder.append("d");
        _builder.newLine();
        final String model = _builder.toString();
        final Tree tree = this.parseHelper.parse(model);
        Resource _eResource = tree.eResource();
        final XtextResource resource = ((XtextResource) _eResource);
        final int idx = model.indexOf(" // 8");
        resource.update(idx, 0, "c");
        EObject _head = IterableExtensions.<EObject>head(resource.getContents());
        final Tree reparsed = ((Tree) _head);
        Assert.assertNotSame(tree, reparsed);
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : EObject(org.eclipse.emf.ecore.EObject) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) XtextResource(org.eclipse.xtext.resource.XtextResource) Resource(org.eclipse.emf.ecore.resource.Resource) Tree(org.eclipse.xtext.parser.indentation.indentationAwareTestLanguage.Tree) XtextResource(org.eclipse.xtext.resource.XtextResource) Test(org.junit.Test)

Example 24 with Tree

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

the class NodeModelTest method getRootNode.

private ICompositeNode getRootNode(final CharSequence seq) {
    try {
        final Tree model = this.parseHelper.parse(seq.toString().replaceAll("\r\n", "\n"));
        final ICompositeNode result = NodeModelUtils.getNode(model).getRootNode();
        this.invariantChecker.checkInvariant(result);
        return result;
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : Tree(org.eclipse.xtext.parser.indentation.indentationAwareTestLanguage.Tree) ICompositeNode(org.eclipse.xtext.nodemodel.ICompositeNode)

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