feat: add Copilot Java quick assist - #415
Conversation
|
@microsoft-github-policy-service agree |
There was a problem hiding this comment.
Pull request overview
Adds a Java (JDT) Quick Assist integration that surfaces a “Suggest fix with GitHub Copilot” proposal for problem markers overlapping the caret/selection, and routes it into the existing “Open Chat” command with a prefilled (but not auto-sent) prompt. This fits the UI bundle’s existing chat command flow and keeps the initial scope limited to org.eclipse.jdt.ui.quickAssistProcessors, aligning with the linked request to have Copilot available from Eclipse’s Ctrl+1 quick assist experience.
Changes:
- Register a new JDT quick assist processor that conditionally offers a Copilot proposal when signed in.
- Collect and deduplicate overlapping problem marker messages (in source order) and build a focused prompt for chat prefill.
- Add UI test coverage for marker selection/dedup behavior and extension-point registration.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/quickfix/QuickFixProcessorSupport.java | Implements Copilot availability check, marker overlap detection, message dedup/sort, and chat command parameter creation. |
| com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/quickfix/JavaCopilotQuickAssistProcessor.java | Adds the JDT IQuickAssistProcessor that produces the Copilot proposal based on caret/selection diagnostics. |
| com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/quickfix/CopilotQuickFixProposal.java | Defines the completion proposal that opens Copilot Chat with a prefilled prompt and Copilot icon/label. |
| com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/i18n/messages.properties | Adds user-facing strings for the quick assist proposal label and prompt header text. |
| com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/i18n/Messages.java | Wires new NLS keys for quick assist strings. |
| com.microsoft.copilot.eclipse.ui/plugin.xml | Registers the Java quick assist processor via org.eclipse.jdt.ui.quickAssistProcessors. |
| com.microsoft.copilot.eclipse.ui/plugin.properties | Adds the extension name string for the quick assist processor. |
| com.microsoft.copilot.eclipse.ui/META-INF/MANIFEST.MF | Adds optional dependency on org.eclipse.jdt.ui for the quick assist integration. |
| com.microsoft.copilot.eclipse.ui.test/src/com/microsoft/copilot/eclipse/ui/quickfix/QuickFixProcessorSupportTests.java | Unit tests for overlap logic, ordering/dedup, prompt building, and chat parameter prefill behavior. |
| com.microsoft.copilot.eclipse.ui.test/src/com/microsoft/copilot/eclipse/ui/quickfix/QuickAssistExtensionTests.java | Verifies extension-point registration and hides proposal when Copilot is unavailable. |
| com.microsoft.copilot.eclipse.ui.test/META-INF/MANIFEST.MF | Adds org.eclipse.jdt.ui dependency for test runtime. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
Thanks, please check the ci failure. Meanwhile some questions:
|
|
Thanks, these were good catches. I checked JDT's I pushed 4877ace to make the context explicit. The Copilot proposal now returns its own selection from For multiple problem markers at the same range, we show one Copilot proposal. Its prompt contains all unique diagnostic messages, ordered by marker offset and then by message for deterministic ties. Identical messages are deduplicated. I added a regression test for multiple markers sharing the same range, including a duplicate message. I also checked the CI failure. The Java 17 test runtime was instantiating the processor, which caused it to load a JDT UI interface compiled for Java 21. The extension registration test now verifies the registry metadata without loading the processor class. A complete |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 11 out of 11 changed files in this pull request and generated no new comments.
Suppressed comments (1)
com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/quickfix/JavaCopilotQuickAssistProcessor.java:46
hasAssists()andgetAssists()both callcreateProposal(context), andcreateProposal()does relatively expensive work (allocates a fullDocumentfrom the compilation unit buffer and scans allIMarker.PROBLEMmarkers). If the JDT UI querieshasAssists()frequently (e.g., to update the lightbulb), this can double the work and make the editor feel sluggish.
Consider caching the last computed proposal keyed by (compilation unit + selection offset/length) so getAssists() can reuse the result from hasAssists(), or refactor so the expensive computation is only performed once per invocation context.
@Override
public boolean hasAssists(IInvocationContext context) throws CoreException {
return createProposal(context) != null;
}
@Override
public IJavaCompletionProposal[] getAssists(IInvocationContext context, IProblemLocation[] locations)
throws CoreException {
IJavaCompletionProposal proposal = createProposal(context);
return proposal == null ? null : new IJavaCompletionProposal[] { proposal };
}
| @Override | ||
| public boolean hasAssists(IInvocationContext context) throws CoreException { | ||
| return createProposal(context) != null; | ||
| } |
There was a problem hiding this comment.
Could hasAssists() use a lightweight availability check instead of creating the full proposal? JDT may call this method frequently when updating the quick-assist light bulb. Currently, createProposal() copies the entire compilation unit into a new Document, scans all problem markers, sorts and deduplicates them, builds the prompt, and creates a proposal. The same work is then repeated by getAssists().
Consider adding a short-circuiting helper that returns as soon as it finds an overlapping problem marker, while leaving the full proposal construction to getAssists().
There was a problem hiding this comment.
Thanks for pointing this out. I updated hasAssists() to use a separate availability check that stops as soon as it finds an overlapping problem marker. getAssists() still handles the full diagnostic collection and proposal construction, so that work is no longer repeated just to update the light bulb. I added tests for the new path, and clean verify passes locally.
The availability check still creates a Document up front because we also support line-only markers. I left that unchanged for now to keep this update focused. If you think it would be worthwhile, I can also make the Document creation lazy for the usual character-range marker case.
Summary
This intentionally limits the initial implementation to
org.eclipse.jdt.ui.quickAssistProcessors, as agreed in the issue discussion.Testing
mvn -q verify -Dtest=QuickFixProcessorSupportTests,QuickAssistExtensionTests -DfailIfNoTests=falsemvn -q clean verifyFixes #70