Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 456822

Summary: rename refactorings should use import rewrite
Product: [Eclipse Project] JDT Reporter: John Glassmyer <eclipse>
Component: UIAssignee: JDT-UI-Inbox <jdt-ui-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3    
Version: 4.4.1   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard: stalebug

Description John Glassmyer CLA 2015-01-06 13:57:20 EST
Refactor -> Rename searches for and updates references to the renamed element in compilation units within the project, replacing the old name with the new name.

Unfortunately, simply replacing the old name with the new name is not sufficient for references occurring in import declarations, as it is likely to result in an incorrect order of imports:

    import com.example.Apple;
    import com.example.Banana;
    import com.example.Cherry;

  Rename "Banana" to "Durian".

    import com.example.Apple;
    import com.example.Durian;
    import com.example.Cherry;

This can be avoided by using jdt.core's ImportRewrite to remove the import of the old name and add an import of the new name in each affected compilation unit.

This is already done in RenamePackageProcessor, but not in the others (types, methods, fields / enum constants).

The use of ImportRewrite in RenamePackageProcessor should be extracted and reused in the other RenameXXXProcessor classes.
Comment 1 Eclipse Genie CLA 2019-11-17 17:20:47 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.