diff options
2 files changed, 13 insertions, 1 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 b80a1e6e69..fb983d8814 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 @@ -12528,4 +12528,16 @@ public void testBug500135() { "}";
formatSource(source);
}
+/**
+ * https://bugs.eclipse.org/500853 - [Formatter] java code formatter doesn't honour new parentheses settings
+ */
+public void testBug500853() {
+ this.formatterPrefs.parenthesis_positions_in_method_declaration = new String(DefaultCodeFormatterConstants.PRESERVE_POSITIONS);
+ String source =
+ "public class SomeClass {\n" +
+ " void foo() {\n" +
+ " }\n" +
+ "}";
+ formatSource(source);
+}
}
diff --git a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/LineBreaksPreparator.java b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/LineBreaksPreparator.java index 5927ea5259..b0a5584366 100644 --- a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/LineBreaksPreparator.java +++ b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/LineBreaksPreparator.java @@ -760,7 +760,7 @@ public class LineBreaksPreparator extends ASTVisitor { //$FALL-THROUGH$ case DefaultCodeFormatterConstants.SEPARATE_LINES: case DefaultCodeFormatterConstants.PRESERVE_POSITIONS: - boolean always = positionsSetting != DefaultCodeFormatterConstants.PRESERVE_POSITIONS; + boolean always = !positionsSetting.equals(DefaultCodeFormatterConstants.PRESERVE_POSITIONS); Token afterOpening = this.tm.get(openingParenIndex + 1); if (always || this.tm.countLineBreaksBetween(this.tm.get(openingParenIndex), afterOpening) > 0) { afterOpening.setWrapPolicy( |