Bug 24934

Summary: Move top level doesn't optimize the imports[refactoring]
Product: [Eclipse Project] JDT Reporter: Erich Gamma <erich_gamma>
Component: CoreAssignee: Jerome Lanneluc <jerome_lanneluc>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: akiezun
Version: 2.0   
Target Milestone: 2.1 M4   
Hardware: PC   
OS: Windows 2000   
Whiteboard:

Description Erich Gamma CLA 2002-10-17 07:53:50 EDT
After a Move to top level refactoring you end up with unused import errors.
Comment 1 Adam Kiezun CLA 2002-11-11 10:28:32 EST
the culprit is SearchEngine::searchDeclarationsOfReferencedTypes

small test case (where 5 types are found instead of just 1):

package d;
import java.awt.Canvas;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Rectangle;
import java.awt.SystemColor;
class B {
    static class Inner {
        Color color;
    }
    Canvas canvas;
    Color color;
    Graphics graphics;
    Rectangle rectangle;
    SystemColor systemColor;
} 


Comment 2 Philipe Mulet CLA 2002-11-13 08:49:54 EST
What were you searching for exactly ?
Comment 3 Adam Kiezun CLA 2002-11-13 09:11:27 EST
sorry for the cryptic description

SearchEngine.searchDeclarationsOfReferencedTypes with the
class Inner as a parameter
Comment 4 Jerome Lanneluc CLA 2002-11-18 05:44:36 EST
DeclarationOfReferenceTypesPattern was not filtering out the import references 
that were not enclosed in the java element.

Fixed and added regression test 
JavaSearchTests.testDeclarationOfReferencedTypes6().
Comment 5 David Audel CLA 2002-12-17 09:59:50 EST
Verified.