### 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 28 Aug 2007 11:00:45 -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/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.221 diff -u -r1.221 messages.properties --- compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties 11 Jul 2007 13:40:49 -0000 1.221 +++ compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties 28 Aug 2007 11:00:49 -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 @@ -586,4 +587,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.351 diff -u -r1.351 ProblemReporter.java --- compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java 19 Jul 2007 14:07:25 -0000 1.351 +++ compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java 28 Aug 2007 11:00:49 -0000 @@ -275,6 +275,7 @@ case IProblem.JavadocUsingDeprecatedMethod: case IProblem.JavadocUsingDeprecatedType: case IProblem.JavadocHiddenReference: + case IProblem.JavadocInvalidSeeUrlReference: return CompilerOptions.InvalidJavadoc; case IProblem.JavadocMissingParamTag: @@ -4196,7 +4197,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); @@ -4263,6 +4264,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/core/compiler/IProblem.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/IProblem.java,v retrieving revision 1.190 diff -u -r1.190 IProblem.java --- compiler/org/eclipse/jdt/core/compiler/IProblem.java 11 Jul 2007 13:47:21 -0000 1.190 +++ compiler/org/eclipse/jdt/core/compiler/IProblem.java 28 Aug 2007 11:00:47 -0000 @@ -813,7 +813,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/parser/AbstractCommentParser.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/AbstractCommentParser.java,v retrieving revision 1.68 diff -u -r1.68 AbstractCommentParser.java --- compiler/org/eclipse/jdt/internal/compiler/parser/AbstractCommentParser.java 16 Jul 2007 20:02:16 -0000 1.68 +++ compiler/org/eclipse/jdt/internal/compiler/parser/AbstractCommentParser.java 28 Aug 2007 11:00:47 -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; } @@ -1081,15 +1081,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;