Bug 383787

Summary: [quick fix] Moving a class via Quick Fix will not resolve imports correctly
Product: [Eclipse Project] JDT Reporter: Eugen Paraschiv <hanriseldon>
Component: UIAssignee: JDT-UI-Inbox <jdt-ui-inbox>
Status: ASSIGNED --- QA Contact:
Severity: enhancement    
Priority: P3 CC: amj87.iitr, deepakazad, manju656, tomasz.zarna
Version: 4.2   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description Eugen Paraschiv CLA 2012-06-28 08:37:17 EDT
Build Identifier: 20120614-1722

If the package of a Java class is manually modified, then a quick fix appears to move the file in the correct new package. However, if the class has dependencies from the same package - these do not appear in the imports (because they're in the same package). Moving the file should however add these necessary imports automatically - otherwise the file will have compilation errors. 
To reproduce, simply move a java class that uses another one from the same package - it will no longer compile. 

Reproducible: Always
Comment 1 Tomasz Zarna CLA 2012-07-03 09:54:35 EDT
To make sure we're on the same page, are you suggesting the quick fix ("Move 'xxx.java' to package 'y'") should do the same as Refactor > Mode (Alt + Shift + V) from the context menu?
Comment 2 Eugen Paraschiv CLA 2012-07-03 10:45:09 EDT
Yes I am. Refactor would leave the system in a consistent state, whereas this operation doesn't. 
Thanks. 
Eugen.
Comment 3 Ayushman Jain CLA 2012-07-03 12:05:08 EDT
I thought the problem is in organize imports, but if the refactor works fine, then this should too. 
Moving to JDT/UI for comment.
Comment 4 Martin Mathew CLA 2013-06-27 01:00:51 EDT
Remotely related to bug 222700. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=222700#c5

Ideally we should use the 'Move' refactoring operation to handle this scenario, which will take care of the internal consistency of the Java file. But since this Quick Fix require changes to a single file, we should take this up as an improvement for the current Quick Fix.