### Eclipse Workspace Patch 1.0 #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.34 diff -u -r1.34 FormatterCommentsBugsTest.java --- src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java 14 Jan 2009 10:48:43 -0000 1.34 +++ src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java 26 Feb 2009 15:20:40 -0000 @@ -3229,6 +3229,356 @@ } /** + * @bug 260011: [formatter] Formatting of html in javadoc comments doesn't work with style attributes + * @test Ensure that the comment formatter understand
html tag with attributes + * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=260011" + */ +public void testBug260011() throws JavaModelException { + String source = + "public class Test {\n" + + " /**\n" + + " * some comment text here\n" + + " *
\n" + + " * some text to be styled a certain way\n" + + " *
\n" + + " */\n" + + " void foo() {}\n" + + "\n" + + "}\n"; + formatSource(source, + "public class Test {\n" + + " /**\n" + + " * some comment text here\n" + + " *\n" + + " * some text to be styled a certain way\n" + + " *
\n" + + " */\n" + + " void foo() {\n" + + " }\n" + + "\n" + + "}\n" + ); +} +public void testBug260011_01() throws JavaModelException { + String source = + "public class Test {\n" + + " /**\n" + + " * some comment text here\n" + + " *\n" + + " * some text\n" + + " * to be styled\n" + + " * a certain way\n" + + " * \n" + + " *\n" + + " * end of comment\n" + + " */\n" + + " void foo() {}\n" + + "\n" + + "}\n"; + formatSource(source, + "public class Test {\n" + + " /**\n" + + " * some comment text here\n" + + " * \n" + + " *
\n" + + " * some text\n" + + " * to be styled\n" + + " * a certain way\n" + + " * \n" + + " *\n" + + " * \n" + + " * end of comment\n" + + " */\n" + + " void foo() {\n" + + " }\n" + + "\n" + + "}\n" + ); +} +public void testBug260011_03() throws JavaModelException { + String source = + "public class Test {\n" + + "\n" + + " /**\n" + + " * Indent char is a space char but not a line delimiters.\n" + + " *
== Character.isWhitespace(ch) && ch != \'\\n\' && ch != \'\\r\'
\n" +
+ " */\n" +
+ " public void foo() {\n" +
+ " }\n" +
+ "}\n";
+ formatSource(source,
+ "public class Test {\n" +
+ "\n" +
+ " /**\n" +
+ " * Indent char is a space char but not a line delimiters.\n" +
+ " * == Character.isWhitespace(ch) && ch != \'\\n\' && ch != \'\\r\'
\n" +
+ " */\n" +
+ " public void foo() {\n" +
+ " }\n" +
+ "}\n"
+ );
+}
+public void testBug260011_04() throws JavaModelException {
+ String source =
+ "public class Test {\n" +
+ "\n" +
+ " /**\n" +
+ " * The list of variable declaration fragments (element type: \n" +
+ " * ). Defaults to an empty list.\n" +
+ " */\n" +
+ " int field;\n" +
+ "}\n";
+ formatSource(source,
+ "public class Test {\n" +
+ "\n" +
+ " /**\n" +
+ " * The list of variable declaration fragments (element type:\n" +
+ " * ). Defaults to an empty list.\n" +
+ " */\n" +
+ " int field;\n" +
+ "}\n"
+ );
+}
+public void testBug260011_05() throws JavaModelException {
+ String source =
+ "public class Test {\n" +
+ "\n" +
+ " /**\n" +
+ " * Compares version strings.\n" +
+ " * \n" +
+ " * @return result of comparison, as integer;\n" +
+ " * <0 if left is less than right
\n" +
+ " * 0 if left is equals to right
\n" +
+ " * >0 if left is greater than right
\n" +
+ " */\n" +
+ " int foo() {\n" +
+ " return 0;\n" +
+ " }\n" +
+ "}\n";
+ formatSource(source,
+ "public class Test {\n" +
+ "\n" +
+ " /**\n" +
+ " * Compares version strings.\n" +
+ " * \n" +
+ " * @return result of comparison, as integer;\n" +
+ " * <0 if left is less than right
\n" +
+ " * 0 if left is equals to right
\n" +
+ " * >0 if left is greater than right
\n" +
+ " */\n" +
+ " int foo() {\n" +
+ " return 0;\n" +
+ " }\n" +
+ "}\n"
+ );
+}
+public void testBug260011_06() throws JavaModelException {
+ String source =
+ "public interface Test {\n" +
+ "\n" +
+ " /**\n" +
+ " * Returns the length of this array.\n" +
+ " * \n" +
+ " * @return the length of this array\n" +
+ " * @exception DebugException if this method fails. Reasons include:\n" +
+ " * - Failure communicating with the VM. The DebugException\'s\n" +
+ " * status code contains the underlying exception responsible for\n" +
+ " * the failure.
\n" +
+ " *
\n" +
+ " * Failure communicating with the VM. The\n" +
+ " * DebugException\'s status code contains the underlying\n" +
+ " * exception responsible for the failure. \n" +
+ " * if the element isn\'t associated with a change.\n" +
+ " * \n" +
+ " * @return the change or null
\n" +
+ " */\n" +
+ " public String getChange();\n" +
+ "}\n";
+ formatSource(source,
+ "public interface Test {\n" +
+ "\n" +
+ " /**\n" +
+ " * Returns the change directly associated with this change element or \n" +
+ " * if the element isn\'t associated with a change.\n" +
+ " * \n" +
+ " * @return the change or null
\n" +
+ " */\n" +
+ " public String getChange();\n" +
+ "}\n"
+ );
+}
+public void testBug260011_08() throws JavaModelException {
+ String source =
+ "public interface Test {\n" +
+ "\n" +
+ " /**\n" +
+ " * Answer the element factory for an id, or nullnull\n" +
+ " */\n" +
+ " void foo();\n" +
+ "}\n";
+ formatSource(source,
+ "public interface Test {\n" +
+ "\n" +
+ " /**\n" +
+ " * Creates and opens a dialog to edit the given template.\n" +
+ " * \n" +
+ " */\n" +
+ " void foo();\n" +
+ "}\n"
+ );
+}
+public void testBug260011_11() throws JavaModelException {
+ String source =
+ "public class Test {\n" +
+ "\n" +
+ " /** \n" +
+ " *
Binary property IDS_Trinary_Operator (new).
\n" +
+ " * \n" +
+ " * @stable ICU 2.6\n" +
+ " */ \n" +
+ " public static final int IDS_TRINARY_OPERATOR = 19; \n" +
+ "}\n";
+ formatSource(source,
+ "public class Test {\n" +
+ "\n" +
+ " /**\n" +
+ " *
\n" +
+ " * Binary property IDS_Trinary_Operator (new).\n" +
+ " *
\n" +
+ " * \n" +
+ " * \n" +
+ " * @stable ICU 2.6\n" +
+ " */\n" +
+ " public static final int IDS_TRINARY_OPERATOR = 19;\n" +
+ "}\n"
+ );
+}
+
+/**
* @bug 260274: [formatter] * character is removed while formatting block comments
* @test Ensure that the comment formatter keep '*' characters while formatting block comments
* @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=260274"
#P org.eclipse.jdt.core
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.22
diff -u -r1.22 FormatterCommentParser.java
--- formatter/org/eclipse/jdt/internal/formatter/FormatterCommentParser.java 19 Aug 2008 16:16:39 -0000 1.22
+++ formatter/org/eclipse/jdt/internal/formatter/FormatterCommentParser.java 26 Feb 2009 15:20:42 -0000
@@ -142,13 +142,6 @@
int length = htmlTag == null ? 0 : htmlTag.length;
int tagId = 0;
if (length > 0) {
- for (int i=0, max=JAVADOC_SPECIAL_TAGS.length; i' is missing
+ return false;
+ case TerminalTokens.TokenNameGREATER:
+ // simple tag without attributes
+ break;
+ case TerminalTokens.TokenNameGREATER_EQUAL:
+ case TerminalTokens.TokenNameRIGHT_SHIFT:
+ case TerminalTokens.TokenNameRIGHT_SHIFT_EQUAL:
+ // simple tag without attributes, but the closing '>' is followed by an '=' or '>'
+ break;
+ default:
+ this.index = currentPosition;
+ loop: while (true) {
+// currentPosition = this.index;
+ switch (readChar()) {
+ case '<':
+ if (hasWhitespaces) {
+ // not 100% sure this is a tag definition => give up
+ return false;
+ }
+ // opening tag => consider the current one as closed
+ this.index = currentPosition;
+ this.scanner.startPosition = currentPosition;
+ this.scanner.currentPosition = currentPosition;
+ this.scanner.currentCharacter = '<';
+ break loop;
+ case '>':
+ // simple tag without attributes
+ this.scanner.startPosition = this.index;
+ this.scanner.currentPosition = this.index;
+ this.scanner.currentCharacter = peekChar();
+ break loop;
+ default:
+ break;
+ }
+ if (this.index >= this.javadocTextEnd) {
+ // the end of the comment is reached => consider current tag as closed
+ this.index = currentPosition;
+ this.scanner.startPosition = currentPosition;
+ this.scanner.currentPosition = currentPosition;
+ break;
+ }
}
- } else {
- // invalid syntax
- return false;
- }
- }
+ }
// Push texts
if (this.lineStarted && this.textStart != -1 && this.textStart < endTextPosition) {
Index: formatter/org/eclipse/jdt/internal/formatter/comment/IJavaDocTagConstants.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/comment/IJavaDocTagConstants.java,v
retrieving revision 1.12
diff -u -r1.12 IJavaDocTagConstants.java
--- formatter/org/eclipse/jdt/internal/formatter/comment/IJavaDocTagConstants.java 27 Jun 2008 16:03:57 -0000 1.12
+++ formatter/org/eclipse/jdt/internal/formatter/comment/IJavaDocTagConstants.java 26 Feb 2009 15:20:42 -0000
@@ -67,8 +67,8 @@
};
/** Javadoc parameter tags */
- // TODO (eric) should have another name than 'param' for the following tags
- // TODO (eric) investigate how and why this list was created
+ // TODO (frederic) should have another name than 'param' for the following tags
+ // TODO (frederic) investigate how and why this list was created
public static final char[][] JAVADOC_PARAM_TAGS= new char[][] {
"@exception".toCharArray(), //$NON-NLS-1$
"@param".toCharArray(), //$NON-NLS-1$
@@ -89,16 +89,6 @@
"tr".toCharArray(), //$NON-NLS-1$
};
- /**
- * Following table is used to identify special tags which may have more complex
- * opening than just <name>
- */
- public static final char[][] JAVADOC_SPECIAL_TAGS= new char[][] {
- "table".toCharArray(), //$NON-NLS-1$
- "tr".toCharArray(), //$NON-NLS-1$
- "td".toCharArray(), //$NON-NLS-1$
- };
-
/** Javadoc tag prefix */
public static final char JAVADOC_TAG_PREFIX= '@';
@@ -151,5 +141,4 @@
static final int JAVADOC_SEPARATOR_TAGS_ID = 0x1000;
static final int JAVADOC_SINGLE_TAGS_ID = JAVADOC_SINGLE_BREAK_TAG_ID; // ID max for tags ID with no opening/closing (e.g. .... )
static final int JAVADOC_CLOSED_TAG = 0x10000;
- static final int JAVADOC_SPECIAL_TAGS_ID = 0x20000;
}