### 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 12 May 2009 11:33:20 -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+"}" + ); +} } #P org.eclipse.jdt.core Index: codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnJavadocTag.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnJavadocTag.java,v retrieving revision 1.7 diff -u -r1.7 CompletionOnJavadocTag.java --- codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnJavadocTag.java 7 Mar 2009 00:58:59 -0000 1.7 +++ codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnJavadocTag.java 12 May 2009 11:33:27 -0000 @@ -11,6 +11,7 @@ package org.eclipse.jdt.internal.codeassist.complete; import org.eclipse.jdt.core.compiler.CharOperation; +import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration; import org.eclipse.jdt.internal.compiler.ast.JavadocSingleNameReference; import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; import org.eclipse.jdt.internal.compiler.lookup.ClassScope; @@ -89,6 +90,16 @@ char[][] specifiedTags = null; switch (kind) { case Scope.COMPILATION_UNIT_SCOPE: + // bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=255752 + // Check for FAKE_TYPE_NAME to allow proposals (@see CompletionParser#consumeCompilationUnit) + CompilationUnitDeclaration compilationUnit = scope.referenceCompilationUnit(); + if (compilationUnit != null && + (compilationUnit.types.length > 0 && compilationUnit.types[0].name == CompletionParser.FAKE_TYPE_NAME)) { + specifiedTags = CLASS_TAGS; + } else { + specifiedTags = COMPILATION_UNIT_TAGS; + } + break; case Scope.CLASS_SCOPE: specifiedTags = CLASS_TAGS; break; Index: compiler/org/eclipse/jdt/internal/compiler/parser/JavadocTagConstants.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/JavadocTagConstants.java,v retrieving revision 1.20 diff -u -r1.20 JavadocTagConstants.java --- compiler/org/eclipse/jdt/internal/compiler/parser/JavadocTagConstants.java 28 Apr 2009 16:53:02 -0000 1.20 +++ compiler/org/eclipse/jdt/internal/compiler/parser/JavadocTagConstants.java 12 May 2009 11:33:28 -0000 @@ -212,6 +212,7 @@ TAG_DOC_ROOT, TAG_VALUE, }; + public static final char[][] COMPILATION_UNIT_TAGS = {}; public static final char[][] CLASS_TAGS = { TAG_SEE, TAG_SINCE,