Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 372840 - [quick fix] Add a quick fix to add the missing default in a switch statement
Summary: [quick fix] Add a quick fix to add the missing default in a switch statement
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.8   Edit
Hardware: PC Windows 7
: P3 enhancement (vote)
Target Milestone: 3.8 M6   Edit
Assignee: Deepak Azad CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 265744
Blocks:
  Show dependency tree
 
Reported: 2012-02-29 07:21 EST by Deepak Azad CLA
Modified: 2012-03-07 13:01 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Deepak Azad CLA 2012-02-29 07:21:06 EST
See bug 265744

We should add a quick fix to add the missing default for IProblem.MissingEnumDefaultCase.
Comment 1 Deepak Azad CLA 2012-02-29 07:35:20 EST
Also see bug 372818 comment 2.
Comment 2 Deepak Azad CLA 2012-03-03 09:32:33 EST
- Updated the preference label
- Quick fix works for the new problem
- Quick fix/assist always adds a default statement if it is missing.

http://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/commit/?id=f3fc6fb7bb9a825e5a97a39f3440add027e8bb48
Comment 3 Markus Keller CLA 2012-03-05 08:21:39 EST
Please combine these two LocalCorrectionsSubProcessor methods into one:
evaluateMissingDefaultCase(List<Statement>)
evaluateMissingEnumConstantCases(ITypeBinding, List<Statement>)

They are always used together, so callers can be simplified and we avoid looping twice.

Furthermore, the quick fix for "The switch on the enum type Thread.State should have a default case" is not what I'd expect:
It's OK to have the "Add missing case statements" fix there as well iff there are really uncovered enum constants, but the first proposal should be "Add default case", which doesn't add any case statements for missing constants.