Community
Participate
Working Groups
In the attached project, move the compilation unit other/ToMove.java to the foo package. The result is that the import statement is removed. The import statement refers to an inner type in the foo.Outer class. Next, fix the import statements in foo.ToMove, and then move it back to the other package. Now, the import statements include foo.Outer when they don't need to.
Created attachment 198505 [details] Project referred to in description
It looks like one problem is that the method org.eclipse.jdt.internal.corext.refactoring.reorg.MoveCuUpdateCreator.getDestinationPackageTypes() calls getAllTypes instead of getTypes. Simply changing the method call would likely solve the first problem described in the description (ie- the erroneous removal of the inner class import). The second problem (the erroneous addition of the outer import) is likely caused by the method org.eclipse.jdt.internal.corext.refactoring.structure.ReferenceFinderUtil.getTypeReferencesIn(IJavaElement, WorkingCopyOwner, IProgressMonitor) erroneously including outer types as a reference. The fix for this is a little more nuanced. Let me check if I can see something easily.
It looks like org.eclipse.jdt.internal.core.search.matching.TypeReferenceLocator.reportDeclaration(ReferenceBinding, int, MatchLocator, SimpleSet) is reporting a match for a particular type, and then also reporting a match for all of its enclosing types. In this particular situation, this is the wrong behavior. Perhaps there can be a flag passed into TypeReferenceLocator that can toggle implicitly matching on enclosing types.
Moving to JDT/UI as this should be better handled there
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.