Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 158645 Details for
Bug 260381
[formatter] Javadoc formatter breaks {@code ...} tags.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
New complete patch
v03.txt (text/plain), 38.76 KB, created by
Frederic Fusier
on 2010-02-09 17:14:24 EST
(
hide
)
Description:
New complete patch
Filename:
MIME Type:
Creator:
Frederic Fusier
Created:
2010-02-09 17:14:24 EST
Size:
38.76 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: formatter/org/eclipse/jdt/internal/formatter/FormatJavadocBlock.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/FormatJavadocBlock.java,v >retrieving revision 1.9 >diff -u -r1.9 FormatJavadocBlock.java >--- formatter/org/eclipse/jdt/internal/formatter/FormatJavadocBlock.java 10 Nov 2009 21:38:04 -0000 1.9 >+++ formatter/org/eclipse/jdt/internal/formatter/FormatJavadocBlock.java 9 Feb 2010 17:58:04 -0000 >@@ -31,6 +31,7 @@ > final static int PARAM_TAG = 0x0020; > final static int IN_PARAM_TAG = 0x0040; > final static int IN_DESCRIPTION = 0x0080; >+ final static int IMMUTABLE = 0x0100; > > // constants > final static int MAX_TAG_HIERARCHY = 10; >@@ -53,6 +54,11 @@ > case TAG_THROWS_VALUE: > case TAG_EXCEPTION_VALUE: > this.flags |= PARAM_TAG; >+ break; >+ case TAG_CODE_VALUE: >+ case TAG_LITERAL_VALUE: >+ this.flags |= IMMUTABLE; >+ break; > } > } > >@@ -141,6 +147,9 @@ > } > } > addNode(text); >+ if (isImmutable()) { >+ text.immutable = true; >+ } > } > > void clean() { >@@ -322,6 +331,18 @@ > return (this.flags & PARAM_TAG) == PARAM_TAG; > } > >+/** >+ * Returns whether the block is immutable or not. >+ * <p> >+ * Currently, only @code inline tag block are considered as immutable. >+ * >+ * @return <code>true</code> if the block is immutable, >+ * <code>false</code> otherwise. >+ */ >+public boolean isImmutable() { >+ return (this.flags & IMMUTABLE) == IMMUTABLE; >+} >+ > void setHeaderLine(int javadocLineStart) { > if (javadocLineStart == this.lineStart) { > this.flags |= ON_HEADER_LINE; >@@ -332,9 +353,10 @@ > } > > protected void toString(StringBuffer buffer) { >- if ((this.flags & INLINED) != 0) buffer.append('{'); >+ boolean inlined = (this.flags & INLINED) != 0; >+ if (inlined) buffer.append(" {"); //$NON-NLS-1$ > buffer.append('@'); >- buffer.append(this.tagValue); >+ buffer.append(TAG_NAMES[this.tagValue]); > super.toString(buffer); > if (this.reference == null) { > buffer.append('\n'); >@@ -345,6 +367,7 @@ > } > if (this.nodesPtr > -1) { > for (int i = 0; i <= this.nodesPtr; i++) { >+ if (inlined) buffer.append('\t'); > this.nodes[i].toString(buffer); > } > } >Index: formatter/org/eclipse/jdt/internal/formatter/FormatJavadocNode.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/FormatJavadocNode.java,v >retrieving revision 1.6 >diff -u -r1.6 FormatJavadocNode.java >--- formatter/org/eclipse/jdt/internal/formatter/FormatJavadocNode.java 27 Jun 2008 16:04:07 -0000 1.6 >+++ formatter/org/eclipse/jdt/internal/formatter/FormatJavadocNode.java 9 Feb 2010 17:58:04 -0000 >@@ -56,6 +56,17 @@ > return false; > } > >+/** >+ * Returns whether the node is immutable or not. If <code>true</code>, then >+ * the formatter will leave it contents unchanged. >+ * >+ * @return <code>true</code> if the node is immutable, <code>false</code> >+ * otherwise. >+ */ >+public boolean isImmutable() { >+ return false; >+} >+ > public String toString() { > StringBuffer buffer = new StringBuffer(); > toString(buffer); >Index: formatter/org/eclipse/jdt/internal/formatter/FormatJavadocText.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/FormatJavadocText.java,v >retrieving revision 1.8 >diff -u -r1.8 FormatJavadocText.java >--- formatter/org/eclipse/jdt/internal/formatter/FormatJavadocText.java 27 Jun 2008 16:04:08 -0000 1.8 >+++ formatter/org/eclipse/jdt/internal/formatter/FormatJavadocText.java 9 Feb 2010 17:58:04 -0000 >@@ -31,6 +31,7 @@ > long[] separators; > int separatorsPtr = -1; > private int htmlTagIndex = -1; >+ boolean immutable = false; > FormatJavadocNode[] htmlNodes; > int[] htmlIndexes; > int htmlNodesPtr = -1; >@@ -49,6 +50,7 @@ > * child node. > */ > void appendText(FormatJavadocText text) { >+ this.immutable = text.immutable; > if (this.depth == text.depth) { > addSeparator(text); > this.sourceEnd = text.sourceEnd; >@@ -167,6 +169,7 @@ > * > * @return <code>true</code> if the node is an immutable tag, > * <code>false</code> otherwise. >+ *@deprecated Use {@link #isImmutable()} instead > */ > public boolean isImmutableHtmlTag() { > return this.htmlTagIndex != -1 && (this.htmlTagIndex & JAVADOC_TAGS_ID_MASK) == JAVADOC_IMMUTABLE_TAGS_ID; >@@ -174,6 +177,21 @@ > } > > /** >+ * Returns whether the text is immutable or not. >+ * <p> >+ * A text in considered as immutable when it belongs to an immutable block >+ * or when it's an immutable html tag. >+ * </p> >+ * >+ * @return <code>true</code> if the node is an immutable tag, >+ * <code>false</code> otherwise. >+ */ >+public boolean isImmutable() { >+ return this.immutable || (this.htmlTagIndex != -1 && (this.htmlTagIndex & JAVADOC_TAGS_ID_MASK) == JAVADOC_IMMUTABLE_TAGS_ID); >+ >+} >+ >+/** > * Returns whether the text at the given separator index position is after a > * separator tag or not. > * >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.31 >diff -u -r1.31 FormatterCommentParser.java >--- formatter/org/eclipse/jdt/internal/formatter/FormatterCommentParser.java 9 Feb 2010 08:56:38 -0000 1.31 >+++ formatter/org/eclipse/jdt/internal/formatter/FormatterCommentParser.java 9 Feb 2010 17:58:05 -0000 >@@ -356,6 +356,7 @@ > this.scanner.resetTo(this.index, this.javadocEnd); > return true; > } >+ this.tagValue = TAG_OTHERS_VALUE; // tag is invalid, do not keep the parsed tag value > return false; > } > >@@ -382,6 +383,7 @@ > } > this.scanner.resetTo(this.tagSourceEnd+1, this.javadocEnd); > } >+ this.tagValue = TAG_OTHERS_VALUE; // tag is invalid, do not keep the parsed tag value > } > return valid; > } >@@ -394,6 +396,7 @@ > if (!valid) { > this.scanner.resetTo(this.tagSourceEnd+1, this.javadocEnd); > this.index = this.tagSourceEnd+1; >+ this.tagValue = TAG_OTHERS_VALUE; // tag is invalid, do not keep the parsed tag value > } > return valid; > } >@@ -506,7 +509,7 @@ > if (length == TAG_LINK_LENGTH && CharOperation.equals(TAG_LINK, tagName)) { > this.tagValue = TAG_LINK_VALUE; > if (this.inlineTagStarted || (this.kind & COMPLETION_PARSER) != 0) { >- valid= parseReference(); >+ valid = parseReference(); > } else { > // bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=53290 > // Cannot have @link outside inline comment >@@ -605,7 +608,6 @@ > } else if (this.invalidTagName) { > this.textStart = previousPosition; > } else if (this.astPtr == ptr) { >- this.tagValue = TAG_OTHERS_VALUE; // tag is invalid, do not keep the parsed tag value > createTag(); > } > return true; >@@ -620,6 +622,7 @@ > // If invalid, restart from the end tag position > this.scanner.resetTo(this.tagSourceEnd+1, this.javadocEnd); > this.index = this.tagSourceEnd+1; >+ this.tagValue = TAG_OTHERS_VALUE; // tag is invalid, do not keep the parsed tag value > } > return valid; > } >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.190 >diff -u -r1.190 Scribe.java >--- formatter/org/eclipse/jdt/internal/formatter/Scribe.java 7 Jan 2010 20:18:49 -0000 1.190 >+++ formatter/org/eclipse/jdt/internal/formatter/Scribe.java 9 Feb 2010 17:58:06 -0000 >@@ -2866,7 +2866,7 @@ > if (newLines > 0) newLines = 1; > } > } >- if (newLines == 0) { >+ if (newLines == 0 && (!node.isImmutable() || block.reference != null)) { > newLines = printJavadocBlockNodesNewLines(block, node, previousEnd); > } > printJavadocGapLines(previousEnd+1, nodeStart-1, newLines, clearBlankLines, false, null); >@@ -2898,18 +2898,16 @@ > // Print node > if (node.isText()) { > FormatJavadocText text = (FormatJavadocText) node; >- if (text.isHtmlTag()) { >- if (text.isImmutableHtmlTag()) { >- // Indent if new line was added >- if (newLines > 0 && this.commentIndentation != null) { >- addInsertEdit(node.sourceStart, this.commentIndentation); >- this.column += this.commentIndentation.length(); >- } >- printJavadocHtmlImmutableTag(text, block, newLines > 0); >- this.column += getTextLength(block, text); >- } else { >- printJavadocHtmlTag(text, block, newLines>0); >+ if (text.isImmutable()) { >+ // Indent if new line was added >+ if (newLines > 0 && this.commentIndentation != null) { >+ addInsertEdit(node.sourceStart, this.commentIndentation); >+ this.column += this.commentIndentation.length(); > } >+ printJavadocImmutableText(text, block, newLines > 0); >+ this.column += getTextLength(block, text); >+ } else if (text.isHtmlTag()) { >+ printJavadocHtmlTag(text, block, newLines>0); > } else { > printJavadocText(text, block, newLines>0); > } >@@ -2934,15 +2932,26 @@ > try { > this.scanner.resetTo(nodeStart , node.sourceEnd); > int length = 0; >- int newLines = 0; > boolean newLine = false; > boolean headerLine = block.isHeaderLine() && this.lastNumberOfNewLines == 0; > int firstColumn = 1 + this.indentationLevel + BLOCK_LINE_PREFIX_LENGTH; > if (this.commentIndentation != null) firstColumn += this.commentIndentation.length(); > if (headerLine) maxColumn++; >- if (node.isText()) { >- FormatJavadocText text = (FormatJavadocText)node; >- if (text.isImmutableHtmlTag()) { >+ FormatJavadocText text = null; >+ boolean isImmutableNode = node.isImmutable(); >+ boolean nodeIsText = node.isText(); >+ if (nodeIsText) { >+ text = (FormatJavadocText)node; >+ } else { >+ FormatJavadocBlock inlinedBlock = (FormatJavadocBlock)node; >+ if (isImmutableNode) { >+ text = (FormatJavadocText) inlinedBlock.getLastNode(); >+ length += inlinedBlock.tagEnd - inlinedBlock.sourceStart + 1; // tag length >+ this.scanner.resetTo(text.sourceStart , node.sourceEnd); >+ } >+ } >+ if (text != null) { >+ if (isImmutableNode) { > if (nodeStart > (previousEnd+1)) { > length++; // include space between nodes > } >@@ -2952,8 +2961,10 @@ > int token = this.scanner.getNextToken(); > switch (token) { > case TerminalTokens.TokenNameWHITESPACE: >- if (CharOperation.indexOf('\n', this.scanner.source, this.scanner.startPosition, this.scanner.currentPosition) >= 0) { >- return newLines; >+ if (nodeIsText) { >+ if (CharOperation.indexOf('\n', this.scanner.source, this.scanner.startPosition, this.scanner.currentPosition) >= 0) { >+ return 0; >+ } > } > length = 1; > break; >@@ -2975,15 +2986,10 @@ > } > lastColumn += length; > if (lastColumn > maxColumn) { >- newLines++; >- if (headerLine) { >- maxColumn--; >- headerLine = false; >- } >- lastColumn = firstColumn; >+ return 1; > } > } >- return newLines; >+ return 0; > } > if (text.isHtmlTag()) { > if (text.getHtmlTagID() == JAVADOC_SINGLE_BREAK_TAG_ID) { >@@ -3146,7 +3152,7 @@ > private int getTextLength(FormatJavadocBlock block, FormatJavadocText text) { > > // Special case for immutable tags >- if (text.isImmutableHtmlTag()) { >+ if (text.isImmutable()) { > this.scanner.resetTo(text.sourceStart , text.sourceEnd); > int textLength = 0; > while (!this.scanner.atEnd()) { >@@ -3468,23 +3474,16 @@ > } > } > >- private void printJavadocHtmlImmutableTag(FormatJavadocText text, FormatJavadocBlock block, boolean textOnNewLine) { >+ private void printJavadocImmutableText(FormatJavadocText text, FormatJavadocBlock block, boolean textOnNewLine) { > > try { > // Iterate on text line separators > int lineNumber = text.lineStart; > this.scanner.tokenizeWhiteSpace = false; > StringBuffer buffer = null; >- for (int idx=1, max=text.separatorsPtr; idx<max ; idx++) { >+ for (int idx=0, max=text.separatorsPtr; idx<=max ; idx++) { > int start = (int) text.separators[idx]; >- int lineStart = Util.getLineNumber(start, this.lineEnds, lineNumber, this.maxLines); >- if (buffer == null) { >- buffer = new StringBuffer(); >- this.column = 1; >- printIndentationIfNecessary(buffer); >- buffer.append(BLOCK_LINE_PREFIX); >- this.column += BLOCK_LINE_PREFIX_LENGTH; >- } >+ int lineStart = Util.getLineNumber(start, this.lineEnds, lineNumber-1, this.maxLines); > while (lineNumber < lineStart) { > int end = this.lineEnds[lineNumber-1]; > this.scanner.resetTo(end, start); >@@ -3499,6 +3498,13 @@ > if (this.scanner.currentCharacter == ' ') { > this.scanner.getNextChar(); > } >+ if (buffer == null) { >+ buffer = new StringBuffer(); >+ this.column = 1; >+ printIndentationIfNecessary(buffer); >+ buffer.append(BLOCK_LINE_PREFIX); >+ this.column += BLOCK_LINE_PREFIX_LENGTH; >+ } > addReplaceEdit(end+1, this.scanner.getCurrentTokenEndPosition(), buffer.toString()); > lineNumber++; > } >@@ -3562,7 +3568,7 @@ > if (textStart < previousEnd) { > addReplaceEdit(textStart, previousEnd, buffer.toString()); > } >- boolean immutable = htmlTag == null ? false : htmlTag.isImmutableHtmlTag(); >+ boolean immutable = node.isImmutable(); > if (newLines == 0) { > newLines = printJavadocBlockNodesNewLines(block, node, previousEnd); > } >@@ -3579,7 +3585,7 @@ > addInsertEdit(node.sourceStart, this.commentIndentation); > this.column += this.commentIndentation.length(); > } >- printJavadocHtmlImmutableTag(htmlTag, block, textOnNewLine); >+ printJavadocImmutableText(htmlTag, block, textOnNewLine); > this.column += getTextLength(block, htmlTag); > linesAfter = 0; > } else { >#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.48 >diff -u -r1.48 FormatterCommentsBugsTest.java >--- src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java 9 Feb 2010 08:56:41 -0000 1.48 >+++ src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java 9 Feb 2010 17:58:10 -0000 >@@ -4071,8 +4071,7 @@ > "\n" + > " /**\n" + > " * Returns the change directly associated with this change element or <code\n" + >- " * null</code>\n" + >- " * if the element isn\'t associated with a change.\n" + >+ " * null</code> if the element isn\'t associated with a change.\n" + > " * \n" + > " * @return the change or <code>null</code>\n" + > " */\n" + >@@ -4398,6 +4397,574 @@ > } > > /** >+ * @bug 260381: [formatter] Javadoc formatter breaks {@code ...} tags. >+ * @test Ensure that the @code tag is similar to <code> HTML tag >+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=260381" >+ */ >+public void testBug260381() throws JavaModelException { >+ String source = >+ "/**\n" + >+ " * Comments that can be formated in several lines...\n" + >+ " * \n" + >+ " * @author Myself\n" + >+ " * @version {@code $Revision: 1.2 $ $Date: 2009/01/07 12:27:50 $ $Author:myself $ $Source: /projects/cvs/module/project/src/com/foo/Main.java,v $}\n" + >+ " */\n" + >+ "public class X01 {\n" + >+ "}\n"; >+ formatSource(source); >+} >+public void testBug260381b() throws JavaModelException { >+ String source = >+ "/**\n" + >+ " * Comments that can be formated in several lines...\n" + >+ " * \n" + >+ " * @author Myself\n" + >+ " * @version <code>$Revision: 1.2 $ $Date: 2009/01/07 12:27:50 $ $Author:myself $ $Source: /projects/cvs/module/project/src/com/foo/Main.java,v $</code>\n" + >+ " */\n" + >+ "public class X01b {\n" + >+ "}\n"; >+ formatSource(source); >+} >+public void testBug260381c() throws JavaModelException { >+ String source = >+ "/**\n" + >+ " * Comments that can be formated in several lines...\n" + >+ " * \n" + >+ " * @author Myself\n" + >+ " * @version\n" + >+ " * <code>3.0 xxxxxxxxxxxxxx xwxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</code>\n" + >+ " */\n" + >+ "public class X01c {\n" + >+ "}\n"; >+ formatSource(source, >+ "/**\n" + >+ " * Comments that can be formated in several lines...\n" + >+ " * \n" + >+ " * @author Myself\n" + >+ " * @version <code>3.0 xxxxxxxxxxxxxx xwxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</code>\n" + >+ " */\n" + >+ "public class X01c {\n" + >+ "}\n" >+ ); >+} >+public void testBug260381d() throws JavaModelException { >+ String source = >+ "/**\n" + >+ " * Comments that can be formated in several lines...\n" + >+ " * \n" + >+ " * @author Myself\n" + >+ " * @see Object <code>$Revision: 1.2 $ $Date: 2009/01/07 12:27:50 $ $Author:myself $ $Source: /projects/cvs/module/project/src/com/foo/Main.java,v $</code>\n" + >+ " */\n" + >+ "public class X02 {\n" + >+ "}\n"; >+ formatSource(source, >+ "/**\n" + >+ " * Comments that can be formated in several lines...\n" + >+ " * \n" + >+ " * @author Myself\n" + >+ " * @see Object\n" + >+ " * <code>$Revision: 1.2 $ $Date: 2009/01/07 12:27:50 $ $Author:myself $ $Source: /projects/cvs/module/project/src/com/foo/Main.java,v $</code>\n" + >+ " */\n" + >+ "public class X02 {\n" + >+ "}\n" >+ ); >+} >+public void testBug260381e() throws JavaModelException { >+ String source = >+ "/**\n" + >+ " * Comments that can be formated in several lines...\n" + >+ " * \n" + >+ " * {@code $Revision: 1.2 $ $Date: 2009/01/07 12:27:50 $ $Author:myself $\n" + >+ " * $Source: /projects/cvs/module/project/src/com/foo/Main.java,v $}\n" + >+ " */\n" + >+ "public class X03 {\n" + >+ "}\n"; >+ formatSource(source); >+} >+public void testBug260381f() throws JavaModelException { >+ String source = >+ "/**\n" + >+ " * Literal inline tag should also be untouched by the formatter\n" + >+ " * \n" + >+ " * @version {@literal $Revision: 1.2 $ $Date: 2009/01/07 12:27:50 $ $Author:myself $ $Source: /projects/cvs/module/project/src/com/foo/Main.java,v $}\n" + >+ " */\n" + >+ "public class X04 {\n" + >+ "\n" + >+ "}\n"; >+ formatSource(source); >+} >+public void testBug260381_wksp2_01() throws JavaModelException { >+ String source = >+ "package wksp2;\n" + >+ "public interface I01 {\n" + >+ " /**\n" + >+ " * Returns the composition of two functions. For {@code f: A->B} and\n" + >+ " * {@code g: B->C}, composition is defined as the function h such that\n" + >+ " * {@code h(a) == g(f(a))} for each {@code a}.\n" + >+ " *\n" + >+ " * @see <a href=\"//en.wikipedia.org/wiki/Function_composition\">\n" + >+ " * function composition</a>\n" + >+ " *\n" + >+ " * @param g the second function to apply\n" + >+ " * @param f the first function to apply\n" + >+ " * @return the composition of {@code f} and {@code g}\n" + >+ " */\n" + >+ " void foo();\n" + >+ "}\n"; >+ formatSource(source, >+ "package wksp2;\n" + >+ "\n" + >+ "public interface I01 {\n" + >+ " /**\n" + >+ " * Returns the composition of two functions. For {@code f: A->B} and\n" + >+ " * {@code g: B->C}, composition is defined as the function h such that\n" + >+ " * {@code h(a) == g(f(a))} for each {@code a}.\n" + >+ " * \n" + >+ " * @see <a href=\"//en.wikipedia.org/wiki/Function_composition\"> function\n" + >+ " * composition</a>\n" + >+ " * \n" + >+ " * @param g\n" + >+ " * the second function to apply\n" + >+ " * @param f\n" + >+ " * the first function to apply\n" + >+ " * @return the composition of {@code f} and {@code g}\n" + >+ " */\n" + >+ " void foo();\n" + >+ "}\n" >+ ); >+} >+public void testBug260381_wksp2_01b() throws JavaModelException { >+ String source = >+ "package wksp2;\n" + >+ "public interface I01b {\n" + >+ " /**\n" + >+ " * Returns the composition of two functions. For <code> f: A->B</code> and\n" + >+ " * <code> g: B->C</code>, composition is defined as the function h such that\n" + >+ " * <code> h(a) == g(f(a))</code> for each <code> a</code>.\n" + >+ " *\n" + >+ " * @see <a href=\"//en.wikipedia.org/wiki/Function_composition\">\n" + >+ " * function composition</a>\n" + >+ " *\n" + >+ " * @param g the second function to apply\n" + >+ " * @param f the first function to apply\n" + >+ " * @return the composition of <code> f</code> and <code> g</code>\n" + >+ " */\n" + >+ " void foo();\n" + >+ "}\n"; >+ formatSource(source, >+ "package wksp2;\n" + >+ "\n" + >+ "public interface I01b {\n" + >+ " /**\n" + >+ " * Returns the composition of two functions. For <code> f: A->B</code> and\n" + >+ " * <code> g: B->C</code>, composition is defined as the function h such that\n" + >+ " * <code> h(a) == g(f(a))</code> for each <code> a</code>.\n" + >+ " * \n" + >+ " * @see <a href=\"//en.wikipedia.org/wiki/Function_composition\"> function\n" + >+ " * composition</a>\n" + >+ " * \n" + >+ " * @param g\n" + >+ " * the second function to apply\n" + >+ " * @param f\n" + >+ " * the first function to apply\n" + >+ " * @return the composition of <code> f</code> and <code> g</code>\n" + >+ " */\n" + >+ " void foo();\n" + >+ "}\n" >+ ); >+} >+public void testBug260381_wksp2_01c() throws JavaModelException { >+ String source = >+ "package wksp2;\n" + >+ "public interface I01c {\n" + >+ " /**\n" + >+ " * Returns the composition of two functions. For <code> f: A->B</code> and\n" + >+ " * <code>\n" + >+ " * g: B->C\n" + >+ " * </code>,\n" + >+ " * composition is defined as the function h such that\n" + >+ " * <code>\n" + >+ " * h(a) == g(f(a))\n" + >+ " * </code>\n" + >+ " * for each\n" + >+ " * <code>\n" + >+ " * a\n" + >+ " * </code>.\n" + >+ " *\n" + >+ " * @see <a href=\"//en.wikipedia.org/wiki/Function_composition\">\n" + >+ " * function composition</a>\n" + >+ " *\n" + >+ " * @param g the second function to apply\n" + >+ " * @param f the first function to apply\n" + >+ " * @return the composition of <code> f</code> and <code> g</code>\n" + >+ " */\n" + >+ " void foo();\n" + >+ "}\n"; >+ formatSource(source, >+ "package wksp2;\n" + >+ "\n" + >+ "public interface I01c {\n" + >+ " /**\n" + >+ " * Returns the composition of two functions. For <code> f: A->B</code> and\n" + >+ " * <code>\n" + >+ " * g: B->C\n" + >+ " * </code>, composition is defined as the function h such that <code>\n" + >+ " * h(a) == g(f(a))\n" + >+ " * </code> for each <code>\n" + >+ " * a\n" + >+ " * </code>.\n" + >+ " * \n" + >+ " * @see <a href=\"//en.wikipedia.org/wiki/Function_composition\"> function\n" + >+ " * composition</a>\n" + >+ " * \n" + >+ " * @param g\n" + >+ " * the second function to apply\n" + >+ " * @param f\n" + >+ " * the first function to apply\n" + >+ " * @return the composition of <code> f</code> and <code> g</code>\n" + >+ " */\n" + >+ " void foo();\n" + >+ "}\n" >+ ); >+} >+public void testBug260381_wksp2_02() throws JavaModelException { >+ String source = >+ "package wksp2;\n" + >+ "\n" + >+ "public interface I02 {\n" + >+ "\n" + >+ " /**\n" + >+ " * Implementations of {@code computeNext} <b>must</b> invoke this method when\n" + >+ " * there are no elements left in the iteration.\n" + >+ " *\n" + >+ " * @return {@code null}; a convenience so your {@link #computeNext}\n" + >+ " * implementation can use the simple statement {@code return endOfData();}\n" + >+ " */\n" + >+ " void foo();\n" + >+ "}\n"; >+ formatSource(source, >+ "package wksp2;\n" + >+ "\n" + >+ "public interface I02 {\n" + >+ "\n" + >+ " /**\n" + >+ " * Implementations of {@code computeNext} <b>must</b> invoke this method\n" + >+ " * when there are no elements left in the iteration.\n" + >+ " * \n" + >+ " * @return {@code null}; a convenience so your {@link #computeNext}\n" + >+ " * implementation can use the simple statement\n" + >+ " * {@code return endOfData();}\n" + >+ " */\n" + >+ " void foo();\n" + >+ "}\n" >+ ); >+} >+public void testBug260381_wksp2_03() throws JavaModelException { >+ String source = >+ "package wksp2;\n" + >+ "\n" + >+ "public interface I03 {\n" + >+ " /**\n" + >+ " * A builder for creating immutable bimap instances, especially {@code public\n" + >+ " * static final} bimaps (\"constant bimaps\"). Example: <pre> {@code\n" + >+ " *\n" + >+ " * static final ImmutableBiMap<String, Integer> WORD_TO_INT =\n" + >+ " * new ImmutableBiMap.Builder<String, Integer>()\n" + >+ " * .put(\"one\", 1)\n" + >+ " * .put(\"two\", 2)\n" + >+ " * .put(\"three\", 3)\n" + >+ " * .build();}</pre>\n" + >+ " *\n" + >+ " * For <i>small</i> immutable bimaps, the {@code ImmutableBiMap.of()} methods\n" + >+ " * are even more convenient.\n" + >+ " *\n" + >+ " * <p>Builder instances can be reused - it is safe to call {@link #build}\n" + >+ " * multiple times to build multiple bimaps in series. Each bimap is a superset\n" + >+ " * of the bimaps created before it.\n" + >+ " */\n" + >+ " void foo();\n" + >+ "}\n"; >+ formatSource(source, >+ "package wksp2;\n" + >+ "\n" + >+ "public interface I03 {\n" + >+ " /**\n" + >+ " * A builder for creating immutable bimap instances, especially\n" + >+ " * {@code public static final} bimaps (\"constant bimaps\"). Example:\n" + >+ " * \n" + >+ " * <pre>\n" + >+ " * {\n" + >+ " * @code\n" + >+ " * static final ImmutableBiMap<String, Integer> WORD_TO_INT = new ImmutableBiMap.Builder<String, Integer>()\n" + >+ " * .put("one", 1).put("two", 2).put("three", 3).build();\n" + >+ " * }\n" + >+ " * </pre>\n" + >+ " * \n" + >+ " * For <i>small</i> immutable bimaps, the {@code ImmutableBiMap.of()}\n" + >+ " * methods are even more convenient.\n" + >+ " * \n" + >+ " * <p>\n" + >+ " * Builder instances can be reused - it is safe to call {@link #build}\n" + >+ " * multiple times to build multiple bimaps in series. Each bimap is a\n" + >+ " * superset of the bimaps created before it.\n" + >+ " */\n" + >+ " void foo();\n" + >+ "}\n" >+ ); >+} >+public void testBug260381_wksp2_04() throws JavaModelException { >+ String source = >+ "package wksp2;\n" + >+ "\n" + >+ "public interface I04 {\n" + >+ "\n" + >+ " /**\n" + >+ " * Returns an immutable multiset containing the given elements.\n" + >+ " * \n" + >+ " * <p>The multiset is ordered by the first occurrence of each element. For\n" + >+ " * example, {@code ImmutableMultiset.copyOf(Arrays.asList(2, 3, 1, 3))} yields\n" + >+ " * a multiset with elements in the order {@code 2, 3, 3, 1}.\n" + >+ " *\n" + >+ " * <p>Note that if {@code c} is a {@code Collection<String>}, then {@code\n" + >+ " * ImmutableMultiset.copyOf(c)} returns an {@code ImmutableMultiset<String>}\n" + >+ " * containing each of the strings in {@code c}, while\n" + >+ " * {@code ImmutableMultiset.of(c)} returns an\n" + >+ " * {@code ImmutableMultiset<Collection<String>>} containing one element (the\n" + >+ " * given collection itself).\n" + >+ " *\n" + >+ " * <p><b>Note:</b> Despite what the method name suggests, if {@code elements}\n" + >+ " * is an {@code ImmutableMultiset}, no copy will actually be performed, and\n" + >+ " * the given multiset itself will be returned.\n" + >+ " *\n" + >+ " * @throws NullPointerException if any of {@code elements} is null\n" + >+ " */\n" + >+ " void foo();\n" + >+ "}\n"; >+ formatSource(source, >+ "package wksp2;\n" + >+ "\n" + >+ "public interface I04 {\n" + >+ "\n" + >+ " /**\n" + >+ " * Returns an immutable multiset containing the given elements.\n" + >+ " * \n" + >+ " * <p>\n" + >+ " * The multiset is ordered by the first occurrence of each element. For\n" + >+ " * example, {@code ImmutableMultiset.copyOf(Arrays.asList(2, 3, 1, 3))}\n" + >+ " * yields a multiset with elements in the order {@code 2, 3, 3, 1}.\n" + >+ " * \n" + >+ " * <p>\n" + >+ " * Note that if {@code c} is a {@code Collection<String>}, then\n" + >+ " * {@code ImmutableMultiset.copyOf(c)} returns an\n" + >+ " * {@code ImmutableMultiset<String>} containing each of the strings in\n" + >+ " * {@code c}, while {@code ImmutableMultiset.of(c)} returns an\n" + >+ " * {@code ImmutableMultiset<Collection<String>>} containing one element (the\n" + >+ " * given collection itself).\n" + >+ " * \n" + >+ " * <p>\n" + >+ " * <b>Note:</b> Despite what the method name suggests, if {@code elements}\n" + >+ " * is an {@code ImmutableMultiset}, no copy will actually be performed, and\n" + >+ " * the given multiset itself will be returned.\n" + >+ " * \n" + >+ " * @throws NullPointerException\n" + >+ " * if any of {@code elements} is null\n" + >+ " */\n" + >+ " void foo();\n" + >+ "}\n" >+ ); >+} >+public void testBug260381_wksp2_05() throws JavaModelException { >+ String source = >+ "package wksp2;\n" + >+ "\n" + >+ "public interface I05 {\n" + >+ "\n" + >+ " /**\n" + >+ " * Indexes the specified values into a {@code Multimap} by applying a\n" + >+ " * specified function to each item in an {@code Iterable} of values. Each\n" + >+ " * value will be stored as a value in the specified multimap. The key used to\n" + >+ " * store that value in the multimap will be the result of calling the function\n" + >+ " * on that value. Depending on the multimap implementation, duplicate entries\n" + >+ " * (equal keys and equal values) may be collapsed.\n" + >+ " *\n" + >+ " * <p>For example,\n" + >+ " *\n" + >+ " * <pre class=\"code\">\n" + >+ " * List<String> badGuys =\n" + >+ " * Arrays.asList(\"Inky\", \"Blinky\", \"Pinky\", \"Pinky\", \"Clyde\");\n" + >+ " * Function<String, Integer> stringLengthFunction = ...;\n" + >+ " * Multimap<Integer, String> index = Multimaps.newHashMultimap();\n" + >+ " * Multimaps.index(badGuys, stringLengthFunction, index);\n" + >+ " * System.out.println(index); </pre>\n" + >+ " *\n" + >+ " * prints\n" + >+ " *\n" + >+ " * <pre class=\"code\">\n" + >+ " * {4=[Inky], 5=[Pinky, Clyde], 6=[Blinky]} </pre>\n" + >+ " *\n" + >+ " * The {@link HashMultimap} collapses the duplicate occurrence of\n" + >+ " * {@code (5, \"Pinky\")}.\n" + >+ " *\n" + >+ " * @param values the values to add to the multimap\n" + >+ " * @param keyFunction the function used to produce the key for each value\n" + >+ " * @param multimap the multimap to store the key value pairs\n" + >+ " */\n" + >+ " void foo();\n" + >+ "}\n"; >+ formatSource(source, >+ "package wksp2;\n" + >+ "\n" + >+ "public interface I05 {\n" + >+ "\n" + >+ " /**\n" + >+ " * Indexes the specified values into a {@code Multimap} by applying a\n" + >+ " * specified function to each item in an {@code Iterable} of values. Each\n" + >+ " * value will be stored as a value in the specified multimap. The key used\n" + >+ " * to store that value in the multimap will be the result of calling the\n" + >+ " * function on that value. Depending on the multimap implementation,\n" + >+ " * duplicate entries (equal keys and equal values) may be collapsed.\n" + >+ " * \n" + >+ " * <p>\n" + >+ " * For example,\n" + >+ " * \n" + >+ " * <pre class=\"code\">\n" + >+ " * List<String> badGuys =\n" + >+ " * Arrays.asList(\"Inky\", \"Blinky\", \"Pinky\", \"Pinky\", \"Clyde\");\n" + >+ " * Function<String, Integer> stringLengthFunction = ...;\n" + >+ " * Multimap<Integer, String> index = Multimaps.newHashMultimap();\n" + >+ " * Multimaps.index(badGuys, stringLengthFunction, index);\n" + >+ " * System.out.println(index);\n" + >+ " * </pre>\n" + >+ " * \n" + >+ " * prints\n" + >+ " * \n" + >+ " * <pre class=\"code\">\n" + >+ " * {4=[Inky], 5=[Pinky, Clyde], 6=[Blinky]}\n" + >+ " * </pre>\n" + >+ " * \n" + >+ " * The {@link HashMultimap} collapses the duplicate occurrence of\n" + >+ " * {@code (5, \"Pinky\")}.\n" + >+ " * \n" + >+ " * @param values\n" + >+ " * the values to add to the multimap\n" + >+ " * @param keyFunction\n" + >+ " * the function used to produce the key for each value\n" + >+ " * @param multimap\n" + >+ " * the multimap to store the key value pairs\n" + >+ " */\n" + >+ " void foo();\n" + >+ "}\n" >+ ); >+} >+public void testBug260381_wksp2_06() throws JavaModelException { >+ String source = >+ "package wksp2;\n" + >+ "\n" + >+ "public interface I06 {\n" + >+ "\n" + >+ " /**\n" + >+ " * Adds a number of occurrences of an element to this multiset. Note that if\n" + >+ " * {@code occurrences == 1}, this method has the identical effect to {@link\n" + >+ " * #add(Object)}. This method is functionally equivalent (except in the case\n" + >+ " * of overflow) to the call {@code addAll(Collections.nCopies(element,\n" + >+ " * occurrences))}, which would presumably perform much more poorly.\n" + >+ " *\n" + >+ " * @param element the element to add occurrences of; may be {@code null} only\n" + >+ " * if explicitly allowed by the implementation\n" + >+ " * @param occurrences the number of occurrences of this element to add. May\n" + >+ " * be zero, in which case no change will be made.\n" + >+ " * @return the previous count of this element before the operation; possibly\n" + >+ " * zero - TODO: make this the actual behavior!\n" + >+ " * @throws IllegalArgumentException if {@code occurrences} is negative, or if\n" + >+ " * this operation would result in more than {@link Integer#MAX_VALUE}\n" + >+ " * occurrences of the element \n" + >+ " * @throws NullPointerException if {@code element} is null and this\n" + >+ " * implementation does not permit null elements. Note that if {@code\n" + >+ " * occurrences} is zero, the implementation may opt to return normally.\n" + >+ " */\n" + >+ " boolean /*int*/ add(E element, int occurrences);\n" + >+ "}\n"; >+ formatSource(source, >+ "package wksp2;\n" + >+ "\n" + >+ "public interface I06 {\n" + >+ "\n" + >+ " /**\n" + >+ " * Adds a number of occurrences of an element to this multiset. Note that if\n" + >+ " * {@code occurrences == 1}, this method has the identical effect to\n" + >+ " * {@link #add(Object)}. This method is functionally equivalent (except in\n" + >+ " * the case of overflow) to the call\n" + >+ " * {@code addAll(Collections.nCopies(element, occurrences))}, which would\n" + >+ " * presumably perform much more poorly.\n" + >+ " * \n" + >+ " * @param element\n" + >+ " * the element to add occurrences of; may be {@code null} only if\n" + >+ " * explicitly allowed by the implementation\n" + >+ " * @param occurrences\n" + >+ " * the number of occurrences of this element to add. May be zero,\n" + >+ " * in which case no change will be made.\n" + >+ " * @return the previous count of this element before the operation; possibly\n" + >+ " * zero - TODO: make this the actual behavior!\n" + >+ " * @throws IllegalArgumentException\n" + >+ " * if {@code occurrences} is negative, or if this operation\n" + >+ " * would result in more than {@link Integer#MAX_VALUE}\n" + >+ " * occurrences of the element\n" + >+ " * @throws NullPointerException\n" + >+ " * if {@code element} is null and this implementation does not\n" + >+ " * permit null elements. Note that if {@code occurrences} is\n" + >+ " * zero, the implementation may opt to return normally.\n" + >+ " */\n" + >+ " boolean /* int */add(E element, int occurrences);\n" + >+ "}\n" >+ ); >+} >+public void testBug260381_wksp2_07() throws JavaModelException { >+ String source = >+ "package wksp2;\n" + >+ "\n" + >+ "public interface I07 {\n" + >+ "\n" + >+ " /**\n" + >+ " * Constructs a new, empty multiset, sorted according to the specified\n" + >+ " * comparator. All elements inserted into the multiset must be <i>mutually\n" + >+ " * comparable</i> by the specified comparator: {@code comparator.compare(e1,\n" + >+ " * e2)} must not throw a {@code ClassCastException} for any elements {@code\n" + >+ " * e1} and {@code e2} in the multiset. If the user attempts to add an element\n" + >+ " * to the multiset that violates this constraint, the {@code add(Object)} call\n" + >+ " * will throw a {@code ClassCastException}.\n" + >+ " *\n" + >+ " * @param comparator the comparator that will be used to sort this multiset. A\n" + >+ " * null value indicates that the elements\' <i>natural ordering</i> should\n" + >+ " * be used.\n" + >+ " */\n" + >+ " void foo();\n" + >+ "}\n"; >+ formatSource(source, >+ "package wksp2;\n" + >+ "\n" + >+ "public interface I07 {\n" + >+ "\n" + >+ " /**\n" + >+ " * Constructs a new, empty multiset, sorted according to the specified\n" + >+ " * comparator. All elements inserted into the multiset must be <i>mutually\n" + >+ " * comparable</i> by the specified comparator:\n" + >+ " * {@code comparator.compare(e1, e2)} must not throw a\n" + >+ " * {@code ClassCastException} for any elements {@code e1} and {@code e2} in\n" + >+ " * the multiset. If the user attempts to add an element to the multiset that\n" + >+ " * violates this constraint, the {@code add(Object)} call will throw a\n" + >+ " * {@code ClassCastException}.\n" + >+ " * \n" + >+ " * @param comparator\n" + >+ " * the comparator that will be used to sort this multiset. A null\n" + >+ " * value indicates that the elements\' <i>natural ordering</i>\n" + >+ " * should be used.\n" + >+ " */\n" + >+ " void foo();\n" + >+ "}\n" >+ ); >+} >+ >+/** > * @bug 260798: [formatter] Strange behavior of never join lines > * @test Ensure that the formatter indents lines correctly when never join lines pref is activated > * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=260798"
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 260381
:
139842
|
158645
|
158835
|
158838
|
158839
|
159072