diff options
author | Mateusz Matela | 2017-03-22 21:31:14 +0000 |
---|---|---|
committer | Mateusz Matela | 2017-04-02 20:50:33 +0000 |
commit | 6440a95d11c2ec54750dac953cf4729c7ad71178 (patch) | |
tree | b8a9aee0a5fb1905970165655f3f1f4d723332b5 /org.eclipse.jdt.core.tests.model | |
parent | e91774991ef50c53f3d817f5983287aa2e8ee4ae (diff) | |
download | eclipse.jdt.core-6440a95d11c2ec54750dac953cf4729c7ad71178.tar.gz eclipse.jdt.core-6440a95d11c2ec54750dac953cf4729c7ad71178.tar.xz eclipse.jdt.core-6440a95d11c2ec54750dac953cf4729c7ad71178.zip |
Bug 514017 - [formatter] Count comment width from starting position: change default to trueI20170404-0840I20170404-0245I20170403-2000
Change-Id: I9048616cdb1890cc4286dc5f5f5fe3775f69665e
Signed-off-by: Mateusz Matela <mateusz.matela@gmail.com>
Diffstat (limited to 'org.eclipse.jdt.core.tests.model')
5 files changed, 73 insertions, 4 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 6b591cb2ac..e279366f03 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2016 IBM Corporation and others. + * Copyright (c) 2000, 2017 IBM Corporation 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 @@ -3281,6 +3281,7 @@ public void testBug290905b() throws JavaModelException { ); } public void testBug290905c() throws JavaModelException { + useOldCommentWidthCounting(); this.formatterPrefs.tab_char = DefaultCodeFormatterOptions.MIXED; this.formatterPrefs.tab_size = 0; this.formatterPrefs.indentation_size = 0; @@ -3304,6 +3305,7 @@ public void testBug290905c() throws JavaModelException { ); } public void testBug290905d() throws JavaModelException { + useOldCommentWidthCounting(); this.formatterPrefs.tab_char = DefaultCodeFormatterOptions.MIXED; this.formatterPrefs.tab_size = 0; this.formatterPrefs.indentation_size = 0; @@ -3327,6 +3329,7 @@ public void testBug290905d() throws JavaModelException { ); } public void testBug290905e() throws JavaModelException { + useOldCommentWidthCounting(); this.formatterPrefs.tab_char = DefaultCodeFormatterOptions.TAB; this.formatterPrefs.tab_size = 0; this.formatterPrefs.indentation_size = 0; @@ -3350,6 +3353,7 @@ public void testBug290905e() throws JavaModelException { ); } public void testBug290905f() throws JavaModelException { + useOldCommentWidthCounting(); this.formatterPrefs.tab_char = DefaultCodeFormatterOptions.TAB; this.formatterPrefs.tab_size = 0; this.formatterPrefs.indentation_size = 0; @@ -3418,6 +3422,7 @@ public void testBug293240() { * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=293300" */ public void testBug293300_wksp1_01() { + useOldCommentWidthCounting(); String source = "package wksp1;\n" + "\n" + @@ -3455,6 +3460,7 @@ public void testBug293300_wksp1_01() { ); } public void testBug293300_wkps1_02() { + useOldCommentWidthCounting(); String source = "package wksp1;\n" + "\n" + @@ -3522,6 +3528,7 @@ public void testBug293300_wkps1_03() { ); } public void testBug293300_wkps1_04() { + useOldCommentWidthCounting(); String source = "package wksp1;\n" + "\n" + @@ -3723,6 +3730,7 @@ public void testBug293300_wksp2_03() { ); } public void testBug293300_wksp2_04() { + useOldCommentWidthCounting(); String source = "package wksp2;\n" + "\n" + @@ -4201,6 +4209,7 @@ public void testBug293300_wksp2_05e_spaces() { formatSource(source, EXPECTED_OUTPUT_WKSP2E3_SPACES); } public void testBug293300_wksp_06() { + useOldCommentWidthCounting(); String source = "package wksp2;\n" + "\n" + @@ -4408,6 +4417,7 @@ public void testBug293300_wksp2_09() { ); } public void testBug293300_wksp2_10() { + useOldCommentWidthCounting(); String source = "package wksp2;\n" + "\n" + @@ -4493,6 +4503,7 @@ public void testBug293300_wksp2_11() { ); } public void testBug293300_wksp2_12a() { + useOldCommentWidthCounting(); String source = "package wksp2;\n" + "\n" + @@ -4531,6 +4542,7 @@ public void testBug293300_wksp2_12a() { ); } public void testBug293300_wksp2_12b() { + useOldCommentWidthCounting(); String source = "package wksp2;\n" + "\n" + @@ -4569,6 +4581,7 @@ public void testBug293300_wksp2_12b() { ); } public void testBug293300_wksp2_13() { + useOldCommentWidthCounting(); String source = "package wksp2;\n" + "\n" + @@ -4653,6 +4666,7 @@ public void _testBug293300_wksp2_15a() { ); } public void testBug293300_wksp2_15b() { + useOldCommentWidthCounting(); String source = "package wksp2;\n" + "\n" + @@ -5072,6 +5086,7 @@ public void testBug295175d() { ); } public void testBug295175e() { + useOldCommentWidthCounting(); String source = "package wksp3;\n" + "\n" + @@ -5100,6 +5115,7 @@ public void testBug295175e() { ); } public void testBug295175f() { + useOldCommentWidthCounting(); String source = "package wksp1;\n" + "\n" + @@ -5137,6 +5153,7 @@ public void testBug295175f() { * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=295238" */ public void testBug295238() { + useOldCommentWidthCounting(); this.formatterPrefs.join_lines_in_comments = false; String source = "package wksp1;\n" + @@ -5173,6 +5190,7 @@ public void testBug295238() { } // the following test already passed with v_A21, but failed with first version of the patch public void testBug295238b1() { + useOldCommentWidthCounting(); this.formatterPrefs.join_lines_in_comments = false; String source = "package wksp1;\n" + @@ -5206,6 +5224,7 @@ public void testBug295238b1() { } // the following test failed with v_A21 and with the version v00 of the patch public void testBug295238b2() { + useOldCommentWidthCounting(); this.formatterPrefs.join_lines_in_comments = false; String source = "package wksp1;\n" + @@ -5234,6 +5253,7 @@ public void testBug295238b2() { } // the following test failed with v_A21 and with the version v00 of the patch public void testBug295238b3() { + useOldCommentWidthCounting(); this.formatterPrefs.join_lines_in_comments = false; String source = "package wksp1;\n" + @@ -7462,6 +7482,7 @@ public void testBug320754_03() throws JavaModelException { * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=328240" */ public void testBug328240() { + useOldCommentWidthCounting(); String source = "package com.example;\n" + "\n" + @@ -8404,6 +8425,7 @@ public void testBug330313_wksp1_14() { ); } public void testBug330313_wksp1_14_njl() { + useOldCommentWidthCounting(); this.formatterPrefs.join_wrapped_lines = false; String source = "package wksp1;\n" + @@ -9627,6 +9649,7 @@ public void testBug330313_wksp1_46_njl() { ); } public void testBug330313_wksp1_47_njl() { + useOldCommentWidthCounting(); this.formatterPrefs.join_wrapped_lines = false; String source = "package wksp1;\n" + @@ -9674,6 +9697,7 @@ public void testBug330313_wksp1_47_njl() { ); } public void testBug330313_wksp1_48_njl() { + useOldCommentWidthCounting(); this.formatterPrefs.join_wrapped_lines = false; String source = "package wksp1;\n" + @@ -11235,6 +11259,7 @@ public void testBug474916() { * https://bugs.eclipse.org/474918 - [formatter] doesn't align fields in declarations of annotations, enums and anonymous classes */ public void testBug474918() { + useOldCommentWidthCounting(); this.formatterPrefs.align_type_members_on_columns = true; String source = "import java.util.function.Function;\r\n" + @@ -11299,6 +11324,7 @@ public void testBug474918() { * https://bugs.eclipse.org/474918 - [formatter] doesn't align fields in declarations of annotations, enums and anonymous classes */ public void testBug474918b() { + useOldCommentWidthCounting(); this.formatterPrefs.align_type_members_on_columns = true; this.formatterPrefs.tab_char = DefaultCodeFormatterOptions.SPACE; String source = @@ -11364,6 +11390,7 @@ public void testBug474918b() { * https://bugs.eclipse.org/474918 - [formatter] doesn't align fields in declarations of annotations, enums and anonymous classes */ public void testBug474918c() { + useOldCommentWidthCounting(); this.formatterPrefs.align_type_members_on_columns = true; this.formatterPrefs.use_tabs_only_for_leading_indentations = true; String source = diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java index 4c6f07e036..a08fb5048d 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2016 IBM Corporation and others. + * Copyright (c) 2000, 2017 IBM Corporation 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 @@ -1628,6 +1628,7 @@ public void testBug233259a() throws JavaModelException { ); } public void testBug233259b() throws JavaModelException { + useOldCommentWidthCounting(); this.formatterPrefs.comment_line_length = 40; // difference with 3.3 formatter: // split html reference as this allow not to go over the max line width @@ -2484,6 +2485,7 @@ public void testBug237051c() throws JavaModelException { ); } public void testBug237051d() throws JavaModelException { + useOldCommentWidthCounting(); String source = "public class X {\n" + "\n" + @@ -2898,6 +2900,7 @@ public void testBug238210_X01() throws JavaModelException { ); } public void testBug238210_X02() throws JavaModelException { + useOldCommentWidthCounting(); String source = "package eclipse30;\n" + "\n" + @@ -2915,6 +2918,7 @@ public void testBug238210_X02() throws JavaModelException { ); } public void testBug238210_X03() throws JavaModelException { + useOldCommentWidthCounting(); String source = "package eclipse30;\n" + "\n" + @@ -3161,6 +3165,7 @@ public void testBug239130_clearBlankLines_preserveLineBreaks() throws JavaModelE } // duplicate bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=196124 public void testBug239130_196124_default() throws JavaModelException { + useOldCommentWidthCounting(); String source = "public class X {\n" + "\n" + @@ -3247,6 +3252,7 @@ public void testBug239130_96696_block_default() throws JavaModelException { formatSource(source, source); } public void testBug239130_96696_block_clearBlankLines() throws JavaModelException { + useOldCommentWidthCounting(); this.formatterPrefs.join_wrapped_lines = false; this.formatterPrefs.comment_clear_blank_lines_in_block_comment = true; String source = @@ -3325,6 +3331,7 @@ public void testBug239130_96696_javadoc_default() throws JavaModelException { formatSource(source, source); } public void testBug239130_96696_javadoc_clearBlankLines() throws JavaModelException { + useOldCommentWidthCounting(); this.formatterPrefs.comment_clear_blank_lines_in_javadoc_comment = true; String source = "public class Test {\n" + @@ -3426,6 +3433,7 @@ public void testBug239719() throws JavaModelException { ); } public void testBug239719b() throws JavaModelException { + useOldCommentWidthCounting(); String source = "public class X01 {\n" + " \n" + @@ -4282,6 +4290,7 @@ public void testBug260011_05() throws JavaModelException { ); } public void testBug260011_06() throws JavaModelException { + useOldCommentWidthCounting(); String source = "public interface Test {\n" + "\n" + @@ -4525,6 +4534,7 @@ public void testBug260274d() throws JavaModelException { ); } public void testBug260274e() throws JavaModelException { + useOldCommentWidthCounting(); String source = "class X {\n" + "/*\n" + @@ -4544,6 +4554,7 @@ public void testBug260274e() throws JavaModelException { ); } public void testBug260274f() throws JavaModelException { + useOldCommentWidthCounting(); String source = "class X {\n" + "/* *****************************************************************************\n" + @@ -4564,6 +4575,7 @@ public void testBug260274f() throws JavaModelException { ); } public void testBug260274g() throws JavaModelException { + useOldCommentWidthCounting(); String source = "class X {\n" + "/*\n" + @@ -4894,6 +4906,7 @@ public void testBug260381k() throws JavaModelException { formatSource(source); } public void testBug260381_wksp1_01() throws JavaModelException { + useOldCommentWidthCounting(); String source = "package wksp1;\n" + "\n" + @@ -5067,6 +5080,7 @@ public void testBug260381_wksp2_01c() throws JavaModelException { ); } public void testBug260381_wksp2_02() throws JavaModelException { + useOldCommentWidthCounting(); String source = "package wksp2;\n" + "\n" + @@ -5099,6 +5113,7 @@ public void testBug260381_wksp2_02() throws JavaModelException { ); } public void testBug260381_wksp2_03() throws JavaModelException { + useOldCommentWidthCounting(); String source = "package wksp2;\n" + "\n" + @@ -5177,6 +5192,7 @@ public void testBug260381_wksp2_03b() throws JavaModelException { ); } public void testBug260381_wksp2_04() throws JavaModelException { + useOldCommentWidthCounting(); String source = "package wksp2;\n" + "\n" + @@ -5238,6 +5254,7 @@ public void testBug260381_wksp2_04() throws JavaModelException { ); } public void testBug260381_wksp2_05() throws JavaModelException { + useOldCommentWidthCounting(); String source = "package wksp2;\n" + "\n" + @@ -5321,6 +5338,7 @@ public void testBug260381_wksp2_05() throws JavaModelException { ); } public void testBug260381_wksp2_06() throws JavaModelException { + useOldCommentWidthCounting(); String source = "package wksp2;\n" + "\n" + @@ -5383,6 +5401,7 @@ public void testBug260381_wksp2_06() throws JavaModelException { ); } public void testBug260381_wksp2_07() throws JavaModelException { + useOldCommentWidthCounting(); String source = "package wksp2;\n" + "\n" + @@ -5427,6 +5446,7 @@ public void testBug260381_wksp2_07() throws JavaModelException { ); } public void testBug260381_wksp2_08() throws JavaModelException { + useOldCommentWidthCounting(); String source = "package wksp2;\n" + "\n" + @@ -6420,6 +6440,7 @@ public void testBug305518() { "}\n"); } public void testBug305518_wksp2_01() { + useOldCommentWidthCounting(); String source = "public class X01 {\n" + "/**\n" + @@ -6750,6 +6771,7 @@ public void testBug309835_wksp1_01() { ); } public void testBug309835_wksp1_02() { + useOldCommentWidthCounting(); String source = "public class X02 {\n" + "\n" + @@ -6814,6 +6836,7 @@ public void testBug309835_wksp2_01() { * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=311864" */ public void testBug311864() throws JavaModelException { + useOldCommentWidthCounting(); this.formatterPrefs.use_tags = true; String source = "public class Test {\n" + @@ -7110,6 +7133,7 @@ public void testBug313651_wksp3_02() { ); } public void testBug348338() { + useOldCommentWidthCounting(); String source = "public class X03 {\n" + " /**\n" + @@ -7201,6 +7225,7 @@ public void testBug471918() { * https://bugs.eclipse.org/474011 - [formatter] non-nls strings are duplicated by formatter */ public void testBug474011() { + useOldCommentWidthCounting(); String source = "class A {\n" + " String aaaaaaaaaaaaaaaa = \"11111111111111111111111111111111111111\"; //$NON-NLS-1$ aaa bbb ccc\n" + @@ -7228,6 +7253,7 @@ public void testBug474011() { * https://bugs.eclipse.org/475294 - [formatter] "Preserve whitespace..." problems with wrapped line comments */ public void testBug475294() { + useOldCommentWidthCounting(); this.formatterPrefs.comment_preserve_white_space_between_code_and_line_comments = true; String source = "public class A {\n" + @@ -7277,6 +7303,7 @@ public void testBug475294() { * https://bugs.eclipse.org/475294 - [formatter] "Preserve whitespace..." problems with wrapped line comments */ public void testBug475294b() { + useOldCommentWidthCounting(); this.formatterPrefs.comment_preserve_white_space_between_code_and_line_comments = true; this.formatterPrefs.use_tabs_only_for_leading_indentations = true; String source = @@ -7581,6 +7608,7 @@ public void testBug510995b() { * https://bugs.eclipse.org/512095 - [formatter] Unstable wrap on a line with wrapped code and wrapped block comment */ public void testBug512095() { + useOldCommentWidthCounting(); String source = "class Test1 {\n" + " void f() {\n" + diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsTests.java index 9edcdc6bd2..bb85ca7f23 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsTests.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2015 IBM Corporation and others. + * Copyright (c) 2000, 2017 IBM Corporation 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 @@ -239,6 +239,7 @@ private Map getDefaultCompilerOptions() { } void formatUnit(String packageName, String unitName) throws JavaModelException{ + useOldCommentWidthCounting(); formatUnit(packageName, unitName, CodeFormatter.K_COMPILATION_UNIT | CodeFormatter.F_INCLUDE_COMMENTS, 0, false, 0, -1, null); } @@ -732,6 +733,7 @@ public void testLineComments01() throws JavaModelException { formatUnit("comments.line", "X01.java"); } public void testLineComments02() throws JavaModelException { + useOldCommentWidthCounting(); String source = "public class X02 {\r\n" + " int field; // This is a long comment that should be split in multiple line comments in case the line comment formatting is enabled\r\n" + @@ -745,6 +747,7 @@ public void testLineComments02() throws JavaModelException { ); } public void testLineComments02b() throws JavaModelException { + useOldCommentWidthCounting(); String source = "public interface X02b {\r\n" + "\r\n" + @@ -776,6 +779,7 @@ public void testLineComments06() throws JavaModelException { formatUnit("comments.line", "X06.java"); } public void testLineComments07() throws JavaModelException { + useOldCommentWidthCounting(); String source = "package test.comments.line;\r\n" + "\r\n" + @@ -826,6 +830,7 @@ public void testLineComments10() throws JavaModelException { formatUnit("comments.line", "X10.java"); } public void testLineComments11() throws JavaModelException { + useOldCommentWidthCounting(); this.formatterPrefs.comment_line_length = 40; String source = "package test.comments.line;\r\n" + diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterRegressionTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterRegressionTests.java index ba62f3862e..3eda4a0a75 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterRegressionTests.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterRegressionTests.java @@ -107,6 +107,14 @@ public class FormatterRegressionTests extends AbstractJavaModelTests { private void setFormatterOptions80() { this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, Integer.toString(80)); } + + /** + * Helper function for tests that are expect comment width counted from the + * beginning of the line, not from comment's starting position. + */ + protected void useOldCommentWidthCounting() { + this.formatterPrefs.comment_count_line_length_from_starting_position = false; + } /** * Returns the OS path to the directory that contains this plugin. * diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/comment/SingleLineTestCase.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/comment/SingleLineTestCase.java index e3d7195c2a..7ad666b31a 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/comment/SingleLineTestCase.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/comment/SingleLineTestCase.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2015 IBM Corporation and others. + * Copyright (c) 2000, 2017 IBM Corporation 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 @@ -145,6 +145,7 @@ public class SingleLineTestCase extends CommentTestCase { public void testCommentWrapping5() { setUserOption(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); + setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_COUNT_LINE_LENGTH_FROM_STARTING_POSITION, DefaultCodeFormatterConstants.FALSE); String prefix= "public class Test {" + DELIMITER + " int test; // test test test test test test test test test test test test"; String inputInfix= " "; String expectedInfix= DELIMITER + "\t\t\t\t" + PREFIX; |