-
Notifications
You must be signed in to change notification settings - Fork 917
Description
Apache NetBeans version
Apache NetBeans 28
What happened
When used as case labels in switch statements, enum constants don't need to be imported. However, copy-pasting such a switch statements has NetBeans unnecessarily trigger the "Import Classes" dialog, and creating unnecessary (and possibly conflicting) imports for the copied enum constants when the dialog is acknoledged with "OK".
Language / Project Type / NetBeans Component
Java, Editor, Refactoring
How to reproduce
Example
switch (Thread.currentThread().getState())
{
case NEW: System.out.println("new"); break;
case BLOCKED: System.out.println("blocked"); break;
// etc.
}Copy the switch statement and paste it into the same or a differen Java source file.
=> The "Import Classes" dialog appears, unnecessarily wanting to add imports for the enum constants.
The same happens for arrow-style (->) case statements.
Did this work correctly in an earlier version?
No / Don't know
Operating System
Windows
JDK
JDK 21
Apache NetBeans packaging
Apache NetBeans binary zip
Anything else
NetBeans should IMO recognize when an enum constant occurs within a case construct in the copy-pasted code, and for such occurrence not regard the constants as being in need of imports.
Are you willing to submit a pull request?
No