### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core.tests.compiler Index: src/org/eclipse/jdt/core/tests/compiler/regression/JavadocBugsTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocBugsTest.java,v retrieving revision 1.61 diff -u -r1.61 JavadocBugsTest.java --- src/org/eclipse/jdt/core/tests/compiler/regression/JavadocBugsTest.java 16 Apr 2009 14:59:18 -0000 1.61 +++ src/org/eclipse/jdt/core/tests/compiler/regression/JavadocBugsTest.java 24 Apr 2009 12:17:19 -0000 @@ -3319,7 +3319,7 @@ * @see 73995 */ public void testBug73995() { - runNegativeTest( + runConformTest( new String[] { "X.java", "public class X extends Base {\n" + @@ -3339,14 +3339,7 @@ "/** return \"The foo2 value\" */" + "public int foo2(){return 0;}\n" + "}" - }, - "----------\n" + - "1. ERROR in X.java (at line 10)\n" + - " * {@unknown_tag}\n" + - " ^^^^^^^^^^^\n" + - "Javadoc: Unexpected tag\n" + - "----------\n" - ); + }); } /** @@ -8504,7 +8497,7 @@ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=267833" */ public void testBug267833() { - runNegativeTest( + runConformTest( new String[] { "X.java", "/**\n" + @@ -8513,14 +8506,7 @@ "*/\n" + "public class X {\n" + "}" - }, - "----------\n" + - "1. ERROR in X.java (at line 2)\n" + - " * Invalid custom tag {@custom \"Invalid\"} \n" + - " ^^^^^^\n" + - "Javadoc: Unexpected tag\n" + - "----------\n" - ); + }); } /** * Additional test for bug 267833 @@ -8567,8 +8553,8 @@ "X.java", "public class X {\n" + "/** \n" + - "* Description {@see value} , {@return value}, {@since value}, {@param i}, {@throws NullPointerException}\n" + - "* and more {@author jay}, {@category cat}, {@deprecated}, {@exception Exception}, {@version 1.1}\n" + + "* Description {@see String} , {@return int}, {@since 1.0}, {@param i}, {@throws NullPointerException}\n" + + "* and more {@author jay}, {@category cat}, {@deprecated}, {@exception NullPointerException}, {@version 1.1}\n" + "* and more {@since 1.0}, {@serial 0L}, {@serialData data}, {@serialField field}\n" + "* @param i\n" + "* @return value\n" + @@ -8580,53 +8566,53 @@ "}\n" }, "----------\n" + "1. ERROR in X.java (at line 3)\n" + - " * Description {@see value} , {@return value}, {@since value}, {@param i}, {@throws NullPointerException}\n" + + " * Description {@see String} , {@return int}, {@since 1.0}, {@param i}, {@throws NullPointerException}\n" + " ^^^\n" + "Javadoc: Unexpected tag\n" + "----------\n" + "2. ERROR in X.java (at line 3)\n" + - " * Description {@see value} , {@return value}, {@since value}, {@param i}, {@throws NullPointerException}\n" + - " ^^^^^^\n" + + " * Description {@see String} , {@return int}, {@since 1.0}, {@param i}, {@throws NullPointerException}\n" + + " ^^^^^^\n" + "Javadoc: Unexpected tag\n" + "----------\n" + "3. ERROR in X.java (at line 3)\n" + - " * Description {@see value} , {@return value}, {@since value}, {@param i}, {@throws NullPointerException}\n" + - " ^^^^^\n" + + " * Description {@see String} , {@return int}, {@since 1.0}, {@param i}, {@throws NullPointerException}\n" + + " ^^^^^\n" + "Javadoc: Unexpected tag\n" + "----------\n" + "4. ERROR in X.java (at line 3)\n" + - " * Description {@see value} , {@return value}, {@since value}, {@param i}, {@throws NullPointerException}\n" + - " ^^^^^\n" + + " * Description {@see String} , {@return int}, {@since 1.0}, {@param i}, {@throws NullPointerException}\n" + + " ^^^^^\n" + "Javadoc: Unexpected tag\n" + "----------\n" + "5. ERROR in X.java (at line 3)\n" + - " * Description {@see value} , {@return value}, {@since value}, {@param i}, {@throws NullPointerException}\n" + - " ^^^^^^\n" + + " * Description {@see String} , {@return int}, {@since 1.0}, {@param i}, {@throws NullPointerException}\n" + + " ^^^^^^\n" + "Javadoc: Unexpected tag\n" + "----------\n" + "6. ERROR in X.java (at line 4)\n" + - " * and more {@author jay}, {@category cat}, {@deprecated}, {@exception Exception}, {@version 1.1}\n" + + " * and more {@author jay}, {@category cat}, {@deprecated}, {@exception NullPointerException}, {@version 1.1}\n" + " ^^^^^^\n" + "Javadoc: Unexpected tag\n" + "----------\n" + "7. ERROR in X.java (at line 4)\n" + - " * and more {@author jay}, {@category cat}, {@deprecated}, {@exception Exception}, {@version 1.1}\n" + + " * and more {@author jay}, {@category cat}, {@deprecated}, {@exception NullPointerException}, {@version 1.1}\n" + " ^^^^^^^^\n" + "Javadoc: Unexpected tag\n" + "----------\n" + "8. ERROR in X.java (at line 4)\n" + - " * and more {@author jay}, {@category cat}, {@deprecated}, {@exception Exception}, {@version 1.1}\n" + + " * and more {@author jay}, {@category cat}, {@deprecated}, {@exception NullPointerException}, {@version 1.1}\n" + " ^^^^^^^^^^\n" + "Javadoc: Unexpected tag\n" + "----------\n" + "9. ERROR in X.java (at line 4)\n" + - " * and more {@author jay}, {@category cat}, {@deprecated}, {@exception Exception}, {@version 1.1}\n" + + " * and more {@author jay}, {@category cat}, {@deprecated}, {@exception NullPointerException}, {@version 1.1}\n" + " ^^^^^^^^^\n" + "Javadoc: Unexpected tag\n" + "----------\n" + "10. ERROR in X.java (at line 4)\n" + - " * and more {@author jay}, {@category cat}, {@deprecated}, {@exception Exception}, {@version 1.1}\n" + - " ^^^^^^^\n" + + " * and more {@author jay}, {@category cat}, {@deprecated}, {@exception NullPointerException}, {@version 1.1}\n" + + " ^^^^^^^\n" + "Javadoc: Unexpected tag\n" + "----------\n" + "11. ERROR in X.java (at line 5)\n" + #P org.eclipse.jdt.core Index: compiler/org/eclipse/jdt/internal/compiler/parser/JavadocParser.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/JavadocParser.java,v retrieving revision 1.78 diff -u -r1.78 JavadocParser.java --- compiler/org/eclipse/jdt/internal/compiler/parser/JavadocParser.java 16 Apr 2009 14:59:22 -0000 1.78 +++ compiler/org/eclipse/jdt/internal/compiler/parser/JavadocParser.java 24 Apr 2009 12:17:22 -0000 @@ -508,22 +508,24 @@ boolean valid = false; switch (firstChar) { case 'a': - if (!this.inlineTagStarted && length == TAG_AUTHOR_LENGTH && CharOperation.equals(TAG_AUTHOR, tagName, 0, length)) { + if (length == TAG_AUTHOR_LENGTH && CharOperation.equals(TAG_AUTHOR, tagName, 0, length)) { this.tagValue = TAG_AUTHOR_VALUE; this.tagWaitingForDescription = this.tagValue; } break; case 'c': - if (!this.inlineTagStarted && length == TAG_CATEGORY_LENGTH && CharOperation.equals(TAG_CATEGORY, tagName, 0, length)) { + if (length == TAG_CATEGORY_LENGTH && CharOperation.equals(TAG_CATEGORY, tagName, 0, length)) { this.tagValue = TAG_CATEGORY_VALUE; - valid = parseIdentifierTag(false); // TODO (frederic) reconsider parameter value when @category will be significant in spec + if (!this.inlineTagStarted) { + valid = parseIdentifierTag(false); // TODO (frederic) reconsider parameter value when @category will be significant in spec + } } else if (length == TAG_CODE_LENGTH && this.inlineTagStarted && CharOperation.equals(TAG_CODE, tagName, 0, length)) { this.tagValue = TAG_CODE_VALUE; this.tagWaitingForDescription = this.tagValue; } break; case 'd': - if (!this.inlineTagStarted && length == TAG_DEPRECATED_LENGTH && CharOperation.equals(TAG_DEPRECATED, tagName, 0, length)) { + if (length == TAG_DEPRECATED_LENGTH && CharOperation.equals(TAG_DEPRECATED, tagName, 0, length)) { this.deprecated = true; valid = true; this.tagValue = TAG_DEPRECATED_VALUE; @@ -536,9 +538,11 @@ } break; case 'e': - if (!this.inlineTagStarted && length == TAG_EXCEPTION_LENGTH && CharOperation.equals(TAG_EXCEPTION, tagName, 0, length)) { + if (length == TAG_EXCEPTION_LENGTH && CharOperation.equals(TAG_EXCEPTION, tagName, 0, length)) { this.tagValue = TAG_EXCEPTION_VALUE; - valid = parseThrows(); + if (!this.inlineTagStarted) { + valid = parseThrows(); + } } break; case 'i': @@ -571,65 +575,59 @@ this.tagValue = TAG_LINK_VALUE; if (this.inlineTagStarted || (this.kind & COMPLETION_PARSER) != 0) { valid= parseReference(); - } else { - // bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=53290 - // Cannot have @link outside inline comment - valid = false; - if (this.reportProblems) { - this.sourceParser.problemReporter().javadocUnexpectedTag(this.tagSourceStart, this.tagSourceEnd); - } } } else if (length == TAG_LINKPLAIN_LENGTH && CharOperation.equals(TAG_LINKPLAIN, tagName, 0, length)) { this.tagValue = TAG_LINKPLAIN_VALUE; if (this.inlineTagStarted) { valid = parseReference(); - } else { - valid = false; - if (this.reportProblems) { - this.sourceParser.problemReporter().javadocUnexpectedTag(this.tagSourceStart, this.tagSourceEnd); - } - } + } } else if (length == TAG_LITERAL_LENGTH && this.inlineTagStarted && CharOperation.equals(TAG_LITERAL, tagName, 0, length)) { this.tagValue = TAG_LITERAL_VALUE; this.tagWaitingForDescription = this.tagValue; } break; case 'p': - if (!this.inlineTagStarted && length == TAG_PARAM_LENGTH && CharOperation.equals(TAG_PARAM, tagName, 0, length)) { + if (length == TAG_PARAM_LENGTH && CharOperation.equals(TAG_PARAM, tagName, 0, length)) { this.tagValue = TAG_PARAM_VALUE; - valid = parseParam(); + if (!this.inlineTagStarted) { + valid = parseParam(); + } } break; case 'r': - if (!this.inlineTagStarted && length == TAG_RETURN_LENGTH && CharOperation.equals(TAG_RETURN, tagName, 0, length)) { + if (length == TAG_RETURN_LENGTH && CharOperation.equals(TAG_RETURN, tagName, 0, length)) { this.tagValue = TAG_RETURN_VALUE; - valid = parseReturn(); + if (!this.inlineTagStarted) { + valid = parseReturn(); + } } break; case 's': - if (!this.inlineTagStarted) { - if (length == TAG_SEE_LENGTH && CharOperation.equals(TAG_SEE, tagName, 0, length)) { - this.tagValue = TAG_SEE_VALUE; + if (length == TAG_SEE_LENGTH && CharOperation.equals(TAG_SEE, tagName, 0, length)) { + this.tagValue = TAG_SEE_VALUE; + if (!this.inlineTagStarted) { valid = parseReference(); - } else if (length == TAG_SERIAL_LENGTH && CharOperation.equals(TAG_SERIAL, tagName, 0, length)) { - this.tagValue = TAG_SERIAL_VALUE; - this.tagWaitingForDescription = this.tagValue; - } else if (length == TAG_SERIAL_DATA_LENGTH && CharOperation.equals(TAG_SERIAL_DATA, tagName, 0, length)) { - this.tagValue = TAG_SERIAL_DATA_VALUE; - this.tagWaitingForDescription = this.tagValue; - } else if (length == TAG_SERIAL_FIELD_LENGTH && CharOperation.equals(TAG_SERIAL_FIELD, tagName, 0, length)) { - this.tagValue = TAG_SERIAL_FIELD_VALUE; - this.tagWaitingForDescription = this.tagValue; - } else if (length == TAG_SINCE_LENGTH && CharOperation.equals(TAG_SINCE, tagName, 0, length)) { - this.tagValue = TAG_SINCE_VALUE; - this.tagWaitingForDescription = this.tagValue; - } - } + } + } else if (length == TAG_SERIAL_LENGTH && CharOperation.equals(TAG_SERIAL, tagName, 0, length)) { + this.tagValue = TAG_SERIAL_VALUE; + this.tagWaitingForDescription = this.tagValue; + } else if (length == TAG_SERIAL_DATA_LENGTH && CharOperation.equals(TAG_SERIAL_DATA, tagName, 0, length)) { + this.tagValue = TAG_SERIAL_DATA_VALUE; + this.tagWaitingForDescription = this.tagValue; + } else if (length == TAG_SERIAL_FIELD_LENGTH && CharOperation.equals(TAG_SERIAL_FIELD, tagName, 0, length)) { + this.tagValue = TAG_SERIAL_FIELD_VALUE; + this.tagWaitingForDescription = this.tagValue; + } else if (length == TAG_SINCE_LENGTH && CharOperation.equals(TAG_SINCE, tagName, 0, length)) { + this.tagValue = TAG_SINCE_VALUE; + this.tagWaitingForDescription = this.tagValue; + } break; case 't': - if (!this.inlineTagStarted && length == TAG_THROWS_LENGTH && CharOperation.equals(TAG_THROWS, tagName, 0, length)) { + if (length == TAG_THROWS_LENGTH && CharOperation.equals(TAG_THROWS, tagName, 0, length)) { this.tagValue = TAG_THROWS_VALUE; - valid = parseThrows(); + if (!this.inlineTagStarted) { + valid = parseThrows(); + } } break; case 'v': @@ -638,9 +636,6 @@ if (this.sourceLevel >= ClassFileConstants.JDK1_5) { if (this.inlineTagStarted) { valid = parseReference(); - } else { - valid = false; - if (this.reportProblems) this.sourceParser.problemReporter().javadocUnexpectedTag(this.tagSourceStart, this.tagSourceEnd); } } else { if (this.validValuePositions == -1) { @@ -657,7 +652,7 @@ if (this.reportProblems) this.sourceParser.problemReporter().javadocUnexpectedTag(this.tagSourceStart, this.tagSourceEnd); } } - } else if (!this.inlineTagStarted && length == TAG_VERSION_LENGTH && CharOperation.equals(TAG_VERSION, tagName, 0, length)) { + } else if (length == TAG_VERSION_LENGTH && CharOperation.equals(TAG_VERSION, tagName, 0, length)) { this.tagValue = TAG_VERSION_VALUE; this.tagWaitingForDescription = this.tagValue; } else { @@ -669,12 +664,21 @@ break; } this.textStart = this.index; - if (this.tagValue != TAG_OTHERS_VALUE && !this.inlineTagStarted) { - this.lastBlockTagValue = this.tagValue; - } - if (this.inlineTagStarted && this.reportProblems - && (this.tagValue >= JAVADOC_TAG_TYPE.length || JAVADOC_TAG_TYPE[this.tagValue] != TAG_TYPE_INLINE)) { - this.sourceParser.problemReporter().javadocUnexpectedTag(this.tagSourceStart, this.tagSourceEnd); + if (this.tagValue != TAG_OTHERS_VALUE) { + if (!this.inlineTagStarted) { + this.lastBlockTagValue = this.tagValue; + } + // see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=267833 + // Report a problem if a block tag is being used in the context of an inline tag and vice versa. + if ((this.inlineTagStarted && JAVADOC_TAG_TYPE[this.tagValue] == TAG_TYPE_BLOCK) + || (!this.inlineTagStarted && JAVADOC_TAG_TYPE[this.tagValue] == TAG_TYPE_INLINE)) { + valid = false; + this.tagValue = TAG_OTHERS_VALUE; + this.tagWaitingForDescription = NO_TAG_VALUE; + if (this.reportProblems) { + this.sourceParser.problemReporter().javadocUnexpectedTag(this.tagSourceStart, this.tagSourceEnd); + } + } } return valid; }