View | Details | Raw Unified | Return to bug 129983
Collapse All | Expand All

(-)model/org/eclipse/jdt/internal/core/SearchableEnvironment.java (-7 / +25 lines)
Lines 67-72 Link Here
67
		this(project, owner == null ? null : JavaModelManager.getJavaModelManager().getWorkingCopies(owner, true/*add primary WCs*/));
67
		this(project, owner == null ? null : JavaModelManager.getJavaModelManager().getWorkingCopies(owner, true/*add primary WCs*/));
68
	}
68
	}
69
69
70
	private static int convertSearchFilterToModelFilter(int searchFilter) {
71
		switch (searchFilter) {
72
			case IJavaSearchConstants.CLASS:
73
				return NameLookup.ACCEPT_CLASSES;
74
			case IJavaSearchConstants.INTERFACE:
75
				return NameLookup.ACCEPT_INTERFACES;
76
			case IJavaSearchConstants.ENUM:
77
				return NameLookup.ACCEPT_ENUMS;
78
			case IJavaSearchConstants.ANNOTATION_TYPE:
79
				return NameLookup.ACCEPT_ANNOTATIONS;
80
			case IJavaSearchConstants.CLASS_AND_ENUM:
81
				return NameLookup.ACCEPT_CLASSES | NameLookup.ACCEPT_ENUMS;
82
			case IJavaSearchConstants.CLASS_AND_INTERFACE:
83
				return NameLookup.ACCEPT_CLASSES | NameLookup.ACCEPT_INTERFACES;
84
			default:
85
				return NameLookup.ACCEPT_ALL;
86
		}
87
	}
70
	/**
88
	/**
71
	 * Returns the given type in the the given package if it exists,
89
	 * Returns the given type in the the given package if it exists,
72
	 * otherwise <code>null</code>.
90
	 * otherwise <code>null</code>.
Lines 166-172 Link Here
166
	}
184
	}
167
185
168
	/**
186
	/**
169
	 * Find the top-level types (classes and interfaces) that are defined
187
	 * Find the top-level types that are defined
170
	 * in the current environment and whose name starts with the
188
	 * in the current environment and whose name starts with the
171
	 * given prefix. The prefix is a qualified name separated by periods
189
	 * given prefix. The prefix is a qualified name separated by periods
172
	 * or a simple name (ex. java.util.V or V).
190
	 * or a simple name (ex. java.util.V or V).
Lines 180-186 Link Here
180
	 * This method can not be used to find member types... member
198
	 * This method can not be used to find member types... member
181
	 * types are found relative to their enclosing type.
199
	 * types are found relative to their enclosing type.
182
	 */
200
	 */
