How to add completions after onSuccess is completed

已回答

I have an endpoint that sends me the suggested autocomplete values but since the call is async, I'm not sure how to trigger the autocomplete list to show up with the endpoint suggestions.

in MyCompletionProvider I have the following code

```

protected void addCompletions(@NotNull final CompletionParameters completionParameters,
final ProcessingContext processingContext, @NotNull final CompletionResultSet resultSet) {

PsiElement element = completionParameters.getPosition();
String text = element.getContext().getText().replace("IntellijIdeaRulezzz", "");

Vertx vertx = Vertx.vertx();
DqlClient.create(new PlatformConfig())
.init(vertx)
.flatMap(client -> client.autoComplete(text))
.onSuccess(System.out::println)
.onFailure(err -> System.err.println("Wrong " + err.getMessage()))
.onComplete(ar -> {
System.out.println(ar);
LookupElementBuilder.create(ar.map("suggestions"));

resultSet.addElement(LookupElementBuilder.create("test"));
});

resultSet.addElement(LookupElementBuilder.create("later"));
}
```
With this I'm always getting the "later" suggestion but never reaching the "test" value or able to show what my suggestions (but able to see them in the console).
Is there any way to trigger the pop up?

0

You'll have to wait for successful `onComplete` call to have finished. Right now you return immediately after last adding `later` element.

0

请先登录再写评论。