Summary: | [ast rewrite] Wrong indentation for statement inserted before SwitchCase | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Markus Keller <markus.kell.r> | ||||||||
Component: | Core | Assignee: | David Audel <david_audel> | ||||||||
Status: | VERIFIED FIXED | QA Contact: | |||||||||
Severity: | normal | ||||||||||
Priority: | P3 | CC: | daniel_megert, Olivier_Thomann, philippe_mulet | ||||||||
Version: | 3.4 | ||||||||||
Target Milestone: | 3.5 M6 | ||||||||||
Hardware: | PC | ||||||||||
OS: | Windows XP | ||||||||||
Whiteboard: | |||||||||||
Attachments: |
|
Description
Markus Keller
2008-09-08 13:47:57 EDT
This one is annoying... Same problem when you remove a statement in front of a SwitchCase, e.g. have: void m() { switch (1) { case 1: System.out.println("Hello"); break; System.out.println("Unreachable"); break; case 2: System.out.println("Hello3"); return; default: System.out.println("Hell4"); break; } } Quick Fix to remove unreachable code gives: void m() { switch (1) { case 1: System.out.println("Hello"); break; case 2: System.out.println("Hello3"); return; default: System.out.println("Hell4"); break; } } => "case 2:" should keep original indentation. See bug 257524 for a problem in the formatter with unreachable code. Created attachment 124661 [details]
Proposed fix
All statements in a switch statement do not have the same indentation and ASTRewriteAnalyzer does not update this indentation when necessary.
This patch improve ASTRewriteAnalyzer to produce correct indentation.
Created attachment 124662 [details]
Correct patch
I attached the wrong patch, the correct patch is this one.
Created attachment 124665 [details]
Proposed patch for JDTUI tests
Some JDTUI regressions test failed with the fix. This is a patch for these tests.
OK, will look at the patch once you've committed the JDT Core side. Released for 3.5M6. Released jdtcore patch and added tests: ASTRewritingStatementsTest#testSwitchStatement2() -> testSwitchStatement10() Looks good, I released the UI patch. Verified for 3.5M6 using I20090310-0100. |