183
	public void findTypes(char[] prefix, final boolean findMembers, boolean camelCaseMatch, final ISearchRequestor storage) {
201
	public void findTypes(char[] prefix, final boolean findMembers, boolean camelCaseMatch, int searchFor, final ISearchRequestor storage) {
184
202
185
		/*
203
		/*
186
			if (true){
204
			if (true){
Lines 196-202 Link Here
196
					findTypes(
214
					findTypes(
197
						new String(prefix),
215
						new String(prefix),
198
						storage,
216
						storage,
199
						NameLookup.ACCEPT_ALL);
217
						convertSearchFilterToModelFilter(searchFor));
200
					return;
218
					return;
201
				}
219
				}
202
				excludePath = ((IJavaElement) this.unitToSkip).getPath().toString();
220
				excludePath = ((IJavaElement) this.unitToSkip).getPath().toString();
Lines 265-273 Link Here
265
				new BasicSearchEngine(this.workingCopies).searchAllTypeNames(
283
				new BasicSearchEngine(this.workingCopies).searchAllTypeNames(
266
					qualification,
284
					qualification,
267
					SearchPattern.R_EXACT_MATCH,
285
					SearchPattern.R_EXACT_MATCH,
268
					simpleName,
286
					simpleName.length == 0 ? null : simpleName, //TODO(david) remove once bug 156340 will be fixed
269
					matchRule, // not case sensitive
287
					matchRule, // not case sensitive
270
					IJavaSearchConstants.TYPE,
288
					searchFor,
271
					this.searchScope,
289
					this.searchScope,
272
					typeRequestor,
290
					typeRequestor,
273
					CANCEL_IF_NOT_READY_TO_SEARCH,
291
					CANCEL_IF_NOT_READY_TO_SEARCH,
Lines 276-288 Link Here
276
				findTypes(
294
				findTypes(
277
					new String(prefix),
295
					new String(prefix),
278
					storage,
296
					storage,
279
					NameLookup.ACCEPT_ALL);
297
					convertSearchFilterToModelFilter(searchFor));
280
			}
298
			}
281
		} catch (JavaModelException e) {
299
		} catch (JavaModelException e) {
282
			findTypes(
300
			findTypes(
283
				new String(prefix),
301
				new String(prefix),
284
				storage,
302
				storage,
285
				NameLookup.ACCEPT_ALL);
303
				convertSearchFilterToModelFilter(searchFor));
286
		}
304
		}
287
	}
305
	}
288
306
(-)model/org/eclipse/jdt/internal/core/CancelableNameEnvironment.java (-2 / +2 lines)
Lines 50-57 Link Here
50
		return super.findType(compoundTypeName);
50
		return super.findType(compoundTypeName);
51
	}
51
	}
52
52
53
	public void findTypes(char[] prefix, boolean findMembers, boolean camelCaseMatch, ISearchRequestor storage) {
53
	public void findTypes(char[] prefix, boolean findMembers, boolean camelCaseMatch, int searchFor, ISearchRequestor storage) {
54
		checkCanceled();
54
		checkCanceled();
55
		super.findTypes(prefix, findMembers, camelCaseMatch, storage);
55
		super.findTypes(prefix, findMembers, camelCaseMatch, searchFor, storage);
56
	}
56
	}
57
}
57
}
(-)codeassist/org/eclipse/jdt/internal/codeassist/SelectionEngine.java (-4 / +5 lines)
Lines 15-20 Link Here
15
15
16
import org.eclipse.jdt.core.Signature;
16
import org.eclipse.jdt.core.Signature;
17
import org.eclipse.jdt.core.compiler.*;
17
import org.eclipse.jdt.core.compiler.*;
18
import org.eclipse.jdt.core.search.IJavaSearchConstants;
18
import org.eclipse.jdt.internal.codeassist.impl.*;
19
import org.eclipse.jdt.internal.codeassist.impl.*;
19
import org.eclipse.jdt.internal.codeassist.select.*;
20
import org.eclipse.jdt.internal.codeassist.select.*;
20
import org.eclipse.jdt.internal.compiler.*;
21
import org.eclipse.jdt.internal.compiler.*;
Lines 613-619 Link Here
613
							char[][] tokens = ((SelectionOnImportReference) importReference).tokens;
614
							char[][] tokens = ((SelectionOnImportReference) importReference).tokens;
614
							this.noProposal = false;
615
							this.noProposal = false;
615
							this.requestor.acceptPackage(CharOperation.concatWith(tokens, '.'));
616
							this.requestor.acceptPackage(CharOperation.concatWith(tokens, '.'));
616
							this.nameEnvironment.findTypes(CharOperation.concatWith(tokens, '.'), false, false,this);
617
							this.nameEnvironment.findTypes(CharOperation.concatWith(tokens, '.'), false, false, IJavaSearchConstants.TYPE, this);
617
							
618
							
618
							this.lookupEnvironment.buildTypeBindings(parsedUnit, null /*no access restriction*/);
619
							this.lookupEnvironment.buildTypeBindings(parsedUnit, null /*no access restriction*/);
619
							if ((this.unitScope = parsedUnit.scope) != null) {
620
							if ((this.unitScope = parsedUnit.scope) != null) {
Lines 638-644 Link Here
638
							if(!this.acceptedAnswer) {
639
							if(!this.acceptedAnswer) {
639
								acceptQualifiedTypes();
640
								acceptQualifiedTypes();
640
								if (!this.acceptedAnswer) {
641
								if (!this.acceptedAnswer) {
641
									this.nameEnvironment.findTypes(this.selectedIdentifier, false, false,this);
642
									this.nameEnvironment.findTypes(this.selectedIdentifier, false, false, IJavaSearchConstants.TYPE, this);
642
									// try with simple type name
643
									// try with simple type name
643
									if(!this.acceptedAnswer) {
644
									if(!this.acceptedAnswer) {
644
										acceptQualifiedTypes();
645
										acceptQualifiedTypes();
Lines 687-693 Link Here
687
			// only reaches here if no selection could be derived from the parsed tree
688
			// only reaches here if no selection could be derived from the parsed tree
688
			// thus use the selected source and perform a textual type search
689
			// thus use the selected source and perform a textual type search
689
			if (!this.acceptedAnswer) {
690
			if (!this.acceptedAnswer) {
690
				this.nameEnvironment.findTypes(this.selectedIdentifier, false, false,this);
691
				this.nameEnvironment.findTypes(this.selectedIdentifier, false, false, IJavaSearchConstants.TYPE, this);
691
				
692
				
692
				// accept qualified types only if no unqualified type was accepted
693
				// accept qualified types only if no unqualified type was accepted
693
				if(!this.acceptedAnswer) {
694
				if(!this.acceptedAnswer) {
Lines 1120-1126 Link Here
1120
			// thus use the selected source and perform a textual type search
1121
			// thus use the selected source and perform a textual type search
1121
			if (!this.acceptedAnswer && searchInEnvironment) {
1122
			if (!this.acceptedAnswer && searchInEnvironment) {
1122
				if (this.selectedIdentifier != null) {
1123
				if (this.selectedIdentifier != null) {
1123
					this.nameEnvironment.findTypes(typeName, false, false,this);
1124
					this.nameEnvironment.findTypes(typeName, false, false, IJavaSearchConstants.TYPE, this);
1124
					
1125
					
1125
					// accept qualified types only if no unqualified type was accepted
1126
					// accept qualified types only if no unqualified type was accepted
1126
					if(!this.acceptedAnswer) {
1127
					if(!this.acceptedAnswer) {
(-)codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java (-8 / +34 lines)
Lines 26-31 Link Here
26
import org.eclipse.jdt.core.compiler.CategorizedProblem;
26
import org.eclipse.jdt.core.compiler.CategorizedProblem;
27
import org.eclipse.jdt.core.compiler.CharOperation;
27
import org.eclipse.jdt.core.compiler.CharOperation;
28
import org.eclipse.jdt.core.compiler.IProblem;
28
import org.eclipse.jdt.core.compiler.IProblem;
29
import org.eclipse.jdt.core.search.IJavaSearchConstants;
29
30
30
import org.eclipse.jdt.internal.codeassist.complete.*;
31
import org.eclipse.jdt.internal.codeassist.complete.*;
31
import org.eclipse.jdt.internal.codeassist.impl.AssistParser;
32
import org.eclipse.jdt.internal.codeassist.impl.AssistParser;
Lines 561-572 Link Here
561
	}
562
	}
562
563
563
	private void proposeType(char[] packageName, char[] simpleTypeName, int modifiers, int accessibility, char[] typeName, char[] fullyQualifiedName, boolean isQualified) {
564
	private void proposeType(char[] packageName, char[] simpleTypeName, int modifiers, int accessibility, char[] typeName, char[] fullyQualifiedName, boolean isQualified) {
564
		if(this.assistNodeIsClass) {
565
		if(this.assistNodeIsInterface) {
565
			if((modifiers & (ClassFileConstants.AccInterface | ClassFileConstants.AccAnnotation | ClassFileConstants.AccEnum)) != 0 ) return;
566
			//TODO(david) remove this code once bug 157177 will be fixed. 
566
		} else if(this.assistNodeIsInterface) {
567
			if((modifiers & (ClassFileConstants.AccInterface | ClassFileConstants.AccAnnotation)) == 0) return;
567
			if((modifiers & (ClassFileConstants.AccInterface | ClassFileConstants.AccAnnotation)) == 0) return;
568
		} else if (this.assistNodeIsAnnotation) {
569
			if((modifiers & ClassFileConstants.AccAnnotation) == 0) return;
570
		}
568
		}
571
		
569
		
572
		char[] completionName = fullyQualifiedName;
570
		char[] completionName = fullyQualifiedName;
Lines 2833-2838 Link Here
2833
					importName,
2831
					importName,
2834
					findMembers, 
2832
					findMembers, 
2835
					this.options.camelCaseMatch,
2833
					this.options.camelCaseMatch,
2834
					IJavaSearchConstants.TYPE,
2836
					this);
2835
					this);
2837
			acceptTypes();
2836
			acceptTypes();
2838
		}
2837
		}
Lines 5094-5100 Link Here
5094
			this.findTypesFromStaticImports(token, scope, proposeAllMemberTypes, typesFound);
5093
			this.findTypesFromStaticImports(token, scope, proposeAllMemberTypes, typesFound);
5095
		}
5094
		}
5096
		
5095
		
5097
		if (token.length == 0) {
5096
		boolean isEmptyPrefix = token.length == 0;
5097
		if (isEmptyPrefix && !this.assistNodeIsAnnotation) {
5098
			if(proposeType && this.expectedTypesPtr > -1) {
5098
			if(proposeType && this.expectedTypesPtr > -1) {
5099
				next : for (int i = 0; i <= this.expectedTypesPtr; i++) {
5099
				next : for (int i = 0; i <= this.expectedTypesPtr; i++) {
5100
					if(this.expectedTypes[i] instanceof ReferenceBinding) {
5100
					if(this.expectedTypes[i] instanceof ReferenceBinding) {
Lines 5194-5200 Link Here
5194
				}
5194
				}
5195
			} 
5195
			} 
5196
		} else {
5196
		} else {
5197
			if(!this.requestor.isIgnored(CompletionProposal.KEYWORD)) {
5197
			if(!isEmptyPrefix && !this.requestor.isIgnored(CompletionProposal.KEYWORD)) {
5198
				if (this.assistNodeInJavadoc == 0 || (this.assistNodeInJavadoc & CompletionOnJavadoc.BASE_TYPES) != 0) {
5198
				if (this.assistNodeInJavadoc == 0 || (this.assistNodeInJavadoc & CompletionOnJavadoc.BASE_TYPES) != 0) {
5199
					findKeywords(token, BASE_TYPE_NAMES, false, false);
5199
					findKeywords(token, BASE_TYPE_NAMES, false, false);
5200
				}
5200
				}
Lines 5210-5223 Link Here
5210
								'.');
5210
								'.');
5211
					this.knownTypes.put(fullyQualifiedTypeName, this);
5211
					this.knownTypes.put(fullyQualifiedTypeName, this);
5212
				}
5212
				}
5213
				int searchFor = IJavaSearchConstants.TYPE;
5214
				if(this.assistNodeIsClass) {
5215
					searchFor = IJavaSearchConstants.CLASS;
5216
				} else if(this.assistNodeIsInterface) {
5217
					//TODO(david) update this code once bug 157177 will be fixed. 
5218
					//searchFor = IJavaSearchConstants.INTERFACE;
5219
					searchFor = IJavaSearchConstants.TYPE;
5220
				} else if(this.assistNodeIsEnum) {
5221
					searchFor = IJavaSearchConstants.ENUM;
5222
				} else if(this.assistNodeIsAnnotation) {
5223
					searchFor = IJavaSearchConstants.ANNOTATION_TYPE;
5224
				}
5213
				this.nameEnvironment.findTypes(
5225
				this.nameEnvironment.findTypes(
5214
						token,
5226
						token,
5215
						proposeAllMemberTypes,
5227
						proposeAllMemberTypes,
5216
						this.options.camelCaseMatch,
5228
						this.options.camelCaseMatch,
5229
						searchFor,
5217
						this);
5230
						this);
5218
				acceptTypes();
5231
				acceptTypes();
5219
			}
5232
			}
5220
			if(!this.requestor.isIgnored(CompletionProposal.PACKAGE_REF)) {
5233
			if(!isEmptyPrefix && !this.requestor.isIgnored(CompletionProposal.PACKAGE_REF)) {
5221
				this.nameEnvironment.findPackages(token, this);
5234
				this.nameEnvironment.findPackages(token, this);
5222
			}
5235
			}
5223
		}
5236
		}
Lines 5315-5324 Link Here
5315
		}
5328
		}
5316
		
5329
		
5317
		if(proposeType) {
5330
		if(proposeType) {
5331
			int searchFor = IJavaSearchConstants.TYPE;
5332
			if(this.assistNodeIsClass) {
5333
				searchFor = IJavaSearchConstants.CLASS;
5334
			} else if(this.assistNodeIsInterface) {
5335
				//TODO(david) update this code once bug 157177 will be fixed. 
5336
				//searchFor = IJavaSearchConstants.INTERFACE;
5337
				searchFor = IJavaSearchConstants.TYPE;
5338
			} else if(this.assistNodeIsEnum) {
5339
				searchFor = IJavaSearchConstants.ENUM;
5340
			} else if(this.assistNodeIsAnnotation) {
5341
				searchFor = IJavaSearchConstants.ANNOTATION_TYPE;
5342
			}
5318
			this.nameEnvironment.findTypes(
5343
			this.nameEnvironment.findTypes(
5319
					qualifiedName,
5344
					qualifiedName,
5320
					false,
5345
					false,
5321
					this.options.camelCaseMatch,
5346
					this.options.camelCaseMatch,
5347
					searchFor,
5322
					this);
5348
					this);
5323
			acceptTypes();
5349
			acceptTypes();
5324
		}
5350
		}
(-)workspace/Completion/src3/pkgannotation/QQAnnotation.java (-4 lines)
Removed Link Here
1
package pkgannotations;
2
@interface QQAnnotation {
3
	
4
}
(-)src/org/eclipse/jdt/core/tests/model/CompletionTests_1_5.java (-29 / +113 lines)
Lines 2091-2151 Link Here
2091
	}
2091
	}
2092
}
2092
}
2093
public void test0075() throws JavaModelException {
2093
public void test0075() throws JavaModelException {
2094
	this.wc = getWorkingCopy(
2094
	this.workingCopies = new ICompilationUnit[2];
2095
	this.workingCopies[0] = getWorkingCopy(
2095
			"/Completion/src3/test0075/Test.java",
2096
			"/Completion/src3/test0075/Test.java",
2096
			"package test0075;\n" +
2097
			"package test0075;\n" +
2097
			"public @QQAnnot class Test {\n" +
2098
			"public @QQAnnot class Test {\n" +
2098
			"}");
2099
			"}");
2099
	
2100
	
2100
	
2101
	this.workingCopies[1] = getWorkingCopy(
2102
		"/Completion/src/pkgannotations/QQAnnotation.java",
2103
		"package pkgannotations;"+
2104
		"public @interface QQAnnotation {\n"+
2105
		"}");
2106
2101
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
2107
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
2102
	String str = this.wc.getSource();
2108
	String str = this.workingCopies[0].getSource();
2103
	String completeBehind = "@QQAnnot";
2109
	String completeBehind = "@QQAnnot";
2104
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2110
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2105
	this.wc.codeComplete(cursorLocation, requestor);
2111
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
2106
2112
2107
	assertResults(
2113
	assertResults(
2108
			"QQAnnotation[TYPE_REF]{pkgannotations.QQAnnotation, pkgannotations, Lpkgannotations.QQAnnotation;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_ANNOTATION + R_NON_RESTRICTED) + "}",
2114
			"QQAnnotation[TYPE_REF]{pkgannotations.QQAnnotation, pkgannotations, Lpkgannotations.QQAnnotation;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_ANNOTATION + R_NON_RESTRICTED) + "}",
2109
			requestor.getResults());
2115
			requestor.getResults());
2110
}
2116
}
2111
public void test0076() throws JavaModelException {
2117
public void test0076() throws JavaModelException {	
2112
	this.wc = getWorkingCopy(
2118
	this.workingCopies = new ICompilationUnit[2];
2119
	this.workingCopies[0] = getWorkingCopy(
2113
			"/Completion/src3/test0076/Test.java",
2120
			"/Completion/src3/test0076/Test.java",
2114
			"package test0076;\n" +
2121
			"package test0076;\n" +
2115
			"public @QQAnnot class Test\n" +
2122
			"public @QQAnnot class Test\n" +
2116
			"");
2123
			"");
2117
	
2124
	
2125
	this.workingCopies[1] = getWorkingCopy(
2126
		"/Completion/src/pkgannotations/QQAnnotation.java",
2127
		"package pkgannotations;"+
2128
		"public @interface QQAnnotation {\n"+
2129
		"}");
2118
	
2130
	
2119
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
2131
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
2120
	String str = this.wc.getSource();
2132
	String str = this.workingCopies[0].getSource();
2121
	String completeBehind = "@QQAnnot";
2133
	String completeBehind = "@QQAnnot";
2122
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2134
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2123
	this.wc.codeComplete(cursorLocation, requestor);
2135
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
2124
2136
2125
	assertResults(
2137
	assertResults(
2126
			"QQAnnotation[TYPE_REF]{pkgannotations.QQAnnotation, pkgannotations, Lpkgannotations.QQAnnotation;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_ANNOTATION + R_NON_RESTRICTED) + "}",
2138
			"QQAnnotation[TYPE_REF]{pkgannotations.QQAnnotation, pkgannotations, Lpkgannotations.QQAnnotation;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_ANNOTATION + R_NON_RESTRICTED) + "}",
2127
			requestor.getResults());
2139
			requestor.getResults());
2128
}
2140
}
2129
public void test0077() throws JavaModelException {
2141
public void test0077() throws JavaModelException {
2130
	this.wc = getWorkingCopy(
2142
	this.workingCopies = new ICompilationUnit[2];
2143
	this.workingCopies[0] = getWorkingCopy(
2131
			"/Completion/src3/test0077/Test.java",
2144
			"/Completion/src3/test0077/Test.java",
2132
			"package test0077;\n" +
2145
			"package test0077;\n" +
2133
			"public @QQAnnot\n" +
2146
			"public @QQAnnot\n" +
2134
			"");
2147
			"");
2135
	
2148
	
2149
	this.workingCopies[1] = getWorkingCopy(
2150
		"/Completion/src/pkgannotations/QQAnnotation.java",
2151
		"package pkgannotations;"+
2152
		"public @interface QQAnnotation {\n"+
2153
		"}");
2154
	
2136
	
2155
	
2137
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
2156
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
2138
	String str = this.wc.getSource();
2157
	String str = this.workingCopies[0].getSource();
2139
	String completeBehind = "@QQAnnot";
2158
	String completeBehind = "@QQAnnot";
2140
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2159
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2141
	this.wc.codeComplete(cursorLocation, requestor);
2160
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
2142
2161
2143
	assertResults(
2162
	assertResults(
2144
			"QQAnnotation[TYPE_REF]{pkgannotations.QQAnnotation, pkgannotations, Lpkgannotations.QQAnnotation;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_ANNOTATION + R_NON_RESTRICTED) + "}",
2163
			"QQAnnotation[TYPE_REF]{pkgannotations.QQAnnotation, pkgannotations, Lpkgannotations.QQAnnotation;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_ANNOTATION + R_NON_RESTRICTED) + "}",
2145
			requestor.getResults());
2164
			requestor.getResults());
2146
}
2165
}
2147
public void test0078() throws JavaModelException {
2166
public void test0078() throws JavaModelException {
2148
	this.wc = getWorkingCopy(
2167
	this.workingCopies = new ICompilationUnit[2];
2168
	this.workingCopies[0] = getWorkingCopy(
2149
			"/Completion/src3/test0078/Test.java",
2169
			"/Completion/src3/test0078/Test.java",
2150
			"package test0078;\n" +
2170
			"package test0078;\n" +
2151
			"public class Test {\n" +
2171
			"public class Test {\n" +
Lines 2153-2259 Link Here
2153
			"  }\n" +
2173
			"  }\n" +
2154
			"}");
2174
			"}");
2155
	
2175
	
2176
	this.workingCopies[1] = getWorkingCopy(
2177
		"/Completion/src/pkgannotations/QQAnnotation.java",
2178
		"package pkgannotations;"+
2179
		"public @interface QQAnnotation {\n"+
2180
		"}");
2156
	
2181
	
2157
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
2182
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
2158
	String str = this.wc.getSource();
2183
	String str = this.workingCopies[0].getSource();
2159
	String completeBehind = "@QQAnnot";
2184
	String completeBehind = "@QQAnnot";
2160
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2185
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2161
	this.wc.codeComplete(cursorLocation, requestor);
2186
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
2162
2187
2163
	assertResults(
2188
	assertResults(
2164
			"QQAnnotation[TYPE_REF]{pkgannotations.QQAnnotation, pkgannotations, Lpkgannotations.QQAnnotation;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_ANNOTATION + R_NON_RESTRICTED) + "}",
2189
			"QQAnnotation[TYPE_REF]{pkgannotations.QQAnnotation, pkgannotations, Lpkgannotations.QQAnnotation;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_ANNOTATION + R_NON_RESTRICTED) + "}",
2165
			requestor.getResults());
2190
			requestor.getResults());
