Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 329626 - [quick assist] RFE: Quick fix to set all case statements in an Enum switch
Summary: [quick assist] RFE: Quick fix to set all case statements in an Enum switch
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.7   Edit
Hardware: PC Windows 7
: P3 enhancement (vote)
Target Milestone: 3.7 M5   Edit
Assignee: Deepak Azad CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-11-06 23:08 EDT by Paul Benedict CLA
Modified: 2010-12-10 01:05 EST (History)
2 users (show)

See Also:
markus.kell.r: review+


Attachments
fix + tests (9.73 KB, patch)
2010-12-09 11:28 EST, Deepak Azad CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Benedict CLA 2010-11-06 23:08:21 EDT
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
Comment 1 Markus Keller CLA 2010-11-29 10:48:01 EST
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).
Comment 2 Paul Benedict CLA 2010-11-29 11:15:29 EST
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
        }
    }
Comment 3 Markus Keller CLA 2010-11-29 12:56:36 EST
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.
Comment 4 Deepak Azad CLA 2010-12-09 11:28:46 EST
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.
Comment 5 Markus Keller CLA 2010-12-09 12:04:21 EST
Looks good.
Comment 6 Deepak Azad CLA 2010-12-10 01:05:41 EST
Fixed in HEAD.