### 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.205 diff -u -r1.205 Scribe.java --- formatter/org/eclipse/jdt/internal/formatter/Scribe.java 23 Apr 2010 10:04:24 -0000 1.205 +++ formatter/org/eclipse/jdt/internal/formatter/Scribe.java 25 Apr 2010 15:51:32 -0000 @@ -4100,7 +4100,7 @@ } } this.needSpace = idx > 0; - printJavadocTextLine(buffer, nextStart, end, block, idx==0 /*first text?*/, needIndentation, false /*not an html tag*/); + printJavadocTextLine(buffer, nextStart, end, block, idx==0 || (!joinLines && textOnNewLine)/*first text?*/, needIndentation, false /*not an html tag*/); textOnNewLine = false; // Replace with current buffer if there are several empty lines between text lines @@ -4119,6 +4119,9 @@ printJavadocGapLines(end+1, nextStart-1, newLines, this.formatter.preferences.comment_clear_blank_lines_in_javadoc_comment, false, null); textOnNewLine = true; } + else if (startLine > endLine) { + textOnNewLine = !joinLines; + } } } @@ -4154,6 +4157,7 @@ if (needIndentation && this.commentIndentation != null) { buffer.append(this.commentIndentation); this.column += this.commentIndentation.length(); + firstColumn += this.commentIndentation.length(); } if (this.column < firstColumn) { this.column = firstColumn; @@ -4246,7 +4250,7 @@ tokensBufferLength = 0; textOnNewLine = false; } - if ((tokensBufferLength > 0 || tokenLength < maxColumn) && (!textOnNewLine || !firstText)) { + if ((tokensBufferLength > 0 || /*(firstColumn+tokenLength) < maxColumn || (insertSpace &&*/ this.column > firstColumn) && (!textOnNewLine || !firstText)) { this.lastNumberOfNewLines++; this.line++; if (newLineString == null) { @@ -4272,7 +4276,7 @@ this.column += tokensString.length(); tokensBuffer.setLength(0); tokensBufferLength = 0; - } + } buffer.append(this.scanner.source, tokenStart, tokenLength); this.column += tokenLength; textOnNewLine = false; #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.63 diff -u -r1.63 FormatterCommentsBugsTest.java --- src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java 23 Mar 2010 10:40:25 -0000 1.63 +++ src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java 25 Apr 2010 15:51:36 -0000 @@ -6548,4 +6548,208 @@ ); } +/** + * @bug 309835: [formatter] adds blank lines on each run + * @test Test that no line is added when the word exceeds the line width + * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=309835" + */ +public void testBug309835() { + this.formatterPrefs.join_lines_in_comments = false; + this.formatterPrefs.comment_line_length = 120; + String source = + "package org.eclipse.bug.test;\n" + + "\n" + + "/**\n" + + " * @author Bug Reporter\n" + + " * ThisIsAVeryLongCommentWithoutSpaces_TheFormatterTriesToBreakTheLine_ButTheResultOfItIsThatANewLineIsAdded_____\n" + + " * \n" + + " * Try to press Ctrl+Shift+F to format the code. If the unbreakable line is exactly 121 characters long,\n" + + " * a blank line is inserted on each formating.\n" + + " * Check project preferences to see the format settings\n" + + " * (max. line length 80 chars, max. comment line length 120 chars)\n" + + " */\n" + + "public class FormatterBug {\n" + + "}\n"; + formatSource(source); +} +public void testBug309835b() { + this.formatterPrefs.comment_line_length = 120; + String source = + "package org.eclipse.bug.test;\n" + + "\n" + + "/**\n" + + " * @author Bug Reporter\n" + + " * ThisIsAVeryLongCommentWithoutSpaces_TheFormatterTriesToBreakTheLine_ButTheResultOfItIsThatANewLineIsAdded_____\n" + + " * \n" + + " * Try to press Ctrl+Shift+F to format the code. If the unbreakable line is exactly 121 characters long,\n" + + " * a blank line is inserted on each formating.\n" + + " * Check project preferences to see the format settings\n" + + " * (max. line length 80 chars, max. comment line length 120 chars)\n" + + " */\n" + + "public class FormatterBug {\n" + + "}\n"; + formatSource(source, + "package org.eclipse.bug.test;\n" + + "\n" + + "/**\n" + + " * @author Bug Reporter\n" + + " * ThisIsAVeryLongCommentWithoutSpaces_TheFormatterTriesToBreakTheLine_ButTheResultOfItIsThatANewLineIsAdded_____\n" + + " * \n" + + " * Try to press Ctrl+Shift+F to format the code. If the unbreakable line is exactly 121 characters long, a blank\n" + + " * line is inserted on each formating. Check project preferences to see the format settings (max. line length 80\n" + + " * chars, max. comment line length 120 chars)\n" + + " */\n" + + "public class FormatterBug {\n" + + "}\n" + ); +} +public void testBug309835c() { + this.formatterPrefs.join_lines_in_comments = false; + String source = + "package org.eclipse.bug.test;\n" + + "\n" + + "/**\n" + + " * @author Bug Reporter\n" + + " * ThisIsAVeryLongCommentWithoutSpaces_TheFormatterTriesToBreakTheLine_ButTheResultOfItIsThatANewLineIsAdded_____\n" + + " * \n" + + " * Try to press Ctrl+Shift+F to format the code. If the unbreakable line is exactly 121 characters long,\n" + + " * a blank line is inserted on each formating.\n" + + " * Check project preferences to see the format settings\n" + + " * (max. line length 80 chars, max. comment line length 120 chars)\n" + + " */\n" + + "public class FormatterBug {\n" + + "}\n"; + formatSource(source, + "package org.eclipse.bug.test;\n" + + "\n" + + "/**\n" + + " * @author Bug Reporter\n" + + " * ThisIsAVeryLongCommentWithoutSpaces_TheFormatterTriesToBreakTheLine_ButTheResultOfItIsThatANewLineIsAdded_____\n" + + " * \n" + + " * Try to press Ctrl+Shift+F to format the code. If the unbreakable line\n" + + " * is exactly 121 characters long,\n" + + " * a blank line is inserted on each formating.\n" + + " * Check project preferences to see the format settings\n" + + " * (max. line length 80 chars, max. comment line length 120 chars)\n" + + " */\n" + + "public class FormatterBug {\n" + + "}\n" + ); +} +public void testBug309835d() { + String source = + "package org.eclipse.bug.test;\n" + + "\n" + + "/**\n" + + " * @author Bug Reporter\n" + + " * ThisIsAVeryLongCommentWithoutSpaces_TheFormatterTriesToBreakTheLine_ButTheResultOfItIsThatANewLineIsAdded_____\n" + + " * \n" + + " * Try to press Ctrl+Shift+F to format the code. If the unbreakable line is exactly 121 characters long,\n" + + " * a blank line is inserted on each formating.\n" + + " * Check project preferences to see the format settings\n" + + " * (max. line length 80 chars, max. comment line length 120 chars)\n" + + " */\n" + + "public class FormatterBug {\n" + + "}\n"; + formatSource(source, + "package org.eclipse.bug.test;\n" + + "\n" + + "/**\n" + + " * @author Bug Reporter\n" + + " * ThisIsAVeryLongCommentWithoutSpaces_TheFormatterTriesToBreakTheLine_ButTheResultOfItIsThatANewLineIsAdded_____\n" + + " * \n" + + " * Try to press Ctrl+Shift+F to format the code. If the unbreakable line\n" + + " * is exactly 121 characters long, a blank line is inserted on each\n" + + " * formating. Check project preferences to see the format settings (max.\n" + + " * line length 80 chars, max. comment line length 120 chars)\n" + + " */\n" + + "public class FormatterBug {\n" + + "}\n" + ); +} +public void testBug309835_wksp1_01() { + String source = + "public class X01 {\n" + + "\n" + + " /**\n" + + " * @param severity the severity to search for. Must be one of FATAL\n" + + " * , ERROR, WARNING or INFO\n" + + " */\n" + + " public void foo(int severity) {\n" + + " }\n" + + "}\n"; + formatSource(source, + "public class X01 {\n" + + "\n" + + " /**\n" + + " * @param severity\n" + + " * the severity to search for. Must be one of FATAL\n" + + " * , ERROR, WARNING or INFO\n" + + " */\n" + + " public void foo(int severity) {\n" + + " }\n" + + "}\n" + ); +} +public void testBug309835_wksp1_02() { + String source = + "public class X02 {\n" + + "\n" + + " /**\n" + + " * INTERNAL USE-ONLY\n" + + " * Generate the byte for a problem method info that correspond to a boggus method.\n" + + " *\n" + + " * @param method org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration\n" + + " * @param methodBinding org.eclipse.jdt.internal.compiler.nameloopkup.MethodBinding\n" + + " */\n" + + " public void foo(int severity) {\n" + + " }\n" + + "}\n"; + formatSource(source, + "public class X02 {\n" + + "\n" + + " /**\n" + + " * INTERNAL USE-ONLY Generate the byte for a problem method info that\n" + + " * correspond to a boggus method.\n" + + " * \n" + + " * @param method\n" + + " * org.eclipse.jdt.internal.compiler.ast.\n" + + " * AbstractMethodDeclaration\n" + + " * @param methodBinding\n" + + " * org.eclipse.jdt.internal.compiler.nameloopkup.MethodBinding\n" + + " */\n" + + " public void foo(int severity) {\n" + + " }\n" + + "}\n" + ); +} +public void testBug309835_wksp2_01() { + String source = + "public class X01 {\n" + + "\n" + + " /**\n" + + " * Given a jar file, get the names of any AnnotationProcessorFactory\n" + + " * implementations it offers. The information is based on the Sun\n" + + " * \n" + + " * Jar Service Provider spec: the jar file contains a META-INF/services\n" + + " */\n" + + " public void foo() {\n" + + " }\n" + + "}\n"; + formatSource(source, + "public class X01 {\n" + + "\n" + + " /**\n" + + " * Given a jar file, get the names of any AnnotationProcessorFactory\n" + + " * implementations it offers. The information is based on the Sun Jar Service Provider spec: the jar file contains a\n" + + " * META-INF/services\n" + + " */\n" + + " public void foo() {\n" + + " }\n" + + "}\n" + ); +} + } Index: workspace/FormatterJavadoc/test/wksp/ganymede/out/clear_blank_lines/X03.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/workspace/FormatterJavadoc/test/wksp/ganymede/out/clear_blank_lines/X03.java,v retrieving revision 1.2 diff -u -r1.2 X03.java --- workspace/FormatterJavadoc/test/wksp/ganymede/out/clear_blank_lines/X03.java 13 May 2008 17:06:12 -0000 1.2 +++ workspace/FormatterJavadoc/test/wksp/ganymede/out/clear_blank_lines/X03.java 25 Apr 2010 15:51:36 -0000 @@ -15,7 +15,8 @@ *

