### 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.128 diff -u -r1.128 Scribe.java --- formatter/org/eclipse/jdt/internal/formatter/Scribe.java 27 Apr 2008 10:01:19 -0000 1.128 +++ formatter/org/eclipse/jdt/internal/formatter/Scribe.java 27 Apr 2008 16:25:10 -0000 @@ -1789,7 +1789,7 @@ int previousStart = currentTokenStartPosition; if (!isNlsTag && includesLineComments()) { - printLineComment(currentTokenStartPosition, currentTokenEndPosition); + printLineComment(currentTokenStartPosition, currentTokenEndPosition-1); } else { // do nothing!? loop: while (nextCharacterStart <= currentTokenEndPosition && (currentCharacter = this.scanner.getNextChar()) != -1) { @@ -1843,6 +1843,7 @@ this.numberOfIndentations = this.indentationLevel / this.indentationSize; // Consume the comment prefix + this.scanner.resetTo(commentStart, commentEnd); StringBuffer buffer = new StringBuffer(); this.scanner.getNextChar(); buffer.append(this.scanner.currentCharacter); @@ -1856,6 +1857,7 @@ int previousPosition = commentStart; char previousChar = 0; boolean firstWord = true; + this.scanner.skipComments = true; // Consume text token per token while (!this.scanner.atEnd()) { @@ -1925,7 +1927,7 @@ buffer.append(this.lineSeparator); this.line++; this.lastNumberOfNewLines++; - } else if (previousPosition < commentEnd) { + } else { this.scanner.resetTo(previousPosition, commentEnd); while (!this.scanner.atEnd()) { this.scanner.getNextChar(); @@ -1941,7 +1943,8 @@ } // Replace the existing comment with new one - addReplaceEdit(commentStart, commentEnd-1, buffer.toString()); + addReplaceEdit(commentStart, commentEnd, buffer.toString()); + this.scanner.skipComments = false; } public void printEmptyLines(int linesNumber) { @@ -2071,9 +2074,6 @@ } if (!block.isDescription()) { this.column += previousEnd - block.sourceStart + 1; - if (block.isInlined()) { - this.column++; // Add extra character for inline tag - } FormatJavadocReference reference= block.reference; if (reference != null) { // format reference @@ -2107,7 +2107,10 @@ while (token == TerminalTokens.TokenNameWHITESPACE || token == TerminalTokens.TokenNameMULTIPLY) { token = this.scanner.getNextToken(); } - buffer.append(this.scanner.source, this.scanner.startPosition, this.scanner.currentPosition-this.scanner.startPosition); + if (token == TerminalTokens.TokenNameRBRACE) { + buffer.append(this.scanner.source, this.scanner.startPosition, this.scanner.currentPosition-this.scanner.startPosition); + this.column += (this.scanner.atEnd() ? this.scanner.eofPosition : this.scanner.currentPosition) - this.scanner.startPosition; + } } catch (InvalidInputException e) { buffer.append('}'); } @@ -2118,7 +2121,6 @@ } // tag section: iterate through the blocks composing this tag but the last one -// if (block.isHeaderLine()) maxColumn++; for (int i=0; i<=maxNodes; i++) { FormatJavadocNode node = block.nodes[i]; int nodeStart = node.sourceStart; Index: formatter/org/eclipse/jdt/internal/formatter/FormatterCommentParser.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/FormatterCommentParser.java,v retrieving revision 1.5 diff -u -r1.5 FormatterCommentParser.java --- formatter/org/eclipse/jdt/internal/formatter/FormatterCommentParser.java 27 Apr 2008 10:01:19 -0000 1.5 +++ formatter/org/eclipse/jdt/internal/formatter/FormatterCommentParser.java 27 Apr 2008 16:25:08 -0000 @@ -26,6 +26,7 @@ public class FormatterCommentParser extends JavadocParser implements IJavaDocTagConstants { char[][] htmlTags; int htmlTagsPtr = -1; + private boolean invalidTagName; FormatterCommentParser(Parser sourceParser) { super(sourceParser); @@ -115,6 +116,65 @@ } /* + * Return the html tag index in the various arrays of IJavaDocTagConstants. + * The returned int is set as follow: + * - the array index is set on bits 0 to 7 + * - the tag category is set on bit 8 to 15 (0xFF00 if no array includes the tag) + */ +private int getHtmlTagIndex(char[] htmlTag) { + int length = htmlTag == null ? 0 : htmlTag.length; + if (length > 0) { + for (int i=0, max=JAVADOC_SINGLE_BREAK_TAG.length; i= this.scanner.eofPosition) { + this.invalidTagName = true; + return null; + } + this.tagSourceStart = this.scanner.getCurrentTokenStartPosition(); + this.tagSourceEnd = this.scanner.getCurrentTokenEndPosition(); + char[] tagName = this.scanner.getCurrentIdentifierSource(); + return tagName; +} + +/* * Parse an HTML tag expected to be either opening (e.g. ) or * closing (e.g. ). */ @@ -132,7 +192,7 @@ case TerminalTokens.TokenNameIdentifier: // HTML tag opening htmlTag = this.scanner.getCurrentIdentifierSource(); - htmlIndex = htmlTagIndex(htmlTag); + htmlIndex = getHtmlTagIndex(htmlTag); if (htmlIndex == JAVADOC_TAGS_ID_MASK) return valid; if ((htmlIndex & JAVADOC_TAGS_ID_MASK) > JAVADOC_SINGLE_TAGS_ID) { if (this.htmlTagsPtr == -1 || !CharOperation.equals(this.htmlTags[this.htmlTagsPtr], htmlTag, false)) { @@ -157,7 +217,7 @@ return valid; } char[] identifier = this.scanner.getCurrentIdentifierSource(); - htmlIndex = htmlTagIndex(identifier); + htmlIndex = getHtmlTagIndex(identifier); if (htmlIndex == JAVADOC_TAGS_ID_MASK) return valid; while (!CharOperation.equals(htmlTag, identifier, false)) { if (htmlTagsPtr <= 0) { @@ -202,49 +262,6 @@ return valid; } -/* - * Return the html tag index in the various arrays of IJavaDocTagConstants. - * The returned int is set as follow: - * - the array index is set on bits 0 to 7 - * - the tag category is set on bit 8 to 15 (0xFF00 if no array includes the tag) - */ -private int htmlTagIndex(char[] htmlTag) { - int length = htmlTag == null ? 0 : htmlTag.length; - if (length > 0) { - for (int i=0, max=JAVADOC_SINGLE_BREAK_TAG.length; i= this.scanner.eofPosition) { + this.tagSourceStart = previousPosition; + this.tagSourceEnd = this.tokenPreviousPosition; + if (this.reportProblems) this.sourceParser.problemReporter().javadocInvalidTag(this.tagSourceStart, this.tagSourceEnd); + return null; + } + this.tagSourceStart = this.scanner.getCurrentTokenStartPosition(); + this.tagSourceEnd = this.scanner.getCurrentTokenEndPosition(); + char[] tagName = this.scanner.getCurrentIdentifierSource(); + return tagName; + } + /* * Parse @throws tag declaration and flag missing description if corresponding option is enabled */ @@ -411,21 +430,8 @@ // Read tag name int currentPosition = this.index; int token = readTokenAndConsume(); - if (currentPosition != this.scanner.startPosition) { - this.tagSourceStart = previousPosition; - this.tagSourceEnd = currentPosition; - if (this.reportProblems) this.sourceParser.problemReporter().javadocInvalidTag(this.tagSourceStart, this.tagSourceEnd); - return false; - } - if (this.index >= this.scanner.eofPosition) { - this.tagSourceStart = previousPosition; - this.tagSourceEnd = this.tokenPreviousPosition; - if (this.reportProblems) this.sourceParser.problemReporter().javadocInvalidTag(this.tagSourceStart, this.tagSourceEnd); - return false; - } - this.tagSourceStart = this.scanner.getCurrentTokenStartPosition(); - this.tagSourceEnd = this.scanner.getCurrentTokenEndPosition(); - char[] tagName = this.scanner.getCurrentIdentifierSource(); + char[] tagName = getTagName(previousPosition, currentPosition); + if (tagName == null) return false; // Try to get tag name other than java identifier // (see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=51660) Index: compiler/org/eclipse/jdt/internal/compiler/parser/AbstractCommentParser.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/AbstractCommentParser.java,v retrieving revision 1.71 diff -u -r1.71 AbstractCommentParser.java --- compiler/org/eclipse/jdt/internal/compiler/parser/AbstractCommentParser.java 23 Apr 2008 10:13:37 -0000 1.71 +++ compiler/org/eclipse/jdt/internal/compiler/parser/AbstractCommentParser.java 27 Apr 2008 16:25:07 -0000 @@ -287,7 +287,7 @@ if (this.lineStarted && this.textStart != -1 && this.textStart < textEndPosition) { pushText(this.textStart, textEndPosition); } - refreshInlineTagPosition(textEndPosition); + refreshInlineTagPosition(previousPosition); } if (!isFormatterParser) this.textStart = this.index; this.inlineTagStarted = false; #P org.eclipse.jdt.core.tests.model Index: src/org/eclipse/jdt/core/tests/formatter/comment/JavaDocTestCase.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/comment/JavaDocTestCase.java,v retrieving revision 1.18 diff -u -r1.18 JavaDocTestCase.java --- src/org/eclipse/jdt/core/tests/formatter/comment/JavaDocTestCase.java 25 Apr 2008 13:11:53 -0000 1.18 +++ src/org/eclipse/jdt/core/tests/formatter/comment/JavaDocTestCase.java 27 Apr 2008 16:25:17 -0000 @@ -19,6 +19,7 @@ import org.eclipse.jdt.core.formatter.CodeFormatter; import org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants; +import org.eclipse.jdt.internal.formatter.DefaultCodeFormatter; import org.eclipse.jdt.internal.formatter.comment.JavaDocLine; import org.eclipse.jdt.internal.formatter.comment.MultiCommentLine; import org.eclipse.text.edits.TextEdit; @@ -557,18 +558,18 @@ } /** - * [formatting] Javadoc Formatter mishandles spaces in comments - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49686 - */ - public void testMultilineInlineTag2() { - setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH, "20"); //$NON-NLS-1$ - final String prefix= PREFIX + DELIMITER + INFIX + "{@link Objecterr}s"; - final String postfix= "are cool." + DELIMITER + POSTFIX; - String input= prefix + " " + postfix; //$NON-NLS-1$ - String expected= prefix + DELIMITER + INFIX + postfix; - String result= testFormat(input); - assertEquals(expected, result); - } + * [formatting] Javadoc Formatter mishandles spaces in comments + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49686 + */ + public void testMultilineInlineTag2() { + setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH, "20"); //$NON-NLS-1$ + final String prefix= PREFIX + DELIMITER + INFIX + "{@link Objecterr}"; + final String postfix= "s are cool." + DELIMITER + POSTFIX; + String input= prefix + postfix; //$NON-NLS-1$ + String expected= prefix + DELIMITER + INFIX + postfix; + String result= testFormat(input); + assertEquals(expected, result); + } /** * [formatting] Javadoc Formatter mishandles spaces in comments @@ -697,6 +698,7 @@ String expected = "/**" + DELIMITER + " *
" + DELIMITER + 
+				(DefaultCodeFormatter.ENABLE_NEW_COMMENTS_FORMAT ? " * " +  DELIMITER : "") +
 				" * 
