use of org.graalvm.tools.lsp.server.types.CompletionList in project graal by oracle.
the class CompletionTest method objectPropertyCompletionViaCoverageData.
@Test
public void objectPropertyCompletionViaCoverageData() throws InterruptedException, ExecutionException {
URI uri = createDummyFileUriForSL();
Future<?> future = truffleAdapter.parse(PROG_OBJ_NOT_CALLED, "sl", uri);
future.get();
Future<Boolean> futureCoverage = truffleAdapter.runCoverageAnalysis(uri);
futureCoverage.get();
setTriggerCharacters();
replace(uri, Range.create(Position.create(8, 12), Position.create(8, 12)), ".", "extraneous input '.'");
Future<CompletionList> futureC = truffleAdapter.completion(uri, 8, 13, null);
CompletionList completionList = futureC.get();
assertEquals(1, completionList.getItems().size());
CompletionItem item = completionList.getItems().get(0);
assertEquals("p", item.getLabel());
assertEquals("Number", item.getDetail());
assertEquals(CompletionItemKind.Property, item.getKind());
}
use of org.graalvm.tools.lsp.server.types.CompletionList in project graal by oracle.
the class CompletionTest method checkEmpty.
private void checkEmpty(URI uri, int line, int column) throws InterruptedException, ExecutionException {
Future<CompletionList> futureCompletions = truffleAdapter.completion(uri, line, column, null);
CompletionList completionList = futureCompletions.get();
assertFalse(completionList.isIncomplete());
List<CompletionItem> items = completionList.getItems();
assertTrue(items.isEmpty());
}
use of org.graalvm.tools.lsp.server.types.CompletionList in project graal by oracle.
the class CompletionTest method checkGlobalsAndLocals.
private int checkGlobalsAndLocals(URI uri, int line, int column, int numberOfGlobalsItems, Object... vars) throws InterruptedException, ExecutionException {
Future<CompletionList> futureCompletions = truffleAdapter.completion(uri, line, column, null);
CompletionList completionList = futureCompletions.get();
assertFalse(completionList.isIncomplete());
List<CompletionItem> items = completionList.getItems();
assertFalse(items.isEmpty());
NodeInfo nodeInfo = SLLanguage.lookupNodeInfo(SLHelloEqualsWorldBuiltin.class);
assertNotNull(nodeInfo);
String shortName = nodeInfo.shortName();
assertTrue("Built-in function " + shortName + " not found.", items.stream().anyMatch(item -> item.getLabel().startsWith(shortName)));
for (int i = 0; i < vars.length; i += 2) {
String var = (String) vars[i];
boolean present = (boolean) vars[i + 1];
if (present) {
assertTrue(var + " should be found in function scope", items.stream().anyMatch(item -> item.getLabel().startsWith(var)));
} else {
assertTrue(var + " should not be found in main-function scope", items.stream().noneMatch(item -> item.getLabel().startsWith(var)));
}
}
if (numberOfGlobalsItems != -1) {
assertEquals(numberOfGlobalsItems, items.size());
}
return items.size();
}
use of org.graalvm.tools.lsp.server.types.CompletionList in project graal by oracle.
the class CompletionTest method objectPropertyCompletionLocalFile.
@Test
public void objectPropertyCompletionLocalFile() throws InterruptedException, ExecutionException {
URI uri = createDummyFileUriForSL();
Future<?> future = truffleAdapter.parse(PROG_OBJ_NOT_CALLED, "sl", uri);
future.get();
setTriggerCharacters();
replace(uri, Range.create(Position.create(2, 12), Position.create(2, 12)), ".", "extraneous input '.'");
Future<CompletionList> futureC = truffleAdapter.completion(uri, 2, 13, null);
CompletionList completionList = futureC.get();
assertEquals(1, completionList.getItems().size());
CompletionItem item = completionList.getItems().get(0);
assertEquals("p", item.getLabel());
assertEquals("Number", item.getDetail());
assertEquals(CompletionItemKind.Property, item.getKind());
replace(uri, Range.create(Position.create(2, 12), Position.create(2, 13)), "", null);
replace(uri, Range.create(Position.create(12, 7), Position.create(12, 7)), ".", "missing IDENTIFIER");
futureC = truffleAdapter.completion(uri, 12, 8, null);
try {
futureC.get();
fail();
} catch (ExecutionException e) {
assertTrue(e.getCause() instanceof DiagnosticsNotification);
}
}
Aggregations