2166
}
2191
}
2167
public void test0079() throws JavaModelException {
2192
public void test0079() throws JavaModelException {
2168
	this.wc = getWorkingCopy(
2193
	this.workingCopies = new ICompilationUnit[2];
2194
	this.workingCopies[0] = getWorkingCopy(
2169
			"/Completion/src3/test0078/Test.java",
2195
			"/Completion/src3/test0078/Test.java",
2170
			"package test0078;\n" +
2196
			"package test0078;\n" +
2171
			"public class Test {\n" +
2197
			"public class Test {\n" +
2172
			"  public @QQAnnot void foo(\n" +
2198
			"  public @QQAnnot void foo(\n" +
2173
			"}");
2199
			"}");
2174
	
2200
	
2201
	this.workingCopies[1] = getWorkingCopy(
2202
		"/Completion/src/pkgannotations/QQAnnotation.java",
2203
		"package pkgannotations;"+
2204
		"public @interface QQAnnotation {\n"+
2205
		"}");
2175
	
2206
	
2176
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
2207
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
2177
	String str = this.wc.getSource();
2208
	String str = this.workingCopies[0].getSource();
2178
	String completeBehind = "@QQAnnot";
2209
	String completeBehind = "@QQAnnot";
2179
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2210
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2180
	this.wc.codeComplete(cursorLocation, requestor);
2211
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
2181
2212
2182
	assertResults(
2213
	assertResults(
2183
			"QQAnnotation[TYPE_REF]{pkgannotations.QQAnnotation, pkgannotations, Lpkgannotations.QQAnnotation;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_ANNOTATION + R_NON_RESTRICTED) + "}",
2214
			"QQAnnotation[TYPE_REF]{pkgannotations.QQAnnotation, pkgannotations, Lpkgannotations.QQAnnotation;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_ANNOTATION + R_NON_RESTRICTED) + "}",
2184
			requestor.getResults());
2215
			requestor.getResults());
