Bug 493214 - [quick fix] Add option to static import enum literal where this is "obvious"
Summary: [quick fix] Add option to static import enum literal where this is "obvious"
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.6   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-05-09 04:52 EDT by Lukas Eder CLA
Modified: 2016-05-09 04:52 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Lukas Eder CLA 2016-05-09 04:52:57 EDT
I have the following code:

------------------------------------------------
package test;

public @interface Test {

    E e() default X;

    enum E {
        X, Y, Z
    }
}
------------------------------------------------

In the above context, "default X" can mean only one thing: "default E.X". Unfortunately, quick fix only offers two options "create field X" and "create constant X", both of which don't even produce compilable code. Instead, the following two options would be very useful:

1. Static import E.X
2. Qualify X to be E.X

The respective output of the two refactorings would be:


1. Static import E.X
------------------------------------------------
package test;

import static test.Test.E.X;

public @interface Test {

    E e() default X;

    enum E {
        X, Y, Z
    }
}
------------------------------------------------

2. Qualify X to be E.X
------------------------------------------------
package test;

public @interface Test {

    E e() default E.X;

    enum E {
        X, Y, Z
    }
}
------------------------------------------------