use of org.eclipse.xtext.parser.indentation.indentationAwareTestLanguage.Tree in project xtext-core by eclipse.
the class IndentationAwareLanguageTest method testTree_01.
@Test
public void testTree_01() {
StringConcatenation _builder = new StringConcatenation();
_builder.append("a");
_builder.newLine();
_builder.append("\t");
_builder.append("b");
_builder.newLine();
_builder.append("\t ");
_builder.append("c");
_builder.newLine();
_builder.append("\t");
_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\t");
_builder_1.append("c");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.append("d");
_builder_1.newLine();
Assert.assertEquals(_builder_1.toString(), this.asText(tree));
}
use of org.eclipse.xtext.parser.indentation.indentationAwareTestLanguage.Tree in project xtext-core by eclipse.
the class IndentationAwareLanguageTest method parseAndValidate.
private Tree parseAndValidate(final CharSequence s) {
final Tree result = this.parse(s);
this.validationTestHelper.assertNoIssues(result);
Resource _eResource = result.eResource();
final XtextResource resource = ((XtextResource) _eResource);
final ICompositeNode node = resource.getParseResult().getRootNode();
this.invariantChecker.checkInvariant(node);
return result;
}
use of org.eclipse.xtext.parser.indentation.indentationAwareTestLanguage.Tree in project xtext-core by eclipse.
the class IndentationAwarePartialParsingErrorTest method testResourceUpdate_02.
@Test
public void testResourceUpdate_02() {
try {
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("// tab and 8 spaces (eq 2 tabs)");
_builder.newLine();
_builder.append("\t");
_builder.append("y");
_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(" // tab");
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);
}
}
use of org.eclipse.xtext.parser.indentation.indentationAwareTestLanguage.Tree 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());
}
use of org.eclipse.xtext.parser.indentation.indentationAwareTestLanguage.Tree in project xtext-core by eclipse.
the class IndentationAwareLanguageTest method testTree_07.
@Test
public void testTree_07() {
StringConcatenation _builder = new StringConcatenation();
_builder.append("\"a\"");
_builder.newLine();
_builder.append("\t");
_builder.newLine();
_builder.append("\"b\"");
_builder.newLine();
_builder.append("\t\t");
_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));
}
Aggregations