Project: JDT
Bug 350285 ASTRewrite destroys formatting on CatchClause#setBody(copyTarget)
Reported: 2011-06-24 11:57:11 | Status: verified fixed

BETA_JAVA7, but most probably not Java 7 related The new Quick Fix to convert a multi-catch to separate catch blocks tried to use newCatchClause.setBody( (Block) rewrite.createCopyTarget(catchClause.getBody())); in QuickAssistProcessor#getUnrollMultiCatchProposals(..), but this mangled e.g. public class E { void foo() { try { System.out.println("foo"); } catch (IllegalArgumentException | NullPointerException ex) { ex.printStackTrace(); } } } into void foo() { try { System.out.println("foo"); } catch (IllegalArgumentException ex) { ex.printStackTrace(); } catch (NullPointerException ex) { ex.printStackTrace(); } } As a workaround, we now copy statement-by-statement, but this should not be necessary, and it can lose comments if they are separated by newlines. UI tests are in AssistQuickFixTest17.

Files changed in fix:
org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AssistQuickFixTest17.java