| Summary: | [quick assist] RFE: Quick fix to set all case statements in an Enum switch | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Paul Benedict <pbenedict> | ||||
| Component: | UI | Assignee: | Deepak Azad <deepakazad> | ||||
| Status: | RESOLVED FIXED | QA Contact: | |||||
| Severity: | enhancement | ||||||
| Priority: | P3 | CC: | daniel_megert, markus.kell.r | ||||
| Version: | 3.7 | Flags: | markus.kell.r:
review+
|
||||
| Target Milestone: | 3.7 M5 | ||||||
| Hardware: | PC | ||||||
| OS: | Windows 7 | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
|
Description
Paul Benedict
We already offer this as a quick fix (Ctrl+1) when the compiler option
"Enum type constant not covered on 'switch'" is enabled, e.g. here:
public class Try {
enum Enum {
A, BB, CCC, DDDD
}
void foo(Enum e) {
switch (e) {
case A:
case BB:
break;
// default:
}
}
}
If no error/warning is available, just set the caret into the 'switch' keyword and use the quick assist (also Ctrl+1).
My request is to allow the quick fix *inside* the switch statement. I don't think it's very apparent that you have to go to the top of the switch() to invoke the help. That's a bit limiting. It would be very nice to have this enabled at this position:
void foo(Enum e) {
switch (e) {
case A:
case BB:
>>cursor here
}
}
Fair enough. Deepak, please have a look. Try to enable it only on the top level inside the SwitchStatement or in a SwitchCase node, and make sure its priority is low enough to not interfere with other quick assists. Created attachment 184872 [details]
fix + tests
Note that the quick assist is not available on the switch statement expression, otherwise both the quick fix and the quick assist can be present in the proposal list.
Looks good. Fixed in HEAD. |