### 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.11 diff -u -r1.11 FormatJavadocBlock.java --- formatter/org/eclipse/jdt/internal/formatter/FormatJavadocBlock.java 12 Feb 2010 18:33:45 -0000 1.11 +++ formatter/org/eclipse/jdt/internal/formatter/FormatJavadocBlock.java 14 Feb 2010 15:53:26 -0000 @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.jdt.internal.formatter; +import org.eclipse.jdt.internal.compiler.parser.Scanner; import org.eclipse.jdt.internal.formatter.comment.IJavaDocTagConstants; /** @@ -279,6 +280,19 @@ } /** + * Returns whether the block is immutable or not. + *
+ * Currently, only {@code} and {@literal} inline tags block are considered as + * immutable. + *
+ * @returntrue
if the block is immutable,
+ * false
otherwise.
+ */
+public boolean isImmutable() {
+ return (this.flags & IMMUTABLE) == IMMUTABLE;
+}
+
+/**
* Returns whether the block is a description or inlined in a description.
* @see #isParamTag()
*
@@ -311,9 +325,9 @@
}
/**
- * Returns whether the text is on the same line of the tag.
+ * Returns whether the the tag is on one line only.
*
- * @return true
if the text is on the same line than the tag,
+ * @return true
if the tag is on one line only,
* false
otherwise.
*/
public boolean isOneLineTag() {
@@ -331,19 +345,6 @@
return (this.flags & PARAM_TAG) == PARAM_TAG;
}
-/**
- * Returns whether the block is immutable or not.
- * - * Currently, only {@code} and {@literal} inline tags block are considered as - * immutable. - *
- * @returntrue
if the block is immutable,
- * false
otherwise.
- */
-public boolean isImmutable() {
- return (this.flags & IMMUTABLE) == IMMUTABLE;
-}
-
void setHeaderLine(int javadocLineStart) {
if (javadocLineStart == this.lineStart) {
this.flags |= ON_HEADER_LINE;
@@ -366,6 +367,49 @@
this.reference.toString(buffer);
buffer.append(")\n"); //$NON-NLS-1$
}
+ StringBuffer flagsBuffer = new StringBuffer();
+ if (isDescription()) {
+ if (flagsBuffer.length() > 0) flagsBuffer.append(',');
+ flagsBuffer.append("description"); //$NON-NLS-1$
+ }
+ if (isFirst()) {
+ if (flagsBuffer.length() > 0) flagsBuffer.append(',');
+ flagsBuffer.append("first"); //$NON-NLS-1$
+ }
+ if (isHeaderLine()) {
+ if (flagsBuffer.length() > 0) flagsBuffer.append(',');
+ flagsBuffer.append("header line"); //$NON-NLS-1$
+ }
+ if (isImmutable()) {
+ if (flagsBuffer.length() > 0) flagsBuffer.append(',');
+ flagsBuffer.append("immutable"); //$NON-NLS-1$
+ }
+ if (isInDescription()) {
+ if (flagsBuffer.length() > 0) flagsBuffer.append(',');
+ flagsBuffer.append("in description"); //$NON-NLS-1$
+ }
+ if (isInlined()) {
+ if (flagsBuffer.length() > 0) flagsBuffer.append(',');
+ flagsBuffer.append("inlined"); //$NON-NLS-1$
+ }
+ if (isInParamTag()) {
+ if (flagsBuffer.length() > 0) flagsBuffer.append(',');
+ flagsBuffer.append("in param tag"); //$NON-NLS-1$
+ }
+ if (isOneLineTag()) {
+ if (flagsBuffer.length() > 0) flagsBuffer.append(',');
+ flagsBuffer.append("one line tag"); //$NON-NLS-1$
+ }
+ if (isParamTag()) {
+ if (flagsBuffer.length() > 0) flagsBuffer.append(',');
+ flagsBuffer.append("param tag"); //$NON-NLS-1$
+ }
+ if (flagsBuffer.length() > 0) {
+ if (inlined) buffer.append('\t');
+ buffer.append(" flags: "); //$NON-NLS-1$
+ buffer.append(flagsBuffer);
+ buffer.append('\n');
+ }
if (this.nodesPtr > -1) {
for (int i = 0; i <= this.nodesPtr; i++) {
if (inlined) buffer.append('\t');
@@ -392,4 +436,16 @@
this.nodes[i].toStringDebug(buffer, source);
}
}
+
+void update(Scanner scanner) {
+ int blockEnd = scanner.getLineNumber(this.sourceEnd);
+ if (blockEnd == this.lineStart) {
+ this.flags |= FormatJavadocBlock.ONE_LINE_TAG;
+ }
+ for (int i=0; i<=this.nodesPtr; i++) {
+ if (!this.nodes[i].isText()) {
+ ((FormatJavadocBlock)this.nodes[i]).update(scanner);
+ }
+ }
+}
}
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.10
diff -u -r1.10 FormatJavadocText.java
--- formatter/org/eclipse/jdt/internal/formatter/FormatJavadocText.java 12 Feb 2010 18:33:46 -0000 1.10
+++ formatter/org/eclipse/jdt/internal/formatter/FormatJavadocText.java 14 Feb 2010 15:53:26 -0000
@@ -50,7 +50,7 @@
* child node.
*/
void appendText(FormatJavadocText text) {
- this.immutable = text.immutable;
+ text.immutable = this.immutable;
if (this.depth == text.depth) {
addSeparator(text);
this.sourceEnd = text.sourceEnd;
@@ -169,7 +169,6 @@
*
* @return true
if the node is an immutable tag,
* false
otherwise.
- *@deprecated Use {@link #isImmutable()} instead
*/
public boolean isImmutableHtmlTag() {
return this.htmlTagIndex != -1 && (this.htmlTagIndex & JAVADOC_TAGS_ID_MASK) == JAVADOC_IMMUTABLE_TAGS_ID;
@@ -230,6 +229,9 @@
StringBuffer indentation = new StringBuffer();
for (int t=0; t<=this.depth; t++) indentation.append('\t');
buffer.append(indentation);
+ if (isImmutable()) {
+ buffer.append("immutable "); //$NON-NLS-1$
+ }
buffer.append("text"); //$NON-NLS-1$
super.toString(buffer);
buffer.append(" ("); //$NON-NLS-1$
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.32
diff -u -r1.32 FormatterCommentParser.java
--- formatter/org/eclipse/jdt/internal/formatter/FormatterCommentParser.java 11 Feb 2010 12:18:52 -0000 1.32
+++ formatter/org/eclipse/jdt/internal/formatter/FormatterCommentParser.java 14 Feb 2010 15:53:27 -0000
@@ -796,10 +796,7 @@
for (int i=0; i$Revision: 1.51 $ $Date: 2010/02/12 18:33:47 $ $Author: oliviert $ $Source: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java,v $
\n" +
+ " * @version {@code\n" +
+ " * The text here should not be formatted.... }\n" +
" */\n" +
"public class X01b {\n" +
"}\n";
- formatSource(source);
+ formatSource(source,
+ "/**\n" +
+ " * Comments that can be formated in several lines...\n" +
+ " * \n" +
+ " * @author Myself\n" +
+ " * @version {@code The text here should not be formatted.... }\n" +
+ " */\n" +
+ "public class X01b {\n" +
+ "}\n"
+ );
}
public void testBug260381c() throws JavaModelException {
String source =
@@ -4431,8 +4454,10 @@
" * Comments that can be formated in several lines...\n" +
" * \n" +
" * @author Myself\n" +
- " * @version\n" +
- " * 3.0 xxxxxxxxxxxxxx xwxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
\n" +
+ " * @version {@code \n" +
+ " * \n" +
+ " \n" +
+ " * The text here should not be formatted.... }\n" +
" */\n" +
"public class X01c {\n" +
"}\n";
@@ -4441,7 +4466,10 @@
" * Comments that can be formated in several lines...\n" +
" * \n" +
" * @author Myself\n" +
- " * @version 3.0 xxxxxxxxxxxxxx xwxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
\n" +
+ " * @version {@code \n" +
+ " * \n" +
+ " * \n" +
+ " * The text here should not be formatted.... }\n" +
" */\n" +
"public class X01c {\n" +
"}\n"
@@ -4453,41 +4481,131 @@
" * Comments that can be formated in several lines...\n" +
" * \n" +
" * @author Myself\n" +
- " * @see Object $Revision: 1.51 $ $Date: 2010/02/12 18:33:47 $ $Author: oliviert $ $Source: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java,v $
\n" +
+ " * @version The text here should not be formatted....
\n" +
" */\n" +
"public class X02 {\n" +
"}\n";
+ formatSource(source);
+}
+public void testBug260381e() throws JavaModelException {
+ String source =
+ "/**\n" +
+ " * Comments that can be formated in several lines...\n" +
+ " * \n" +
+ " * @author Myself\n" +
+ " * @version\n" +
+ " * The text here should not be formatted....
\n" +
+ " */\n" +
+ "public class X02b {\n" +
+ "}\n";
+ formatSource(source,
+ "/**\n" +
+ " * Comments that can be formated in several lines...\n" +
+ " * \n" +
+ " * @author Myself\n" +
+ " * @version The text here should not be formatted....
\n" +
+ " */\n" +
+ "public class X02b {\n" +
+ "}\n"
+ );
+}
+public void testBug260381f() throws JavaModelException {
+ String source =
+ "/**\n" +
+ " * Comments that can be formated in several lines...\n" +
+ " * \n" +
+ " * @author Myself\n" +
+ " * @see Object The text here should not be formatted....
\n" +
+ " */\n" +
+ "public class X02c {\n" +
+ "}\n";
formatSource(source,
"/**\n" +
" * Comments that can be formated in several lines...\n" +
" * \n" +
" * @author Myself\n" +
" * @see Object\n" +
- " * $Revision: 1.51 $ $Date: 2010/02/12 18:33:47 $ $Author: oliviert $ $Source: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java,v $
\n" +
+ " * The text here should not be formatted....
\n" +
" */\n" +
- "public class X02 {\n" +
+ "public class X02c {\n" +
"}\n"
);
}
-// TODO (frederic) Disabled as it fails with HEAD...
-public void _testBug260381e() throws JavaModelException {
+public void testBug260381g() throws JavaModelException {
String source =
"/**\n" +
" * Comments that can be formated in several lines...\n" +
" * \n" +
- " * {@code $Revision: 1.51 $ $Date: 2010/02/12 18:33:47 $ $Author: oliviert $\n" +
- " * $Source: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java,v $}\n" +
+ " * {@code The text here should not be formatted.... }\n" +
" */\n" +
"public class X03 {\n" +
"}\n";
formatSource(source);
}
-public void testBug260381f() throws JavaModelException {
+public void testBug260381h() throws JavaModelException {
+ String source =
+ "/**\n" +
+ " * Comments that can be formated in several lines...\n" +
+ " * \n" +
+ " * The text here should \n" +
+ " * not be formatted....
\n" +
+ " */\n" +
+ "public class X03b {\n" +
+ "}\n";
+ formatSource(source);
+}
+public void testBug260381i() throws JavaModelException {
+ String source =
+ "/**\n" +
+ " * Comments that can be formated in several lines...\n" +
+ " * \n" +
+ " * {@code The text here should\n" +
+ " * not be formatted.... }\n" +
+ " */\n" +
+ "public class X03c {\n" +
+ "}\n";
+ formatSource(source,
+ "/**\n" +
+ " * Comments that can be formated in several lines...\n" +
+ " * \n" +
+ " * {@code The text here should\n" +
+ " * not be formatted.... }\n" +
+ " */\n" +
+ "public class X03c {\n" +
+ "}\n"
+ );
+}
+public void testBug260381j() throws JavaModelException {
+ String source =
+ "/**\n" +
+ " * Comments that can be formated in several lines...\n" +
+ " * \n" +
+ " * {@code \n" +
+ " * The text here should\n" +
+ " * not \n" +
+ " * be formatted.... }\n" +
+ " */\n" +
+ "public class X03d {\n" +
+ "}\n";
+ formatSource(source,
+ "/**\n" +
+ " * Comments that can be formated in several lines...\n" +
+ " * \n" +
+ " * {@code \n" +
+ " * The text here should\n" +
+ " * not \n" +
+ " * be formatted.... }\n" +
+ " */\n" +
+ "public class X03d {\n" +
+ "}\n"
+ );
+}
+public void testBug260381k() throws JavaModelException {
String source =
"/**\n" +
" * Literal inline tag should also be untouched by the formatter\n" +
" * \n" +
- " * @version {@literal $Revision: 1.51 $ $Date: 2010/02/12 18:33:47 $ $Author: oliviert $ $Source: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java,v $}\n" +
+ " * @version {@literal The text here should not be formatted.... }\n" +
" */\n" +
"public class X04 {\n" +
"\n" +
@@ -4730,7 +4848,8 @@
"public interface I03 {\n" +
" /**\n" +
" * A builder for creating immutable bimap instances, especially\n" +
- " * {@code public static final} bimaps (\"constant bimaps\"). Example:\n" +
+ " * {@code public\n" +
+ " * static final} bimaps (\"constant bimaps\"). Example:\n" +
" * \n" +
" * \n" + " * {\n" + @@ -4752,6 +4871,29 @@ "}\n" ); } +public void testBug260381_wksp2_03b() throws JavaModelException { + String source = + "package wksp2;\n" + + "\n" + + "public interface I03b {\n" + + " /**\n" + + " * A builder for creating immutable bimap instances, xxxxxxxx {@code public\n" + + " * static final} bimaps (\"constant bimaps\").\n" + + " */\n" + + " void foo();\n" + + "}\n"; + formatSource(source, + "package wksp2;\n" + + "\n" + + "public interface I03b {\n" + + " /**\n" + + " * A builder for creating immutable bimap instances, xxxxxxxx {@code public\n" + + " * static final} bimaps (\"constant bimaps\").\n" + + " */\n" + + " void foo();\n" + + "}\n" + ); +} public void testBug260381_wksp2_04() throws JavaModelException { String source = "package wksp2;\n" + @@ -4769,8 +4911,8 @@ " * ImmutableMultiset.copyOf(c)} returns an {@code ImmutableMultiset}\n" + " * containing each of the strings in {@code c}, while\n" + " * {@code ImmutableMultiset.of(c)} returns an\n" + - " * {@code ImmutableMultiset >} containing one element (the\n" + - " * given collection itself).\n" + + " * {@code ImmutableMultiset >} containing one element\n" + + " * (the given collection itself).\n" + " *\n" + " * Note: Despite what the method name suggests, if {@code elements}\n" + " * is an {@code ImmutableMultiset}, no copy will actually be performed, and\n" + @@ -4934,8 +5076,8 @@ " * {@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" + + " * {@code addAll(Collections.nCopies(element,\n" + + " * occurrences))}, which would presumably perform much more poorly.\n" + " * \n" + " * @param element\n" + " * the element to add occurrences of; may be {@code null} only if\n" + @@ -4987,12 +5129,11 @@ " /**\n" + " * Constructs a new, empty multiset, sorted according to the specified\n" + " * comparator. All elements inserted into the multiset must be mutually\n" + - " * comparable 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" + + " * comparable by the specified comparator: {@code comparator.compare(e1,\n" + + " * e2)} must not throw a {@code ClassCastException} for any elements\n" + + " * {@code e1} and {@code e2} in the multiset. If the user attempts to add an\n" + + " * element to the multiset that violates this constraint, the\n" + + " * {@code add(Object)} call will throw a {@code ClassCastException}.\n" + " * \n" + " * @param comparator\n" + " * the comparator that will be used to sort this multiset. A null\n" +