2185
}
2216
}
2186
public void test0080() throws JavaModelException {
2217
public void test0080() throws JavaModelException {
2187
	this.wc = getWorkingCopy(
2218
	this.workingCopies = new ICompilationUnit[2];
2219
	this.workingCopies[0] = getWorkingCopy(
2188
			"/Completion/src3/test0078/Test.java",
2220
			"/Completion/src3/test0078/Test.java",
2189
			"package test0078;\n" +
2221
			"package test0078;\n" +
2190
			"public class Test {\n" +
2222
			"public class Test {\n" +
2191
			"  public @QQAnnot int var;\n" +
2223
			"  public @QQAnnot int var;\n" +
2192
			"}");
2224
			"}");
2193
	
2225
	
2226
	this.workingCopies[1] = getWorkingCopy(
2227
		"/Completion/src/pkgannotations/QQAnnotation.java",
2228
		"package pkgannotations;"+
2229
		"public @interface QQAnnotation {\n"+
2230
		"}");
2194
	
2231
	
2195
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
2232
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
2196
	String str = this.wc.getSource();
2233
	String str = this.workingCopies[0].getSource();
2197
	String completeBehind = "@QQAnnot";
2234
	String completeBehind = "@QQAnnot";
2198
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2235
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2199
	this.wc.codeComplete(cursorLocation, requestor);
2236
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
2200
2237
2201
	assertResults(
2238
	assertResults(
2202
			"QQAnnotation[TYPE_REF]{pkgannotations.QQAnnotation, pkgannotations, Lpkgannotations.QQAnnotation;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_ANNOTATION + R_NON_RESTRICTED) + "}",
2239
			"QQAnnotation[TYPE_REF]{pkgannotations.QQAnnotation, pkgannotations, Lpkgannotations.QQAnnotation;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_ANNOTATION + R_NON_RESTRICTED) + "}",
2203
			requestor.getResults());
2240
			requestor.getResults());
