### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core.tests.model Index: src/org/eclipse/jdt/core/tests/dom/ASTConverterJavadocTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterJavadocTest.java,v retrieving revision 1.67 diff -u -r1.67 ASTConverterJavadocTest.java --- src/org/eclipse/jdt/core/tests/dom/ASTConverterJavadocTest.java 31 Jan 2006 10:03:20 -0000 1.67 +++ src/org/eclipse/jdt/core/tests/dom/ASTConverterJavadocTest.java 1 Feb 2006 14:04:28 -0000 @@ -113,7 +113,7 @@ // Run test cases subset COPY_DIR = false; System.err.println("WARNING: only subset of tests will be executed!!!"); - suite.addTest(new ASTConverterJavadocTest("testBug125676")); + suite.addTest(new ASTConverterJavadocTest("testBug125903")); return suite; } @@ -3188,7 +3188,7 @@ } /** - * Bug 125676: [javadoc][dom] ASTNode not including javadoc + * @bug 125676: [javadoc] @category should not read beyond end of line * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=125676" */ public void testBug125676() throws JavaModelException { @@ -3249,4 +3249,39 @@ ); verifyWorkingCopiesComments(); } + + /** + * @bug 125903: [javadoc] Treat whitespace in javadoc tags as invalid tags + * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=125903" + */ + public void testBug125903() throws JavaModelException { + workingCopies = new ICompilationUnit[1]; + astLevel = AST.JLS3; + workingCopies[0] = getWorkingCopy("/Converter15/src/javadoc/b125903/Test.java", + "package javadoc.b125903;\n" + + "/**\n" + + " * {@ link java.lang.String}\n" + + " * @ since 2.1\n" + + " */\n" + + "public class Test {\n" + + "\n" + + "}\n" + ); + CompilationUnit compilUnit = (CompilationUnit) runConversion(workingCopies[0], true); + verifyWorkingCopiesComments(); + if (docCommentSupport.equals(JavaCore.ENABLED)) { + // Verify method javadoc + ASTNode node = getASTNode(compilUnit, 0); + assertEquals("Invalid type for node: "+node, ASTNode.TYPE_DECLARATION, node.getNodeType()); + TypeDeclaration typeDeclaration = (TypeDeclaration) node; + Javadoc javadoc = typeDeclaration.getJavadoc(); + assertNotNull("TypeDeclaration should have a javadoc comment", javadoc); + List tags = javadoc.tags(); + TagElement tag = (TagElement) tags.get(0); + tag = (TagElement) tag.fragments().get(0); + assertEquals("Tag name should be empty", tag.getTagName(), "@"); + tag = (TagElement) tags.get(1); + assertEquals("Tag name should be empty", tag.getTagName(), "@"); + } + } } #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.14 diff -u -r1.14 JavadocBugsTest.java --- src/org/eclipse/jdt/core/tests/compiler/regression/JavadocBugsTest.java 17 Nov 2005 18:52:14 -0000 1.14 +++ src/org/eclipse/jdt/core/tests/compiler/regression/JavadocBugsTest.java 1 Feb 2006 14:04:31 -0000 @@ -36,7 +36,7 @@ static { // TESTS_PREFIX = "testBug83127"; // TESTS_NAMES = new String[] { "testBug68017javadocWarning2" }; -// TESTS_NUMBERS = new int[] { 83285 }; +// TESTS_NUMBERS = new int[] { 125903 }; // TESTS_RANGE = new int[] { 21, 50 }; } public static Test suite() { @@ -3961,4 +3961,34 @@ } ); } + + /** + * Bug 125903: [javadoc] Treat whitespace in javadoc tags as invalid tags + * @see "http://bugs.eclipse.org/bugs/show_bug.cgi?id=125903" + */ + public void testBug125903() { + this.reportMissingJavadocTags = CompilerOptions.ERROR; + runNegativeTest( + new String[] { + "X.java", + "/**\n" + + " * {@ link java.lang.String}\n" + + " * @ since 2.1\n" + + " */\n" + + "public class X {\n" + + "}\n" + }, + "----------\n" + + "1. ERROR in X.java (at line 2)\n" + + " * {@ link java.lang.String}\n" + + " ^^\n" + + "Javadoc: Invalid tag\n" + + "----------\n" + + "2. ERROR in X.java (at line 3)\n" + + " * @ since 2.1\n" + + " ^^\n" + + "Javadoc: Invalid tag\n" + + "----------\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.50 diff -u -r1.50 JavadocParser.java --- compiler/org/eclipse/jdt/internal/compiler/parser/JavadocParser.java 30 Jan 2006 16:23:47 -0000 1.50 +++ compiler/org/eclipse/jdt/internal/compiler/parser/JavadocParser.java 1 Feb 2006 14:04:34 -0000 @@ -355,7 +355,14 @@ boolean valid = false; // Read tag name + int currentPosition = this.index; int token = readTokenAndConsume(); + if (currentPosition != this.scanner.startPosition) { + this.tagSourceStart = previousPosition; + this.tagSourceEnd = currentPosition; + if (this.reportProblems) this.sourceParser.problemReporter().javadocInvalidTag(this.tagSourceStart, this.tagSourceEnd); + return false; + } if (this.index >= this.scanner.eofPosition) { this.tagSourceStart = previousPosition; this.tagSourceEnd = this.tokenPreviousPosition; Index: dom/org/eclipse/jdt/core/dom/DocCommentParser.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/DocCommentParser.java,v retrieving revision 1.31 diff -u -r1.31 DocCommentParser.java --- dom/org/eclipse/jdt/core/dom/DocCommentParser.java 31 Jan 2006 10:03:01 -0000 1.31 +++ dom/org/eclipse/jdt/core/dom/DocCommentParser.java 1 Feb 2006 14:04:34 -0000 @@ -337,10 +337,16 @@ protected boolean parseTag(int previousPosition) throws InvalidInputException { // Read tag name + int currentPosition = this.index; int token = readTokenAndConsume(); - this.tagSourceStart = this.scanner.getCurrentTokenStartPosition(); - this.tagSourceEnd = this.scanner.getCurrentTokenEndPosition(); - char[] tagName = this.scanner.getCurrentIdentifierSource(); + char[] tagName = CharOperation.NO_CHAR; + if (currentPosition == this.scanner.startPosition) { + this.tagSourceStart = this.scanner.getCurrentTokenStartPosition(); + this.tagSourceEnd = this.scanner.getCurrentTokenEndPosition(); + tagName = this.scanner.getCurrentIdentifierSource(); + } else { + this.tagSourceEnd = currentPosition-1; + } // Try to get tag name other than java identifier // (see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=51660) @@ -385,6 +391,11 @@ this.scanner.currentPosition = this.tagSourceEnd+1; this.tagSourceStart = previousPosition; + // tage name may be empty (see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=125903) + if (tagName.length == 0) { + return false; + } + // Decide which parse to perform depending on tag name this.tagValue = NO_TAG_VALUE; boolean valid = true;