use of org.eclipse.xtext.ide.server.Document in project xtext-core by eclipse.
the class WorkspaceManagerTest method testDoRead.
@Test
public void testDoRead() {
StringConcatenation _builder = new StringConcatenation();
_builder.append("type Test {");
_builder.newLine();
_builder.append(" ");
_builder.append("string foo");
_builder.newLine();
_builder.append("}");
_builder.newLine();
final URI path = this.operator_mappedTo("MyType1.testlang", _builder);
this.workspaceManger.doBuild(Collections.<URI>unmodifiableList(CollectionLiterals.<URI>newArrayList(path)), CollectionLiterals.<URI>emptyList(), null);
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("type Test {");
_builder_1.newLine();
_builder_1.append(" ");
_builder_1.append("Test foo");
_builder_1.newLine();
_builder_1.append("}");
_builder_1.newLine();
final String inMemContents = _builder_1.toString();
this.workspaceManger.didOpen(path, 1, inMemContents).build(null);
final Function2<Document, XtextResource, String> _function = (Document $0, XtextResource $1) -> {
return $0.getContents();
};
Assert.assertEquals(inMemContents, this.workspaceManger.<String>doRead(path, _function));
}
use of org.eclipse.xtext.ide.server.Document in project xtext-core by eclipse.
the class DocumentTest method testOffSet_empty.
@Test
public void testOffSet_empty() {
Document _document = new Document(1, "");
final Procedure1<Document> _function = (Document it) -> {
Assert.assertEquals(0, it.getOffSet(this.position(0, 0)));
try {
it.getOffSet(this.position(0, 12));
Assert.fail();
} catch (final Throwable _t) {
if (_t instanceof IndexOutOfBoundsException) {
} else {
throw Exceptions.sneakyThrow(_t);
}
}
};
ObjectExtensions.<Document>operator_doubleArrow(_document, _function);
}
use of org.eclipse.xtext.ide.server.Document in project xtext-core by eclipse.
the class DocumentTest method testUpdate_03.
@Test
public void testUpdate_03() {
StringConcatenation _builder = new StringConcatenation();
_builder.append("hello world");
_builder.newLine();
_builder.append("foo");
_builder.newLine();
_builder.append("bar");
String _normalize = this.normalize(_builder);
Document _document = new Document(1, _normalize);
final Procedure1<Document> _function = (Document it) -> {
TextEdit _change = this.change(this.position(0, 0), this.position(2, 3), "");
Assert.assertEquals("", it.applyChanges(Collections.<TextEdit>unmodifiableList(CollectionLiterals.<TextEdit>newArrayList(_change))).getContents());
};
ObjectExtensions.<Document>operator_doubleArrow(_document, _function);
}
use of org.eclipse.xtext.ide.server.Document in project xtext-core by eclipse.
the class DocumentTest method testUpdate_01.
@Test
public void testUpdate_01() {
StringConcatenation _builder = new StringConcatenation();
_builder.append("hello world");
_builder.newLine();
_builder.append("foo");
_builder.newLine();
_builder.append("bar");
_builder.newLine();
String _normalize = this.normalize(_builder);
Document _document = new Document(1, _normalize);
final Procedure1<Document> _function = (Document it) -> {
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("hello world");
_builder_1.newLine();
_builder_1.append("bar");
_builder_1.newLine();
TextEdit _change = this.change(this.position(1, 0), this.position(2, 0), "");
Assert.assertEquals(this.normalize(_builder_1), it.applyChanges(Collections.<TextEdit>unmodifiableList(CollectionLiterals.<TextEdit>newArrayList(_change))).getContents());
};
ObjectExtensions.<Document>operator_doubleArrow(_document, _function);
}
use of org.eclipse.xtext.ide.server.Document in project xtext-core by eclipse.
the class DocumentTest method testUpdate_nonIncrementalChange.
@Test
public void testUpdate_nonIncrementalChange() {
StringConcatenation _builder = new StringConcatenation();
_builder.append("hello world");
_builder.newLine();
_builder.append("foo");
_builder.newLine();
_builder.append("bar");
String _normalize = this.normalize(_builder);
Document _document = new Document(1, _normalize);
final Procedure1<Document> _function = (Document it) -> {
TextEdit _change = this.change(null, null, " foo ");
Assert.assertEquals(" foo ", it.applyChanges(Collections.<TextEdit>unmodifiableList(CollectionLiterals.<TextEdit>newArrayList(_change))).getContents());
};
ObjectExtensions.<Document>operator_doubleArrow(_document, _function);
}
Aggregations