### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core.tests.model Index: src/org/eclipse/jdt/core/tests/model/JavadocBugsCompletionModelTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavadocBugsCompletionModelTest.java,v retrieving revision 1.26 diff -u -r1.26 JavadocBugsCompletionModelTest.java --- src/org/eclipse/jdt/core/tests/model/JavadocBugsCompletionModelTest.java 24 Oct 2008 15:29:59 -0000 1.26 +++ src/org/eclipse/jdt/core/tests/model/JavadocBugsCompletionModelTest.java 6 May 2009 17:04:28 -0000 @@ -1129,4 +1129,46 @@ "field[FIELD_REF]{field, Lbugs.b171016.BasicTestBugs;, I, field, null, "+this.positions+R_DRICNRNS+"}" ); } +/** + * @bug 255752 [javadoc][assist] Inappropriate completion proposals for javadoc at compilation unit level + * @test that there are no tag completions offered at the compilation unit level for a non package-info.java + * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=255752" + */ +public void testBug255752() throws JavaModelException { + String source = + "/**\n" + + " *\n" + + " * @\n" + + " */" + + "package javadoc.bugs;\n" + + "public class BasicTestBugs {}\n"; + completeInJavadoc("/Completion/src/javadoc/bugs/BasicTestBugs.java", source, true, "@", -1); + assertSortedResults(""); +} +/** + * Additional tests for bug 255752 + * @test whether an orphan Javadoc comment gets all the possible tags applicable to the class level. + */ +public void testBug255752a() throws JavaModelException { + String source = + "/**\n" + + " *\n" + + " * @\n" + + " */" + + "\n"; + completeInJavadoc("/Completion/src/javadoc/bugs/BasicTestBugs.java", source, true, "@", -1); + assertResults( + "author[JAVADOC_BLOCK_TAG]{@author, null, null, author, null, "+this.positions+JAVADOC_RELEVANCE+"}\n" + + "deprecated[JAVADOC_BLOCK_TAG]{@deprecated, null, null, deprecated, null, "+this.positions+JAVADOC_RELEVANCE+"}\n" + + "see[JAVADOC_BLOCK_TAG]{@see, null, null, see, null, "+this.positions+JAVADOC_RELEVANCE+"}\n" + + "version[JAVADOC_BLOCK_TAG]{@version, null, null, version, null, "+this.positions+JAVADOC_RELEVANCE+"}\n" + + "category[JAVADOC_BLOCK_TAG]{@category, null, null, category, null, "+this.positions+JAVADOC_RELEVANCE+"}\n" + + "since[JAVADOC_BLOCK_TAG]{@since, null, null, since, null, "+this.positions+JAVADOC_RELEVANCE+"}\n" + + "serial[JAVADOC_BLOCK_TAG]{@serial, null, null, serial, null, "+this.positions+JAVADOC_RELEVANCE+"}\n" + + "link[JAVADOC_INLINE_TAG]{{@link}, null, null, link, null, "+this.positions+JAVADOC_RELEVANCE+"}\n" + + "docRoot[JAVADOC_INLINE_TAG]{{@docRoot}, null, null, docRoot, null, "+this.positions+JAVADOC_RELEVANCE+"}\n" + + "linkplain[JAVADOC_INLINE_TAG]{{@linkplain}, null, null, linkplain, null, "+this.positions+JAVADOC_RELEVANCE+"}\n" + + "value[JAVADOC_INLINE_TAG]{{@value}, null, null, value, null, "+this.positions+JAVADOC_RELEVANCE+"}" + ); +} } 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.85 diff -u -r1.85 ASTConverterJavadocTest.java --- src/org/eclipse/jdt/core/tests/dom/ASTConverterJavadocTest.java 3 Dec 2008 14:36:39 -0000 1.85 +++ src/org/eclipse/jdt/core/tests/dom/ASTConverterJavadocTest.java 6 May 2009 17:04:26 -0000 @@ -2401,10 +2401,10 @@ Javadoc docComment = (Javadoc) compilUnit.getCommentList().get(0); // Do not need to verify following statement as we know it's ok as verifyComments did not fail // Verify package declaration javadoc - assertTrue("Javadoc should be set on package declaration", docComment == packDecl.getJavadoc()); +// assertTrue("Javadoc should be set on package declaration", docComment == packDecl.getJavadoc()); // Verify package declaration declaration source start - assertEquals("Source range of PackageDeclaration should include Javadoc child", docComment.getStartPosition(), packDecl.getStartPosition()); +// assertEquals("Source range of PackageDeclaration should include Javadoc child", docComment.getStartPosition(), packDecl.getStartPosition()); } } public void testBug93880_15b() throws JavaModelException { @@ -2517,7 +2517,7 @@ Javadoc docComment = (Javadoc) compilUnit.getCommentList().get(0); // Do not need to verify following statement as we know it's ok as verifyComments did not fail // Verify package declaration declaration source start - assertEquals("Source range of PackageDeclaration should include Javadoc child", docComment.getStartPosition(), packDecl.getStartPosition()); +// assertEquals("Source range of PackageDeclaration should include Javadoc child", docComment.getStartPosition(), packDecl.getStartPosition()); } } public void testBug93880_14b() throws JavaModelException { @@ -2536,7 +2536,7 @@ Javadoc docComment = (Javadoc) compilUnit.getCommentList().get(0); // Do not need to verify following statement as we know it's ok as verifyComments did not fail // Verify package declaration declaration source start - assertEquals("Source range of PackageDeclaration should include Javadoc child", docComment.getStartPosition(), packDecl.getStartPosition()); +// assertEquals("Source range of PackageDeclaration should include Javadoc child", docComment.getStartPosition(), packDecl.getStartPosition()); } } public void testBug93880_14c() throws JavaModelException { #P org.eclipse.jdt.core Index: compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java,v retrieving revision 1.402 diff -u -r1.402 Parser.java --- compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java 6 May 2009 13:01:15 -0000 1.402 +++ compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java 6 May 2009 17:04:42 -0000 @@ -4806,7 +4806,8 @@ } protected void consumePackageComment() { // get possible comment for syntax since 1.5 - if(this.options.sourceLevel >= ClassFileConstants.JDK1_5) { + // Consider comments only for the package-info.java (https://bugs.eclipse.org/bugs/show_bug.cgi?id=255752) + if(this.options.sourceLevel >= ClassFileConstants.JDK1_5 && this.compilationUnit.isPackageInfo()) { checkComment(); resetModifiers(); }