2204
}
2241
}
2205
public void test0081() throws JavaModelException {
2242
public void test0081() throws JavaModelException {
2206
	this.wc = getWorkingCopy(
2243
	this.workingCopies = new ICompilationUnit[2];
2244
	this.workingCopies[0] = getWorkingCopy(
2207
			"/Completion/src3/test0078/Test.java",
2245
			"/Completion/src3/test0078/Test.java",
2208
			"package test0078;\n" +
2246
			"package test0078;\n" +
2209
			"public class Test {\n" +
2247
			"public class Test {\n" +
2210
			"  public @QQAnnot int var\n" +
2248
			"  public @QQAnnot int var\n" +
2211
			"}");
2249
			"}");
2212
	
2250
	
2251
	this.workingCopies[1] = getWorkingCopy(
2252
		"/Completion/src/pkgannotations/QQAnnotation.java",
2253
		"package pkgannotations;"+
2254
		"public @interface QQAnnotation {\n"+
2255
		"}");
2213
	
2256
	
2214
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
2257
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
2215
	String str = this.wc.getSource();
2258
	String str = this.workingCopies[0].getSource();
2216
	String completeBehind = "@QQAnnot";
2259
	String completeBehind = "@QQAnnot";
2217
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2260
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2218
	this.wc.codeComplete(cursorLocation, requestor);
2261
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
2219
2262
2220
	assertResults(
2263
	assertResults(
2221
			"QQAnnotation[TYPE_REF]{pkgannotations.QQAnnotation, pkgannotations, Lpkgannotations.QQAnnotation;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_ANNOTATION + R_NON_RESTRICTED) + "}",
2264
			"QQAnnotation[TYPE_REF]{pkgannotations.QQAnnotation, pkgannotations, Lpkgannotations.QQAnnotation;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_ANNOTATION + R_NON_RESTRICTED) + "}",
2222
			requestor.getResults());
2265
			requestor.getResults());
