eclipse-jdt / eclipse-jdt/eclipse.jdt.ui

No working cancellation for completion (unit.codeComplete receives NullProgressMonitor)

Open
#2,106 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
59
Forks
127
Avg merge
23h 30m
Merged PRs (30d)
35

Description

While debugging some perf issue with Javac backend, I realized that it looks like in the current state, JDT editor does never cancel a completion request with async work.
In the ContentAssistant, the JavaCompletionProcessor is created and receives a reference to the ContentAssistant (fine, we may need it to detect whether completion has to be cancelled or not), this delegates to JavaAllCompletionProposalComputer which will in turn delegate to `CompilationUnit.codeComplete` passing it the monitor created by `ContentAssistProcess.createProgressMonitor()`, usually a `NullProgressMonitor`.
So inside `CompletionEngine` and descendants, the monitor we get does not change state when the completion popup is closed, leading to computation completing for nothing, taking CPU, threads and so on.

I suspect 1 solution is to create a better monitor in `createProgressMonitor`, a monitor that would look at the state of the ContentAssistant, or leverage the existing CompletionListener to set the monitor "canceled" state when completion session ends.

Contributor guide

Open the contributing guide

Research direction

Start at ContentAssistProcess.createProgressMonitor() and trace how JavaCompletionProcessor delegates through JavaAllCompletionProposalComputer to CompilationUnit.codeComplete. Review the existing CompletionListener and ContentAssistant lifecycle to understand when a completion session ends. Done means an in-progress completion can observe cancellation after the popup closes without changing unrelated completion behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
desktop, developer-experience
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.