### Eclipse Workspace Patch 1.0 #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.196 diff -u -r1.196 Scribe.java --- formatter/org/eclipse/jdt/internal/formatter/Scribe.java 2 Mar 2010 18:28:48 -0000 1.196 +++ formatter/org/eclipse/jdt/internal/formatter/Scribe.java 3 Mar 2010 10:23:18 -0000 @@ -2470,7 +2470,7 @@ commentIndentationLevel = this.column - 1; } else { if (onFirstColumn && - (!this.formatter.preferences.comment_format_line_comment_starting_on_first_column || + ((includesLineComments && !this.formatter.preferences.comment_format_line_comment_starting_on_first_column) || this.formatter.preferences.never_indent_line_comments_on_first_column) ) { commentIndentationLevel = this.column - 1; #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.56 diff -u -r1.56 FormatterCommentsBugsTest.java --- src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java 1 Mar 2010 17:09:26 -0000 1.56 +++ src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java 3 Mar 2010 10:23:29 -0000 @@ -3625,7 +3625,7 @@ * @test Test the new formatter capability to completely ignore line comments starting at first column * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=251133" */ -public void testBug251133_Line01() throws JavaModelException { +public void testBug251133() throws JavaModelException { String source = "public class X01 {\n" + "// int a = 1;\n" + @@ -3638,36 +3638,103 @@ "}" ); } -public void testBug251133_Line02() throws JavaModelException { +public void testBug251133a() throws JavaModelException { + this.formatterPrefs.comment_format_line_comment = true; + this.formatterPrefs.comment_format_line_comment_starting_on_first_column = true; + this.formatterPrefs.never_indent_line_comments_on_first_column = false; + String source = + "public class X {\n" + + "// first column comment \n" + + "}"; + formatSource(source, + "public class X {\n" + + " // first column comment\n" + + "}" + ); +} +public void testBug251133b() throws JavaModelException { + this.formatterPrefs.comment_format_line_comment = true; + this.formatterPrefs.comment_format_line_comment_starting_on_first_column = true; this.formatterPrefs.never_indent_line_comments_on_first_column = true; String source = - "public class X01 {\n" + - "// int a = 1;\n" + - "// int b = 2;\n" + + "public class X {\n" + + "// first column comment \n" + "}"; formatSource(source, - "public class X01 {\n" + - "// int a = 1;\n" + - "// int b = 2;\n" + + "public class X {\n" + + "// first column comment\n" + "}" ); } -public void testBug251133_Line03() throws JavaModelException { +public void testBug251133c() throws JavaModelException { + this.formatterPrefs.comment_format_line_comment = true; + this.formatterPrefs.comment_format_line_comment_starting_on_first_column = false; + this.formatterPrefs.never_indent_line_comments_on_first_column = false; + String source = + "public class X {\n" + + "// first column comment \n" + + "}"; + formatSource(source); +} +public void testBug251133d() throws JavaModelException { + this.formatterPrefs.comment_format_line_comment = true; this.formatterPrefs.comment_format_line_comment_starting_on_first_column = false; + this.formatterPrefs.never_indent_line_comments_on_first_column = true; String source = - "public class X01 {\n" + - "// int a = 1;\n" + - "// int b = 2;\n" + + "public class X {\n" + + "// first column comment \n" + "}"; formatSource(source); } -public void testBug251133_Line04() throws JavaModelException { +public void testBug251133e() throws JavaModelException { + this.formatterPrefs.comment_format_line_comment = false; + this.formatterPrefs.comment_format_line_comment_starting_on_first_column = true; this.formatterPrefs.never_indent_line_comments_on_first_column = false; + String source = + "public class X {\n" + + "// first column comment \n" + + "}"; + formatSource(source, + "public class X {\n" + + " // first column comment \n" + + "}" + ); +} +public void testBug251133f() throws JavaModelException { + this.formatterPrefs.comment_format_line_comment = false; + this.formatterPrefs.comment_format_line_comment_starting_on_first_column = true; + this.formatterPrefs.never_indent_line_comments_on_first_column = true; + String source = + "public class X {\n" + + "// first column comment \n" + + "}"; + formatSource(source, + "public class X {\n" + + "// first column comment \n" + + "}" + ); +} +public void testBug251133g() throws JavaModelException { + this.formatterPrefs.comment_format_line_comment = false; this.formatterPrefs.comment_format_line_comment_starting_on_first_column = false; + this.formatterPrefs.never_indent_line_comments_on_first_column = false; String source = - "public class X01 {\n" + - "// int a = 1;\n" + - "// int b = 2;\n" + + "public class X {\n" + + "// first column comment \n" + + "}"; + formatSource(source, + "public class X {\n" + + " // first column comment \n" + + "}" + ); +} +public void testBug251133h() throws JavaModelException { + this.formatterPrefs.comment_format_line_comment = false; + this.formatterPrefs.comment_format_line_comment_starting_on_first_column = false; + this.formatterPrefs.never_indent_line_comments_on_first_column = true; + String source = + "public class X {\n" + + "// first column comment \n" + "}"; formatSource(source); }