2223
}
2266
}
2224
public void test0082() throws JavaModelException {
2267
public void test0082() throws JavaModelException {
2225
	this.wc = getWorkingCopy(
2268
	this.workingCopies = new ICompilationUnit[2];
2269
	this.workingCopies[0] = getWorkingCopy(
2226
			"/Completion/src3/test0078/Test.java",
2270
			"/Completion/src3/test0078/Test.java",
2227
			"package test0078;\n" +
2271
			"package test0078;\n" +
2228
			"public class Test {\n" +
2272
			"public class Test {\n" +
2229
			"  void foo(@QQAnnot int i) {}\n" +
2273
			"  void foo(@QQAnnot int i) {}\n" +
2230
			"}");
2274
			"}");
2231
	
2275
	
2276
	this.workingCopies[1] = getWorkingCopy(
2277
		"/Completion/src/pkgannotations/QQAnnotation.java",
2278
		"package pkgannotations;"+
2279
		"public @interface QQAnnotation {\n"+
2280
		"}");
2281
	
2232
	
2282
	
2233
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
2283
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
2234
	String str = this.wc.getSource();
2284
	String str = this.workingCopies[0].getSource();
2235
	String completeBehind = "@QQAnnot";
2285
	String completeBehind = "@QQAnnot";
2236
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2286
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2237
	this.wc.codeComplete(cursorLocation, requestor);
2287
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
2238
2288
2239
	assertResults(
2289
	assertResults(
2240
			"QQAnnotation[TYPE_REF]{pkgannotations.QQAnnotation, pkgannotations, Lpkgannotations.QQAnnotation;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_ANNOTATION + R_NON_RESTRICTED) + "}",
2290
			"QQAnnotation[TYPE_REF]{pkgannotations.QQAnnotation, pkgannotations, Lpkgannotations.QQAnnotation;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_ANNOTATION + R_NON_RESTRICTED) + "}",
2241
			requestor.getResults());
2291
			requestor.getResults());
