### 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.36 diff -u -r1.36 JavadocBugsTest.java --- src/org/eclipse/jdt/core/tests/compiler/regression/JavadocBugsTest.java 16 Mar 2007 18:31:22 -0000 1.36 +++ src/org/eclipse/jdt/core/tests/compiler/regression/JavadocBugsTest.java 3 Jul 2007 10:15:58 -0000 @@ -5773,4 +5773,236 @@ "Javadoc: Missing tag for parameter anotherInt\n" + "----------\n"); } + + /** + * @bug 168849: [javadoc] Javadoc warning on @see reference in class level docs. + * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=168849" + */ + public void testBug168849a() { + String[] units = new String[] { + "pkg/X.java", + "package pkg;\n" + + "\n" + + "public class X {\n" + + " /**\n" + + " * @see http://www.eclipse.org/\n" + + " */\n" + + " public void foo() { \n" + + " \n" + + " }\n" + + "}\n" + }; + reportInvalidJavadoc = CompilerOptions.WARNING; + runNegativeTest(units, + "----------\n" + + "1. WARNING in pkg\\X.java (at line 5)\n" + + " * @see http://www.eclipse.org/\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Javadoc: Invalid URL reference. Double quote the reference or use the href syntax \n" + + "----------\n"); + } + + public void testBug168849b() { + String[] units = new String[] { + "pkg/X.java", + "package pkg;\n" + + "\n" + + "public class X {\n" + + " /**\n" + + " * @see http://ftp.eclipse.org/\n" + + " */\n" + + " public void foo() { \n" + + " \n" + + " }\n" + + "}\n" + }; + reportInvalidJavadoc = CompilerOptions.WARNING; + runNegativeTest(units, + "----------\n" + + "1. WARNING in pkg\\X.java (at line 5)\n" + + " * @see http://ftp.eclipse.org/\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Javadoc: Invalid URL reference. Double quote the reference or use the href syntax \n" + + "----------\n"); + } + + public void testBug168849c() { + String[] units = new String[] { + "pkg/X.java", + "package pkg;\n" + + "\n" + + "public class X {\n" + + " /**\n" + + " * @see ://\n" + + " */\n" + + " public void foo() { \n" + + " \n" + + " }\n" + + "}\n" + }; + reportInvalidJavadoc = CompilerOptions.WARNING; + runNegativeTest(units, + "----------\n" + + "1. WARNING in pkg\\X.java (at line 5)\n" + + " * @see ://\n" + + " ^^^\n" + + "Javadoc: Missing reference\n" + + "----------\n"); + } + + public void testBug168849d() { + String[] units = new String[] { + "pkg/X.java", + "package pkg;\n" + + "\n" + + "public class X {\n" + + " /**\n" + + " * @see http\u003A\u002F\u002Fwww.eclipse.org\n" + + " */\n" + + " public void foo() { \n" + + " \n" + + " }\n" + + "}\n" + }; + reportInvalidJavadoc = CompilerOptions.WARNING; + runNegativeTest(units, + "----------\n" + + "1. WARNING in pkg\\X.java (at line 5)\n" + + " * @see http://www.eclipse.org\n" + + " ^^^^^^^^^^^^^^^^^^^^^^\n" + + "Javadoc: Invalid URL reference. Double quote the reference or use the href syntax \n" + + "----------\n"); + } + + public void testBug168849e() { + String[] units = new String[] { + "pkg/X.java", + "package pkg;\n" + + "\n" + + "public class X {\n" + + " /**\n" + + " * @see \"http\u003A\u002F\u002Fwww.eclipse.org\"\n" + + " */\n" + + " public void foo() { \n" + + " \n" + + " }\n" + + "}\n" + }; + reportInvalidJavadoc = CompilerOptions.WARNING; + runConformTest(units); + } + + public void testBug168849f() { + String[] units = new String[] { + "pkg/X.java", + "package pkg;\n" + + "\n" + + "public class X {\n" + + " /**\n" + + " * @see \"http://www.eclipse.org/\"\n" + + " */\n" + + " public void foo() { \n" + + " \n" + + " }\n" + + "}\n" + }; + reportInvalidJavadoc = CompilerOptions.WARNING; + runConformTest(units); + } + + public void testBug168849g() { + String[] units = new String[] { + "pkg/X.java", + "package pkg;\n" + + "\n" + + "public class X {\n" + + " /**\n" + + " * @see http:/ invalid reference\n" + + " */\n" + + " public void foo() { \n" + + " \n" + + " }\n" + + "}\n" + }; + reportInvalidJavadoc = CompilerOptions.WARNING; + runNegativeTest(units, + "----------\n" + + "1. WARNING in pkg\\X.java (at line 5)\n" + + " * @see http:/ invalid reference\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Javadoc: Malformed reference (missing end space separator)\n" + + "----------\n"); + } + + public void testBug168849h() { + String[] units = new String[] { + "pkg/X.java", + "package pkg;\n" + + "\n" + + "public class X {\n" + + " /**\n" + + " * @see Object:/ invalid reference\n" + + " */\n" + + " public void foo() { \n" + + " \n" + + " }\n" + + "}\n" + }; + reportInvalidJavadoc = CompilerOptions.WARNING; + runNegativeTest(units, + "----------\n" + + "1. WARNING in pkg\\X.java (at line 5)\n" + + " * @see Object:/ invalid reference\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Javadoc: Malformed reference (missing end space separator)\n" + + "----------\n"); + } + + public void testBug168849i() { + String[] units = new String[] { + "pkg/X.java", + "package pkg;\n" + + "\n" + + "public class X {\n" + + " /**\n" + + " * @see http\u003A\u002F invalid reference\n" + + " */\n" + + " public void foo() { \n" + + " \n" + + " }\n" + + "}\n" + }; + reportInvalidJavadoc = CompilerOptions.WARNING; + runNegativeTest(units, + "----------\n" + + "1. WARNING in pkg\\X.java (at line 5)\n" + + " * @see http:/ invalid reference\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Javadoc: Malformed reference (missing end space separator)\n" + + "----------\n"); + } + + public void testBug168849j() { + String[] units = new String[] { + "pkg/X.java", + "package pkg;\n" + + "\n" + + "public class X {\n" + + " /**\n" + + " * @see Object\u003A\u002F invalid reference\n" + + " */\n" + + " public void foo() { \n" + + " \n" + + " }\n" + + "}\n" + }; + reportInvalidJavadoc = CompilerOptions.WARNING; + runNegativeTest(units, + "----------\n" + + "1. WARNING in pkg\\X.java (at line 5)\n" + + " * @see Object:/ invalid reference\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Javadoc: Malformed reference (missing end space separator)\n" + + "----------\n"); + } } #P org.eclipse.jdt.core Index: compiler/org/eclipse/jdt/core/compiler/IProblem.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/IProblem.java,v retrieving revision 1.188 diff -u -r1.188 IProblem.java --- compiler/org/eclipse/jdt/core/compiler/IProblem.java 2 Mar 2007 10:46:03 -0000 1.188 +++ compiler/org/eclipse/jdt/core/compiler/IProblem.java 3 Jul 2007 10:16:00 -0000 @@ -810,7 +810,9 @@ /* * Javadoc comments - */ + */ + /** @since 3.4 */ + int JavadocInvalidSeeUrlReference = Javadoc + Internal + 463; /** * Problem warned on duplicated tag. * @since 3.3 Index: compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties,v retrieving revision 1.220 diff -u -r1.220 messages.properties --- compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties 26 Mar 2007 17:16:24 -0000 1.220 +++ compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties 3 Jul 2007 10:16:03 -0000 @@ -372,7 +372,8 @@ 460 = Empty block should be documented -### DOC +### DOC +463 = Invalid URL reference. Double quote the reference or use the href syntax 464 = Unexpected duplicated tag @{0} 465 = ''{0}'' visibility for malformed doc comments hides this ''{1}'' reference 466 = Invalid member type qualification @@ -584,4 +585,4 @@ 856 = The constructor {0}({1}) of type {2} is not generic; it cannot be parameterized with arguments <{3}> 857 = Incorrect number of type arguments for generic constructor <{3}>{0}({1}) of type {2}; it cannot be parameterized with arguments <{4}> 858 = The parameterized constructor <{3}>{0}({1}) of type {2} is not applicable for the arguments ({4}) -859 = The constructor {0}({1}) of raw type {2} is no longer generic; it cannot be parameterized with arguments <{3}> +859 = The constructor {0}({1}) of raw type {2} is no longer generic; it cannot be parameterized with arguments <{3}> \ No newline at end of file Index: compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java,v retrieving revision 1.348 diff -u -r1.348 ProblemReporter.java --- compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java 19 Apr 2007 17:16:24 -0000 1.348 +++ compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java 3 Jul 2007 10:16:02 -0000 @@ -275,6 +275,7 @@ case IProblem.JavadocUsingDeprecatedMethod: case IProblem.JavadocUsingDeprecatedType: case IProblem.JavadocHiddenReference: + case IProblem.JavadocInvalidSeeUrlReference: return CompilerOptions.InvalidJavadoc; case IProblem.JavadocMissingParamTag: @@ -4176,7 +4177,7 @@ this.handle(IProblem.JavadocInvalidSeeArgs, NoArgument, NoArgument, sourceStart, sourceEnd); } public void javadocInvalidSeeUrlReference(int sourceStart, int sourceEnd) { - this.handle(IProblem.JavadocInvalidSeeHref, NoArgument, NoArgument, sourceStart, sourceEnd); + this.handle(IProblem.JavadocInvalidSeeUrlReference, NoArgument, NoArgument, sourceStart, sourceEnd); } public void javadocInvalidTag(int sourceStart, int sourceEnd) { this.handle(IProblem.JavadocInvalidTag, NoArgument, NoArgument, sourceStart, sourceEnd); @@ -4243,6 +4244,10 @@ public void javadocMalformedSeeReference(int sourceStart, int sourceEnd) { this.handle(IProblem.JavadocMalformedSeeReference, NoArgument, NoArgument, sourceStart, sourceEnd); } +public void javadocMalformedSeeUrlReference(int sourceStart, int sourceEnd) { + this.handle(IProblem.JavadocInvalidSeeHref, NoArgument, NoArgument, sourceStart, sourceEnd); +} + public void javadocMissing(int sourceStart, int sourceEnd, int modifiers){ int severity = computeSeverity(IProblem.JavadocMissing); if (severity == ProblemSeverities.Ignore) return; 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.67 diff -u -r1.67 AbstractCommentParser.java --- compiler/org/eclipse/jdt/internal/compiler/parser/AbstractCommentParser.java 27 Apr 2007 15:51:39 -0000 1.67 +++ compiler/org/eclipse/jdt/internal/compiler/parser/AbstractCommentParser.java 3 Jul 2007 10:16:00 -0000 @@ -544,7 +544,7 @@ this.currentTokenType = -1; // Signal syntax error if (this.tagValue != TAG_VALUE_VALUE) { // do not report error for @value tag, this will be done after... - if (this.reportProblems) this.sourceParser.problemReporter().javadocInvalidSeeUrlReference(start, this.lineEnd); + if (this.reportProblems) this.sourceParser.problemReporter().javadocMalformedSeeUrlReference(start, this.lineEnd); } return false; } @@ -561,7 +561,7 @@ this.currentTokenType = -1; // Signal syntax error if (this.tagValue != TAG_VALUE_VALUE) { // do not report error for @value tag, this will be done after... - if (this.reportProblems) this.sourceParser.problemReporter().javadocInvalidSeeUrlReference(start, this.lineEnd); + if (this.reportProblems) this.sourceParser.problemReporter().javadocMalformedSeeUrlReference(start, this.lineEnd); } return false; } @@ -592,7 +592,7 @@ this.currentTokenType = -1; // Signal syntax error if (this.tagValue != TAG_VALUE_VALUE) { // do not report error for @value tag, this will be done after... - if (this.reportProblems) this.sourceParser.problemReporter().javadocInvalidSeeUrlReference(start, this.lineEnd); + if (this.reportProblems) this.sourceParser.problemReporter().javadocMalformedSeeUrlReference(start, this.lineEnd); } return false; } @@ -1083,15 +1083,29 @@ if (this.reportProblems) this.sourceParser.problemReporter().javadocInvalidReference(typeRefStartPosition, this.lineEnd); return false; } - - // Verify that line end does not start with an open parenthese (which could be a constructor reference wrongly written...) - // See bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=47215 - char ch = peekChar(); - if (ch == '(') { - if (this.reportProblems) this.sourceParser.problemReporter().javadocMissingHashCharacter(typeRefStartPosition, this.lineEnd, String.valueOf(this.source, typeRefStartPosition, this.lineEnd-typeRefStartPosition+1)); - return false; + + int currentIndex = this.index; // store current index + char ch = readChar(); + switch (ch) { + // Verify that line end does not start with an open parenthese (which could be a constructor reference wrongly written...) + // See bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=47215 + case '(' : + if (this.reportProblems) this.sourceParser.problemReporter().javadocMissingHashCharacter(typeRefStartPosition, this.lineEnd, String.valueOf(this.source, typeRefStartPosition, this.lineEnd-typeRefStartPosition+1)); + return false; + // Search for the :// URL pattern + // See bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=168849 + case ':' : + ch = readChar(); + if (ch == '/' && ch == readChar()) { + if (this.reportProblems) { + this.sourceParser.problemReporter().javadocInvalidSeeUrlReference(typeRefStartPosition, this.lineEnd); + return false; + } + } } - + // revert to last stored index + this.index = currentIndex; + // Verify that we get white space after reference if (!verifySpaceOrEndComment()) { this.index = this.tokenPreviousPosition;