Community
Participate
Working Groups
200410260800: When running organize imports on a cu with references to enum types, existing imports to enum types are incorrectly removed
Enums aren't part of the all types cache yet. Assume that they aren't reported as a result of the all types search. Moving to JDT/Core.
*** Bug 78011 has been marked as a duplicate of this bug. ***
Enums are reported by all types cache since JDT/Core v_516 (ie 2004/10/26)... Let's say 3.1 M3 to make simpler... Using last integration build, when you hit Ctrl-Shift-T, you are able to see enumerations in proposed list. However, organize imports still remove all references to enum types... Back to JDT/UI
Could reproduce: --- MyEnum.java: package pack; public enum MyEnum { A, B, C ] --- A.java package other; import pack.MyEnum; public class A { MyEnum enum; } -> organize imports on A removes the import The problem is that the binding of the enum reports isTopLevel() == false and isMember() == false should be isTopLevel() == true back to jdt.core
Fixed and released in HEAD. Regression test added. See test57 of ASTConverterTest15
*** Bug 78716 has been marked as a duplicate of this bug. ***
Could not find any test case for this bug ? ASTConverter15Test#test0057 is not about this bug. Olivier what is the test case ?
ImportOrganizeTest.test_bug78716 is test case? Also see sample code in Bug 78011
Joe, this is not the JDT/Core test case, ImportOrganizerTests is a JDT/UI test class. Of course, as bug 78716 is a duplicate, this test verifies that bug 77398 is fixed, but we wanted to verify also that JDT/Core have a specific test to verify it... In fact, test case test057 in ASTConverter15Test was modified to add verification that enum binding isTopLevel() returns true... By the way, verified for 3.1 M4 using build I200412142000 + ASTView 1.0.2 + breakpoint at ASTViewerLabelProvider.getText(Object obj) condition: ((ASTNode)obj).getNodeType() == ASTNode.IMPORT_DECLARATION + code snippet in Debugger Display view: org.eclipse.jdt.core.dom.ImportDeclaration decl = (org.eclipse.jdt.core.dom.ImportDeclaration) obj; ((org.eclipse.jdt.core.dom.ITypeBinding)decl.resolveBinding()).isTopLevel();