### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core.tests.model Index: src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java,v retrieving revision 1.25 diff -u -r1.25 FormatterCommentsBugsTest.java --- src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java 21 Aug 2008 08:53:21 -0000 1.25 +++ src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java 29 Aug 2008 11:33:34 -0000 @@ -84,7 +84,7 @@ formatUnit("bugs.b230944", "X01.java"); } public void testBug230944b() throws JavaModelException { - this.preferences.comment_line_length = 40; + this.formatterPrefs.comment_line_length = 40; formatUnit("bugs.b230944", "X02.java"); } @@ -97,7 +97,7 @@ formatUnit("bugs.b231263", "BadFormattingSample.java"); } public void testBug231263a() throws JavaModelException { - this.preferences.comment_line_length = 40; + this.formatterPrefs.comment_line_length = 40; formatUnit("bugs.b231263", "X.java"); } @@ -107,29 +107,29 @@ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=231297" */ public void testBug231297() throws JavaModelException { - this.preferences.comment_line_length = 40; + this.formatterPrefs.comment_line_length = 40; formatUnit("bugs.b231297", "X.java"); } public void testBug231297a() throws JavaModelException { - this.preferences.comment_line_length = 30; + this.formatterPrefs.comment_line_length = 30; formatUnit("bugs.b231297", "X01.java"); } public void testBug231297b() throws JavaModelException { // Difference with old formatter: // 1) fixed non formatted inline tag description - this.preferences.comment_line_length = 40; + this.formatterPrefs.comment_line_length = 40; formatUnit("bugs.b231297", "X02.java"); } public void testBug231297c() throws JavaModelException { // Difference with old formatter: // 1) fixed non formatted inline tag description - this.preferences.comment_line_length = 40; + this.formatterPrefs.comment_line_length = 40; formatUnit("bugs.b231297", "X03.java"); } public void testBug231297d() throws JavaModelException { // Difference with old formatter: // 1) fixed non formatted inline tag description - this.preferences.comment_line_length = 40; + this.formatterPrefs.comment_line_length = 40; formatUnit("bugs.b231297", "X03b.java"); } @@ -139,43 +139,43 @@ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=232285" */ public void testBug232285a() throws JavaModelException { - this.preferences.comment_line_length = 40; + this.formatterPrefs.comment_line_length = 40; formatUnit("bugs.b232285", "X01.java"); } public void testBug232285b() throws JavaModelException { - this.preferences.comment_line_length = 40; + this.formatterPrefs.comment_line_length = 40; formatUnit("bugs.b232285", "X01b.java"); } public void testBug232285c() throws JavaModelException { - this.preferences.comment_line_length = 40; + this.formatterPrefs.comment_line_length = 40; formatUnit("bugs.b232285", "X01c.java"); } public void testBug232285d() throws JavaModelException { - this.preferences.comment_line_length = 40; + this.formatterPrefs.comment_line_length = 40; formatUnit("bugs.b232285", "X01d.java"); } public void testBug232285e() throws JavaModelException { - this.preferences.comment_line_length = 40; + this.formatterPrefs.comment_line_length = 40; formatUnit("bugs.b232285", "X01e.java"); } public void testBug232285f() throws JavaModelException { - this.preferences.comment_line_length = 40; + this.formatterPrefs.comment_line_length = 40; formatUnit("bugs.b232285", "X01f.java"); } public void testBug232285g() throws JavaModelException { - this.preferences.comment_line_length = 40; + this.formatterPrefs.comment_line_length = 40; formatUnit("bugs.b232285", "X02.java"); } public void testBug232285h() throws JavaModelException { - this.preferences.comment_line_length = 40; + this.formatterPrefs.comment_line_length = 40; formatUnit("bugs.b232285", "X03.java"); } public void testBug232285i() throws JavaModelException { - this.preferences.comment_line_length = 40; + this.formatterPrefs.comment_line_length = 40; formatUnit("bugs.b232285", "X04.java"); } public void testBug232285j() throws JavaModelException { - this.preferences.comment_line_length = 40; + this.formatterPrefs.comment_line_length = 40; formatUnit("bugs.b232285", "X04b.java"); } @@ -185,7 +185,7 @@ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=232488" */ public void testBug232488() throws JavaModelException { - this.preferences.comment_line_length = 40; + this.formatterPrefs.comment_line_length = 40; formatUnit("bugs.b232488", "X01.java"); } @@ -195,11 +195,11 @@ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=232466" */ public void testBug232466a() throws JavaModelException { - this.preferences.comment_line_length = 40; + this.formatterPrefs.comment_line_length = 40; formatUnit("bugs.b232466", "X01.java"); } public void testBug232466b() throws JavaModelException { - this.preferences.comment_line_length = 40; + this.formatterPrefs.comment_line_length = 40; formatUnit("bugs.b232466", "X02.java"); } @@ -218,11 +218,10 @@ "\r\n#]" + "}\r\n" + ""; - // TODO fix the incorrect indentation before the javadoc comment (also in 3.3 and 3.4M6) formatSource(source, "public class A {\n" + "\n" + - " /*\n" + + " /*\n" + " * A block comment on two lines\n" + " */\n" + "\n" + @@ -247,7 +246,7 @@ " public void foo() {\n" + " }\n" + "\n" + - " /*\n" + + " /*\r\n" + " * A block comment \n" + " * on two lines\n" + " */\n" + @@ -272,17 +271,15 @@ "#]\n" + "\n" + "}"; - // TODO fix the incorrect indentation before the javadoc comment (also in 3.3 and 3.4M6) formatSource(source, "public class C {\n" + " \n" + - " /**\n" + + " /**\n" + " * a b c d .\n" + " */\n" + " void m1() {\n" + "\n" + - " } \n" + - "\n" + + " }\n" + "\n" + "}" ); @@ -313,7 +310,7 @@ " * a b c d .\n" + " */\n" + " void m1() {\n" + - " \n" + + "\n" + " } \n" + "\n" + "\n" + @@ -370,11 +367,10 @@ "\n" + "\n" + "}"; - // TODO fix the incorrect indentation before the javadoc comment (also in 3.3 and 3.4M6) formatSource(source, "public class C {\n" + - " \n" + - " /**\n" + + "\n" + + " /**\n" + " * a b c d .\n" + " */\n" + " void m1 ( ) {\n" + @@ -468,17 +464,15 @@ "#]\n" + "\n" + "}"; - // TODO fix the incorrect indentation before the block comment (also in 3.3 and 3.4M6) formatSource(source, "public class D {\n" + " \n" + - " /*\n" + + " /*\n" + " * a b c d .\n" + " */\n" + " void m2() {\n" + "\n" + - " } \n" + - "\n" + + " }\n" + "\n" + "}" ); @@ -509,7 +503,7 @@ " * a b c d .\n" + " */\n" + " void m2() {\n" + - " \n" + + "\n" + " } \n" + "\n" + "\n" + @@ -566,11 +560,10 @@ "\n" + "\n" + "}"; - // TODO fix the incorrect indentation before the block comment (also in 3.3 and 3.4M6) formatSource(source, "public class D {\n" + - " \n" + - " /*\n" + + "\n" + + " /*\n" + " * a b c d .\n" + " */\n" + " void m2 ( ) {\n" + @@ -657,13 +650,11 @@ " }\n" + "#] \n" + "}"; - // TODO fix the incorrect indentation before the method declaration (also in 3.3 and 3.4M6) - // Note that the line comment wasn't formatted using 3.3 and 3.4 M6 formatSource(source, "public class E {\n" + " \n" + "\n" + - " void m3() { // this is a bug\n" + + " void m3() { // this is a bug\n" + "\n" + " }\n" + " \n" + @@ -707,7 +698,7 @@ "public class E {\n" + " \n" + "\n" + - " void m3() { // this is a bug\n" + + " void m3() { // this is a bug\n" + "\n" + " }\n" + "\n" + @@ -750,7 +741,7 @@ "public class E { \n" + " \n" + "\n" + - " void m3() { // this is a bug\n" + + " void m3() { // this is a bug\n" + "\n" + " }\n" + " \n" + @@ -772,7 +763,7 @@ "public class E { \n" + " \n" + "\n" + - " void m3() { // this is a bug\n" + + " void m3() { // this is a bug\n" + "\n" + " }\n" + " \n" + @@ -796,7 +787,7 @@ " \n" + "\n" + " void m3() { \n" + - " // this is a bug\n" + + " // this is a bug\n" + "\n" + " }\n" + " \n" + @@ -832,63 +823,63 @@ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=232788" */ public void testBug232788_Tabs01() throws JavaModelException { - this.preferences.comment_line_length = 40; - this.preferences.tab_size = 1; - this.preferences.indentation_size = 1; + this.formatterPrefs.comment_line_length = 40; + this.formatterPrefs.tab_size = 1; + this.formatterPrefs.indentation_size = 1; formatUnit("bugs.b232788", "X01_tabs.java"); } public void testBug232788_Spaces01() throws JavaModelException { - this.preferences.comment_line_length = 40; - this.preferences.tab_char = DefaultCodeFormatterOptions.SPACE; - this.preferences.tab_size = 1; - this.preferences.indentation_size = 1; + this.formatterPrefs.comment_line_length = 40; + this.formatterPrefs.tab_char = DefaultCodeFormatterOptions.SPACE; + this.formatterPrefs.tab_size = 1; + this.formatterPrefs.indentation_size = 1; formatUnit("bugs.b232788", "X01_spaces.java"); } public void testBug232788_Mixed01() throws JavaModelException { - this.preferences.comment_line_length = 40; - this.preferences.tab_char = DefaultCodeFormatterOptions.MIXED; - this.preferences.tab_size = 1; - this.preferences.indentation_size = 1; + this.formatterPrefs.comment_line_length = 40; + this.formatterPrefs.tab_char = DefaultCodeFormatterOptions.MIXED; + this.formatterPrefs.tab_size = 1; + this.formatterPrefs.indentation_size = 1; formatUnit("bugs.b232788", "X01_mixed.java"); } public void testBug232788_Tabs02() throws JavaModelException { - this.preferences.comment_line_length = 40; - this.preferences.tab_size = 0; - this.preferences.indentation_size = 0; + this.formatterPrefs.comment_line_length = 40; + this.formatterPrefs.tab_size = 0; + this.formatterPrefs.indentation_size = 0; formatUnit("bugs.b232788", "X02_tabs.java"); } public void testBug232788_Spaces02() throws JavaModelException { - this.preferences.comment_line_length = 40; - this.preferences.tab_char = DefaultCodeFormatterOptions.SPACE; - this.preferences.tab_size = 0; - this.preferences.indentation_size = 0; + this.formatterPrefs.comment_line_length = 40; + this.formatterPrefs.tab_char = DefaultCodeFormatterOptions.SPACE; + this.formatterPrefs.tab_size = 0; + this.formatterPrefs.indentation_size = 0; formatUnit("bugs.b232788", "X02_spaces.java"); } public void testBug232788_Mixed02() throws JavaModelException { - this.preferences.comment_line_length = 40; - this.preferences.tab_char = DefaultCodeFormatterOptions.MIXED; - this.preferences.tab_size = 0; - this.preferences.indentation_size = 0; + this.formatterPrefs.comment_line_length = 40; + this.formatterPrefs.tab_char = DefaultCodeFormatterOptions.MIXED; + this.formatterPrefs.tab_size = 0; + this.formatterPrefs.indentation_size = 0; formatUnit("bugs.b232788", "X02_mixed.java"); } public void testBug232788_Tabs03() throws JavaModelException { - this.preferences.comment_line_length = 40; - this.preferences.tab_size = 1; - this.preferences.indentation_size = 1; + this.formatterPrefs.comment_line_length = 40; + this.formatterPrefs.tab_size = 1; + this.formatterPrefs.indentation_size = 1; formatUnit("bugs.b232788", "X03_tabs.java"); } public void testBug232788_Spaces03() throws JavaModelException { - this.preferences.comment_line_length = 40; - this.preferences.tab_char = DefaultCodeFormatterOptions.SPACE; - this.preferences.tab_size = 1; - this.preferences.indentation_size = 1; + this.formatterPrefs.comment_line_length = 40; + this.formatterPrefs.tab_char = DefaultCodeFormatterOptions.SPACE; + this.formatterPrefs.tab_size = 1; + this.formatterPrefs.indentation_size = 1; formatUnit("bugs.b232788", "X03_spaces.java"); } public void testBug232788_Mixed03() throws JavaModelException { - this.preferences.comment_line_length = 40; - this.preferences.tab_char = DefaultCodeFormatterOptions.MIXED; - this.preferences.tab_size = 1; - this.preferences.indentation_size = 1; + this.formatterPrefs.comment_line_length = 40; + this.formatterPrefs.tab_char = DefaultCodeFormatterOptions.MIXED; + this.formatterPrefs.tab_size = 1; + this.formatterPrefs.indentation_size = 1; formatUnit("bugs.b232788", "X03_mixed.java"); } @@ -908,7 +899,7 @@ " * block [# #] \n" + " * comment\n" + " */\n" + - " // single [# #] line comment\n" + + " // [#single line#] comment\n" + "}"; formatSource(source, "\n" + @@ -916,10 +907,10 @@ " /**\n" + " * Javadoc comment\n" + " */\n" + - " /*\n" + + " /*\n" + " * block comment\n" + " */\n" + - " // single line comment\n" + + " // single line comment\n" + "}" ); } @@ -951,7 +942,7 @@ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=233224" */ public void testBug233224() throws JavaModelException { - this.preferences.comment_line_length = 40; + this.formatterPrefs.comment_line_length = 40; formatUnit("bugs.b233224", "X01.java"); } @@ -961,7 +952,7 @@ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=233259" */ public void testBug233259a() throws JavaModelException { - this.preferences.comment_line_length = 40; + this.formatterPrefs.comment_line_length = 40; String source = "public class X {\n" + " /**\n" + @@ -981,7 +972,7 @@ ); } public void testBug233259b() throws JavaModelException { - this.preferences.comment_line_length = 40; + 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 String source = @@ -1004,7 +995,7 @@ ); } public void testBug233259c() throws JavaModelException { - this.preferences.comment_line_length = 40; + this.formatterPrefs.comment_line_length = 40; String source = "public class X {\n" + " /**\n" + @@ -1025,7 +1016,7 @@ ); } public void testBug233259d() throws JavaModelException { - this.preferences.comment_line_length = 40; + this.formatterPrefs.comment_line_length = 40; String source = "public class X {\n" + " /**\n" + @@ -1052,7 +1043,7 @@ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=237942" */ public void testBug237942a() throws JavaModelException { - this.preferences.comment_line_length = 40; + this.formatterPrefs.comment_line_length = 40; String source = "public class X {\n" + " /**\n" + @@ -1072,7 +1063,7 @@ ); } public void testBug237942b() throws JavaModelException { - this.preferences.comment_line_length = 40; + this.formatterPrefs.comment_line_length = 40; // difference with 3.3 formatter: // do not split string reference as this can lead to javadoc syntax error String source = @@ -1094,7 +1085,7 @@ ); } public void testBug237942c() throws JavaModelException { - this.preferences.comment_line_length = 40; + this.formatterPrefs.comment_line_length = 40; // difference with 3.3 formatter: // do not split string reference as this can lead to javadoc syntax error String source = @@ -1116,7 +1107,7 @@ ); } public void testBug237942d() throws JavaModelException { - this.preferences.comment_line_length = 40; + this.formatterPrefs.comment_line_length = 40; // difference with 3.3 formatter: // do not split string reference as this can lead to javadoc syntax error String source = @@ -1162,6 +1153,317 @@ ); } +//static { TESTS_PREFIX = "testBug234583"; } +/** + * @bug 234583: [formatter] Code formatter should adapt edits instead of regions + * @test Ensure that selected region(s) are correctly formatted + * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=234583" + */ +public void testBug234583a() throws JavaModelException { + String source = + "public class X {\n" + + "[# int i= 1; #]\n" + + "}\n"; + formatSource(source, + "public class X {\n" + + " int i = 1;\n" + + "}\n" + ); +} +public void testBug234583b() throws JavaModelException { + String source = + "public class X { \n" + + "\n" + + "\n" + + "\n" + + "[# int i= 1; #]\n" + + "\n" + + "\n" + + "\n" + + "\n" + + " }\n"; + formatSource(source, + "public class X { \n" + + "\n" + + "\n" + + "\n" + + " int i = 1;\n" + + "\n" + + "\n" + + "\n" + + "\n" + + " }\n" + ); +} +public void testBug234583c() throws JavaModelException { + String source = + "public class X { \n" + + "\n" + + "\n" + + "\n" + + "[# int i= 1; \n" + + "#]\n" + + "\n" + + "\n" + + "\n" + + " }\n"; + formatSource(source, + "public class X { \n" + + "\n" + + "\n" + + "\n" + + " int i = 1;\n" + + "\n" + + "\n" + + "\n" + + " }\n" + ); +} +public void testBug234583d() throws JavaModelException { + String source = + "public class X { \n" + + "\n" + + "\n" + + "[#\n" + + " int i= 1; \n" + + "\n" + + "#]\n" + + "\n" + + "\n" + + " }\n"; + formatSource(source, + "public class X { \n" + + "\n" + + "\n" + + " int i = 1;\n" + + "\n" + + "\n" + + " }\n" + ); +} +public void testBug234583e() throws JavaModelException { + String source = + "public class X { \n" + + "\n" + + "[#\n" + + "\n" + + " int i= 1; \n" + + "\n" + + "\n" + + "#]\n" + + "\n" + + " }\n"; + formatSource(source, + "public class X { \n" + + "\n" + + " int i = 1;\n" + + "\n" + + " }\n" + ); +} +public void testBug234583f() throws JavaModelException { + String source = + "public class X { \n" + + "[#\n" + + "\n" + + "\n" + + " int i= 1; \n" + + "\n" + + "\n" + + "\n" + + "#]\n" + + " }\n"; + formatSource(source, + "public class X { \n" + + "\n" + + " int i = 1;\n" + + "\n" + + " }\n" + ); +} +public void testBug234583g() throws JavaModelException { + String source = + "public class X { [#\n" + + "\n" + + "\n" + + "\n" + + " int i= 1; \n" + + "\n" + + "\n" + + "\n" + + "\n" + + "#] }\n"; + formatSource(source, + "public class X { \n" + + "\n" + + " int i = 1;\n" + + "\n" + + " }\n" + ); +} +public void testBug234583h() throws JavaModelException { + String source = + "public class X { [# \n" + + "\n" + + "\n" + + "\n" + + " int i= 1; \n" + + "\n" + + "\n" + + "\n" + + "\n" + + " #] }\n"; + formatSource(source, + "public class X { \n" + + "\n" + + " int i = 1;\n" + + "\n" + + " }\n" + ); +} +public void testBug234583i() throws JavaModelException { + String source = + "public class X {[# \n" + + "\n" + + "\n" + + "\n" + + " int i= 1; \n" + + "\n" + + "\n" + + "\n" + + "\n" + + " #]}\n"; + formatSource(source, + "public class X {\n" + + "\n" + + " int i = 1;\n" + + "\n" + + "}\n" + ); +} +// duplicate https://bugs.eclipse.org/bugs/show_bug.cgi?id=239447 +public void testBug234583_Bug239447() throws JavaModelException { + String source = + "public class Bug239447 {\n" + + " private static final String CONTENT = \"test.ObjectB {\\n\"\n" + + "[# + \" multiEle = { name=\\\"Foo\\\" }\\n\"#]\n" + + " + \" multiEle = :x { name=\\\"Bar\\\" }\\n\" + \" singleEle = x;\\n\"\n" + + " + \"}\";\n" + + "\n" + + "}\n"; + formatSource(source, + "public class Bug239447 {\n" + + " private static final String CONTENT = \"test.ObjectB {\\n\"\n" + + " + \" multiEle = { name=\\\"Foo\\\" }\\n\"\n" + + " + \" multiEle = :x { name=\\\"Bar\\\" }\\n\" + \" singleEle = x;\\n\"\n" + + " + \"}\";\n" + + "\n" + + "}\n" + ); +} +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=237453 +public void testBug234583_Bug237453a() throws JavaModelException { + String source = + "package test1;\n" + + "\n" + + "public class E1 {\n" + + " void foo() {\n" + + " }\n" + + " [#\n" + + " #]\n" + + " void bar() {\n" + + " }\n" + + "}"; + formatSource(source, + "package test1;\n" + + "\n" + + "public class E1 {\n" + + " void foo() {\n" + + " }\n" + + " \n" + + " void bar() {\n" + + " }\n" + + "}" + ); +} +public void testBug234583_Bug237453b() throws JavaModelException { + String source = + "package test1;\n" + + "\n" + + "public class E1 {\n" + + " void foo() {\n" + + " }\n" + + " \n" + + "[# #]\n" + + " void bar() {\n" + + " }\n" + + "}"; + formatSource(source, + "package test1;\n" + + "\n" + + "public class E1 {\n" + + " void foo() {\n" + + " }\n" + + " \n" + + " \n" + + " void bar() {\n" + + " }\n" + + "}" + ); +} +// duplicate https://bugs.eclipse.org/bugs/show_bug.cgi?id=237592 +public void testBug234583_Bug237592() throws JavaModelException { + String source = + "package test;\n" + + "\n" + + "public class Test {\n" + + "\n" + + " void foo() {\n" + + " }\n" + + "\n" + + "[# #]\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + "[# #]\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " void bar() {\n" + + " }\n" + + "\n" + + "}\n"; + formatSource(source, + "package test;\n" + + "\n" + + "public class Test {\n" + + "\n" + + " void foo() {\n" + + " }\n" + + "\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " void bar() {\n" + + " }\n" + + "\n" + + "}\n" + ); +} + /** * @bug 236230: [formatter] SIOOBE while formatting a compilation unit. * @test Ensure that no exception occurs while formatting @@ -1239,7 +1541,7 @@ ); } public void testBug236230c() throws JavaModelException { - this.preferences.comment_format_header = true; + this.formatterPrefs.comment_format_header = true; String source = "/**\n" + " * Need a javadoc comment before to get the exception.\n" + @@ -1493,7 +1795,7 @@ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=238090" */ public void testBug238090() throws JavaModelException { - this.preferences.comment_line_length = 40; + this.formatterPrefs.comment_line_length = 40; String source = "package test.bugs;\n" + "public class LongNameClass {\n" + @@ -1964,7 +2266,7 @@ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=241345" */ public void testBug241345() throws JavaModelException { - this.preferences.comment_format_html = false; + this.formatterPrefs.comment_format_html = false; String source = "/**\n" + " *
Should not format HTML paragraph
\n" + Index: src/org/eclipse/jdt/core/tests/formatter/FormatterRegressionTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterRegressionTests.java,v retrieving revision 1.234 diff -u -r1.234 FormatterRegressionTests.java --- src/org/eclipse/jdt/core/tests/formatter/FormatterRegressionTests.java 19 Aug 2008 01:01:29 -0000 1.234 +++ src/org/eclipse/jdt/core/tests/formatter/FormatterRegressionTests.java 29 Aug 2008 11:33:37 -0000 @@ -54,6 +54,8 @@ private static final String LINE_SEPARATOR = System.getProperty("line.separator"); private long time; + DefaultCodeFormatterOptions formatterPrefs; + static { // TESTS_NUMBERS = new int[] { 715 }; // TESTS_RANGE = new int[] { 715, -1 }; @@ -147,6 +149,14 @@ return org.eclipse.jdt.internal.core.util.Util.editedString(source, edit); } + + /** + * Init formatter preferences with Eclipse default settings. + */ + protected void setUp() throws Exception { + super.setUp(); + this.formatterPrefs = DefaultCodeFormatterOptions.getEclipseDefaultSettings(); + } /** * Create project and set the jar placeholder. @@ -203,6 +213,69 @@ assertSourceEquals("Different number of length", Util.convertToIndependantLineDelimiter(expectedContents), actualContents); } + DefaultCodeFormatter codeFormatter() { + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(this.formatterPrefs, JAVA_PROJECT.getOptions(true)); + return codeFormatter; + } + + void assertLineEquals(String actualContents, String originalSource, String expectedContents) { + String outputSource = expectedContents == null ? originalSource : expectedContents; + assertLineEquals(actualContents, originalSource, outputSource, false /* do not check null */); + } + + void formatSource(String source, String formattedOutput) { + formatSource(source, formattedOutput, CodeFormatter.K_COMPILATION_UNIT | CodeFormatter.F_INCLUDE_COMMENTS, 0, true /*repeat formatting twice*/); + } + + void formatSource(String source, String formattedOutput, boolean repeat) { + formatSource(source, formattedOutput, CodeFormatter.K_COMPILATION_UNIT | CodeFormatter.F_INCLUDE_COMMENTS, 0, repeat); + } + + void formatSource(String source, String formattedOutput, int kind, int indentationLevel, boolean repeat) { + int regionStart = source.indexOf("[#"); + if (regionStart != -1) { + IRegion[] regions = new Region[10]; + int idx = 0; + int start = 0; + int delta = 0; + StringBuffer buffer = new StringBuffer(); + while (regionStart != -1) { + buffer.append(source.substring(start, regionStart)); + int regionEnd = source.indexOf("#]", regionStart+2); + buffer.append(source.substring(regionStart+2, regionEnd)); + regions[idx++] = new Region(regionStart-delta, regionEnd-(regionStart+2)); + delta += 4; + start = regionEnd + 2; + regionStart = source.indexOf("[#", start); + } + buffer.append(source.substring(start, source.length())); + String newSource = buffer.toString(); + String result; + if (idx == 1) { + // Use offset and length until bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=233967 is fixed + result = runFormatter(codeFormatter(), newSource, kind, indentationLevel, regions[0].getOffset(), regions[0].getLength(), LINE_SEPARATOR, repeat); + } else { + System.arraycopy(regions, 0, regions = new Region[idx], 0, idx); + result = runFormatter(codeFormatter(), newSource, kind, indentationLevel, regions, LINE_SEPARATOR); + } + assertLineEquals(result, newSource, formattedOutput); + } else { + formatSource(source, formattedOutput, kind, indentationLevel, false, 0, -1, null, repeat); + } + } + + void formatSource(String source, String formattedOutput, int kind, int indentationLevel, boolean checkNull, int offset, int length, String lineSeparator, boolean repeat) { + DefaultCodeFormatter codeFormatter = codeFormatter(); + String result; + if (length == -1) { + result = runFormatter(codeFormatter, source, kind, indentationLevel, offset, source.length(), lineSeparator, repeat); + } else { + result = runFormatter(codeFormatter, source, kind, indentationLevel, offset, length, lineSeparator, repeat); + } + assertLineEquals(result, source, formattedOutput); + } + + private void runTest(String packageName, String compilationUnitName) { DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings()); preferences.number_of_empty_lines_to_preserve = 0; @@ -9456,6 +9529,7 @@ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=203304 public void test671() { + /* old version final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); @@ -9464,6 +9538,27 @@ new Region(101, 20) }; runTest(codeFormatter, "test671", "A.java", CodeFormatter.K_COMPILATION_UNIT, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ + */ + String source = + "public class A {\n" + + " public static void main(String[] args) {\n" + + "[# int a = 1;#]\n" + + " int b = 2;\n" + + "[# int c = 3;#]\n" + + " }\n" + + "}\n"; + formatSource(source, + "public class A {\n" + + " public static void main(String[] args) {\n" + + " int a = 1;\n" + + " int b = 2;\n" + + " int c = 3;\n" + + " }\n" + + "}\n", + CodeFormatter.K_COMPILATION_UNIT, + 0 /*no indentation*/, + true /*repeat formatting twice*/ + ); } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=203304 @@ -9492,6 +9587,7 @@ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=203304 public void test674() { + /* old version final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); @@ -9500,6 +9596,64 @@ new Region(276, 54) }; runTest(codeFormatter, "test674", "A.java", CodeFormatter.K_CLASS_BODY_DECLARATIONS, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ + */ + String source = + "public class A {\n" + + " \n" + + " \n" + + " private class Inner1 {[#\n" + + " \n" + + " \n" + + " void bar () { }\n" + + " \n" + + " void i()\n" + + " {\n" + + " \n" + + " }\n" + + " #]}\n" + + " \n" + + " \n" + + " private class Inner2 {\n" + + " void xy() {\n" + + " \n" + + " }\n" + + " }\n" + + "}\n" + + "class B {[#\n" + + " private void foo() {\n" + + " \n" + + " }\n" + + "#]}\n"; + formatSource(source, + "public class A {\n" + + " \n" + + " \n" + + " private class Inner1 {\n" + + "\n" + + " void bar() {\n" + + " }\n" + + "\n" + + " void i() {\n" + + "\n" + + " }\n" + + " }\n" + + " \n" + + " \n" + + " private class Inner2 {\n" + + " void xy() {\n" + + " \n" + + " }\n" + + " }\n" + + "}\n" + + "class B {\n" + + " private void foo() {\n" + + "\n" + + " }\n" + + "}\n", + CodeFormatter.K_CLASS_BODY_DECLARATIONS, + 0 /*no indentation*/, + true /*repeat formatting twice*/ + ); } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=203304 @@ -9631,6 +9785,7 @@ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=208541 public void test685() { + /* old version final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); @@ -9638,6 +9793,22 @@ new Region(18, 35) }; runTest(codeFormatter, "test685", "A.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ + */ + String source = + "public class A {\n" + + " [# int i=1; #] \n" + + "}\n"; + // Note that whitespaces outside the region are kept after the formatting + // This is intentional since fix for bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=234583 + // The formatter should not touch code outside the given region(s)... + formatSource(source, + "public class A {\n" + + " int i = 1; \n" + + "}\n", + CodeFormatter.K_UNKNOWN, + 0 /*no indentation*/, + true /*repeat formatting twice*/ + ); } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=208541 @@ -9661,6 +9832,7 @@ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=208541 public void test688a() { + /* old version final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); @@ -9668,9 +9840,26 @@ new Region(18, 48) }; runTest(codeFormatter, "test688", "A.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ + */ + String source = + "public class A {\n" + + " [# int i=1; \n" + + "}#]\n"; + // Note that whitespaces outside the region are kept after the formatting + // This is intentional since fix for bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=234583 + // The formatter should not touch code outside the given region(s)... + formatSource(source, + "public class A {\n" + + " int i = 1;\n" + + "}\n", + CodeFormatter.K_UNKNOWN, + 0 /*no indentation*/, + true /*repeat formatting twice*/ + ); } public void test688b() { + /* old version final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); @@ -9678,6 +9867,19 @@ new Region(18, 49) }; runTest(codeFormatter, "test688", "A.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ + */ + String source = + "public class A {\n" + + " [# int i=1; \n" + + "}\n#]"; + // Note that whitespaces outside the region are kept after the formatting + // This is intentional since fix for bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=234583 + // The formatter should not touch code outside the given region(s)... + formatSource(source, + "public class A {\n" + + " int i = 1;\n" + + "}\n" + ); } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=208541 @@ -9694,6 +9896,7 @@ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=208541 public void test690() { + /* old version final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); preferences.line_separator = "\r";//$NON-NLS-1$ @@ -9702,10 +9905,32 @@ new Region(31, 23) }; runTest(codeFormatter, "test689", "A.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\r");//$NON-NLS-1$ //$NON-NLS-2$ + */ + this.formatterPrefs.line_separator = "\r";//$NON-NLS-1$ + String source = + "package pkg1;\n" + + "public class A {\n" + + "[# int i = 1; #]\n" + + "\n" + + "}\n"; + // Note that whitespaces outside the region are kept after the formatting + // This is intentional since fix for bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=234583 + // The formatter should not touch code outside the given region(s)... + formatSource(source, + "package pkg1;\n" + + "public class A {\n" + + " int i = 1;\n" + + "\n" + + "}\n", + CodeFormatter.K_UNKNOWN, + 0 /*no indentation*/, + true /*repeat formatting twice*/ + ); } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=208541 public void test691() { + /* old version final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); preferences.line_separator = "\r\n";//$NON-NLS-1$ @@ -9714,6 +9939,27 @@ new Region(31, 22) }; runTest(codeFormatter, "test689", "A.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\r\n");//$NON-NLS-1$ //$NON-NLS-2$ + */ + this.formatterPrefs.line_separator = "\r\n";//$NON-NLS-1$ + String source = + "package pkg1;\n" + + "public class A {\n" + + "[# int i = 1; #] \n" + + "\n" + + "}\n"; + // Note that whitespaces outside the region are kept after the formatting + // This is intentional since fix for bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=234583 + // The formatter should not touch code outside the given region(s)... + formatSource(source, + "package pkg1;\n" + + "public class A {\n" + + " int i = 1; \n" + + "\n" + + "}\n", + CodeFormatter.K_UNKNOWN, + 0 /*no indentation*/, + true /*repeat formatting twice*/ + ); } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=208541 @@ -9810,6 +10056,7 @@ // variation on bugs 208541, 213283, 213284 public void test697a() { + /* old version final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); preferences.line_separator = "\n";//$NON-NLS-1$ @@ -9818,10 +10065,38 @@ new Region(17, 55) // end of line selection }; runTest(codeFormatter, "test697", "A.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ + */ + String source = + "public class A {\n" + + "[# \n" + + " \n" + + " \n" + + " int i = 1; #]\n" + + "\n" + + "\n" + + "\n" + + "}\n" + + ""; + // Note that whitespaces outside the region are kept after the formatting + // This is intentional since fix for bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=234583 + // The formatter should not touch code outside the given region(s)... + formatSource(source, + "public class A {\n" + + "\n" + + " int i = 1;\n" + + "\n" + + "\n" + + "\n" + + "}\n", + CodeFormatter.K_UNKNOWN, + 0 /*no indentation*/, + true /*repeat formatting twice*/ + ); } // variation on bugs 208541, 213283, 213284 public void test697b() { + /* old version final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); preferences.line_separator = "\n";//$NON-NLS-1$ @@ -9830,6 +10105,32 @@ new Region(17, 56) // end of line selection + 1 }; runTest(codeFormatter, "test697", "A.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$ + */ + String source = + "public class A {\n" + + "[# \n" + + " \n" + + " \n" + + " int i = 1; \n" + + "#]\n" + + "\n" + + "\n" + + "}\n" + + ""; + // Note that whitespaces outside the region are kept after the formatting + // This is intentional since fix for bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=234583 + // The formatter should not touch code outside the given region(s)... + formatSource(source, + "public class A {\n" + + "\n" + + " int i = 1;\n" + + "\n" + + "\n" + + "}\n", + CodeFormatter.K_UNKNOWN, + 0 /*no indentation*/, + true /*repeat formatting twice*/ + ); } // variation on bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=208541 @@ -10128,9 +10429,32 @@ String resourcePath = getResource("test713", "formatter.xml"); Map options = DecodeCodeFormatterPreferences.decodeCodeFormatterOptions(resourcePath, "Dani"); assertNotNull("No preferences", options); + /* old version DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); runTest(codeFormatter, "test713", "A.java", CodeFormatter.K_COMPILATION_UNIT, 0, false, 76, 27);//$NON-NLS-1$ //$NON-NLS-2$ + */ + this.formatterPrefs = new DefaultCodeFormatterOptions(options); + String source = + "package pack;\n" + + "\n" + + "public class A {\n" + + " /**\n" + + " * @see A.Inner\n" + + " */\n" + + "[# public class Inner { }\n" + + "#]}"; + formatSource(source, + "package pack;\n" + + "\n" + + "public class A {\n" + + " /**\n" + + " * @see A.Inner\n" + + " */\n" + + " public class Inner {\n" + + " }\n" + + "}" + ); } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=102780 Index: src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsClearBlankLinesTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsClearBlankLinesTests.java,v retrieving revision 1.4 diff -u -r1.4 FormatterCommentsClearBlankLinesTests.java --- src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsClearBlankLinesTests.java 15 May 2008 17:45:45 -0000 1.4 +++ src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsClearBlankLinesTests.java 29 Aug 2008 11:33:34 -0000 @@ -51,10 +51,10 @@ } DefaultCodeFormatter codeFormatter() { - this.preferences.comment_clear_blank_lines_in_block_comment = true; - this.preferences.comment_clear_blank_lines_in_javadoc_comment = true; - this.preferences.comment_format_header = true; - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(this.preferences); + this.formatterPrefs.comment_clear_blank_lines_in_block_comment = true; + this.formatterPrefs.comment_clear_blank_lines_in_javadoc_comment = true; + this.formatterPrefs.comment_format_header = true; + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(this.formatterPrefs); return codeFormatter; } Index: src/org/eclipse/jdt/core/tests/formatter/FormatterJavadocDontIndentTagsTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterJavadocDontIndentTagsTests.java,v retrieving revision 1.4 diff -u -r1.4 FormatterJavadocDontIndentTagsTests.java --- src/org/eclipse/jdt/core/tests/formatter/FormatterJavadocDontIndentTagsTests.java 15 May 2008 17:45:45 -0000 1.4 +++ src/org/eclipse/jdt/core/tests/formatter/FormatterJavadocDontIndentTagsTests.java 29 Aug 2008 11:33:34 -0000 @@ -50,8 +50,8 @@ } DefaultCodeFormatter codeFormatter() { - this.preferences.comment_indent_root_tags = false; // Eclipse default is true - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(this.preferences); + this.formatterPrefs.comment_indent_root_tags = false; // Eclipse default is true + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(this.formatterPrefs); return codeFormatter; } Index: src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsTests.java,v retrieving revision 1.23 diff -u -r1.23 FormatterCommentsTests.java --- src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsTests.java 1 Jul 2008 15:11:02 -0000 1.23 +++ src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsTests.java 29 Aug 2008 11:33:34 -0000 @@ -38,9 +38,6 @@ import org.eclipse.jdt.internal.core.util.CodeSnippetParsingUtil; import org.eclipse.jdt.internal.core.util.SimpleDocument; import org.eclipse.jdt.internal.formatter.DefaultCodeFormatter; -import org.eclipse.jdt.internal.formatter.DefaultCodeFormatterOptions; -import org.eclipse.jface.text.IRegion; -import org.eclipse.jface.text.Region; /** * Javadoc formatter test suite using the Eclipse default settings. @@ -59,8 +56,6 @@ public static List ALL_TEST_SUITES = null; - DefaultCodeFormatterOptions preferences; - public static Test suite() { return buildModelTestSuite(FormatterCommentsTests.class); } @@ -68,10 +63,6 @@ public FormatterCommentsTests(String name) { super(name); } -protected void setUp() throws Exception { - super.setUp(); - this.preferences = DefaultCodeFormatterOptions.getEclipseDefaultSettings(); -} /** * Create project and set the jar placeholder. @@ -97,71 +88,6 @@ } } -DefaultCodeFormatter codeFormatter() { - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(this.preferences, JAVA_PROJECT.getOptions(true)); - return codeFormatter; -} - -/* (non-Javadoc) - * @see org.eclipse.jdt.core.tests.formatter.FormatterRegressionTests#assertLineEquals(java.lang.String, java.lang.String, java.lang.String, boolean) - */ -void assertLineEquals(String actualContents, String originalSource, String expectedContents, boolean checkNull) { - String outputSource = expectedContents == null ? originalSource : expectedContents; - super.assertLineEquals(actualContents, originalSource, outputSource, checkNull); -} - -void formatSource(String source, String formattedOutput) { - formatSource(source, formattedOutput, CodeFormatter.K_COMPILATION_UNIT | CodeFormatter.F_INCLUDE_COMMENTS, 0, true /*repeat formatting twice*/); -} - -void formatSource(String source, String formattedOutput, boolean repeat) { - formatSource(source, formattedOutput, CodeFormatter.K_COMPILATION_UNIT | CodeFormatter.F_INCLUDE_COMMENTS, 0, repeat); -} - -void formatSource(String source, String formattedOutput, int kind, int indentationLevel, boolean repeat) { - int regionStart = source.indexOf("[#"); - if (regionStart != -1) { - IRegion[] regions = new Region[10]; - int idx = 0; - int start = 0; - int delta = 0; - StringBuffer buffer = new StringBuffer(); - while (regionStart != -1) { - buffer.append(source.substring(start, regionStart)); - int regionEnd = source.indexOf("#]", regionStart+2); - buffer.append(source.substring(regionStart+2, regionEnd)); - regions[idx++] = new Region(regionStart-delta, regionEnd-(regionStart+2)); - delta += 4; - start = regionEnd + 2; - regionStart = source.indexOf("[#", start); - } - buffer.append(source.substring(start, source.length())); - String newSource = buffer.toString(); - String result; - if (idx == 1) { - // Use offset and length until bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=233967 is fixed - result = runFormatter(codeFormatter(), newSource, kind, indentationLevel, regions[0].getOffset(), regions[0].getLength(), Util.LINE_SEPARATOR, repeat); - } else { - System.arraycopy(regions, 0, regions = new Region[idx], 0, idx); - result = runFormatter(codeFormatter(), newSource, kind, indentationLevel, regions, Util.LINE_SEPARATOR); - } - assertLineEquals(result, newSource, formattedOutput, false); - } else { - formatSource(source, formattedOutput, kind, indentationLevel, false, 0, -1, null, repeat); - } -} - -void formatSource(String source, String formattedOutput, int kind, int indentationLevel, boolean checkNull, int offset, int length, String lineSeparator, boolean repeat) { - DefaultCodeFormatter codeFormatter = codeFormatter(); - String result; - if (length == -1) { - result = runFormatter(codeFormatter, source, kind, indentationLevel, offset, source.length(), lineSeparator, repeat); - } else { - result = runFormatter(codeFormatter, source, kind, indentationLevel, offset, length, lineSeparator, repeat); - } - assertLineEquals(result, source, formattedOutput, checkNull); -} - void compareFormattedSource(ICompilationUnit compilationUnit) throws JavaModelException { DefaultCodeFormatter codeFormatter = codeFormatter(); String source = compilationUnit.getSource(); @@ -849,7 +775,7 @@ } // TODO Pass this test public void _testLineComments11() throws JavaModelException { - this.preferences.comment_line_length = 40; + this.formatterPrefs.comment_line_length = 40; formatUnit("comments.line", "X11.java"); } Index: src/org/eclipse/jdt/core/tests/formatter/FormatterJavadocDontIndentTagsDescriptionTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterJavadocDontIndentTagsDescriptionTests.java,v retrieving revision 1.4 diff -u -r1.4 FormatterJavadocDontIndentTagsDescriptionTests.java --- src/org/eclipse/jdt/core/tests/formatter/FormatterJavadocDontIndentTagsDescriptionTests.java 15 May 2008 17:45:44 -0000 1.4 +++ src/org/eclipse/jdt/core/tests/formatter/FormatterJavadocDontIndentTagsDescriptionTests.java 29 Aug 2008 11:33:34 -0000 @@ -50,8 +50,8 @@ } DefaultCodeFormatter codeFormatter() { - this.preferences.comment_indent_parameter_description = false; // Eclipse default is true - DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(this.preferences); + this.formatterPrefs.comment_indent_parameter_description = false; // Eclipse default is true + DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(this.formatterPrefs); return codeFormatter; } #P org.eclipse.jdt.core Index: formatter/org/eclipse/jdt/internal/formatter/Scribe.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/Scribe.java,v retrieving revision 1.149 diff -u -r1.149 Scribe.java --- formatter/org/eclipse/jdt/internal/formatter/Scribe.java 21 Aug 2008 08:53:23 -0000 1.149 +++ formatter/org/eclipse/jdt/internal/formatter/Scribe.java 29 Aug 2008 11:33:39 -0000 @@ -165,26 +165,31 @@ if (index >= 0) { // the offset of the region is inside a comment => restart the region from the comment start adaptedOffset = this.commentPositions[index][0]; - if (adaptedOffset < 0) adaptedOffset = -adaptedOffset; - adaptedLength = length + offset - adaptedOffset; - commentIndex = index; - // include also the indentation edit just before the comment if any - for (int j=0; j