* * @see org.eclipse.gmf.mappings.GMFMapPackage#getAuditedMetricTarget() - * @model annotation="http://www.eclipse.org/gmf/2005/constraints/meta def='context' ocl='\'ecore::EDoubleObject\''" + * @model annotation= + * "http://www.eclipse.org/gmf/2005/constraints/meta def='context' ocl='\'ecore::EDoubleObject\''" * @generated */ public class X03 { Index: workspace/FormatterJavadoc/test/wksp/ganymede/out/default/X03.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/workspace/FormatterJavadoc/test/wksp/ganymede/out/default/X03.java,v retrieving revision 1.2 diff -u -r1.2 X03.java --- workspace/FormatterJavadoc/test/wksp/ganymede/out/default/X03.java 13 May 2008 17:06:15 -0000 1.2 +++ workspace/FormatterJavadoc/test/wksp/ganymede/out/default/X03.java 25 Apr 2010 15:51:36 -0000 @@ -17,7 +17,8 @@ *

* * @see org.eclipse.gmf.mappings.GMFMapPackage#getAuditedMetricTarget() - * @model annotation="http://www.eclipse.org/gmf/2005/constraints/meta def='context' ocl='\'ecore::EDoubleObject\''" + * @model annotation= + * "http://www.eclipse.org/gmf/2005/constraints/meta def='context' ocl='\'ecore::EDoubleObject\''" * @generated */ public class X03 { Index: workspace/FormatterJavadoc/test/wksp/ganymede/out/dont_indent_tags/X03.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/workspace/FormatterJavadoc/test/wksp/ganymede/out/dont_indent_tags/X03.java,v retrieving revision 1.2 diff -u -r1.2 X03.java --- workspace/FormatterJavadoc/test/wksp/ganymede/out/dont_indent_tags/X03.java 13 May 2008 17:06:15 -0000 1.2 +++ workspace/FormatterJavadoc/test/wksp/ganymede/out/dont_indent_tags/X03.java 25 Apr 2010 15:51:36 -0000 @@ -17,7 +17,8 @@ *

* * @see org.eclipse.gmf.mappings.GMFMapPackage#getAuditedMetricTarget() - * @model annotation="http://www.eclipse.org/gmf/2005/constraints/meta def='context' ocl='\'ecore::EDoubleObject\''" + * @model annotation= + * "http://www.eclipse.org/gmf/2005/constraints/meta def='context' ocl='\'ecore::EDoubleObject\''" * @generated */ public class X03 {