Bug 383787 - [quick fix] Moving a class via Quick Fix will not resolve imports correctly
Summary: [quick fix] Moving a class via Quick Fix will not resolve imports correctly
Status: ASSIGNED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.2   Edit
Hardware: All All
: P3 enhancement with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-06-28 08:37 EDT by Eugen Paraschiv CLA
Modified: 2013-06-27 01:00 EDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.