2242
}
2292
}
2243
public void test0083() throws JavaModelException {
2293
public void test0083() throws JavaModelException {
2244
	this.wc = getWorkingCopy(
2294
	this.workingCopies = new ICompilationUnit[2];
2295
	this.workingCopies[0] = getWorkingCopy(
2245
			"/Completion/src3/test0078/Test.java",
2296
			"/Completion/src3/test0078/Test.java",
2246
			"package test0078;\n" +
2297
			"package test0078;\n" +
2247
			"public class Test {\n" +
2298
			"public class Test {\n" +
2248
			"  void foo() {@QQAnnot int i}\n" +
2299
			"  void foo() {@QQAnnot int i}\n" +
2249
			"}");
2300
			"}");
2250
	
2301
	
2302
	this.workingCopies[1] = getWorkingCopy(
2303
		"/Completion/src/pkgannotations/QQAnnotation.java",
2304
		"package pkgannotations;"+
2305
		"public @interface QQAnnotation {\n"+
2306
		"}");
2307
	
2251
	
2308
	
2252
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
2309
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
2253
	String str = this.wc.getSource();
2310
	String str = this.workingCopies[0].getSource();
2254
	String completeBehind = "@QQAnnot";
2311
	String completeBehind = "@QQAnnot";
2255
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2312
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2256
	this.wc.codeComplete(cursorLocation, requestor);
2313
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
2257
2314
2258
	assertResults(
2315
	assertResults(
2259
			"QQAnnotation[TYPE_REF]{pkgannotations.QQAnnotation, pkgannotations, Lpkgannotations.QQAnnotation;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_ANNOTATION + R_NON_RESTRICTED) + "}",
2316
			"QQAnnotation[TYPE_REF]{pkgannotations.QQAnnotation, pkgannotations, Lpkgannotations.QQAnnotation;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_ANNOTATION + R_NON_RESTRICTED) + "}",
Lines 8926-8931 Link Here
8926
			"test0.test1[PACKAGE_REF]{test0.test1., test0.test1, null, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}",
8983
			"test0.test1[PACKAGE_REF]{test0.test1., test0.test1, null, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}",
8927
			requestor.getResults());
8984
			requestor.getResults());
