Project: JDT
Bug 184559 [quick fix] Misplaced bold in quick fix/assist preview due to naive diffing
Reported: 2007-04-27 23:01:13 | Status: resolved fixed

Build ID: HEAD as of 4/27/2007 The JDT quick fix/assist preview uses bold to emphasize what the fix/assist changes. CUCorrectionProposal.getAdditionalProposalInfo determines where to put the bold by diffing the old text and the new text. Sometimes the automatically determined diff does not capture the intent of the fix/assist. It would be better to use the edits contained in the TextChange because those are more likely to capture the intent. Steps To Reproduce: 1. Create a new Java project. 2. Create a class as follows: public class Foo { private static final String x = "x"; public static void main(String[] args) { System.out.println("bar"); } } 3. Select the string literal "bar". 4. Press Ctrl+1 to open Quick Fix/Assist. 5. Click "Extract to constant" once. 6. In the additional popup that appears, notice that the "public static final String" of field x, not field BAR, is bold, even though the intent of the assist was to create field BAR. I debugged Eclipse as I carried out these steps and found that the TextChange correctly inserts the "public static final String" of BAR, so using the original TextChange instead of a diff would fix the bug in at least this example.

Files changed in fix:
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/proposals/CUCorrectionProposal.java