### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: buildnotes_jdt-core.html =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/buildnotes_jdt-core.html,v retrieving revision 1.7375 diff -u -r1.7375 buildnotes_jdt-core.html --- buildnotes_jdt-core.html 17 Mar 2010 16:19:23 -0000 1.7375 +++ buildnotes_jdt-core.html 18 Mar 2010 16:51:54 -0000 @@ -48,6 +48,7 @@
Project org.eclipse.jdt.core v_A41 (cvs).

What's new in this drop

+Patch v01 for bug 305830

Problem Reports Fixed

293558 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.201 diff -u -r1.201 Scribe.java --- formatter/org/eclipse/jdt/internal/formatter/Scribe.java 16 Mar 2010 09:58:01 -0000 1.201 +++ formatter/org/eclipse/jdt/internal/formatter/Scribe.java 18 Mar 2010 16:51:55 -0000 @@ -1590,6 +1590,9 @@ } private boolean printBlockComment(int currentTokenStartPosition, int currentTokenEndPosition) { +// if (this.nlsTagCounter > 0) { +// return false; +// } // Compute indentation int maxColumn = this.formatter.preferences.comment_line_length + 1; @@ -1877,22 +1880,24 @@ } // Replace block comment text - if (hasTokens || multiLines) { - StringBuffer replacement = new StringBuffer(); - if (hasTextOnFirstLine == 1) { - if ((hasMultiLines || multiLines)) { - int col = this.column; - replacement.append(this.lineSeparator); - this.column = 1; - printIndentationIfNecessary(replacement); - replacement.append(BLOCK_LINE_PREFIX); - this.column = col; - } else { - replacement.append(' '); + if (this.nlsTagCounter == 0 || !multiLines) { + if (hasTokens || multiLines) { + StringBuffer replacement = new StringBuffer(); + if (hasTextOnFirstLine == 1) { + if ((hasMultiLines || multiLines)) { + int col = this.column; + replacement.append(this.lineSeparator); + this.column = 1; + printIndentationIfNecessary(replacement); + replacement.append(BLOCK_LINE_PREFIX); + this.column = col; + } else { + replacement.append(' '); + } } + replacement.append(buffer); + addReplaceEdit(editStart, editEnd, replacement.toString()); } - replacement.append(buffer); - addReplaceEdit(editStart, editEnd, replacement.toString()); } // Reset #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.60 diff -u -r1.60 FormatterCommentsBugsTest.java --- src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java 16 Mar 2010 09:57:57 -0000 1.60 +++ src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java 18 Mar 2010 16:51:58 -0000 @@ -6339,4 +6339,79 @@ "}\n"); } +/** + * @bug 305830: [formatter] Turning off formatting changes comment's formatting + * @test Verify that turning off formatting in a javadoc does not screw up its indentation + * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=305830" + */ +public void testBug305830() { + this.formatterPrefs = null; + this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, "40"); + this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH, "40"); + String source = + "public class X01 {\n" + + "void foo() {\n" + + "bar(\"a non-nls string\", 0 /*a comment*/); //$NON-NLS-1$\n" + + "}\n" + + "void bar(String string, int i) {\n" + + "}\n" + + "}\n"; + formatSource(source, + "public class X01 {\n" + + " void foo() {\n" + + " bar(\"a non-nls string\", 0 /*a comment*/); //$NON-NLS-1$\n" + + " }\n" + + "\n" + + " void bar(String string, int i) {\n" + + " }\n" + + "}\n" + ); +} +public void testBug305830b() { + this.formatterPrefs = null; + this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, "40"); + this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH, "40"); + String source = + "public class X02 {\n" + + "void foo() {\n" + + "bar(\"str\", 0 /*a comment*/); //$NON-NLS-1$\n" + + "}\n" + + "void bar(String string, int i) {\n" + + "}\n" + + "}\n"; + formatSource(source, + "public class X02 {\n" + + " void foo() {\n" + + " bar(\"str\", 0 /* a comment */); //$NON-NLS-1$\n" + + " }\n" + + "\n" + + " void bar(String string, int i) {\n" + + " }\n" + + "}\n" + ); +} +public void testBug305830c() { + this.formatterPrefs = null; + this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, "40"); + this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH, "40"); + String source = + "public class X03 {\n" + + "void foo() {\n" + + "bar(\"str\", 0 /* a comment */); //$NON-NLS-1$\n" + + "}\n" + + "void bar(String string, int i) {\n" + + "}\n" + + "}\n"; + formatSource(source, + "public class X03 {\n" + + " void foo() {\n" + + " bar(\"str\", 0 /* a comment */); //$NON-NLS-1$\n" + + " }\n" + + "\n" + + " void bar(String string, int i) {\n" + + " }\n" + + "}\n" + ); +} + } 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.29 diff -u -r1.29 FormatterCommentsTests.java --- src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsTests.java 2 Mar 2010 18:29:02 -0000 1.29 +++ src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsTests.java 18 Mar 2010 16:51:58 -0000 @@ -919,7 +919,7 @@ "public class X13 {\r\n" + "\r\n" + "protected void handleWarningToken(String token, boolean isEnabling) {\r\n" + - " if (token.equals(\"pkgDefaultMethod___\") || token.equals(\"packageDefaultMethod___\")/*backward compatible*/ ) { //$NON-NLS-1$ //$NON-NLS-2$\r\n" + + " if (token.equals(\"pkgDefaultMethod___\") || token.equals(\"packageDefaultMethod___\")/*_backward_ _compatible_*/ ) {\r\n" + " }\r\n" + "}\r\n" + "}\r\n"; @@ -927,19 +927,19 @@ // 1) split comment block starts one tab before to avoid possible words over the max line length // note that in this peculiar this was not necessary as even the first word is over the max line length! formatSource(source, - "package test.comments.block;\r\n" + - "\r\n" + - "public class X13 {\r\n" + - "\r\n" + - " protected void handleWarningToken(String token, boolean isEnabling) {\r\n" + - " if (token.equals(\"pkgDefaultMethod___\") || token.equals(\"packageDefaultMethod___\")/*\r\n" + - " * backward\r\n" + - " * compatible\r\n" + - " */) { //$NON-NLS-1$ //$NON-NLS-2$\r\n" + - " }\r\n" + - " }\r\n" + - "}\r\n", - false /* do not repeat */ + "package test.comments.block;\n" + + "\n" + + "public class X13 {\n" + + "\n" + + " protected void handleWarningToken(String token, boolean isEnabling) {\n" + + " if (token.equals(\"pkgDefaultMethod___\")\n" + + " || token.equals(\"packageDefaultMethod___\")/*\n" + + " * _backward_\n" + + " * _compatible_\n" + + " */) {\n" + + " }\n" + + " }\n" + + "}\n" ); } public void testBlockComments14() throws JavaModelException {