本文整理汇总了Java中org.eclipse.lsp4j.CompletionList类的典型用法代码示例。如果您正苦于以下问题:Java CompletionList类的具体用法?Java CompletionList怎么用?Java CompletionList使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CompletionList类属于org.eclipse.lsp4j包,在下文中一共展示了CompletionList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testChangeEventUpdatesStoredText
import org.eclipse.lsp4j.CompletionList; //导入依赖的package包/类
@Test
public void testChangeEventUpdatesStoredText() throws Exception {
CamelLanguageServer camelLanguageServer = initializeLanguageServer("<to uri=\"\" xmlns=\"http://camel.apache.org/schema/blueprint\"></to>\n");
DidChangeTextDocumentParams changeEvent = new DidChangeTextDocumentParams();
VersionedTextDocumentIdentifier textDocument = new VersionedTextDocumentIdentifier();
textDocument.setUri(DUMMY_URI);
changeEvent.setTextDocument(textDocument);
TextDocumentContentChangeEvent contentChange = new TextDocumentContentChangeEvent("<to xmlns=\"http://camel.apache.org/schema/blueprint\" uri=\"\"></to>\n");
changeEvent.setContentChanges(Collections.singletonList(contentChange));
camelLanguageServer.getTextDocumentService().didChange(changeEvent);
//check old position doesn't provide completion
CompletableFuture<Either<List<CompletionItem>, CompletionList>> completionsAtOldPosition = getCompletionFor(camelLanguageServer, new Position(0, 11));
assertThat(completionsAtOldPosition.get().getLeft()).isEmpty();
//check new position provides completion
CompletableFuture<Either<List<CompletionItem>, CompletionList>> completionsAtNewPosition = getCompletionFor(camelLanguageServer, new Position(0, 58));
assertThat(completionsAtNewPosition.get().getLeft()).isNotEmpty();
}
示例2: completion
import org.eclipse.lsp4j.CompletionList; //导入依赖的package包/类
Either<List<CompletionItem>, CompletionList> completion(TextDocumentPositionParams position,
IProgressMonitor monitor) {
List<CompletionItem> completionItems = null;
try {
ICompilationUnit unit = JDTUtils.resolveCompilationUnit(position.getTextDocument().getUri());
completionItems = this.computeContentAssist(unit,
position.getPosition().getLine(),
position.getPosition().getCharacter(), monitor);
} catch (OperationCanceledException ignorable) {
// No need to pollute logs when query is cancelled
monitor.setCanceled(true);
} catch (Exception e) {
JavaLanguageServerPlugin.logException("Problem with codeComplete for " + position.getTextDocument().getUri(), e);
monitor.setCanceled(true);
}
CompletionList $ = new CompletionList();
if (monitor.isCanceled()) {
$.setIsIncomplete(true);
completionItems = null;
JavaLanguageServerPlugin.logInfo("Completion request cancelled");
} else {
JavaLanguageServerPlugin.logInfo("Completion request completed");
}
$.setItems(completionItems == null ? Collections.emptyList() : completionItems);
return Either.forRight($);
}
示例3: completion
import org.eclipse.lsp4j.CompletionList; //导入依赖的package包/类
@Override
public CompletableFuture<Either<List<CompletionItem>, CompletionList>> completion(TextDocumentPositionParams position) {
logInfo(">> document/completion");
CompletionHandler handler = new CompletionHandler();
final IProgressMonitor[] monitors = new IProgressMonitor[1];
CompletableFuture<Either<List<CompletionItem>, CompletionList>> result = computeAsync((cc) -> {
monitors[0] = toMonitor(cc);
if (Boolean.getBoolean(JAVA_LSP_JOIN_ON_COMPLETION)) {
try {
Job.getJobManager().join(DocumentLifeCycleHandler.DOCUMENT_LIFE_CYCLE_JOBS, monitors[0]);
} catch (OperationCanceledException ignorable) {
// No need to pollute logs when query is cancelled
} catch (InterruptedException e) {
JavaLanguageServerPlugin.logException(e.getMessage(), e);
}
}
return handler.completion(position, monitors[0]);
});
result.join();
if (monitors[0].isCanceled()) {
result.cancel(true);
}
return result;
}
示例4: testCompletion_import_package
import org.eclipse.lsp4j.CompletionList; //导入依赖的package包/类
@Test
public void testCompletion_import_package() throws JavaModelException{
ICompilationUnit unit = getWorkingCopy(
"src/java/Foo.java",
"import java.sq \n" +
"public class Foo {\n"+
" void foo() {\n"+
" }\n"+
"}\n");
int[] loc = findCompletionLocation(unit, "java.sq");
CompletionList list = server.completion(JsonMessageHelper.getParams(createCompletionRequest(unit, loc[0], loc[1]))).join().getRight();
assertNotNull(list);
assertEquals(1, list.getItems().size());
CompletionItem item = list.getItems().get(0);
// Check completion item
assertNull(item.getInsertText());
assertEquals("java.sql",item.getLabel());
assertEquals(CompletionItemKind.Module, item.getKind() );
assertEquals("999999215", item.getSortText());
assertNull(item.getTextEdit());
CompletionItem resolvedItem = server.resolveCompletionItem(item).join();
assertNotNull(resolvedItem);
TextEdit te = item.getTextEdit();
assertNotNull(te);
assertEquals("java.sql.*;",te.getNewText());
assertNotNull(te.getRange());
Range range = te.getRange();
assertEquals(0, range.getStart().getLine());
assertEquals(7, range.getStart().getCharacter());
assertEquals(0, range.getEnd().getLine());
//Not checking the range end character
}
示例5: testCompletion_plainTextDoc
import org.eclipse.lsp4j.CompletionList; //导入依赖的package包/类
public void testCompletion_plainTextDoc() throws Exception{
ICompilationUnit unit = getWorkingCopy(
//@formatter:off
"src/java/Foo.java",
"import java.sq \n" +
"public class Foo {\n"+
" void foo() {\n"+
" zz\n"+
" }\n\" }\\n\"+"+
"\n"+
"/** This should be <bold>plain</bold>.*/\n" +
" void zzz() {}\n"+
"}\n");
//@formatter:off
int[] loc = findCompletionLocation(unit, " zz");
CompletionList list = server.completion(JsonMessageHelper.getParams(createCompletionRequest(unit, loc[0], loc[1]))).join().getRight();
assertNotNull(list);
assertFalse("No proposals were found", list.getItems().isEmpty());
CompletionItem item = list.getItems().get(0);
assertEquals("zzz() : void", item.getLabel());
CompletionItem resolvedItem = server.resolveCompletionItem(item).join();
assertEquals("This should be plain.", resolvedItem.getDocumentation());
}
示例6: completion
import org.eclipse.lsp4j.CompletionList; //导入依赖的package包/类
protected Either<List<CompletionItem>, CompletionList> completion(final CancelIndicator origialCancelIndicator, final TextDocumentPositionParams params) {
final LanguageServerImpl.BufferedCancelIndicator cancelIndicator = new LanguageServerImpl.BufferedCancelIndicator(origialCancelIndicator);
final URI uri = this._uriExtensions.toUri(params.getTextDocument().getUri());
final IResourceServiceProvider resourceServiceProvider = this.languagesRegistry.getResourceServiceProvider(uri);
ContentAssistService _get = null;
if (resourceServiceProvider!=null) {
_get=resourceServiceProvider.<ContentAssistService>get(ContentAssistService.class);
}
final ContentAssistService contentAssistService = _get;
if ((contentAssistService == null)) {
CompletionList _completionList = new CompletionList();
return Either.<List<CompletionItem>, CompletionList>forRight(_completionList);
}
final Function2<Document, XtextResource, CompletionList> _function = (Document document, XtextResource resource) -> {
return contentAssistService.createCompletionList(document, resource, params, cancelIndicator);
};
final CompletionList completionList = this.workspaceManager.<CompletionList>doRead(uri, _function);
return Either.<List<CompletionItem>, CompletionList>forRight(completionList);
}
示例7: testRequest
import org.eclipse.lsp4j.CompletionList; //导入依赖的package包/类
@Test public void testRequest() throws Exception {
TextDocumentPositionParams p = new TextDocumentPositionParams();
p.setPosition(new Position(1,1));
p.setTextDocument(new TextDocumentIdentifier("test/foo.txt"));
CompletionList result = new CompletionList();
result.setIsIncomplete(true);
result.setItems(new ArrayList<>());
CompletionItem item = new CompletionItem();
item.setDetail("test");
item.setDocumentation("doc");
item.setFilterText("filter");
item.setInsertText("insert");
item.setKind(CompletionItemKind.Field);
result.getItems().add(item);
server.expectedRequests.put("textDocument/completion", new Pair<>(p, result));
CompletableFuture<Either<List<CompletionItem>, CompletionList>> future = clientLauncher.getRemoteProxy().getTextDocumentService().completion(p);
Assert.assertEquals(Either.forRight(result).toString(), future.get(TIMEOUT, TimeUnit.MILLISECONDS).toString());
client.joinOnEmpty();
}
示例8: testProvideCompletionForCamelBlueprintNamespace
import org.eclipse.lsp4j.CompletionList; //导入依赖的package包/类
@Test
public void testProvideCompletionForCamelBlueprintNamespace() throws Exception {
CamelLanguageServer camelLanguageServer = initializeLanguageServer("<from uri=\"\" xmlns=\"http://camel.apache.org/schema/blueprint\"></from>\n");
CompletableFuture<Either<List<CompletionItem>, CompletionList>> completions = getCompletionFor(camelLanguageServer, new Position(0, 11));
assertThat(completions.get().getLeft()).contains(expectedAhcCompletioncompletionItem);
}
示例9: testProvideCompletionForToCamelBlueprintNamespace
import org.eclipse.lsp4j.CompletionList; //导入依赖的package包/类
@Test
public void testProvideCompletionForToCamelBlueprintNamespace() throws Exception {
CamelLanguageServer camelLanguageServer = initializeLanguageServer("<to uri=\"\" xmlns=\"http://camel.apache.org/schema/blueprint\"></to>\n");
CompletableFuture<Either<List<CompletionItem>, CompletionList>> completions = getCompletionFor(camelLanguageServer, new Position(0, 9));
assertThat(completions.get().getLeft()).contains(expectedAhcCompletioncompletionItem);
}
示例10: testProvideCompletionForCamelSpringNamespace
import org.eclipse.lsp4j.CompletionList; //导入依赖的package包/类
@Test
public void testProvideCompletionForCamelSpringNamespace() throws Exception {
CamelLanguageServer camelLanguageServer = initializeLanguageServer("<from uri=\"\" xmlns=\"http://camel.apache.org/schema/spring\"></from>\n");
CompletableFuture<Either<List<CompletionItem>, CompletionList>> completions = getCompletionFor(camelLanguageServer, new Position(0, 11));
assertThat(completions.get().getLeft()).contains(expectedAhcCompletioncompletionItem);
}
示例11: testProvideCompletionforMultiline
import org.eclipse.lsp4j.CompletionList; //导入依赖的package包/类
@Test
public void testProvideCompletionforMultiline() throws Exception {
CamelLanguageServer camelLanguageServer = initializeLanguageServer(
"<camelContext xmlns=\"http://camel.apache.org/schema/spring\">\n" +
"<to uri=\"\" ></to>\n" +
"</camelContext>");
CompletableFuture<Either<List<CompletionItem>, CompletionList>> completions = getCompletionFor(camelLanguageServer, new Position(1, 9));
assertThat(completions.get().getLeft()).contains(expectedAhcCompletioncompletionItem);
}
示例12: testDONTProvideCompletionForNotCamelnamespace
import org.eclipse.lsp4j.CompletionList; //导入依赖的package包/类
@Test
public void testDONTProvideCompletionForNotCamelnamespace() throws Exception {
CamelLanguageServer camelLanguageServer = initializeLanguageServer("<from uri=\"\"></from>\n");
CompletableFuture<Either<List<CompletionItem>, CompletionList>> completions = getCompletionFor(camelLanguageServer, new Position(0, 11));
assertThat(completions.get().getLeft()).isEmpty();
assertThat(completions.get().getRight()).isNull();
}
示例13: testDONTProvideCompletionWhenNotAfterURIEqualQuote
import org.eclipse.lsp4j.CompletionList; //导入依赖的package包/类
@Test
public void testDONTProvideCompletionWhenNotAfterURIEqualQuote() throws Exception {
CamelLanguageServer camelLanguageServer = initializeLanguageServer("<from uri=\"\" xmlns=\"http://camel.apache.org/schema/spring\"></from>\n");
CompletableFuture<Either<List<CompletionItem>, CompletionList>> completions = getCompletionFor(camelLanguageServer, new Position(0, 6));
assertThat(completions.get().getLeft()).isEmpty();
assertThat(completions.get().getRight()).isNull();
}
示例14: testProvideCamelOptions
import org.eclipse.lsp4j.CompletionList; //导入依赖的package包/类
private void testProvideCamelOptions(String textTotest, int line, int character) throws URISyntaxException, InterruptedException, ExecutionException {
CamelLanguageServer camelLanguageServer = initializeLanguageServer(textTotest);
CompletableFuture<Either<List<CompletionItem>, CompletionList>> completions = getCompletionFor(camelLanguageServer, new Position(line, character));
assertThat(completions.get().getLeft()).contains(
new CompletionItem("true"),
new CompletionItem("false"));
}
示例15: testProvideCompletionForCamelBlueprintNamespace
import org.eclipse.lsp4j.CompletionList; //导入依赖的package包/类
@Test
public void testProvideCompletionForCamelBlueprintNamespace() throws Exception {
CamelLanguageServer camelLanguageServer = initializeLanguageServer(textToTest);
CompletableFuture<Either<List<CompletionItem>, CompletionList>> completions = getCompletionFor(camelLanguageServer, new Position(line, character));
if(shouldHaveCompletion) {
assertThat(completions.get().getLeft()).contains(expectedAhcCompletioncompletionItem);
} else {
assertThat(completions.get().getLeft()).doesNotContain(expectedAhcCompletioncompletionItem);
assertThat(completions.get().getRight()).isNull();
}
}