8928
}
8985
}
8986
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=129983
8987
public void test0290() throws JavaModelException {
8988
	this.workingCopies = new ICompilationUnit[2];
8989
	this.workingCopies[0] = getWorkingCopy(
8990
			"/Completion/src3/test0290/Test.java",
8991
			"package test0290;\n" +
8992
			"@\n" +
8993
			"public class Test {\n" +
8994
			"}");
8995
	
8996
	this.workingCopies[1] = getWorkingCopy(
8997
		"/Completion/src/pkgannotations/QQAnnotation.java",
8998
		"package pkgannotations;"+
8999
		"public @interface QQAnnotation {\n"+
9000
		"}");
9001
	
9002
	
9003
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
9004
	String str = this.workingCopies[0].getSource();
9005
	String completeBehind = "@";
9006
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9007
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
9008
9009
	assertResults(
9010
			"QQAnnotation[TYPE_REF]{pkgannotations.QQAnnotation, pkgannotations, Lpkgannotations.QQAnnotation;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_ANNOTATION + R_NON_RESTRICTED) + "}",
9011
			requestor.getResults());
9012
}
8929
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=153130
9013
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=153130
8930
public void testEC001() throws JavaModelException {
9014
public void testEC001() throws JavaModelException {
8931
	this.workingCopies = new ICompilationUnit[1];
9015
	this.workingCopies = new ICompilationUnit[1];

Return to bug 129983