use of org.eclipse.xtext.testing.TestCompletionConfiguration in project xtext-core by eclipse.
the class CompletionTest method testCompletion_02.
@Test
public void testCompletion_02() {
final Procedure1<TestCompletionConfiguration> _function = (TestCompletionConfiguration it) -> {
it.setModel("type ");
it.setColumn(5);
StringConcatenation _builder = new StringConcatenation();
_builder.append("name (ID) -> name [[0, 5] .. [0, 5]]");
_builder.newLine();
it.setExpectedCompletionItems(_builder.toString());
};
this.testCompletion(_function);
}
use of org.eclipse.xtext.testing.TestCompletionConfiguration in project xtext-core by eclipse.
the class AbstractLanguageServerTest method testCompletion.
protected void testCompletion(final Procedure1<? super TestCompletionConfiguration> configurator) {
try {
@Extension final TestCompletionConfiguration configuration = new TestCompletionConfiguration();
configuration.setFilePath(("MyModel." + this.fileExtension));
configurator.apply(configuration);
final String filePath = this.initializeContext(configuration).getUri();
TextDocumentPositionParams _textDocumentPositionParams = new TextDocumentPositionParams();
final Procedure1<TextDocumentPositionParams> _function = (TextDocumentPositionParams it) -> {
TextDocumentIdentifier _textDocumentIdentifier = new TextDocumentIdentifier(filePath);
it.setTextDocument(_textDocumentIdentifier);
int _line = configuration.getLine();
int _column = configuration.getColumn();
Position _position = new Position(_line, _column);
it.setPosition(_position);
};
TextDocumentPositionParams _doubleArrow = ObjectExtensions.<TextDocumentPositionParams>operator_doubleArrow(_textDocumentPositionParams, _function);
final CompletableFuture<Either<List<CompletionItem>, CompletionList>> completionItems = this.languageServer.completion(_doubleArrow);
final Either<List<CompletionItem>, CompletionList> result = completionItems.get();
List<CompletionItem> _xifexpression = null;
boolean _isLeft = result.isLeft();
if (_isLeft) {
_xifexpression = result.getLeft();
} else {
_xifexpression = result.getRight().getItems();
}
final List<CompletionItem> items = _xifexpression;
final Function1<CompletionItem, String> _function_1 = (CompletionItem it) -> {
return it.getSortText();
};
Assert.assertEquals(items, IterableExtensions.<CompletionItem>toList(IterableExtensions.<CompletionItem, String>sortBy(items, _function_1)));
Procedure1<? super CompletionList> _assertCompletionList = configuration.getAssertCompletionList();
boolean _tripleNotEquals = (_assertCompletionList != null);
if (_tripleNotEquals) {
configuration.getAssertCompletionList().apply(result.getRight());
} else {
final String actualCompletionItems = this.toExpectation(items);
this.assertEquals(configuration.getExpectedCompletionItems(), actualCompletionItems);
}
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtext.testing.TestCompletionConfiguration in project xtext-core by eclipse.
the class CompletionTest method testCompletion_01.
@Test
public void testCompletion_01() {
final Procedure1<TestCompletionConfiguration> _function = (TestCompletionConfiguration it) -> {
it.setModel("");
StringConcatenation _builder = new StringConcatenation();
_builder.append("type -> type [[0, 0] .. [0, 0]]");
_builder.newLine();
it.setExpectedCompletionItems(_builder.toString());
};
this.testCompletion(_function);
}
use of org.eclipse.xtext.testing.TestCompletionConfiguration in project xtext-core by eclipse.
the class CompletionTest method testCompletion_03.
@Test
public void testCompletion_03() {
final Procedure1<TestCompletionConfiguration> _function = (TestCompletionConfiguration it) -> {
StringConcatenation _builder = new StringConcatenation();
_builder.append("type Foo {}");
_builder.newLine();
_builder.append("type Bar {}");
_builder.newLine();
it.setModel(_builder.toString());
it.setLine(1);
it.setColumn("type Bar {".length());
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("Bar (TypeDeclaration) -> Bar [[1, 10] .. [1, 10]]");
_builder_1.newLine();
_builder_1.append("Foo (TypeDeclaration) -> Foo [[1, 10] .. [1, 10]]");
_builder_1.newLine();
_builder_1.append("boolean -> boolean [[1, 10] .. [1, 10]]");
_builder_1.newLine();
_builder_1.append("int -> int [[1, 10] .. [1, 10]]");
_builder_1.newLine();
_builder_1.append("op -> op [[1, 10] .. [1, 10]]");
_builder_1.newLine();
_builder_1.append("string -> string [[1, 10] .. [1, 10]]");
_builder_1.newLine();
_builder_1.append("void -> void [[1, 10] .. [1, 10]]");
_builder_1.newLine();
_builder_1.append("} -> } [[1, 10] .. [1, 10]]");
_builder_1.newLine();
_builder_1.append("{ -> { [[1, 9] .. [1, 10]]");
_builder_1.newLine();
it.setExpectedCompletionItems(_builder_1.toString());
};
this.testCompletion(_function);
}
use of org.eclipse.xtext.testing.TestCompletionConfiguration in project xtext-core by eclipse.
the class CompletionTest method testCompletion_04.
@Test
public void testCompletion_04() {
final Procedure1<TestCompletionConfiguration> _function = (TestCompletionConfiguration it) -> {
StringConcatenation _builder = new StringConcatenation();
_builder.append("type Foo {");
_builder.newLine();
_builder.append(" ");
_builder.append("Foo foo");
_builder.newLine();
_builder.append("}");
_builder.newLine();
it.setModel(_builder.toString());
it.setLine(1);
it.setColumn(" Fo".length());
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("Foo (TypeDeclaration) -> Foo [[1, 4] .. [1, 6]]");
_builder_1.newLine();
_builder_1.append("[ -> [ [[1, 6] .. [1, 6]]");
_builder_1.newLine();
it.setExpectedCompletionItems(_builder_1.toString());
};
this.testCompletion(_function);
}
Aggregations