Bug 182319

Summary: [quick fix] Rename within unit (ctrl-2-r) should support codeassist insert
Product: [Eclipse Project] JDT Reporter: Philipe Mulet <philippe_mulet>
Component: CoreAssignee: Olivier Thomann <Olivier_Thomann>
Status: VERIFIED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: daniel_megert, Olivier_Thomann
Version: 3.3   
Target Milestone: 3.6 M7   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Philipe Mulet CLA 2007-04-13 09:35:27 EDT
Build 3.3M6

I was in a situation where I wanted to use codeassist while doing a local rename, and it didn't work.

Steps: 

1. I had 2 files. 

p/X.java -----------------
package p;
public class X {
   static int NEW_FIELD;
}

q/Y.java -----------------
package q;
import p.X;
public class Y {
  void foo() {
     int i = X.OLD_FIELD;
  }
  void bar() {
     int j = X.OLD_FIELD;
  }
}

2. In Y.java, I selected 1st occurrence of X.OLD_FIELD (in #foo()).
3. Pressed ctrl-2-r to trigger local rename
4. After 'X.', I triggered codeassist to select 'NEW_FIELD'
5. Pressed <enter> to get codeassist insertion.

Observe it didn't fix both references
Comment 1 Martin Aeschlimann CLA 2007-04-15 10:46:00 EDT
The reason is the error range that consists of 'X.OLD_FIELD', not just 'OLD_FIELD'. Note that if you change both references to 'X.OLD_FIELD()', then this works.
I filed bug 182459 against jdt.core
Comment 2 Dani Megert CLA 2010-03-18 04:55:08 EDT
This now works due to the fix for bug 182459.

Note the typo in comment 0:

p/X.java -----------------
package p;
public class X {
   static int NEW_FIELD;
^^^^^^^^^^^^^^^^^^^^^^^^^^ The field needs to be public.
}
Comment 3 Dani Megert CLA 2010-03-18 04:55:48 EDT

*** This bug has been marked as a duplicate of bug 182459 ***
Comment 4 Frederic Fusier CLA 2010-04-26 12:56:32 EDT
Verified for 3.6M7 using I20100425-2000.

Note also that the scenario described in comment 0 is false as you cannot get the Rename in file (Ctrl-2, R) quick fix in versions before 3.6M7... Instead you have to use the "Change to 'NEW_FIELD'" one and observed that using 3.6M6 and before, only the first occurrence of OLD_FIELD is replaced although both are replaced using 3.6M7 :-)