" + DELIMITER + " * " + DELIMITER + " * " + DELIMITER + @@ -874,8 +876,9 @@ " * " + DELIMITER + " */"; - String expected = - "/**" + DELIMITER + + String expected = DefaultCodeFormatter.ENABLE_NEW_COMMENTS_FORMAT + ? input // do not change as is an immutable tag + : "/**" + DELIMITER + " * " + DELIMITER + " *
" + DELIMITER + 
 				" * setLeadingComment("/* traditional comment */"); // correct" + DELIMITER + 
@@ -936,6 +939,40 @@
 		assertEquals(expected, result);
 	}
 
+	public void test109636_4() {
+		if (DefaultCodeFormatter.ENABLE_NEW_COMMENTS_FORMAT) {
+			Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings();
+
+			String input =
+					"/**" + DELIMITER + 
+					" * 
" + DELIMITER + 
+					" * setLeadingComment(\"/* traditional comment */\");  // correct" + DELIMITER + 
+					" * setLeadingComment(\"missing comment delimiters\");  // wrong" + DELIMITER + 
+					" * setLeadingComment(\"/* unterminated traditional comment \");  // wrong" + DELIMITER + 
+					" * setLeadingComment(\"/* broken\\n traditional comment */\");  // correct" + DELIMITER + 
+					" * setLeadingComment(\"// end-of-line comment\\n\");  // correct" + DELIMITER + 
+					" * setLeadingComment(\"// end-of-line comment without line terminator\");  // correct" + DELIMITER + 
+					" * setLeadingComment(\"// broken\\n end-of-line comment\\n\");  // wrong" + DELIMITER + 
+					" * 
" + DELIMITER + + " */"; + + String expected = + "/**" + DELIMITER + + " *
" + DELIMITER + 
+					" * setLeadingComment("/* traditional comment */"); // correct" + DELIMITER + 
+					" * setLeadingComment("missing comment delimiters"); // wrong" + DELIMITER + 
+					" * setLeadingComment("/* unterminated traditional comment "); // wrong" + DELIMITER + 
+					" * setLeadingComment("/* broken\\n traditional comment */"); // correct" + DELIMITER + 
+					" * setLeadingComment("// end-of-line comment\\n"); // correct" + DELIMITER + 
+					" * setLeadingComment("// end-of-line comment without line terminator"); // correct" + DELIMITER + 
+					" * setLeadingComment("// broken\\n end-of-line comment\\n"); // wrong" + DELIMITER + 
+					" * 
" + DELIMITER + + " */"; + String result=testFormat(input, options); + assertEquals(expected, result); + } + } + /** * @bug 228652: [formatter] New line inserted while formatting a region of a compilation unit. * @test Insure that no new line is inserted before the formatted region Index: src/org/eclipse/jdt/core/tests/formatter/comment/MultiLineTestCase.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/comment/MultiLineTestCase.java,v retrieving revision 1.10 diff -u -r1.10 MultiLineTestCase.java --- src/org/eclipse/jdt/core/tests/formatter/comment/MultiLineTestCase.java 6 Mar 2007 04:43:20 -0000 1.10 +++ src/org/eclipse/jdt/core/tests/formatter/comment/MultiLineTestCase.java 27 Apr 2008 16:25:17 -0000 @@ -17,6 +17,7 @@ import junit.framework.Test; +import org.eclipse.jdt.internal.formatter.DefaultCodeFormatter; import org.eclipse.jdt.internal.formatter.comment.MultiCommentLine; public class MultiLineTestCase extends CommentTestCase { @@ -115,7 +116,11 @@ " * Member comment\n" +//$NON-NLS-1$ " */";//$NON-NLS-1$ String result= testFormat(input, 0, input.length(), CodeFormatter.K_MULTI_LINE_COMMENT , 2); - String expectedOutput = "/***********************************************************************\n" + + String expectedOutput = DefaultCodeFormatter.ENABLE_NEW_COMMENTS_FORMAT + ? "/**\n" + + " * Member comment\n" + + " */" + : "/***********************************************************************\n" + " * Member comment\n" + " */"; assertEquals("Different output", expectedOutput, result); Index: src/org/eclipse/jdt/core/tests/formatter/comment/CommentsTestSuite.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/comment/CommentsTestSuite.java,v retrieving revision 1.3 diff -u -r1.3 CommentsTestSuite.java --- src/org/eclipse/jdt/core/tests/formatter/comment/CommentsTestSuite.java 23 Apr 2008 10:13:41 -0000 1.3 +++ src/org/eclipse/jdt/core/tests/formatter/comment/CommentsTestSuite.java 27 Apr 2008 16:25:15 -0000 @@ -22,16 +22,10 @@ public static Test suite() { return new CommentsTestSuite(); } - - // TODO (frederic) Fix the failures on SingleLineTestCase when new formatter is enabled... + public CommentsTestSuite() { addTest(MultiLineTestCase.suite()); - String newFormatter = System.getProperty("org.eclipse.jdt.core.formatter.comments.new"); - if (newFormatter == null) { - addTest(SingleLineTestCase.suite()); - } else { - System.out.println("SingleLineTestCase temporarily disabled as new formatter is enabled!"); - } + addTest(SingleLineTestCase.suite()); addTest(JavaDocTestCase.suite()); } } Index: src/org/eclipse/jdt/core/tests/formatter/comment/SingleLineTestCase.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/comment/SingleLineTestCase.java,v retrieving revision 1.5 diff -u -r1.5 SingleLineTestCase.java --- src/org/eclipse/jdt/core/tests/formatter/comment/SingleLineTestCase.java 6 Mar 2007 04:43:20 -0000 1.5 +++ src/org/eclipse/jdt/core/tests/formatter/comment/SingleLineTestCase.java 27 Apr 2008 16:25:17 -0000 @@ -16,6 +16,7 @@ import org.eclipse.jdt.core.formatter.CodeFormatter; import org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants; +import org.eclipse.jdt.internal.formatter.DefaultCodeFormatter; import org.eclipse.jdt.internal.formatter.comment.SingleCommentLine; public class SingleLineTestCase extends CommentTestCase { @@ -41,29 +42,44 @@ setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH, "5"); //$NON-NLS-1$ setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_CLEAR_BLANK_LINES_IN_BLOCK_COMMENT, DefaultCodeFormatterConstants.FALSE); setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_CLEAR_BLANK_LINES_IN_JAVADOC_COMMENT, DefaultCodeFormatterConstants.FALSE); - assertEquals(PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER, testFormat("//test\ttest" + DELIMITER + "//" + DELIMITER + "//\t\ttest")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ + String expected = DefaultCodeFormatter.ENABLE_NEW_COMMENTS_FORMAT + ? PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + "//"+ DELIMITER + PREFIX + "test" + : PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER; + assertEquals(expected, testFormat("//test\ttest" + DELIMITER + "//" + DELIMITER + "//\t\ttest")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ } public void testClearBlankLines2() { setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH, "5"); //$NON-NLS-1$ setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_CLEAR_BLANK_LINES_IN_BLOCK_COMMENT, DefaultCodeFormatterConstants.FALSE); setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_CLEAR_BLANK_LINES_IN_JAVADOC_COMMENT, DefaultCodeFormatterConstants.FALSE); - assertEquals(PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER, testFormat("//test\t\ttest" + DELIMITER + PREFIX + DELIMITER + "//\t\ttest")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ + String expected = DefaultCodeFormatter.ENABLE_NEW_COMMENTS_FORMAT + ? PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + "//"+ DELIMITER + PREFIX + "test" + : PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER; + assertEquals(expected, testFormat("//test\t\ttest" + DELIMITER + PREFIX + DELIMITER + "//\t\ttest")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ } public void testClearBlankLines3() { setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH, "5"); //$NON-NLS-1$ setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_CLEAR_BLANK_LINES_IN_BLOCK_COMMENT, DefaultCodeFormatterConstants.FALSE); setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_CLEAR_BLANK_LINES_IN_JAVADOC_COMMENT, DefaultCodeFormatterConstants.FALSE); - assertEquals(PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER, testFormat("//test\ttest" + DELIMITER + "//" + DELIMITER + PREFIX + "test\ttest")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ + String expected = DefaultCodeFormatter.ENABLE_NEW_COMMENTS_FORMAT + ? PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + "//"+ DELIMITER + PREFIX + "test" + DELIMITER + PREFIX + "test" + : PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER; + assertEquals(expected, testFormat("//test\ttest" + DELIMITER + "//" + DELIMITER + PREFIX + "test\ttest")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ } public void testCommentBegin1() { - assertEquals(PREFIX + "test" + DELIMITER, testFormat("//test")); //$NON-NLS-1$ //$NON-NLS-2$ + String expected = DefaultCodeFormatter.ENABLE_NEW_COMMENTS_FORMAT + ? PREFIX + "test" + : PREFIX + "test" + DELIMITER; + assertEquals(expected, testFormat("//test")); //$NON-NLS-1$ //$NON-NLS-2$ } public void testCommentBegin2() { - assertEquals(PREFIX + "test" + DELIMITER, testFormat(PREFIX + "test")); //$NON-NLS-1$ //$NON-NLS-2$ + String expected = DefaultCodeFormatter.ENABLE_NEW_COMMENTS_FORMAT + ? PREFIX + "test" + : PREFIX + "test" + DELIMITER; + assertEquals(expected, testFormat(PREFIX + "test")); //$NON-NLS-1$ //$NON-NLS-2$ } public void testCommentBegin3() { @@ -71,11 +87,15 @@ } public void testCommentDelimiter1() { - assertEquals(PREFIX + "test" + DELIMITER, testFormat("//\t\ttest " + DELIMITER + DELIMITER)); //$NON-NLS-1$ //$NON-NLS-2$ + String expected = PREFIX + "test" + DELIMITER; + if (DefaultCodeFormatter.ENABLE_NEW_COMMENTS_FORMAT) expected += DELIMITER; + assertEquals(expected, testFormat("//\t\ttest " + DELIMITER + DELIMITER)); //$NON-NLS-1$ //$NON-NLS-2$ } public void testCommentDelimiter2() { - assertEquals(PREFIX + "test" + DELIMITER, testFormat(PREFIX + "test " + DELIMITER + DELIMITER + DELIMITER)); //$NON-NLS-1$ //$NON-NLS-2$ + String expected = PREFIX + "test" + DELIMITER; + if (DefaultCodeFormatter.ENABLE_NEW_COMMENTS_FORMAT) expected += DELIMITER ; + assertEquals(expected, testFormat(PREFIX + "test " + DELIMITER + DELIMITER + DELIMITER)); //$NON-NLS-1$ //$NON-NLS-2$ } public void testCommentNls1() { @@ -103,30 +123,48 @@ } public void testCommentSpace1() { - assertEquals(PREFIX + "test test" + DELIMITER, testFormat("//test\t \t test")); //$NON-NLS-1$ //$NON-NLS-2$ + String expected = DefaultCodeFormatter.ENABLE_NEW_COMMENTS_FORMAT + ? PREFIX + "test test" + : PREFIX + "test test" + DELIMITER; + assertEquals(expected, testFormat("//test\t \t test")); //$NON-NLS-1$ //$NON-NLS-2$ } public void testCommentSpace2() { - assertEquals(PREFIX + "test test" + DELIMITER, testFormat("//test test")); //$NON-NLS-1$ //$NON-NLS-2$ + String expected = DefaultCodeFormatter.ENABLE_NEW_COMMENTS_FORMAT + ? PREFIX + "test test" + : PREFIX + "test test" + DELIMITER; + assertEquals(expected, testFormat("//test test")); //$NON-NLS-1$ //$NON-NLS-2$ } public void testCommentSpace3() { - assertEquals(PREFIX + "test test" + DELIMITER, testFormat(PREFIX + "test \t \t test")); //$NON-NLS-1$ //$NON-NLS-2$ + String expected = DefaultCodeFormatter.ENABLE_NEW_COMMENTS_FORMAT + ? PREFIX + "test test" + : PREFIX + "test test" + DELIMITER; + assertEquals(expected, testFormat(PREFIX + "test \t \t test")); //$NON-NLS-1$ //$NON-NLS-2$ } public void testCommentWrapping1() { setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH, "5"); //$NON-NLS-1$ - assertEquals(PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER, testFormat("//test\ttest")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + String expected = DefaultCodeFormatter.ENABLE_NEW_COMMENTS_FORMAT + ? PREFIX + "test" + DELIMITER + PREFIX + "test" + : PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER; + assertEquals(expected, testFormat("//test\ttest")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } public void testCommentWrapping2() { setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH, "1"); //$NON-NLS-1$ - assertEquals(PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER, testFormat("//test\ttest")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + String expected = DefaultCodeFormatter.ENABLE_NEW_COMMENTS_FORMAT + ? PREFIX + "test" + DELIMITER + PREFIX + "test" + : PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER; + assertEquals(expected, testFormat("//test\ttest")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } public void testCommentWrapping3() { setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH, "32"); //$NON-NLS-1$ - assertEquals(PREFIX + "test test" + DELIMITER, testFormat("//test\ttest")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + String expected = DefaultCodeFormatter.ENABLE_NEW_COMMENTS_FORMAT + ? PREFIX + "test test" + : PREFIX + "test test" + DELIMITER; + assertEquals(expected, testFormat("//test\ttest")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } public void testCommentWrapping4() { @@ -148,38 +186,59 @@ public void testHeaderComment1() { setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_HEADER, DefaultCodeFormatterConstants.FALSE); setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH, "12"); //$NON-NLS-1$ - assertEquals(PREFIX + "test test" + DELIMITER + PREFIX + "test test" + DELIMITER + PREFIX + "test test" + DELIMITER, testFormat("//test\t\t\t\ttest" + DELIMITER + PREFIX + "test test test test")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ + String expected = DefaultCodeFormatter.ENABLE_NEW_COMMENTS_FORMAT + ? PREFIX + "test test" + DELIMITER + PREFIX + "test test" + DELIMITER + PREFIX + "test test" + : PREFIX + "test test" + DELIMITER + PREFIX + "test test" + DELIMITER + PREFIX + "test test" + DELIMITER; + assertEquals(expected, testFormat("//test\t\t\t\ttest" + DELIMITER + PREFIX + "test test test test")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ } public void testHeaderComment2() { setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_HEADER, DefaultCodeFormatterConstants.FALSE); setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH, "24"); //$NON-NLS-1$ - assertEquals(PREFIX + "test test test test" + DELIMITER + PREFIX + "test" + DELIMITER, testFormat("//test\t\t\t" + DELIMITER + PREFIX + "test test test test" + DELIMITER)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + String expected = DefaultCodeFormatter.ENABLE_NEW_COMMENTS_FORMAT + ? "// test" + DELIMITER + PREFIX + "test test test test" + DELIMITER + : PREFIX + "test test test test" + DELIMITER + PREFIX + "test" + DELIMITER; + assertEquals(expected, testFormat("//test\t\t\t" + DELIMITER + PREFIX + "test test test test" + DELIMITER)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ } public void testIllegalLineLength1() { setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH, "1"); //$NON-NLS-1$ - assertEquals(PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER, testFormat("//test\ttest")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + String expected =PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER; + if (DefaultCodeFormatter.ENABLE_NEW_COMMENTS_FORMAT) expected = expected.substring(0, expected.length()-DELIMITER.length()); + assertEquals(expected, testFormat("//test\ttest")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } public void testIllegalLineLength2() { setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH, "-16"); //$NON-NLS-1$ - assertEquals(PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER, testFormat(PREFIX + "\t\t test\ttest")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + String expected = PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER; + if (DefaultCodeFormatter.ENABLE_NEW_COMMENTS_FORMAT) expected = expected.substring(0, expected.length()-DELIMITER.length()); + assertEquals(expected, testFormat(PREFIX + "\t\t test\ttest")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } public void testMultipleComments1() { setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH, "5"); //$NON-NLS-1$ - assertEquals(PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER, testFormat("//test test" + DELIMITER + PREFIX + "test test test test")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ + String expected = PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER; + if (DefaultCodeFormatter.ENABLE_NEW_COMMENTS_FORMAT) expected = expected.substring(0, expected.length()-DELIMITER.length()); + assertEquals(expected, testFormat("//test test" + DELIMITER + PREFIX + "test test test test")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ } public void testMultipleComments2() { setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH, "12"); //$NON-NLS-1$ - assertEquals(PREFIX + "test test" + DELIMITER + PREFIX + "test test" + DELIMITER + PREFIX + "test test" + DELIMITER + PREFIX + "test" + DELIMITER, testFormat("//test test\ttest" + DELIMITER + PREFIX + DELIMITER + PREFIX + "test test test test")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ + String expected = DefaultCodeFormatter.ENABLE_NEW_COMMENTS_FORMAT + ? "// test test" + DELIMITER + + "// test" + DELIMITER + + "//" + DELIMITER + + "// test test" + DELIMITER + + "// test test" + : PREFIX + "test test" + DELIMITER + PREFIX + "test test" + DELIMITER + PREFIX + "test test" + DELIMITER + PREFIX + "test" + DELIMITER; + assertEquals(expected, testFormat("//test test\ttest" + DELIMITER + PREFIX + DELIMITER + PREFIX + "test test test test")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ } public void testMultipleComments3() { setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH, "11"); //$NON-NLS-1$ - assertEquals(PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER, testFormat("// test\t\t\ttest\ttest" + DELIMITER + PREFIX + "test test test test")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ + String expected = PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER; + if (DefaultCodeFormatter.ENABLE_NEW_COMMENTS_FORMAT) expected = expected.substring(0, expected.length()-DELIMITER.length()); + assertEquals(expected, testFormat("// test\t\t\ttest\ttest" + DELIMITER + PREFIX + "test test test test")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ } public void testIndentedComment1() { @@ -208,13 +267,14 @@ public void testNoChange1() { String content= PREFIX; - assertEquals(content, testFormat(content)); + String expected = DefaultCodeFormatter.ENABLE_NEW_COMMENTS_FORMAT ? "//" : content; + assertEquals(expected, testFormat(content)); } public void testNoFormat1() { setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_LINE_COMMENT, DefaultCodeFormatterConstants.FALSE); setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH, "1"); - String content= PREFIX + "test test"; + String content = PREFIX + "test test"; assertEquals(content, testFormat(content)); } public void _test109581() { Index: workspace/FormatterJavadoc/test/wksp/eclipse/out/default/X19.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/workspace/FormatterJavadoc/test/wksp/eclipse/out/default/X19.java,v retrieving revision 1.1 diff -u -r1.1 X19.java --- workspace/FormatterJavadoc/test/wksp/eclipse/out/default/X19.java 27 Apr 2008 10:01:23 -0000 1.1 +++ workspace/FormatterJavadoc/test/wksp/eclipse/out/default/X19.java 27 Apr 2008 16:25:17 -0000 @@ -17,18 +17,18 @@ * source string. It includes entries for comments of all kinds (line, * block, and doc), arranged in order of increasing source position. *

- * Note on comment parenting: The {@link ASTNode#getParent() getParent()} - * of a doc comment associated with a body declaration is the body - * declaration node; for these comment nodes {@link ASTNode#getRoot() - * getRoot()} will return the compilation unit (assuming an unmodified AST) - * reflecting the fact that these nodes are property located in the AST for - * the compilation unit. However, for other comment nodes, {@link - * ASTNode#getParent() getParent()} will return null, and - * {@link ASTNode#getRoot() getRoot()} will return the comment node itself, - * indicating that these comment nodes are not directly connected to the AST - * for the compilation unit. The {@link Comment#getAlternateRoot - * Comment.getAlternateRoot} method provides a way to navigate from a - * comment to its compilation unit.

+ * Note on comment parenting: The {@link ASTNode#getParent() getParent()} of + * a doc comment associated with a body declaration is the body declaration + * node; for these comment nodes {@link ASTNode#getRoot() getRoot()} will + * return the compilation unit (assuming an unmodified AST) reflecting the + * fact that these nodes are property located in the AST for the compilation + * unit. However, for other comment nodes, {@link ASTNode#getParent() + * getParent()} will return null, and {@link ASTNode#getRoot() + * getRoot()} will return the comment node itself, indicating that these + * comment nodes are not directly connected to the AST for the compilation + * unit. The {@link Comment#getAlternateRoot Comment.getAlternateRoot} + * method provides a way to navigate from a comment to its compilation unit. + *

*

* A note on visitors: The only comment nodes that will be visited when * visiting a compilation unit are the doc comments parented by body Index: workspace/FormatterJavadoc/test/wksp/eclipse/out/default/X18.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/workspace/FormatterJavadoc/test/wksp/eclipse/out/default/X18.java,v retrieving revision 1.1 diff -u -r1.1 X18.java --- workspace/FormatterJavadoc/test/wksp/eclipse/out/default/X18.java 27 Apr 2008 10:01:23 -0000 1.1 +++ workspace/FormatterJavadoc/test/wksp/eclipse/out/default/X18.java 27 Apr 2008 16:25:17 -0000 @@ -43,10 +43,10 @@ *

*

* Lexical or syntax errors detected while parsing can result in a result - * node being marked as {@link ASTNode#MALFORMED MALFORMED} . In more - * severe failure cases where the parser is unable to recognize the input, - * this method returns a {@link CompilationUnit CompilationUnit} node with - * at least the compiler messages. + * node being marked as {@link ASTNode#MALFORMED MALFORMED} . In more severe + * failure cases where the parser is unable to recognize the input, this + * method returns a {@link CompilationUnit CompilationUnit} node with at + * least the compiler messages. *

*

* Each node in the subtree (other than the contrived nodes) carries source Index: workspace/FormatterJavadoc/test/wksp/eclipse/out/dont_indent_descr/X18.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/workspace/FormatterJavadoc/test/wksp/eclipse/out/dont_indent_descr/X18.java,v retrieving revision 1.1 diff -u -r1.1 X18.java --- workspace/FormatterJavadoc/test/wksp/eclipse/out/dont_indent_descr/X18.java 27 Apr 2008 10:01:24 -0000 1.1 +++ workspace/FormatterJavadoc/test/wksp/eclipse/out/dont_indent_descr/X18.java 27 Apr 2008 16:25:17 -0000 @@ -43,10 +43,10 @@ *

*

* Lexical or syntax errors detected while parsing can result in a result - * node being marked as {@link ASTNode#MALFORMED MALFORMED} . In more - * severe failure cases where the parser is unable to recognize the input, - * this method returns a {@link CompilationUnit CompilationUnit} node with - * at least the compiler messages. + * node being marked as {@link ASTNode#MALFORMED MALFORMED} . In more severe + * failure cases where the parser is unable to recognize the input, this + * method returns a {@link CompilationUnit CompilationUnit} node with at + * least the compiler messages. *

*

* Each node in the subtree (other than the contrived nodes) carries source Index: src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsMassiveTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsMassiveTests.java,v retrieving revision 1.8 diff -u -r1.8 FormatterCommentsMassiveTests.java --- src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsMassiveTests.java 27 Apr 2008 10:01:23 -0000 1.8 +++ src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsMassiveTests.java 27 Apr 2008 16:25:15 -0000 @@ -124,16 +124,16 @@ *

    *
  • 3.0 performance workspace (9951 units):
      *
    • 0 error
    • - *
    • 27 failures
    • + *
    • 17 failures
    • *
    • 8 failures due to old formatter
    • - *
    • 863 files have different lines leading spaces
    • - *
    • 15 files have different spaces
    • + *
    • 722 files have different lines leading spaces
    • + *
    • 10 files have different spaces
    • *
  • *
  • ganymede workspace (25819 units):
      *
    • 0 error
    • - *
    • 81 files has still different output while reformatting!
    • - *
    • 1606 files have different line leading spaces when reformatting!
    • - *
    • 91 files have different spaces when reformatting!
    • + *
    • 64 files has still different output while reformatting!
    • + *
    • 1366 files have different line leading spaces when reformatting!
    • + *
    • 11 files have different spaces when reformatting!
    • *
  • *
*/ @@ -388,17 +388,6 @@ commentEnd = -commentEnd; if (commentStart < 0) { // line comments have negative start position commentStart = -commentStart; - String comment = formattedComments[i]; - if (comment.trim().length() > 2) { // non empty comment - char ch = source.charAt(commentEnd); - if (ch == '\r' || ch == '\n') { - commentEnd++; - ch = source.charAt(commentEnd); - if (ch == '\r' || ch == '\n') { - commentEnd++; - } - } - } } } document.replace(commentStart, commentEnd - commentStart, formattedComments[i]); 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.6 diff -u -r1.6 FormatterCommentsTests.java --- src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsTests.java 27 Apr 2008 10:01:23 -0000 1.6 +++ src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsTests.java 27 Apr 2008 16:25:15 -0000 @@ -665,6 +665,9 @@ public void testTagOthers02() throws JavaModelException { formatUnit("tags.others", "X02.java"); } +public void testTagOthers03() throws JavaModelException { + formatUnit("tags.others", "X03.java"); +} /* * Test formatter @param @@ -755,6 +758,9 @@ public void testLineComments05() throws JavaModelException { formatUnit("comments.line", "X05.java"); } +public void testLineComments06() throws JavaModelException { + formatUnit("comments.line", "X06.java"); +} /* * Test formatter block lines @@ -916,7 +922,14 @@ public void testWkspEclipse20() throws JavaModelException { formatUnit("wksp.eclipse", "X20.java"); } +public void testWkspEclipse21() throws JavaModelException { + formatUnit("wksp.eclipse", "X20.java"); +} // Ganymede +// TODO pass this test +public void _testWkspGanymede01() throws JavaModelException { + formatUnit("wksp.ganymede", "X02.java"); +} public void testWkspGanymede02() throws JavaModelException { formatUnit("wksp.ganymede", "X02.java"); } Index: workspace/FormatterJavadoc/test/wksp/eclipse/out/dont_indent_tags/X19.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/workspace/FormatterJavadoc/test/wksp/eclipse/out/dont_indent_tags/X19.java,v retrieving revision 1.1 diff -u -r1.1 X19.java --- workspace/FormatterJavadoc/test/wksp/eclipse/out/dont_indent_tags/X19.java 27 Apr 2008 10:01:23 -0000 1.1 +++ workspace/FormatterJavadoc/test/wksp/eclipse/out/dont_indent_tags/X19.java 27 Apr 2008 16:25:17 -0000 @@ -17,18 +17,18 @@ * source string. It includes entries for comments of all kinds (line, * block, and doc), arranged in order of increasing source position. *

- * Note on comment parenting: The {@link ASTNode#getParent() getParent()} - * of a doc comment associated with a body declaration is the body - * declaration node; for these comment nodes {@link ASTNode#getRoot() - * getRoot()} will return the compilation unit (assuming an unmodified AST) - * reflecting the fact that these nodes are property located in the AST for - * the compilation unit. However, for other comment nodes, {@link - * ASTNode#getParent() getParent()} will return null, and - * {@link ASTNode#getRoot() getRoot()} will return the comment node itself, - * indicating that these comment nodes are not directly connected to the AST - * for the compilation unit. The {@link Comment#getAlternateRoot - * Comment.getAlternateRoot} method provides a way to navigate from a - * comment to its compilation unit.

+ * Note on comment parenting: The {@link ASTNode#getParent() getParent()} of + * a doc comment associated with a body declaration is the body declaration + * node; for these comment nodes {@link ASTNode#getRoot() getRoot()} will + * return the compilation unit (assuming an unmodified AST) reflecting the + * fact that these nodes are property located in the AST for the compilation + * unit. However, for other comment nodes, {@link ASTNode#getParent() + * getParent()} will return null, and {@link ASTNode#getRoot() + * getRoot()} will return the comment node itself, indicating that these + * comment nodes are not directly connected to the AST for the compilation + * unit. The {@link Comment#getAlternateRoot Comment.getAlternateRoot} + * method provides a way to navigate from a comment to its compilation unit. + *

*

* A note on visitors: The only comment nodes that will be visited when * visiting a compilation unit are the doc comments parented by body Index: workspace/FormatterJavadoc/test/wksp/eclipse/out/dont_indent_tags/X18.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/workspace/FormatterJavadoc/test/wksp/eclipse/out/dont_indent_tags/X18.java,v retrieving revision 1.1 diff -u -r1.1 X18.java --- workspace/FormatterJavadoc/test/wksp/eclipse/out/dont_indent_tags/X18.java 27 Apr 2008 10:01:23 -0000 1.1 +++ workspace/FormatterJavadoc/test/wksp/eclipse/out/dont_indent_tags/X18.java 27 Apr 2008 16:25:17 -0000 @@ -43,10 +43,10 @@ *

*

* Lexical or syntax errors detected while parsing can result in a result - * node being marked as {@link ASTNode#MALFORMED MALFORMED} . In more - * severe failure cases where the parser is unable to recognize the input, - * this method returns a {@link CompilationUnit CompilationUnit} node with - * at least the compiler messages. + * node being marked as {@link ASTNode#MALFORMED MALFORMED} . In more severe + * failure cases where the parser is unable to recognize the input, this + * method returns a {@link CompilationUnit CompilationUnit} node with at + * least the compiler messages. *

*

* Each node in the subtree (other than the contrived nodes) carries source Index: workspace/Formatter/test553/A_in.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/workspace/Formatter/test553/A_in.java,v retrieving revision 1.1 diff -u -r1.1 A_in.java --- workspace/Formatter/test553/A_in.java 28 Mar 2005 21:15:48 -0000 1.1 +++ workspace/Formatter/test553/A_in.java 27 Apr 2008 16:25:17 -0000 @@ -1 +1 @@ -// This is a really long single line comment that should be wrapped on two lines once it is formatted \ No newline at end of file +// This is a really long single line comment that should be wrapped on two lines once it is formatted Index: workspace/FormatterJavadoc/test/tags/others/out/default/X03.java =================================================================== RCS file: workspace/FormatterJavadoc/test/tags/others/out/default/X03.java diff -N workspace/FormatterJavadoc/test/tags/others/out/default/X03.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ workspace/FormatterJavadoc/test/tags/others/out/default/X03.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,10 @@ +package test.tags.others; + +public interface X03 { + + /** + * A complex type can have one root compositor. @ return root complex type + * compositor + */ + int foo(); +} Index: workspace/FormatterJavadoc/test/wksp/eclipse/out/dont_indent_tags/X21.java =================================================================== RCS file: workspace/FormatterJavadoc/test/wksp/eclipse/out/dont_indent_tags/X21.java diff -N workspace/FormatterJavadoc/test/wksp/eclipse/out/dont_indent_tags/X21.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ workspace/FormatterJavadoc/test/wksp/eclipse/out/dont_indent_tags/X21.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,65 @@ +package test.wksp.eclipse; + +public class X21 { + + /** + * Returns a search pattern based on a given string pattern. The string + * patterns support '*' wild-cards. The remaining parameters are used to + * narrow down the type of expected results.
+ * Examples: + *

    + *
  • search for case insensitive references to Object: + * createSearchPattern("Object", TYPE, REFERENCES, false);
  • + *
  • search for case sensitive references to exact Object() + * constructor: + * createSearchPattern("java.lang.Object()", CONSTRUCTOR, REFERENCES, true); + *
  • + *
  • search for implementers of java.lang.Runnable: + * createSearchPattern("java.lang.Runnable", TYPE, IMPLEMENTORS, true); + *
  • + *
+ * + * @param stringPattern + * the given pattern + * @param searchFor + * determines the nature of the searched elements + *
    + *
  • IJavaSearchConstants.CLASS : only look for classes
  • + *
  • IJavaSearchConstants.INTERFACE : only look for + * interfaces
  • + *
  • IJavaSearchConstants.TYPE : look for both classes and + * interfaces
  • + *
  • IJavaSearchConstants.FIELD : look for fields
  • + *
  • IJavaSearchConstants.METHOD : look for methods
  • + *
  • IJavaSearchConstants.CONSTRUCTOR : look for + * constructors
  • + *
  • IJavaSearchConstants.PACKAGE : look for packages
  • + *
+ * @param limitTo + * determines the nature of the expected matches + *
    + *
  • IJavaSearchConstants.DECLARATIONS : will search + * declarations matching with the corresponding element. In case the element + * is a method, declarations of matching methods in subtypes will also be + * found, allowing to find declarations of abstract methods, etc.
  • + * + *
  • IJavaSearchConstants.REFERENCES : will search + * references to the given element.
  • + * + *
  • IJavaSearchConstants.ALL_OCCURRENCES : will search for + * either declarations or references as specified above.
  • + * + *
  • IJavaSearchConstants.IMPLEMENTORS : for interface, will + * find all types which implements a given interface.
  • + *
+ * + * @param isCaseSensitive + * indicates whether the search is case sensitive or not. + * @return a search pattern on the given string pattern, or + * null if the string pattern is ill-formed. + * @deprecated Use {@link SearchPattern#createPattern(String, int, int, int) + * } instead. + */ + void createSearchPattern() { + } +} Index: workspace/FormatterJavadoc/test/tags/others/X03.java =================================================================== RCS file: workspace/FormatterJavadoc/test/tags/others/X03.java diff -N workspace/FormatterJavadoc/test/tags/others/X03.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ workspace/FormatterJavadoc/test/tags/others/X03.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,10 @@ +package test.tags.others; + +public interface X03 { + +/** + * A complex type can have one root compositor. + @ return root complex type compositor + */ +int foo(); +} Index: workspace/FormatterJavadoc/test/comments/line/X06.java =================================================================== RCS file: workspace/FormatterJavadoc/test/comments/line/X06.java diff -N workspace/FormatterJavadoc/test/comments/line/X06.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ workspace/FormatterJavadoc/test/comments/line/X06.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,15 @@ +package test.comments.line; + +public class X06 { + + String foo() { +// // Move cursor on to the left if the proposal ends with '}' + String str; + // XXX: currently there's no smartness: position the cursor after the proposal +// if (relativeOffset > 0 && proposal.charAt(relativeOffset - 1) == '}') +// relativeOffset--; + + str = toString(); + return str; + } +} Index: workspace/FormatterJavadoc/test/wksp/eclipse/X21.java =================================================================== RCS file: workspace/FormatterJavadoc/test/wksp/eclipse/X21.java diff -N workspace/FormatterJavadoc/test/wksp/eclipse/X21.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ workspace/FormatterJavadoc/test/wksp/eclipse/X21.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,50 @@ +package test.wksp.eclipse; + +public class X21 { + + /** + * Returns a search pattern based on a given string pattern. The string patterns support '*' wild-cards. + * The remaining parameters are used to narrow down the type of expected results. + * + *
+ * Examples: + *
    + *
  • search for case insensitive references to Object: + * createSearchPattern("Object", TYPE, REFERENCES, false);
  • + *
  • search for case sensitive references to exact Object() constructor: + * createSearchPattern("java.lang.Object()", CONSTRUCTOR, REFERENCES, true);
  • + *
  • search for implementers of java.lang.Runnable: + * createSearchPattern("java.lang.Runnable", TYPE, IMPLEMENTORS, true);
  • + *
+ * @param stringPattern the given pattern + * @param searchFor determines the nature of the searched elements + *
    + *
  • IJavaSearchConstants.CLASS: only look for classes
  • + *
  • IJavaSearchConstants.INTERFACE: only look for interfaces
  • + *
  • IJavaSearchConstants.TYPE: look for both classes and interfaces
  • + *
  • IJavaSearchConstants.FIELD: look for fields
  • + *
  • IJavaSearchConstants.METHOD: look for methods
  • + *
  • IJavaSearchConstants.CONSTRUCTOR: look for constructors
  • + *
  • IJavaSearchConstants.PACKAGE: look for packages
  • + *
+ * @param limitTo determines the nature of the expected matches + *
    + *
  • IJavaSearchConstants.DECLARATIONS: will search declarations matching with the corresponding + * element. In case the element is a method, declarations of matching methods in subtypes will also + * be found, allowing to find declarations of abstract methods, etc.
  • + * + *
  • IJavaSearchConstants.REFERENCES: will search references to the given element.
  • + * + *
  • IJavaSearchConstants.ALL_OCCURRENCES: will search for either declarations or references as specified + * above.
  • + * + *
  • IJavaSearchConstants.IMPLEMENTORS: for interface, will find all types which implements a given interface.
  • + *
+ * + * @param isCaseSensitive indicates whether the search is case sensitive or not. + * @return a search pattern on the given string pattern, or null if the string pattern is ill-formed. + * @deprecated Use {@link SearchPattern#createPattern(String, int, int, int)} instead. + */ + void createSearchPattern() { + } +} Index: workspace/FormatterJavadoc/test/wksp/eclipse/out/default/X21.java =================================================================== RCS file: workspace/FormatterJavadoc/test/wksp/eclipse/out/default/X21.java diff -N workspace/FormatterJavadoc/test/wksp/eclipse/out/default/X21.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ workspace/FormatterJavadoc/test/wksp/eclipse/out/default/X21.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,69 @@ +package test.wksp.eclipse; + +public class X21 { + + /** + * Returns a search pattern based on a given string pattern. The string + * patterns support '*' wild-cards. The remaining parameters are used to + * narrow down the type of expected results.
+ * Examples: + *
    + *
  • search for case insensitive references to Object: + * createSearchPattern("Object", TYPE, REFERENCES, false);
  • + *
  • search for case sensitive references to exact Object() + * constructor: + * createSearchPattern("java.lang.Object()", CONSTRUCTOR, REFERENCES, true); + *
  • + *
  • search for implementers of java.lang.Runnable: + * createSearchPattern("java.lang.Runnable", TYPE, IMPLEMENTORS, true); + *
  • + *
+ * + * @param stringPattern + * the given pattern + * @param searchFor + * determines the nature of the searched elements + *
    + *
  • IJavaSearchConstants.CLASS : only look for classes + *
  • + *
  • IJavaSearchConstants.INTERFACE : only look for + * interfaces
  • + *
  • IJavaSearchConstants.TYPE : look for both classes + * and interfaces
  • + *
  • IJavaSearchConstants.FIELD : look for fields
  • + *
  • IJavaSearchConstants.METHOD : look for methods + *
  • + *
  • IJavaSearchConstants.CONSTRUCTOR : look for + * constructors
  • + *
  • IJavaSearchConstants.PACKAGE : look for packages + *
  • + *
+ * @param limitTo + * determines the nature of the expected matches + *
    + *
  • IJavaSearchConstants.DECLARATIONS : will search + * declarations matching with the corresponding element. In case the + * element is a method, declarations of matching methods in subtypes + * will also be found, allowing to find declarations of abstract + * methods, etc.
  • + * + *
  • IJavaSearchConstants.REFERENCES : will search + * references to the given element.
  • + * + *
  • IJavaSearchConstants.ALL_OCCURRENCES : will search + * for either declarations or references as specified above.
  • + * + *
  • IJavaSearchConstants.IMPLEMENTORS : for interface, + * will find all types which implements a given interface.
  • + *
+ * + * @param isCaseSensitive + * indicates whether the search is case sensitive or not. + * @return a search pattern on the given string pattern, or + * null if the string pattern is ill-formed. + * @deprecated Use {@link SearchPattern#createPattern(String, int, int, int) + * } instead. + */ + void createSearchPattern() { + } +} Index: workspace/FormatterJavadoc/test/comments/line/out/default/X06.java =================================================================== RCS file: workspace/FormatterJavadoc/test/comments/line/out/default/X06.java diff -N workspace/FormatterJavadoc/test/comments/line/out/default/X06.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ workspace/FormatterJavadoc/test/comments/line/out/default/X06.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,16 @@ +package test.comments.line; + +public class X06 { + + String foo() { + // // Move cursor on to the left if the proposal ends with '}' + String str; + // XXX: currently there's no smartness: position the cursor after the + // proposal + // if (relativeOffset > 0 && proposal.charAt(relativeOffset - 1) == '}') + // relativeOffset--; + + str = toString(); + return str; + } +} Index: workspace/FormatterJavadoc/test/wksp/eclipse/out/dont_indent_descr/X21.java =================================================================== RCS file: workspace/FormatterJavadoc/test/wksp/eclipse/out/dont_indent_descr/X21.java diff -N workspace/FormatterJavadoc/test/wksp/eclipse/out/dont_indent_descr/X21.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ workspace/FormatterJavadoc/test/wksp/eclipse/out/dont_indent_descr/X21.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,67 @@ +package test.wksp.eclipse; + +public class X21 { + + /** + * Returns a search pattern based on a given string pattern. The string + * patterns support '*' wild-cards. The remaining parameters are used to + * narrow down the type of expected results.
+ * Examples: + *
    + *
  • search for case insensitive references to Object: + * createSearchPattern("Object", TYPE, REFERENCES, false);
  • + *
  • search for case sensitive references to exact Object() + * constructor: + * createSearchPattern("java.lang.Object()", CONSTRUCTOR, REFERENCES, true); + *
  • + *
  • search for implementers of java.lang.Runnable: + * createSearchPattern("java.lang.Runnable", TYPE, IMPLEMENTORS, true); + *
  • + *
+ * + * @param stringPattern + * the given pattern + * @param searchFor + * determines the nature of the searched elements + *
    + *
  • IJavaSearchConstants.CLASS : only look for classes + *
  • + *
  • IJavaSearchConstants.INTERFACE : only look for + * interfaces
  • + *
  • IJavaSearchConstants.TYPE : look for both classes and + * interfaces
  • + *
  • IJavaSearchConstants.FIELD : look for fields
  • + *
  • IJavaSearchConstants.METHOD : look for methods
  • + *
  • IJavaSearchConstants.CONSTRUCTOR : look for + * constructors
  • + *
  • IJavaSearchConstants.PACKAGE : look for packages
  • + *
+ * @param limitTo + * determines the nature of the expected matches + *
    + *
  • IJavaSearchConstants.DECLARATIONS : will search + * declarations matching with the corresponding element. In case the + * element is a method, declarations of matching methods in subtypes will + * also be found, allowing to find declarations of abstract methods, etc. + *
  • + * + *
  • IJavaSearchConstants.REFERENCES : will search + * references to the given element.
  • + * + *
  • IJavaSearchConstants.ALL_OCCURRENCES : will search for + * either declarations or references as specified above.
  • + * + *
  • IJavaSearchConstants.IMPLEMENTORS : for interface, + * will find all types which implements a given interface.
  • + *
+ * + * @param isCaseSensitive + * indicates whether the search is case sensitive or not. + * @return a search pattern on the given string pattern, or + * null if the string pattern is ill-formed. + * @deprecated Use {@link SearchPattern#createPattern(String, int, int, int) + * } instead. + */ + void createSearchPattern() { + } +}