diff options
author | Mateusz Matela | 2016-01-05 14:20:56 +0000 |
---|---|---|
committer | Mateusz Matela | 2016-01-05 14:20:56 +0000 |
commit | 0ce4ce22c72f34e69f5fcefb01350722f8598c48 (patch) | |
tree | 622c735c18d5ba40b5f64db09f875bff21e83cfb | |
parent | 914b6ca8879c091899436a3e165f852aff30c28e (diff) | |
download | eclipse.jdt.core-I20160105-1000.tar.gz eclipse.jdt.core-I20160105-1000.tar.xz eclipse.jdt.core-I20160105-1000.zip |
Bug 479898 - [formatter] removes whitespace between final and first exception in multi-line multi-catchI20160105-1000
2 files changed, 21 insertions, 3 deletions
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java index ced990a46d..5e31729ecb 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java @@ -12304,4 +12304,20 @@ public void testBug485163() { "}"
);
}
-}
\ No newline at end of file +/**
+ * https://bugs.eclipse.org/479898 - [formatter] removes whitespace between final and first exception in multi-line multi-catch
+ */
+public void testBug479898() {
+ this.formatterPrefs.alignment_for_union_type_in_multicatch = Alignment.M_COMPACT_SPLIT + Alignment.M_INDENT_ON_COLUMN;
+ String source =
+ "public class FormattingTest {\r\n" +
+ " public void formatterTest() {\r\n" +
+ " try {\r\n" +
+ " } catch (final InstantiationException | IllegalAccessException | IllegalArgumentException\r\n" +
+ " | NoSuchMethodException e) {\r\n" +
+ " }\r\n" +
+ " }\r\n" +
+ "}";
+ formatSource(source);
+}
+}
diff --git a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/linewrap/WrapPreparator.java b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/linewrap/WrapPreparator.java index 1d245646e8..e128b03e87 100644 --- a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/linewrap/WrapPreparator.java +++ b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/linewrap/WrapPreparator.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2014, 2015 Mateusz Matela and others. + * Copyright (c) 2014, 2016 Mateusz Matela and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -656,7 +656,9 @@ public class WrapPreparator extends ASTVisitor { this.secondaryWrapIndexes.add(this.tm.firstIndexIn(type, -1)); } } - this.wrapParentIndex = this.tm.firstIndexBefore(node, TokenNameLPAREN); + this.wrapParentIndex = this.tm.firstIndexBefore(node, -1); + while (this.tm.get(this.wrapParentIndex).isComment()) + this.wrapParentIndex--; this.wrapGroupEnd = this.tm.lastIndexIn(types.get(types.size() - 1), -1); handleWrap(this.options.alignment_for_union_type_in_multicatch); } else { |