View | Details | Raw Unified | Return to bug 255752 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/model/JavadocBugsCompletionModelTest.java (+42 lines)
Lines 1129-1132 Link Here
1129
		"field[FIELD_REF]{field, Lbugs.b171016.BasicTestBugs;, I, field, null, "+this.positions+R_DRICNRNS+"}"
1129
		"field[FIELD_REF]{field, Lbugs.b171016.BasicTestBugs;, I, field, null, "+this.positions+R_DRICNRNS+"}"
1130
	);
1130
	);
1131
}
1131
}
1132
/**
1133
 * @bug 255752 [javadoc][assist] Inappropriate completion proposals for javadoc at compilation unit level 
1134
 * @test that there are no tag completions offered at the compilation unit level for a non package-info.java
1135
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=255752"
1136
 */
1137
public void testBug255752() throws JavaModelException {
1138
	String source =
1139
		"/**\n" +
1140
		" *\n" +
1141
		" * @\n" +
1142
		" */" +
1143
		"package javadoc.bugs;\n" +
1144
		"public class BasicTestBugs {}\n";
1145
	completeInJavadoc("/Completion/src/javadoc/bugs/BasicTestBugs.java", source, true, "@", -1);
1146
	assertSortedResults("");
1147
}
1148
/**
1149
 * Additional tests for bug 255752
1150
 * @test whether an orphan Javadoc comment gets all the possible tags applicable to the class level.
1151
 */
1152
public void testBug255752a() throws JavaModelException {
1153
	String source =
1154
		"/**\n" +
1155
		" *\n" +
1156
		" * @\n" +
1157
		" */" +
1158
		"\n";
1159
	completeInJavadoc("/Completion/src/javadoc/bugs/BasicTestBugs.java", source, true, "@", -1);
1160
	assertResults(
1161
			"author[JAVADOC_BLOCK_TAG]{@author, null, null, author, null, "+this.positions+JAVADOC_RELEVANCE+"}\n" +
1162
			"deprecated[JAVADOC_BLOCK_TAG]{@deprecated, null, null, deprecated, null, "+this.positions+JAVADOC_RELEVANCE+"}\n" +
1163
			"see[JAVADOC_BLOCK_TAG]{@see, null, null, see, null, "+this.positions+JAVADOC_RELEVANCE+"}\n" +
1164
			"version[JAVADOC_BLOCK_TAG]{@version, null, null, version, null, "+this.positions+JAVADOC_RELEVANCE+"}\n" +
1165
			"category[JAVADOC_BLOCK_TAG]{@category, null, null, category, null, "+this.positions+JAVADOC_RELEVANCE+"}\n" +
1166
			"since[JAVADOC_BLOCK_TAG]{@since, null, null, since, null, "+this.positions+JAVADOC_RELEVANCE+"}\n" +
1167
			"serial[JAVADOC_BLOCK_TAG]{@serial, null, null, serial, null, "+this.positions+JAVADOC_RELEVANCE+"}\n" +
1168
			"link[JAVADOC_INLINE_TAG]{{@link}, null, null, link, null, "+this.positions+JAVADOC_RELEVANCE+"}\n" +
1169
			"docRoot[JAVADOC_INLINE_TAG]{{@docRoot}, null, null, docRoot, null, "+this.positions+JAVADOC_RELEVANCE+"}\n" +
1170
			"linkplain[JAVADOC_INLINE_TAG]{{@linkplain}, null, null, linkplain, null, "+this.positions+JAVADOC_RELEVANCE+"}\n" +
1171
			"value[JAVADOC_INLINE_TAG]{{@value}, null, null, value, null, "+this.positions+JAVADOC_RELEVANCE+"}"
1172
		);
1173
}
1132
}
1174
}
(-)codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnJavadocTag.java (+11 lines)
Lines 11-16 Link Here
11
package org.eclipse.jdt.internal.codeassist.complete;
11
package org.eclipse.jdt.internal.codeassist.complete;
12
12
13
import org.eclipse.jdt.core.compiler.CharOperation;
13
import org.eclipse.jdt.core.compiler.CharOperation;
14
import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
14
import org.eclipse.jdt.internal.compiler.ast.JavadocSingleNameReference;
15
import org.eclipse.jdt.internal.compiler.ast.JavadocSingleNameReference;
15
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
16
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
16
import org.eclipse.jdt.internal.compiler.lookup.ClassScope;
17
import org.eclipse.jdt.internal.compiler.lookup.ClassScope;
Lines 89-94 Link Here
89
		char[][] specifiedTags = null;
90
		char[][] specifiedTags = null;
90
		switch (kind) {
91
		switch (kind) {
91
			case Scope.COMPILATION_UNIT_SCOPE:
92
			case Scope.COMPILATION_UNIT_SCOPE:
93
				// bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=255752
94
				// Check for FAKE_TYPE_NAME to allow proposals (@see CompletionParser#consumeCompilationUnit)
95
				CompilationUnitDeclaration compilationUnit = scope.referenceCompilationUnit();
96
				if (compilationUnit != null &&
97
						(compilationUnit.types.length > 0 && compilationUnit.types[0].name == CompletionParser.FAKE_TYPE_NAME)) {
98
					specifiedTags = CLASS_TAGS;
99
				} else {
100
					specifiedTags = COMPILATION_UNIT_TAGS;
101
				}
102
				break;
92
			case Scope.CLASS_SCOPE:
103
			case Scope.CLASS_SCOPE:
93
				specifiedTags = CLASS_TAGS;
104
				specifiedTags = CLASS_TAGS;
94
				break;
105
				break;
(-)compiler/org/eclipse/jdt/internal/compiler/parser/JavadocTagConstants.java (+1 lines)
Lines 212-217 Link Here
212
		TAG_DOC_ROOT,
212
		TAG_DOC_ROOT,
213
		TAG_VALUE,
213
		TAG_VALUE,
214
	};
214
	};
215
	public static final char[][] COMPILATION_UNIT_TAGS = {};
215
	public static final char[][] CLASS_TAGS = {
216
	public static final char[][] CLASS_TAGS = {
216
		TAG_SEE,
217
		TAG_SEE,
217
		TAG_SINCE,
218
		TAG_SINCE,

Return to bug 255752