Skip to content

Commit

Permalink
Completion "hangs" with no response eclipse#743
Browse files Browse the repository at this point in the history
Getting rid of infinite waiting in LSContentAssistProcessor

Issue: eclipse#743
  • Loading branch information
vrubezhny committed Aug 5, 2023
1 parent 55ce45f commit 7a832b8
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
public class LSContentAssistProcessor implements IContentAssistProcessor {

private static final long TRIGGERS_TIMEOUT = 50;
private static final long GET_TIMEOUT = 1000;
private static final long CONTEXT_INFORMATION_TIMEOUT = 1000;
private IDocument currentDocument;
private String errorMessage;
Expand Down Expand Up @@ -111,7 +112,7 @@ public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int
.withFilter(capabilities -> capabilities.getCompletionProvider() != null)
.collectAll((w, ls) -> ls.getTextDocumentService().completion(param)
.thenAccept(completion -> proposals.addAll(toProposals(document, offset, completion, w))));
this.completionLanguageServersFuture.get();
this.completionLanguageServersFuture.get(GET_TIMEOUT, TimeUnit.MILLISECONDS);
} catch (ResponseErrorException | ExecutionException e) {
if (!CancellationUtil.isRequestCancelledException(e)) { // do not report error if the server has cancelled the request
LanguageServerPlugin.logError(e);
Expand All @@ -123,6 +124,8 @@ public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int
this.errorMessage = createErrorMessage(offset, e);
Thread.currentThread().interrupt();
return createErrorProposal(offset, e);
} catch (TimeoutException e) {
LanguageServerPlugin.logWarning("Could not get completions due to timeout after " + GET_TIMEOUT + " milliseconds", e); //$NON-NLS-1$ //$NON-NLS-2$
}

final var completeProposals = new LSCompletionProposal[proposals.size()];
Expand Down Expand Up @@ -255,7 +258,7 @@ public IContextInformation[] computeContextInformation(ITextViewer viewer, int o
Thread.currentThread().interrupt();
return new IContextInformation[] { /* TODO? show error in context information */ };
} catch (TimeoutException e) {
LanguageServerPlugin.logWarning("Could not compute context information due to timeout after " + CONTEXT_INFORMATION_TIMEOUT + " milliseconds", e); //$NON-NLS-1$//$NON-NLS-2$
LanguageServerPlugin.logWarning("Could not compute context information due to timeout after " + CONTEXT_INFORMATION_TIMEOUT + " milliseconds", e); //$NON-NLS-1$//$NON-NLS-2$
return new IContextInformation[] { /* TODO? show error in context information */ };
}
return contextInformations.toArray(new IContextInformation[0]);
Expand Down

0 comments on commit 7a832b8

Please sign in to comment.