Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 457135

Summary: Enum defined within class incorrectly imported
Product: [Eclipse Project] JDT Reporter: Lawrence Weetman <contact>
Component: UIAssignee: JDT-UI-Inbox <jdt-ui-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: minor    
Priority: P3 CC: contact, noopur_gupta
Version: 3.8.1   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard: stalebug

Description Lawrence Weetman CLA 2015-01-09 06:54:17 EST
We have noticed that when defining an enum within a class, the automatic imports-organizer will import the enum in the imports section of the defining class (for example, when using auto-complete to use that enum in a method signature).

Furthermore, using "organise imports" fails to remove this import, despite the import being marked as unnecessary in the Eclipse warnings panel. 

Therefore, the import has to be removed manually, but is often introduced again by the imports-organizer during subsequent coding.
Comment 1 Lawrence Weetman CLA 2015-01-09 07:05:59 EST
Slight correction to this: it turns out that organizing imports DOES remove the enum import as expected.

The bug which _does_ exist is as follows:

1) Define enum MyEnum within class MyClass.
2) Create another class, such as MyTest.
3) Use a non-existent method with from MyClass in MyTest, such as MyClass.myMethod(MyEnum enum).
4) Use the problem-fixing menu (Ctrl+1) to generate myMethod in MyClass.

At this point, an import for MyEnum is added within the defining class, MyClass.

However, contrary to what I said earlier, organising imports (Ctrl + Shft + O) does remove this.
Comment 2 Lawrence Weetman CLA 2015-01-09 09:29:54 EST
It also seems to be the case that if you later extract MyEnum from MyClass using the refactoring tools, the import statements within MyClass are not updated correctly.
Comment 3 Noopur Gupta CLA 2015-01-20 03:59:05 EST
Reproducible in Eclipse 3.8.1 also.
Comment 4 Eclipse Genie CLA 2020-02-12 18:04:31 EST
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. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. 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.