diff options
author | Mateusz Matela | 2020-07-14 21:20:40 +0000 |
---|---|---|
committer | Mateusz Matela | 2020-07-14 21:28:29 +0000 |
commit | edb49b82dfdf5c2cd9039afb77b8c97a9b2a4e7a (patch) | |
tree | 6ae9657de5892c1f7dbefdebf3b7da84585bb468 | |
parent | 5ba272a2d4a7478e0eb3951208ab49b7c069f37d (diff) | |
download | eclipse.jdt.core-edb49b82dfdf5c2cd9039afb77b8c97a9b2a4e7a.tar.gz eclipse.jdt.core-edb49b82dfdf5c2cd9039afb77b8c97a9b2a4e7a.tar.xz eclipse.jdt.core-edb49b82dfdf5c2cd9039afb77b8c97a9b2a4e7a.zip |
Bug 565053 - [formatter] Parenthesis in "separate lines if wrapped":
wrapping disruptions
Change-Id: Ic61233a5763f6c2d74e559f378f38194f8f41934
Signed-off-by: Mateusz Matela <mateusz.matela@gmail.com>
2 files changed, 34 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 84dab8e485..defc484c20 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 @@ -13059,7 +13059,7 @@ public void testBug220713() { /** * https://bugs.eclipse.org/558421 [formatter] Generate getter/setter creates unnecessary blank line */ -public void testBug() { +public void testBug558421() { this.formatterPrefs.blank_lines_after_last_class_body_declaration = 1; String source = "public int getA() {\n" + @@ -13195,4 +13195,35 @@ public void testBug563487c() { "}\n" + "}"); } +/** + * https://bugs.eclipse.org/565053 - [formatter] Parenthesis in "separate lines if wrapped": wrapping disruptions + */ +public void testBug565053a() { + this.formatterPrefs.parenthesis_positions_in_method_invocation = DefaultCodeFormatterConstants.SEPARATE_LINES_IF_WRAPPED; + this.formatterPrefs.page_width = 92; + formatSource( + "class Example {\n" + + "\n" + + " List SUPPORTED_THINGS = asList(\n" + + " new Thing(\n" + + " \"rocodileaaadasgasgasgasgasgasgaaaaasgsgasgasgasgasfafghasfaa aaadad\"\n" + + " ), \"new Thing()\"\n" + + " );\n" + + "}"); +} +/** + * https://bugs.eclipse.org/565053 - [formatter] Parenthesis in "separate lines if wrapped": wrapping disruptions + */ +public void testBug565053b() { + this.formatterPrefs.parenthesis_positions_in_method_invocation = DefaultCodeFormatterConstants.SEPARATE_LINES_IF_WRAPPED; + this.formatterPrefs.page_width = 100; + formatSource( + "class Example {\n" + + "\n" + + " List SUPPORTED_THINGS = asList(\n" + + " new Thing(\"rocodileaaadasgasgasgasgasgasgaaaaasgsgasgasgasgasfafghasfaa aaadad\")\n" + + " \"new Thing()\"\n" + + " );\n" + + "}"); +} } 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 558fa885fe..6685c1d736 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 @@ -1465,9 +1465,9 @@ public class WrapPreparator extends ASTVisitor { if (isEmpty) break; this.tm.get(openingParenIndex + 1).setWrapPolicy(new WrapPolicy(WrapMode.TOP_PRIORITY, - openingParenIndex, closingParenIndex, this.options.indentation_size, 1, 1, true, false)); + openingParenIndex, closingParenIndex, this.options.indentation_size, this.currentDepth, 1, true, false)); this.tm.get(closingParenIndex).setWrapPolicy(new WrapPolicy(WrapMode.TOP_PRIORITY, - openingParenIndex, closingParenIndex, 0, 1, 1, false, false)); + openingParenIndex, closingParenIndex, 0, this.currentDepth, 1, false, false)); break; case DefaultCodeFormatterConstants.SEPARATE_LINES_IF_NOT_EMPTY: if (isEmpty) |