Community
Participate
Working Groups
Build Identifier: It would be nice if Eclipse would allow me to CTRL+SPACE inside a new switch statement for an Enum, and give me the option to populate all case statements for each value. And if you really want to get fancy, a dialog box where I can check/uncheck the values I desire. Reproducible: Always
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.