| Summary: | [move method] Move method adds enum name to case statements | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Didier Loiseau <didierloiseau+eclipse> |
| Component: | UI | Assignee: | Markus Keller <markus.kell.r> |
| Status: | RESOLVED FIXED | QA Contact: | |
| Severity: | normal | ||
| Priority: | P2 | CC: | daniel_megert, markus.kell.r |
| Version: | 3.7 | ||
| Target Milestone: | 3.8 M7 | ||
| Hardware: | All | ||
| OS: | All | ||
| Whiteboard: | |||
Same in 3.7 M6. Fixed in HEAD. commit fc4f451f07054d44cce5ca22fbae4e09d91c35d4 The fix doesn't make sense and it doesn't work when I copy the 2 classes from comment 0 and paste them into a package p. The missing imports may be a special problem because of the secondary class in the same CU, but it also doesn't work if OtherClass gets its own CU. The problem is that the SwitchCase expression must not be qualified if the switch operates on an Enum. Use Checks.isEnumCase(ASTNode). Reverted the commit for the build input. Commit df8029575a70827bf3da5400c0957a31fce97355 Moving to M6... Fixed with http://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/commit/?id=b0c3b403fb971af242b9d5ac876b884f271b259f and added Raksha's tests with next commit. |
Build Identifier: 20100617-1415 When using the "Move..." refactoring on a method containing a switch over some enum value, the cases values will be prefixed with their enum name. Reproducible: Always Steps to Reproduce: 1. Create a class with the below code 2. Trigger "Move..." refactoring on someMethod 3. Choose to move the method to someField 4. The resulting code does not compile because each case statement contains the enum name ("case MyEnum.FOO:" instead of just "case FOO:") public class MoveMethodWithEnum { OtherClass someField; enum MyEnum { FOO, BAR } void someMethod(MyEnum fooBar) { switch (fooBar) { case FOO: System.out.println("foo"); break; case BAR: System.out.println("bar"); } } } class OtherClass { }