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

Collapse All | Expand All

(-)model/org/eclipse/jdt/core/CompletionRequestor.java (+35 lines)
Lines 60-65 Link Here
60
	 */
60
	 */
61
	private int ignoreSet = 0;
61
	private int ignoreSet = 0;
62
	
62
	
63
	private String[] favoriteReferences;
64
	
63
	/**
65
	/**
64
	 * The set of CompletionProposal kinds that this requestor
66
	 * The set of CompletionProposal kinds that this requestor
65
	 * allows for required proposals; <code>0</code> means the set is empty.
67
	 * allows for required proposals; <code>0</code> means the set is empty.
Lines 194-199 Link Here
194
	}
196
	}
195
	
197
	
196
	/**
198
	/**
199
	 * Returns the favorites references which are used to compute some completion proposals.
200
	 * <p>
201
	 * A favorite reference is a qualified reference as it can be seen in an import statement.<br>
202
	 * e.g. <code>{"java.util.Arrays"}</code><br>
203
	 * It can be an on demand reference.<br>
204
	 * e.g. <code>{"java.util.Arrays.*"}</code>
205
	 * It can be a reference to a static method or field (as in a static import)<br>
206
	 * e.g. <code>{"java.util.Arrays.equals"}</code>
207
	 * </p>
208
	 *
209
	 * @return favorites imports
210
	 * 
211
	 * @since 3.3
212
	 */
213
	public String[] getFavoriteReferences() {
214
		return this.favoriteReferences;
215
	}
216
	
217
	/**
218
	 * Set the favorites references which will be used to compute some completion proposals.
219
	 * A favorite reference is a qualified reference as it can be seen in an import statement.<br>
220
	 * 
221
	 * @param favoriteImports
222
	 * 
223
	 * @see #getFavoriteReferences()
224
	 * 
225
	 * @since 3.3
226
	 */
227
	public void setFavoriteReferences(String[] favoriteImports) {
228
		this.favoriteReferences = favoriteImports;
229
	}
230
	
231
	/**
197
	 * Pro forma notification sent before reporting a batch of
232
	 * Pro forma notification sent before reporting a batch of
198
	 * completion proposals.
233
	 * completion proposals.
199
	 * <p>
234
	 * <p>
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/CompilationUnitScope.java (+8 lines)
Lines 428-433 Link Here
428
	for (int i = 0, length = topLevelTypes.length; i < length; i++)
428
	for (int i = 0, length = topLevelTypes.length; i < length; i++)
429
		topLevelTypes[i].faultInTypesForFieldsAndMethods();
429
		topLevelTypes[i].faultInTypesForFieldsAndMethods();
430
}
430
}
431
// this API is for code assist purpose
432
public Binding findImport(char[][] compoundName, boolean findStaticImports, boolean onDemand) {
433
	if(onDemand) {
434
		return findImport(compoundName, compoundName.length);
435
	} else {
436
		return findSingleImport(compoundName, findStaticImports);
437
	}
438
}
431
private Binding findImport(char[][] compoundName, int length) {
439
private Binding findImport(char[][] compoundName, int length) {
432
	recordQualifiedReference(compoundName);
440
	recordQualifiedReference(compoundName);
433
441
(-)codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java (+385 lines)
Lines 230-235 Link Here
230
	int forbbidenBindingsPtr = -1;
230
	int forbbidenBindingsPtr = -1;
231
	Binding[] forbbidenBindings = new Binding[1];
231
	Binding[] forbbidenBindings = new Binding[1];
232
	
232
	
233
	ImportBinding[] favoriteReferenceBindings;
234
	
233
	boolean assistNodeIsClass;
235
	boolean assistNodeIsClass;
234
	boolean assistNodeIsEnum;
236
	boolean assistNodeIsEnum;
235
	boolean assistNodeIsException;
237
	boolean assistNodeIsException;
Lines 3073-3078 Link Here
3073
		}
3075
		}
3074
	}
3076
	}
3075
	
3077
	
3078
	private void findFieldsAndMethodsFromFavorites(
3079
			char[] token,
3080
			Scope scope,
3081
			InvocationSite invocationSite,
3082
			Scope invocationScope,
3083
			ObjectVector localsFound,
3084
			ObjectVector fieldsFound,
3085
			ObjectVector methodsFound) {
3086
		
3087
		ImportBinding[] favoriteBindings = getFavoriteReferenceBindings(invocationScope);
3088
		
3089
		if (favoriteBindings != null && favoriteBindings.length > 0) {
3090
			for (int i = 0; i < favoriteBindings.length; i++) {
3091
				ImportBinding favoriteBinding = favoriteBindings[i];
3092
				switch (favoriteBinding.resolvedImport.kind()) {
3093
					case Binding.FIELD:
3094
						FieldBinding fieldBinding = (FieldBinding) favoriteBinding.resolvedImport;
3095
						findFieldsFromFavorites(
3096
								token,
3097
								new FieldBinding[]{fieldBinding},
3098
								scope,
3099
								fieldsFound,
3100
								localsFound,
3101
								fieldBinding.declaringClass,
3102
								invocationSite,
3103
								invocationScope);
3104
						break;
3105
					case Binding.METHOD:
3106
						MethodBinding methodBinding = (MethodBinding) favoriteBinding.resolvedImport;
3107
						MethodBinding[] methods = methodBinding.declaringClass.availableMethods();
3108
						long range;
3109
						if ((range = ReferenceBinding.binarySearch(methodBinding.selector, methods)) >= 0) {
3110
							int start = (int) range, end = (int) (range >> 32);
3111
							int length = end - start + 1;
3112
							System.arraycopy(methods, start, methods = new MethodBinding[length], 0, length);
3113
						} else {
3114
							methods = Binding.NO_METHODS;			
3115
						}
3116
						findLocalMethodsFromFavorites(
3117
								token,
3118
								methods,
3119
								scope,
3120
								methodsFound,
3121
								methodBinding.declaringClass,
3122
								invocationSite,
3123
								invocationScope);
3124
						break;
3125
					case Binding.TYPE:
3126
						ReferenceBinding referenceBinding = (ReferenceBinding) favoriteBinding.resolvedImport;
3127
						if(favoriteBinding.onDemand) {
3128
							findFieldsFromFavorites(
3129
									token,
3130
									referenceBinding.availableFields(),
3131
									scope,
3132
									fieldsFound,
3133
									localsFound,
3134
									referenceBinding,
3135
									invocationSite,
3136
									invocationScope);
3137
							
3138
							findLocalMethodsFromFavorites(
3139
									token,
3140
									referenceBinding.availableMethods(),
3141
									scope,
3142
									methodsFound,
3143
									referenceBinding,
3144
									invocationSite,
3145
									invocationScope);
3146
						}
3147
						break;
3148
				}
3149
			}
3150
		}
3151
	}
3152
	
3076
	private void findFieldsAndMethodsFromMissingFieldType(
3153
	private void findFieldsAndMethodsFromMissingFieldType(
3077
		char[] token,
3154
		char[] token,
3078
		Scope scope,
3155
		Scope scope,
Lines 3240-3245 Link Here
3240
		missingTypesConverter.guess(typeRef, scope, substitutionRequestor);
3317
		missingTypesConverter.guess(typeRef, scope, substitutionRequestor);
3241
	}
3318
	}
3242
	
3319
	
3320
	private void findFieldsFromFavorites(
3321
			char[] fieldName,
3322
			FieldBinding[] fields,
3323
			Scope scope,
3324
			ObjectVector fieldsFound,
3325
			ObjectVector localsFound,
3326
			ReferenceBinding receiverType,
3327
			InvocationSite invocationSite,
3328
			Scope invocationScope) {
3329
		
3330
		char[] typeName = CharOperation.concatWith(receiverType.compoundName, '.');
3331
3332
		int fieldLength = fieldName.length;
3333
		next : for (int f = fields.length; --f >= 0;) {			
3334
			FieldBinding field = fields[f];
3335
3336
			if (field.isSynthetic())	continue next;
3337
			
3338
			// only static fields must be proposed
3339
			if (!field.isStatic()) continue next;
3340
3341
			if (fieldLength > field.name.length) continue next;
3342
3343
			if (!CharOperation.prefixEquals(fieldName, field.name, false /* ignore case */)
3344
					&& !(this.options.camelCaseMatch && CharOperation.camelCaseMatch(fieldName, field.name)))	continue next;
3345
3346
			if (this.options.checkDeprecation &&
3347
					field.isViewedAsDeprecated() &&
3348
					!scope.isDefinedInSameUnit(field.declaringClass))
3349
				continue next;
3350
			
3351
			if (this.options.checkVisibility
3352
				&& !field.canBeSeenBy(receiverType, invocationSite, scope))	continue next;
3353
			
3354
			for (int i = fieldsFound.size; --i >= 0;) {
3355
				Object[] other = (Object[])fieldsFound.elementAt(i);
3356
				FieldBinding otherField = (FieldBinding) other[0];
3357
				
3358
				if (field == otherField) continue next;
3359
			}
3360
			
3361
			fieldsFound.add(new Object[]{field, receiverType});
3362
			
3363
			char[] completion = CharOperation.concat(typeName, field.name, '.');
3364
3365
			int relevance = computeBaseRelevance();
3366
			relevance += computeRelevanceForInterestingProposal(field);
3367
			if (fieldName != null) relevance += computeRelevanceForCaseMatching(fieldName, field.name);
3368
			relevance += computeRelevanceForExpectingType(field.type);
3369
			relevance += computeRelevanceForStatic(true, true);
3370
			relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE);
3371
			
3372
			this.noProposal = false;
3373
			
3374
			if (!this.isIgnored(CompletionProposal.FIELD_REF)) {
3375
				CompletionProposal proposal = this.createProposal(CompletionProposal.FIELD_REF, this.actualCompletionPosition);
3376
				proposal.setDeclarationSignature(getSignature(field.declaringClass));
3377
				proposal.setSignature(getSignature(field.type));
3378
				proposal.setDeclarationPackageName(field.declaringClass.qualifiedPackageName());
3379
				proposal.setDeclarationTypeName(field.declaringClass.qualifiedSourceName());
3380
				proposal.setPackageName(field.type.qualifiedPackageName());
3381
				proposal.setTypeName(field.type.qualifiedSourceName()); 
3382
				proposal.setName(field.name);
3383
				proposal.setCompletion(completion);
3384
				proposal.setFlags(field.modifiers);
3385
				proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset);
3386
				proposal.setRelevance(relevance);
3387
				this.requestor.accept(proposal);
3388
				if(DEBUG) {
3389
					this.printDebug(proposal);
3390
				}
3391
			}
3392
		}
3393
	}
3394
	
3243
	private void findImports(CompletionOnImportReference importReference, boolean findMembers) {
3395
	private void findImports(CompletionOnImportReference importReference, boolean findMembers) {
3244
		char[][] tokens = importReference.tokens;
3396
		char[][] tokens = importReference.tokens;
3245
			
3397
			
Lines 4485-4490 Link Here
4485
		methodsFound.addAll(newMethodsFound);
4637
		methodsFound.addAll(newMethodsFound);
4486
	}
4638
	}
4487
	
4639
	
4640
	private void findLocalMethodsFromFavorites(
4641
			char[] methodName,
4642
			MethodBinding[] methods,
4643
			Scope scope,
4644
			ObjectVector methodsFound,
4645
			ReferenceBinding receiverType,
4646
			InvocationSite invocationSite,
4647
			Scope invocationScope) {
4648
		
4649
			char[] typeName = CharOperation.concatWith(receiverType.compoundName, '.');
4650
4651
			int methodLength = methodName.length;
4652
4653
			next : for (int f = methods.length; --f >= 0;) {
4654
				MethodBinding method = methods[f];
4655
4656
				if (method.isSynthetic()) continue next;
4657
4658
				if (method.isDefaultAbstract())	continue next;
4659
4660
				if (method.isConstructor()) continue next;
4661
				
4662
				if (this.options.checkDeprecation &&
4663
						method.isViewedAsDeprecated() &&
4664
						!scope.isDefinedInSameUnit(method.declaringClass))
4665
					continue next;
4666
				
4667
				if (!method.isStatic()) continue next;
4668
4669
				if (this.options.checkVisibility
4670
					&& !method.canBeSeenBy(receiverType, invocationSite, scope)) continue next;
4671
4672
				if (methodLength > method.selector.length) continue next;
4673
					
4674
				if (!CharOperation.prefixEquals(methodName, method.selector, false /* ignore case */)
4675
						&& !(this.options.camelCaseMatch && CharOperation.camelCaseMatch(methodName, method.selector))) {
4676
					continue next;
4677
				}
4678
				
4679
				for (int i = methodsFound.size; --i >= 0;) {
4680
					Object[] other = (Object[]) methodsFound.elementAt(i);
4681
					MethodBinding otherMethod = (MethodBinding) other[0];
4682
					
4683
					if (method == otherMethod) continue next;
4684
				}
4685
				
4686
				methodsFound.add(new Object[]{method, receiverType});
4687
				
4688
				ReferenceBinding superTypeWithSameErasure = (ReferenceBinding)receiverType.findSuperTypeWithSameErasure(method.declaringClass);
4689
				if (method.declaringClass != superTypeWithSameErasure) {
4690
					MethodBinding[] otherMethods = superTypeWithSameErasure.getMethods(method.selector);
4691
					for (int i = 0; i < otherMethods.length; i++) {
4692
						if(otherMethods[i].original() == method.original()) {
4693
							method = otherMethods[i];
4694
						}
4695
					}
4696
				}
4697
				
4698
				int length = method.parameters.length;
4699
				char[][] parameterPackageNames = new char[length][];
4700
				char[][] parameterTypeNames = new char[length][];
4701
4702
				for (int i = 0; i < length; i++) {
4703
					TypeBinding type = method.original().parameters[i];
4704
					parameterPackageNames[i] = type.qualifiedPackageName();
4705
					parameterTypeNames[i] = type.qualifiedSourceName();
4706
				}
4707
				char[][] parameterNames = findMethodParameterNames(method,parameterTypeNames);
4708
4709
				char[] completion = CharOperation.NO_CHAR;
4710
				
4711
				int previousStartPosition = this.startPosition;
4712
				
4713
				if (this.source != null
4714
					&& this.source.length > this.endPosition
4715
					&& this.source[this.endPosition] == '(') {
4716
					completion = method.selector;
4717
				} else {
4718
					completion = CharOperation.concat(method.selector, new char[] { '(', ')' });
4719
				}
4720
				
4721
				completion = CharOperation.concat(typeName, completion, '.');
4722
4723
				int relevance = computeBaseRelevance();
4724
				relevance += computeRelevanceForInterestingProposal();
4725
				if (methodName != null) relevance += computeRelevanceForCaseMatching(methodName, method.selector);
4726
				relevance += computeRelevanceForExpectingType(method.returnType);
4727
				relevance += computeRelevanceForStatic(true, method.isStatic());
4728
				relevance += computeRelevanceForQualification(true);
4729
				relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE);
4730
4731
				
4732
				this.noProposal = false;
4733
				// Standard proposal
4734
				if(!this.isIgnored(CompletionProposal.METHOD_REF)) {
4735
					CompletionProposal proposal = this.createProposal(CompletionProposal.METHOD_REF, this.actualCompletionPosition);
4736
					proposal.setDeclarationSignature(getSignature(method.declaringClass));
4737
					proposal.setSignature(getSignature(method));
4738
					MethodBinding original = method.original();
4739
					if(original != method) {
4740
						proposal.setOriginalSignature(getSignature(original));
4741
					}
4742
					proposal.setDeclarationPackageName(method.declaringClass.qualifiedPackageName());
4743
					proposal.setDeclarationTypeName(method.declaringClass.qualifiedSourceName());
4744
					proposal.setParameterPackageNames(parameterPackageNames);
4745
					proposal.setParameterTypeNames(parameterTypeNames);
4746
					proposal.setPackageName(method.returnType.qualifiedPackageName());
4747
					proposal.setTypeName(method.returnType.qualifiedSourceName());
4748
					proposal.setName(method.selector);
4749
					proposal.setCompletion(completion);
4750
					proposal.setFlags(method.modifiers);
4751
					proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset);
4752
					proposal.setRelevance(relevance);
4753
					if(parameterNames != null) proposal.setParameterNames(parameterNames);
4754
					this.requestor.accept(proposal);
4755
					if(DEBUG) {
4756
						this.printDebug(proposal);
4757
					}
4758
				}
4759
				
4760
				this.startPosition = previousStartPosition;
4761
			}
4762
		}
4763
	
4488
	private CompletionProposal createRequiredTypeProposal(Binding binding, int start, int end, int relevance) {
4764
	private CompletionProposal createRequiredTypeProposal(Binding binding, int start, int end, int relevance) {
4489
		CompletionProposal proposal = null;
4765
		CompletionProposal proposal = null;
4490
		if (binding instanceof ReferenceBinding) {
4766
		if (binding instanceof ReferenceBinding) {
Lines 4525-4532 Link Here
4525
		char[] methodName,
4801
		char[] methodName,
4526
		MethodBinding[] methods,
4802
		MethodBinding[] methods,
4527
		Scope scope,
4803
		Scope scope,
4804
		ObjectVector methodsFound,
4528
		ReferenceBinding receiverType,
4805
		ReferenceBinding receiverType,
4529
		InvocationSite invocationSite) {
4806
		InvocationSite invocationSite) {
4807
		
4808
		ObjectVector newMethodsFound =  new ObjectVector();
4530
4809
4531
		next : for (int f = methods.length; --f >= 0;) {
4810
		next : for (int f = methods.length; --f >= 0;) {
4532
			MethodBinding method = methods[f];
4811
			MethodBinding method = methods[f];
Lines 4550-4555 Link Here
4550
			if (!CharOperation.equals(methodName, method.selector, false /* ignore case */)
4829
			if (!CharOperation.equals(methodName, method.selector, false /* ignore case */)
4551
					&& !(this.options.camelCaseMatch && CharOperation.camelCaseMatch(methodName, method.selector)))
4830
					&& !(this.options.camelCaseMatch && CharOperation.camelCaseMatch(methodName, method.selector)))
4552
				continue next;
4831
				continue next;
4832
			
4833
			for (int i = methodsFound.size; --i >= 0;) {
4834
				Object[] other = (Object[]) methodsFound.elementAt(i);
4835
				MethodBinding otherMethod = (MethodBinding) other[0];
4836
				ReferenceBinding otherReceiverType = (ReferenceBinding) other[1];
4837
				if (method == otherMethod && receiverType == otherReceiverType)
4838
					continue next;
4839
				
4840
				if (CharOperation.equals(method.selector, otherMethod.selector, true)) {
4841
					if (lookupEnvironment.methodVerifier().doesMethodOverride(otherMethod, method)) {
4842
						continue next;
4843
					}
4844
				}
4845
			}
4846
4847
			newMethodsFound.add(new Object[]{method, receiverType});
4553
4848
4554
			int length = method.parameters.length;
4849
			int length = method.parameters.length;
4555
			char[][] parameterPackageNames = new char[length][];
4850
			char[][] parameterPackageNames = new char[length][];
Lines 4611-4616 Link Here
4611
			}
4906
			}
4612
			this.startPosition = previousStartPosition;
4907
			this.startPosition = previousStartPosition;
4613
		}
4908
		}
4909
		
4910
		methodsFound.addAll(newMethodsFound);
4614
	}
4911
	}
4615
	int computeRelevanceForCaseMatching(char[] token, char[] proposalName){
4912
	int computeRelevanceForCaseMatching(char[] token, char[] proposalName){
4616
		if (this.options.camelCaseMatch) {
4913
		if (this.options.camelCaseMatch) {
Lines 5103-5108 Link Here
5103
			(missingTypes && !this.requestor.isAllowingRequiredProposals(kind, CompletionProposal.TYPE_REF));
5400
			(missingTypes && !this.requestor.isAllowingRequiredProposals(kind, CompletionProposal.TYPE_REF));
5104
	}
5401
	}
5105
	
5402
	
5403
	private boolean isIgnored(int kind) {
5404
		return this.requestor.isIgnored(kind);
5405
	}
5406
	
5106
	private void findMethods(
5407
	private void findMethods(
5107
		char[] selector,
5408
		char[] selector,
5108
		TypeBinding[] typeArgTypes,
5409
		TypeBinding[] typeArgTypes,
Lines 6173-6178 Link Here
6173
				currentScope = currentScope.parent;
6474
				currentScope = currentScope.parent;
6174
			}
6475
			}
6175
			
6476
			
6477
			// search in static import
6176
			ImportBinding[] importBindings = scope.compilationUnitScope().imports;
6478
			ImportBinding[] importBindings = scope.compilationUnitScope().imports;
6177
			for (int i = 0; i < importBindings.length; i++) {
6479
			for (int i = 0; i < importBindings.length; i++) {
6178
				ImportBinding importBinding = importBindings[i];
6480
				ImportBinding importBinding = importBindings[i];
Lines 6249-6254 Link Here
6249
											methodBinding.selector,
6551
											methodBinding.selector,
6250
											methodBinding.declaringClass.methods(),
6552
											methodBinding.declaringClass.methods(),
6251
											scope,
6553
											scope,
6554
											methodsFound,
6252
											methodBinding.declaringClass,
6555
											methodBinding.declaringClass,
6253
											invocationSite);
6556
											invocationSite);
6254
								}
6557
								}
Lines 6257-6262 Link Here
6257
					}
6560
					}
6258
				}
6561
				}
6259
			}
6562
			}
6563
			
6564
			if (this.assistNodeInJavadoc == 0) {
6565
				// search in favorites import
6566
				findFieldsAndMethodsFromFavorites(
6567
						token,
6568
						scope,
6569
						invocationSite,
6570
						invocationScope,
6571
						localsFound,
6572
						fieldsFound,
6573
						methodsFound);
6574
			}
6260
		}
6575
		}
6261
	}
6576
	}
6262
	private char[][] findVariableFromUnresolvedReference(LocalDeclaration variable, BlockScope scope, final char[][] discouragedNames) {
6577
	private char[][] findVariableFromUnresolvedReference(LocalDeclaration variable, BlockScope scope, final char[][] discouragedNames) {
Lines 6495-6500 Link Here
6495
		}*/
6810
		}*/
6496
	}
6811
	}
6497
	
6812
	
6813
	private ImportBinding[] getFavoriteReferenceBindings(Scope scope) {
6814
		if (this.favoriteReferenceBindings != null) return this.favoriteReferenceBindings;
6815
		
6816
		String[] favoriteReferences = this.requestor.getFavoriteReferences();
6817
		
6818
		if (favoriteReferences == null || favoriteReferences.length == 0) return null;
6819
		
6820
		ImportBinding[] resolvedImports = new ImportBinding[favoriteReferences.length];
6821
		
6822
		int count = 0;
6823
		next : for (int i = 0; i < favoriteReferences.length; i++) {
6824
			String favoriteReference = favoriteReferences[i];
6825
			
6826
			int length;
6827
			if (favoriteReference == null || (length = favoriteReference.length()) == 0) continue next;
6828
			
6829
			boolean onDemand = favoriteReference.charAt(length - 1) == '*';
6830
			
6831
			char[][] compoundName = CharOperation.splitOn('.', favoriteReference.toCharArray());
6832
			if (onDemand) {
6833
				compoundName = CharOperation.subarray(compoundName, 0, compoundName.length - 1);
6834
			}
6835
			
6836
			// remove duplicate and conflicting
6837
			for (int j = 0; j < count; j++) {
6838
				ImportReference f = resolvedImports[j].reference;
6839
				
6840
				if (CharOperation.equals(f.tokens, compoundName)) continue next;
6841
				
6842
				if (!onDemand && !f.onDemand) {
6843
					if (CharOperation.equals(f.tokens[f.tokens.length - 1], compoundName[compoundName.length - 1]))
6844
						continue next;
6845
				}
6846
			}
6847
			
6848
			boolean isStatic = this.compilerOptions.sourceLevel > ClassFileConstants.JDK1_4;
6849
			
6850
			ImportReference importReference =
6851
				new ImportReference(
6852
						compoundName,
6853
						new long[compoundName.length],
6854
						onDemand,
6855
						isStatic ? ClassFileConstants.AccStatic : ClassFileConstants.AccDefault);
6856
			
6857
			Binding importBinding = this.unitScope.findImport(compoundName, isStatic, onDemand);
6858
			
6859
			if (!importBinding.isValidBinding()) {
6860
				continue next;
6861
			}
6862
			
6863
			if (onDemand) {
6864
				if (importReference.isStatic() && importBinding instanceof PackageBinding) {
6865
					importReference.modifiers = importReference.modifiers & ~ClassFileConstants.AccStatic;
6866
				}
6867
			} else {
6868
				if (importBinding instanceof PackageBinding) {
6869
					continue next;
6870
				}
6871
			}
6872
			
6873
			resolvedImports[count++] =
6874
				new ImportBinding(compoundName, onDemand, importBinding, importReference);
6875
		}
6876
		
6877
		if (resolvedImports.length > count)
6878
			System.arraycopy(resolvedImports, 0, resolvedImports = new ImportBinding[count], 0, count);
6879
		
6880
		return this.favoriteReferenceBindings = resolvedImports;
6881
	}
6882
	
6498
	public AssistParser getParser() {
6883
	public AssistParser getParser() {
6499
6884
6500
		return this.parser;
6885
		return this.parser;
(-)src/org/eclipse/jdt/core/tests/model/CompletionTests.java (+510 lines)
Lines 13343-13346 Link Here
13343
			"zzzzzz[FIELD_REF]{zzzzzz, Ltest.Test;, I, zzzzzz, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
13343
			"zzzzzz[FIELD_REF]{zzzzzz, Ltest.Test;, I, zzzzzz, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
13344
			requestor.getResults());
13344
			requestor.getResults());
13345
}
13345
}
13346
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
13347
public void testFavoriteImports001() throws JavaModelException {
13348
	this.workingCopies = new ICompilationUnit[2];
13349
	this.workingCopies[0] = getWorkingCopy(
13350
			"/Completion/src3/test/Test.java",
13351
			"package test;\n" +
13352
			"public class Test {\n" +
13353
			"    public void method() {\n" +
13354
			"        foo\n" +
13355
			"    }\n" +
13356
			"}");
13357
	
13358
	this.workingCopies[1] = getWorkingCopy(
13359
			"/Completion/src3/test/p/ZZZ.java",
13360
			"package test.p;\n" +
13361
			"public class ZZZ {\n" +
13362
			"    public static int foo;\n" +
13363
			"}");
13364
	
13365
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
13366
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
13367
	
13368
	String str = this.workingCopies[0].getSource();
13369
	String completeBehind = "foo";
13370
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13371
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13372
13373
	assertResults(
13374
			"foo[FIELD_REF]{test.p.ZZZ.foo, Ltest.p.ZZZ;, I, foo, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED)+"}",
13375
			requestor.getResults());
13376
}
13377
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
13378
public void testFavoriteImports002() throws JavaModelException {
13379
	this.workingCopies = new ICompilationUnit[2];
13380
	this.workingCopies[0] = getWorkingCopy(
13381
			"/Completion/src3/test/Test.java",
13382
			"package test;\n" +
13383
			"public class Test {\n" +
13384
			"    public void method() {\n" +
13385
			"        foo\n" +
13386
			"    }\n" +
13387
			"}");
13388
	
13389
	this.workingCopies[1] = getWorkingCopy(
13390
			"/Completion/src3/test/p/ZZZ.java",
13391
			"package test.p;\n" +
13392
			"public class ZZZ {\n" +
13393
			"    public static int foo(){}\n" +
13394
			"}");
13395
	
13396
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
13397
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
13398
	
13399
	String str = this.workingCopies[0].getSource();
13400
	String completeBehind = "foo";
13401
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13402
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13403
13404
	assertResults(
13405
			"foo[METHOD_REF]{test.p.ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED)+"}",
13406
			requestor.getResults());
13407
}
13408
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
13409
public void testFavoriteImports003() throws JavaModelException {
13410
	this.workingCopies = new ICompilationUnit[2];
13411
	this.workingCopies[0] = getWorkingCopy(
13412
			"/Completion/src3/test/Test.java",
13413
			"package test;\n" +
13414
			"public class Test {\n" +
13415
			"    public void method() {\n" +
13416
			"        foo\n" +
13417
			"    }\n" +
13418
			"}");
13419
	
13420
	this.workingCopies[1] = getWorkingCopy(
13421
			"/Completion/src3/test/p/ZZZ.java",
13422
			"package test.p;\n" +
13423
			"public class ZZZ {\n" +
13424
			"    public static int foo;\n" +
13425
			"}");
13426
	
13427
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
13428
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ"});
13429
	
13430
	String str = this.workingCopies[0].getSource();
13431
	String completeBehind = "foo";
13432
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13433
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13434
13435
	assertResults(
13436
			"",
13437
			requestor.getResults());
13438
}
13439
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
13440
public void testFavoriteImports004() throws JavaModelException {
13441
	this.workingCopies = new ICompilationUnit[2];
13442
	this.workingCopies[0] = getWorkingCopy(
13443
			"/Completion/src3/test/Test.java",
13444
			"package test;\n" +
13445
			"public class Test {\n" +
13446
			"    public void method() {\n" +
13447
			"        foo\n" +
13448
			"    }\n" +
13449
			"}");
13450
	
13451
	this.workingCopies[1] = getWorkingCopy(
13452
			"/Completion/src3/test/p/ZZZ.java",
13453
			"package test.p;\n" +
13454
			"public class ZZZ {\n" +
13455
			"    public static int foo(){}\n" +
13456
			"}");
13457
	
13458
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
13459
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ"});
13460
	
13461
	String str = this.workingCopies[0].getSource();
13462
	String completeBehind = "foo";
13463
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13464
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13465
13466
	assertResults(
13467
			"",
13468
			requestor.getResults());
13469
}
13470
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
13471
public void testFavoriteImports005() throws JavaModelException {
13472
	this.workingCopies = new ICompilationUnit[2];
13473
	this.workingCopies[0] = getWorkingCopy(
13474
			"/Completion/src3/test/Test.java",
13475
			"package test;\n" +
13476
			"public class Test {\n" +
13477
			"    public void method() {\n" +
13478
			"        foo\n" +
13479
			"    }\n" +
13480
			"}");
13481
	
13482
	this.workingCopies[1] = getWorkingCopy(
13483
			"/Completion/src3/test/p/ZZZ.java",
13484
			"package test.p;\n" +
13485
			"public class ZZZ {\n" +
13486
			"    public static int foo;\n" +
13487
			"}");
13488
	
13489
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
13490
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.foo"});
13491
	
13492
	String str = this.workingCopies[0].getSource();
13493
	String completeBehind = "foo";
13494
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13495
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13496
13497
	assertResults(
13498
			"",
13499
			requestor.getResults());
13500
}
13501
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
13502
public void testFavoriteImports006() throws JavaModelException {
13503
	this.workingCopies = new ICompilationUnit[2];
13504
	this.workingCopies[0] = getWorkingCopy(
13505
			"/Completion/src3/test/Test.java",
13506
			"package test;\n" +
13507
			"public class Test {\n" +
13508
			"    public void method() {\n" +
13509
			"        foo\n" +
13510
			"    }\n" +
13511
			"}");
13512
	
13513
	this.workingCopies[1] = getWorkingCopy(
13514
			"/Completion/src3/test/p/ZZZ.java",
13515
			"package test.p;\n" +
13516
			"public class ZZZ {\n" +
13517
			"    public static int foo(){}\n" +
13518
			"}");
13519
	
13520
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
13521
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.foo"});
13522
	
13523
	String str = this.workingCopies[0].getSource();
13524
	String completeBehind = "foo";
13525
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13526
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13527
13528
	assertResults(
13529
			"",
13530
			requestor.getResults());
13531
}
13532
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
13533
public void testFavoriteImports007() throws JavaModelException {
13534
	this.workingCopies = new ICompilationUnit[2];
13535
	this.workingCopies[0] = getWorkingCopy(
13536
			"/Completion/src3/test/Test.java",
13537
			"package test;\n" +
13538
			"import test.p.ZZZ.*;\n" +
13539
			"public class Test {\n" +
13540
			"    public void method() {\n" +
13541
			"        foo\n" +
13542
			"    }\n" +
13543
			"}");
13544
	
13545
	this.workingCopies[1] = getWorkingCopy(
13546
			"/Completion/src3/test/p/ZZZ.java",
13547
			"package test.p;\n" +
13548
			"public class ZZZ {\n" +
13549
			"    public static int foo(){}\n" +
13550
			"}");
13551
	
13552
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
13553
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
13554
	
13555
	String str = this.workingCopies[0].getSource();
13556
	String completeBehind = "foo";
13557
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13558
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13559
13560
	assertResults(
13561
			"foo[METHOD_REF]{test.p.ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED)+"}",
13562
			requestor.getResults());
13563
}
13564
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
13565
public void testFavoriteImports009() throws JavaModelException {
13566
	this.workingCopies = new ICompilationUnit[2];
13567
	this.workingCopies[0] = getWorkingCopy(
13568
			"/Completion/src3/test/Test.java",
13569
			"package test;\n" +
13570
			"import test.p.ZZZ.*;\n" +
13571
			"public class Test {\n" +
13572
			"    public void method() {\n" +
13573
			"        foo\n" +
13574
			"    }\n" +
13575
			"}");
13576
	
13577
	this.workingCopies[1] = getWorkingCopy(
13578
			"/Completion/src3/test/p/ZZZ.java",
13579
			"package test.p;\n" +
13580
			"public class ZZZ {\n" +
13581
			"    public static int foo(){}\n" +
13582
			"}");
13583
	
13584
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
13585
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.foo"});
13586
	
13587
	String str = this.workingCopies[0].getSource();
13588
	String completeBehind = "foo";
13589
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13590
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13591
13592
	assertResults(
13593
			"",
13594
			requestor.getResults());
13595
}
13596
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
13597
public void testFavoriteImports011() throws JavaModelException {
13598
	this.workingCopies = new ICompilationUnit[2];
13599
	this.workingCopies[0] = getWorkingCopy(
13600
			"/Completion/src3/test/Test.java",
13601
			"package test;\n" +
13602
			"import test.p.ZZZ.foo;\n" +
13603
			"public class Test {\n" +
13604
			"    public void method() {\n" +
13605
			"        foo\n" +
13606
			"    }\n" +
13607
			"}");
13608
	
13609
	this.workingCopies[1] = getWorkingCopy(
13610
			"/Completion/src3/test/p/ZZZ.java",
13611
			"package test.p;\n" +
13612
			"public class ZZZ {\n" +
13613
			"    public static int foo(){}\n" +
13614
			"}");
13615
	
13616
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
13617
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
13618
	
13619
	String str = this.workingCopies[0].getSource();
13620
	String completeBehind = "foo";
13621
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13622
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13623
13624
	assertResults(
13625
			"foo[METHOD_REF]{test.p.ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED)+"}",
13626
			requestor.getResults());
13627
}
13628
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
13629
public void testFavoriteImports013() throws JavaModelException {
13630
	this.workingCopies = new ICompilationUnit[2];
13631
	this.workingCopies[0] = getWorkingCopy(
13632
			"/Completion/src3/test/Test.java",
13633
			"package test;\n" +
13634
			"import test.p.ZZZ.foo;\n" +
13635
			"public class Test {\n" +
13636
			"    public void method() {\n" +
13637
			"        foo\n" +
13638
			"    }\n" +
13639
			"}");
13640
	
13641
	this.workingCopies[1] = getWorkingCopy(
13642
			"/Completion/src3/test/p/ZZZ.java",
13643
			"package test.p;\n" +
13644
			"public class ZZZ {\n" +
13645
			"    public static int foo(){}\n" +
13646
			"}");
13647
	
13648
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
13649
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.foo"});
13650
	
13651
	String str = this.workingCopies[0].getSource();
13652
	String completeBehind = "foo";
13653
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13654
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13655
13656
	assertResults(
13657
			"",
13658
			requestor.getResults());
13659
}
13660
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
13661
public void testFavoriteImports016() throws JavaModelException {
13662
	this.workingCopies = new ICompilationUnit[2];
13663
	this.workingCopies[0] = getWorkingCopy(
13664
			"/Completion/src3/test/Test.java",
13665
			"package test;\n" +
13666
			"public class Test {\n" +
13667
			"    public class foo {\n" +
13668
			"        public void method() {\n" +
13669
			"            foo\n" +
13670
			"        }\n" +
13671
			"    }\n" +
13672
			"}");
13673
	
13674
	this.workingCopies[1] = getWorkingCopy(
13675
			"/Completion/src3/test/p/ZZZ.java",
13676
			"package test.p;\n" +
13677
			"public class ZZZ {\n" +
13678
			"    public static int foo(){}\n" +
13679
			"}");
13680
	
13681
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
13682
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
13683
	
13684
	String str = this.workingCopies[0].getSource();
13685
	String completeBehind = "foo";
13686
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13687
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13688
13689
	assertResults(
13690
			"foo[METHOD_REF]{test.p.ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED) + "}\n" +
13691
			"Test.foo[TYPE_REF]{foo, test, Ltest.Test$foo;, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
13692
			requestor.getResults());
13693
}
13694
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
13695
public void testFavoriteImports017() throws JavaModelException {
13696
	this.workingCopies = new ICompilationUnit[2];
13697
	this.workingCopies[0] = getWorkingCopy(
13698
			"/Completion/src3/test/Test.java",
13699
			"package test;\n" +
13700
			"public class Test {\n" +
13701
			"    public void foo() {\n" +
13702
			"        foo\n" +
13703
			"    }\n" +
13704
			"}");
13705
	
13706
	this.workingCopies[1] = getWorkingCopy(
13707
			"/Completion/src3/test/p/ZZZ.java",
13708
			"package test.p;\n" +
13709
			"public class ZZZ {\n" +
13710
			"    public static int foo(){}\n" +
13711
			"}");
13712
	
13713
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
13714
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
13715
	
13716
	String str = this.workingCopies[0].getSource();
13717
	String completeBehind = "foo";
13718
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13719
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13720
13721
	assertResults(
13722
			"foo[METHOD_REF]{test.p.ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED) + "}\n" +
13723
			"foo[METHOD_REF]{foo(), Ltest.Test;, ()V, foo, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
13724
			requestor.getResults());
13725
}
13726
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
13727
public void testFavoriteImports018() throws JavaModelException {
13728
	this.workingCopies = new ICompilationUnit[2];
13729
	this.workingCopies[0] = getWorkingCopy(
13730
			"/Completion/src3/test/Test.java",
13731
			"package test;\n" +
13732
			"public class Test {\n" +
13733
			"    public int foo;\n" +
13734
			"    public void method() {\n" +
13735
			"        foo\n" +
13736
			"    }\n" +
13737
			"}");
13738
	
13739
	this.workingCopies[1] = getWorkingCopy(
13740
			"/Completion/src3/test/p/ZZZ.java",
13741
			"package test.p;\n" +
13742
			"public class ZZZ {\n" +
13743
			"    public static int foo(){}\n" +
13744
			"}");
13745
	
13746
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
13747
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
13748
	
13749
	String str = this.workingCopies[0].getSource();
13750
	String completeBehind = "foo";
13751
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13752
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13753
13754
	assertResults(
13755
			"foo[METHOD_REF]{test.p.ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED) + "}\n" +
13756
			"foo[FIELD_REF]{foo, Ltest.Test;, I, foo, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
13757
			requestor.getResults());
13758
}
13759
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
13760
public void testFavoriteImports019() throws JavaModelException {
13761
	this.workingCopies = new ICompilationUnit[2];
13762
	this.workingCopies[0] = getWorkingCopy(
13763
			"/Completion/src3/test/Test.java",
13764
			"package test;\n" +
13765
			"public class Test {\n" +
13766
			"    public void method() {\n" +
13767
			"        int foo = 0;\n" +
13768
			"        foo\n" +
13769
			"    }\n" +
13770
			"}");
13771
	
13772
	this.workingCopies[1] = getWorkingCopy(
13773
			"/Completion/src3/test/p/ZZZ.java",
13774
			"package test.p;\n" +
13775
			"public class ZZZ {\n" +
13776
			"    public static int foo(){}\n" +
13777
			"}");
13778
	
13779
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
13780
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
13781
	
13782
	String str = this.workingCopies[0].getSource();
13783
	String completeBehind = "foo";
13784
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13785
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13786
13787
	assertResults(
13788
			"foo[METHOD_REF]{test.p.ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED) + "}\n" +
13789
			"foo[LOCAL_VARIABLE_REF]{foo, null, I, foo, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
13790
			requestor.getResults());
13791
}
13792
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
13793
public void testFavoriteImports020() throws JavaModelException {
13794
	this.workingCopies = new ICompilationUnit[2];
13795
	this.workingCopies[0] = getWorkingCopy(
13796
			"/Completion/src3/test/Test.java",
13797
			"package test;\n" +
13798
			"public class Test {\n" +
13799
			"    public void method() {\n" +
13800
			"        foo\n" +
13801
			"    }\n" +
13802
			"}");
13803
	
13804
	this.workingCopies[1] = getWorkingCopy(
13805
			"/Completion/src3/test/p/ZZZ.java",
13806
			"package test.p;\n" +
13807
			"public class ZZZ {\n" +
13808
			"    public static int foo(){}\n" +
13809
			"    public static int foo(int i){}\n" +
13810
			"}");
13811
	
13812
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
13813
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
13814
	
13815
	String str = this.workingCopies[0].getSource();
13816
	String completeBehind = "foo";
13817
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13818
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13819
13820
	assertResults(
13821
			"foo[METHOD_REF]{test.p.ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED) + "}\n" +
13822
			"foo[METHOD_REF]{test.p.ZZZ.foo(), Ltest.p.ZZZ;, (I)I, foo, (i), "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED)+"}",
13823
			requestor.getResults());
13824
}
13825
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
13826
public void testFavoriteImports022() throws JavaModelException {
13827
	this.workingCopies = new ICompilationUnit[2];
13828
	this.workingCopies[0] = getWorkingCopy(
13829
			"/Completion/src3/test/Test.java",
13830
			"package test;\n" +
13831
			"public class Test {\n" +
13832
			"    public void method() {\n" +
13833
			"        foo();\n" +
13834
			"    }\n" +
13835
			"}");
13836
	
13837
	this.workingCopies[1] = getWorkingCopy(
13838
			"/Completion/src3/test/p/ZZZ.java",
13839
			"package test.p;\n" +
13840
			"public class ZZZ {\n" +
13841
			"    public static int foo(){}\n" +
13842
			"}");
13843
	
13844
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
13845
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
13846
	
13847
	String str = this.workingCopies[0].getSource();
13848
	String completeBehind = "foo(";
13849
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13850
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13851
13852
	assertResults(
13853
			"",
13854
			requestor.getResults());
13855
}
13346
}
13856
}
(-)src/org/eclipse/jdt/core/tests/model/CompletionTests_1_5.java (+709 lines)
Lines 9425-9428 Link Here
9425
			"Test<T>[TYPE_REF]{, test, Ltest.Test<TT;>;, null, null, ["+startOffset+", "+endOffset+"], "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
9425
			"Test<T>[TYPE_REF]{, test, Ltest.Test<TT;>;, null, null, ["+startOffset+", "+endOffset+"], "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
9426
			requestor.getResults());
9426
			requestor.getResults());
9427
}
9427
}
9428
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
9429
public void testFavoriteImports001() throws JavaModelException {
9430
	this.workingCopies = new ICompilationUnit[2];
9431
	this.workingCopies[0] = getWorkingCopy(
9432
			"/Completion/src3/test/Test.java",
9433
			"package test;\n" +
9434
			"public class Test {\n" +
9435
			"    public void method() {\n" +
9436
			"        foo\n" +
9437
			"    }\n" +
9438
			"}");
9439
	
9440
	this.workingCopies[1] = getWorkingCopy(
9441
			"/Completion/src3/test/p/ZZZ.java",
9442
			"package test.p;\n" +
9443
			"public class ZZZ {\n" +
9444
			"    public static int foo;\n" +
9445
			"}");
9446
	
9447
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
9448
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
9449
	
9450
	String str = this.workingCopies[0].getSource();
9451
	String completeBehind = "foo";
9452
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9453
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
9454
9455
	assertResults(
9456
			"foo[FIELD_REF]{test.p.ZZZ.foo, Ltest.p.ZZZ;, I, foo, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED)+"}",
9457
			requestor.getResults());
9458
}
9459
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
9460
public void testFavoriteImports002() throws JavaModelException {
9461
	this.workingCopies = new ICompilationUnit[2];
9462
	this.workingCopies[0] = getWorkingCopy(
9463
			"/Completion/src3/test/Test.java",
9464
			"package test;\n" +
9465
			"public class Test {\n" +
9466
			"    public void method() {\n" +
9467
			"        foo\n" +
9468
			"    }\n" +
9469
			"}");
9470
	
9471
	this.workingCopies[1] = getWorkingCopy(
9472
			"/Completion/src3/test/p/ZZZ.java",
9473
			"package test.p;\n" +
9474
			"public class ZZZ {\n" +
9475
			"    public static int foo(){}\n" +
9476
			"}");
9477
	
9478
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
9479
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
9480
	
9481
	String str = this.workingCopies[0].getSource();
9482
	String completeBehind = "foo";
9483
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9484
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
9485
9486
	assertResults(
9487
			"foo[METHOD_REF]{test.p.ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED)+"}",
9488
			requestor.getResults());
9489
}
9490
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
9491
public void testFavoriteImports003() throws JavaModelException {
9492
	this.workingCopies = new ICompilationUnit[2];
9493
	this.workingCopies[0] = getWorkingCopy(
9494
			"/Completion/src3/test/Test.java",
9495
			"package test;\n" +
9496
			"public class Test {\n" +
9497
			"    public void method() {\n" +
9498
			"        foo\n" +
9499
			"    }\n" +
9500
			"}");
9501
	
9502
	this.workingCopies[1] = getWorkingCopy(
9503
			"/Completion/src3/test/p/ZZZ.java",
9504
			"package test.p;\n" +
9505
			"public class ZZZ {\n" +
9506
			"    public static int foo;\n" +
9507
			"}");
9508
	
9509
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
9510
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ"});
9511
	
9512
	String str = this.workingCopies[0].getSource();
9513
	String completeBehind = "foo";
9514
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9515
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
9516
9517
	assertResults(
9518
			"",
9519
			requestor.getResults());
9520
}
9521
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
9522
public void testFavoriteImports004() throws JavaModelException {
9523
	this.workingCopies = new ICompilationUnit[2];
9524
	this.workingCopies[0] = getWorkingCopy(
9525
			"/Completion/src3/test/Test.java",
9526
			"package test;\n" +
9527
			"public class Test {\n" +
9528
			"    public void method() {\n" +
9529
			"        foo\n" +
9530
			"    }\n" +
9531
			"}");
9532
	
9533
	this.workingCopies[1] = getWorkingCopy(
9534
			"/Completion/src3/test/p/ZZZ.java",
9535
			"package test.p;\n" +
9536
			"public class ZZZ {\n" +
9537
			"    public static int foo(){}\n" +
9538
			"}");
9539
	
9540
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
9541
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ"});
9542
	
9543
	String str = this.workingCopies[0].getSource();
9544
	String completeBehind = "foo";
9545
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9546
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
9547
9548
	assertResults(
9549
			"",
9550
			requestor.getResults());
9551
}
9552
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
9553
public void testFavoriteImports005() throws JavaModelException {
9554
	this.workingCopies = new ICompilationUnit[2];
9555
	this.workingCopies[0] = getWorkingCopy(
9556
			"/Completion/src3/test/Test.java",
9557
			"package test;\n" +
9558
			"public class Test {\n" +
9559
			"    public void method() {\n" +
9560
			"        foo\n" +
9561
			"    }\n" +
9562
			"}");
9563
	
9564
	this.workingCopies[1] = getWorkingCopy(
9565
			"/Completion/src3/test/p/ZZZ.java",
9566
			"package test.p;\n" +
9567
			"public class ZZZ {\n" +
9568
			"    public static int foo;\n" +
9569
			"}");
9570
	
9571
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
9572
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.foo"});
9573
	
9574
	String str = this.workingCopies[0].getSource();
9575
	String completeBehind = "foo";
9576
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9577
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
9578
9579
	assertResults(
9580
			"foo[FIELD_REF]{test.p.ZZZ.foo, Ltest.p.ZZZ;, I, foo, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED)+"}",
9581
			requestor.getResults());
9582
}
9583
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
9584
public void testFavoriteImports006() throws JavaModelException {
9585
	this.workingCopies = new ICompilationUnit[2];
9586
	this.workingCopies[0] = getWorkingCopy(
9587
			"/Completion/src3/test/Test.java",
9588
			"package test;\n" +
9589
			"public class Test {\n" +
9590
			"    public void method() {\n" +
9591
			"        foo\n" +
9592
			"    }\n" +
9593
			"}");
9594
	
9595
	this.workingCopies[1] = getWorkingCopy(
9596
			"/Completion/src3/test/p/ZZZ.java",
9597
			"package test.p;\n" +
9598
			"public class ZZZ {\n" +
9599
			"    public static int foo(){}\n" +
9600
			"}");
9601
	
9602
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
9603
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.foo"});
9604
	
9605
	String str = this.workingCopies[0].getSource();
9606
	String completeBehind = "foo";
9607
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9608
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
9609
9610
	assertResults(
9611
			"foo[METHOD_REF]{test.p.ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED)+"}",
9612
			requestor.getResults());
9613
}
9614
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
9615
public void testFavoriteImports007() throws JavaModelException {
9616
	this.workingCopies = new ICompilationUnit[2];
9617
	this.workingCopies[0] = getWorkingCopy(
9618
			"/Completion/src3/test/Test.java",
9619
			"package test;\n" +
9620
			"import test.p.ZZZ.*;\n" +
9621
			"public class Test {\n" +
9622
			"    public void method() {\n" +
9623
			"        foo\n" +
9624
			"    }\n" +
9625
			"}");
9626
	
9627
	this.workingCopies[1] = getWorkingCopy(
9628
			"/Completion/src3/test/p/ZZZ.java",
9629
			"package test.p;\n" +
9630
			"public class ZZZ {\n" +
9631
			"    public static int foo(){}\n" +
9632
			"}");
9633
	
9634
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
9635
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
9636
	
9637
	String str = this.workingCopies[0].getSource();
9638
	String completeBehind = "foo";
9639
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9640
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
9641
9642
	assertResults(
9643
			"foo[METHOD_REF]{test.p.ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED)+"}",
9644
			requestor.getResults());
9645
}
9646
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
9647
public void testFavoriteImports008() throws JavaModelException {
9648
	this.workingCopies = new ICompilationUnit[2];
9649
	this.workingCopies[0] = getWorkingCopy(
9650
			"/Completion/src3/test/Test.java",
9651
			"package test;\n" +
9652
			"import static test.p.ZZZ.*;\n" +
9653
			"public class Test {\n" +
9654
			"    public void method() {\n" +
9655
			"        foo\n" +
9656
			"    }\n" +
9657
			"}");
9658
	
9659
	this.workingCopies[1] = getWorkingCopy(
9660
			"/Completion/src3/test/p/ZZZ.java",
9661
			"package test.p;\n" +
9662
			"public class ZZZ {\n" +
9663
			"    public static int foo(){}\n" +
9664
			"}");
9665
	
9666
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
9667
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
9668
	
9669
	String str = this.workingCopies[0].getSource();
9670
	String completeBehind = "foo";
9671
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9672
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
9673
9674
	assertResults(
9675
			"foo[METHOD_REF]{foo(), Ltest.p.ZZZ;, ()I, foo, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED +R_NON_RESTRICTED)+"}",
9676
			requestor.getResults());
9677
}
9678
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
9679
public void testFavoriteImports009() throws JavaModelException {
9680
	this.workingCopies = new ICompilationUnit[2];
9681
	this.workingCopies[0] = getWorkingCopy(
9682
			"/Completion/src3/test/Test.java",
9683
			"package test;\n" +
9684
			"import test.p.ZZZ.*;\n" +
9685
			"public class Test {\n" +
9686
			"    public void method() {\n" +
9687
			"        foo\n" +
9688
			"    }\n" +
9689
			"}");
9690
	
9691
	this.workingCopies[1] = getWorkingCopy(
9692
			"/Completion/src3/test/p/ZZZ.java",
9693
			"package test.p;\n" +
9694
			"public class ZZZ {\n" +
9695
			"    public static int foo(){}\n" +
9696
			"}");
9697
	
9698
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
9699
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.foo"});
9700
	
9701
	String str = this.workingCopies[0].getSource();
9702
	String completeBehind = "foo";
9703
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9704
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
9705
9706
	assertResults(
9707
			"foo[METHOD_REF]{test.p.ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED)+"}",
9708
			requestor.getResults());
9709
}
9710
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
9711
public void testFavoriteImports010() throws JavaModelException {
9712
	this.workingCopies = new ICompilationUnit[2];
9713
	this.workingCopies[0] = getWorkingCopy(
9714
			"/Completion/src3/test/Test.java",
9715
			"package test;\n" +
9716
			"import static test.p.ZZZ.*;\n" +
9717
			"public class Test {\n" +
9718
			"    public void method() {\n" +
9719
			"        foo\n" +
9720
			"    }\n" +
9721
			"}");
9722
	
9723
	this.workingCopies[1] = getWorkingCopy(
9724
			"/Completion/src3/test/p/ZZZ.java",
9725
			"package test.p;\n" +
9726
			"public class ZZZ {\n" +
9727
			"    public static int foo(){}\n" +
9728
			"}");
9729
	
9730
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
9731
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.foo"});
9732
	
9733
	String str = this.workingCopies[0].getSource();
9734
	String completeBehind = "foo";
9735
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9736
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
9737
9738
	assertResults(
9739
			"foo[METHOD_REF]{foo(), Ltest.p.ZZZ;, ()I, foo, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
9740
			requestor.getResults());
9741
}
9742
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
9743
public void testFavoriteImports011() throws JavaModelException {
9744
	this.workingCopies = new ICompilationUnit[2];
9745
	this.workingCopies[0] = getWorkingCopy(
9746
			"/Completion/src3/test/Test.java",
9747
			"package test;\n" +
9748
			"import test.p.ZZZ.foo;\n" +
9749
			"public class Test {\n" +
9750
			"    public void method() {\n" +
9751
			"        foo\n" +
9752
			"    }\n" +
9753
			"}");
9754
	
9755
	this.workingCopies[1] = getWorkingCopy(
9756
			"/Completion/src3/test/p/ZZZ.java",
9757
			"package test.p;\n" +
9758
			"public class ZZZ {\n" +
9759
			"    public static int foo(){}\n" +
9760
			"}");
9761
	
9762
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
9763
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
9764
	
9765
	String str = this.workingCopies[0].getSource();
9766
	String completeBehind = "foo";
9767
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9768
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
9769
9770
	assertResults(
9771
			"foo[METHOD_REF]{test.p.ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED)+"}",
9772
			requestor.getResults());
9773
}
9774
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
9775
public void testFavoriteImports012() throws JavaModelException {
9776
	this.workingCopies = new ICompilationUnit[2];
9777
	this.workingCopies[0] = getWorkingCopy(
9778
			"/Completion/src3/test/Test.java",
9779
			"package test;\n" +
9780
			"import static test.p.ZZZ.foo;\n" +
9781
			"public class Test {\n" +
9782
			"    public void method() {\n" +
9783
			"        foo\n" +
9784
			"    }\n" +
9785
			"}");
9786
	
9787
	this.workingCopies[1] = getWorkingCopy(
9788
			"/Completion/src3/test/p/ZZZ.java",
9789
			"package test.p;\n" +
9790
			"public class ZZZ {\n" +
9791
			"    public static int foo(){}\n" +
9792
			"}");
9793
	
9794
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
9795
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
9796
	
9797
	String str = this.workingCopies[0].getSource();
9798
	String completeBehind = "foo";
9799
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9800
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
9801
9802
	assertResults(
9803
			"foo[METHOD_REF]{foo(), Ltest.p.ZZZ;, ()I, foo, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
9804
			requestor.getResults());
9805
}
9806
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
9807
public void testFavoriteImports013() throws JavaModelException {
9808
	this.workingCopies = new ICompilationUnit[2];
9809
	this.workingCopies[0] = getWorkingCopy(
9810
			"/Completion/src3/test/Test.java",
9811
			"package test;\n" +
9812
			"import test.p.ZZZ.foo;\n" +
9813
			"public class Test {\n" +
9814
			"    public void method() {\n" +
9815
			"        foo\n" +
9816
			"    }\n" +
9817
			"}");
9818
	
9819
	this.workingCopies[1] = getWorkingCopy(
9820
			"/Completion/src3/test/p/ZZZ.java",
9821
			"package test.p;\n" +
9822
			"public class ZZZ {\n" +
9823
			"    public static int foo(){}\n" +
9824
			"}");
9825
	
9826
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
9827
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.foo"});
9828
	
9829
	String str = this.workingCopies[0].getSource();
9830
	String completeBehind = "foo";
9831
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9832
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
9833
9834
	assertResults(
9835
			"foo[METHOD_REF]{test.p.ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED)+"}",
9836
			requestor.getResults());
9837
}
9838
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
9839
public void testFavoriteImports014() throws JavaModelException {
9840
	this.workingCopies = new ICompilationUnit[2];
9841
	this.workingCopies[0] = getWorkingCopy(
9842
			"/Completion/src3/test/Test.java",
9843
			"package test;\n" +
9844
			"import static test.p.ZZZ.foo;\n" +
9845
			"public class Test {\n" +
9846
			"    public void method() {\n" +
9847
			"        foo\n" +
9848
			"    }\n" +
9849
			"}");
9850
	
9851
	this.workingCopies[1] = getWorkingCopy(
9852
			"/Completion/src3/test/p/ZZZ.java",
9853
			"package test.p;\n" +
9854
			"public class ZZZ {\n" +
9855
			"    public static int foo(){}\n" +
9856
			"}");
9857
	
9858
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
9859
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.foo"});
9860
	
9861
	String str = this.workingCopies[0].getSource();
9862
	String completeBehind = "foo";
9863
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9864
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
9865
9866
	assertResults(
9867
			"foo[METHOD_REF]{foo(), Ltest.p.ZZZ;, ()I, foo, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
9868
			requestor.getResults());
9869
}
9870
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
9871
public void testFavoriteImports015() throws JavaModelException {
9872
	this.workingCopies = new ICompilationUnit[3];
9873
	this.workingCopies[0] = getWorkingCopy(
9874
			"/Completion/src3/test/Test.java",
9875
			"package test;\n" +
9876
			"import static test.p.ZZZ.foo;\n" +
9877
			"public class Test {\n" +
9878
			"    public void method() {\n" +
9879
			"        foo\n" +
9880
			"    }\n" +
9881
			"}");
9882
	
9883
	this.workingCopies[1] = getWorkingCopy(
9884
			"/Completion/src3/test/p/ZZZ.java",
9885
			"package test.p;\n" +
9886
			"public class ZZZ {\n" +
9887
			"    public static int foo(){}\n" +
9888
			"}");
9889
	
9890
	this.workingCopies[2] = getWorkingCopy(
9891
			"/Completion/src3/test/q/ZZZ2.java",
9892
			"package test.q;\n" +
9893
			"public class ZZZ2 {\n" +
9894
			"    public static int foo(){}\n" +
9895
			"}");
9896
	
9897
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
9898
	requestor.setFavoriteReferences(new String[]{"test.q.ZZZ2.foo"});
9899
	
9900
	String str = this.workingCopies[0].getSource();
9901
	String completeBehind = "foo";
9902
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9903
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
9904
9905
	assertResults(
9906
			"foo[METHOD_REF]{test.q.ZZZ2.foo(), Ltest.q.ZZZ2;, ()I, foo, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED) + "}\n" +
9907
			"foo[METHOD_REF]{foo(), Ltest.p.ZZZ;, ()I, foo, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
9908
			requestor.getResults());
9909
}
9910
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
9911
public void testFavoriteImports016() throws JavaModelException {
9912
	this.workingCopies = new ICompilationUnit[2];
9913
	this.workingCopies[0] = getWorkingCopy(
9914
			"/Completion/src3/test/Test.java",
9915
			"package test;\n" +
9916
			"public class Test {\n" +
9917
			"    public class foo {\n" +
9918
			"        public void method() {\n" +
9919
			"            foo\n" +
9920
			"        }\n" +
9921
			"    }\n" +
9922
			"}");
9923
	
9924
	this.workingCopies[1] = getWorkingCopy(
9925
			"/Completion/src3/test/p/ZZZ.java",
9926
			"package test.p;\n" +
9927
			"public class ZZZ {\n" +
9928
			"    public static int foo(){}\n" +
9929
			"}");
9930
	
9931
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
9932
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
9933
	
9934
	String str = this.workingCopies[0].getSource();
9935
	String completeBehind = "foo";
9936
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9937
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
9938
9939
	assertResults(
9940
			"foo[METHOD_REF]{test.p.ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED) + "}\n" +
9941
			"Test.foo[TYPE_REF]{foo, test, Ltest.Test$foo;, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
9942
			requestor.getResults());
9943
}
9944
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
9945
public void testFavoriteImports017() throws JavaModelException {
9946
	this.workingCopies = new ICompilationUnit[2];
9947
	this.workingCopies[0] = getWorkingCopy(
9948
			"/Completion/src3/test/Test.java",
9949
			"package test;\n" +
9950
			"public class Test {\n" +
9951
			"    public void foo() {\n" +
9952
			"        foo\n" +
9953
			"    }\n" +
9954
			"}");
9955
	
9956
	this.workingCopies[1] = getWorkingCopy(
9957
			"/Completion/src3/test/p/ZZZ.java",
9958
			"package test.p;\n" +
9959
			"public class ZZZ {\n" +
9960
			"    public static int foo(){}\n" +
9961
			"}");
9962
	
9963
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
9964
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
9965
	
9966
	String str = this.workingCopies[0].getSource();
9967
	String completeBehind = "foo";
9968
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9969
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
9970
9971
	assertResults(
9972
			"foo[METHOD_REF]{test.p.ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED) + "}\n" +
9973
			"foo[METHOD_REF]{foo(), Ltest.Test;, ()V, foo, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
9974
			requestor.getResults());
9975
}
9976
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
9977
public void testFavoriteImports018() throws JavaModelException {
9978
	this.workingCopies = new ICompilationUnit[2];
9979
	this.workingCopies[0] = getWorkingCopy(
9980
			"/Completion/src3/test/Test.java",
9981
			"package test;\n" +
9982
			"public class Test {\n" +
9983
			"    public int foo;\n" +
9984
			"    public void method() {\n" +
9985
			"        foo\n" +
9986
			"    }\n" +
9987
			"}");
9988
	
9989
	this.workingCopies[1] = getWorkingCopy(
9990
			"/Completion/src3/test/p/ZZZ.java",
9991
			"package test.p;\n" +
9992
			"public class ZZZ {\n" +
9993
			"    public static int foo(){}\n" +
9994
			"}");
9995
	
9996
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
9997
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
9998
	
9999
	String str = this.workingCopies[0].getSource();
10000
	String completeBehind = "foo";
10001
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10002
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
10003
10004
	assertResults(
10005
			"foo[METHOD_REF]{test.p.ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED) + "}\n" +
10006
			"foo[FIELD_REF]{foo, Ltest.Test;, I, foo, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
10007
			requestor.getResults());
10008
}
10009
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
10010
public void testFavoriteImports019() throws JavaModelException {
10011
	this.workingCopies = new ICompilationUnit[2];
10012
	this.workingCopies[0] = getWorkingCopy(
10013
			"/Completion/src3/test/Test.java",
10014
			"package test;\n" +
10015
			"public class Test {\n" +
10016
			"    public void method() {\n" +
10017
			"        int foo = 0;\n" +
10018
			"        foo\n" +
10019
			"    }\n" +
10020
			"}");
10021
	
10022
	this.workingCopies[1] = getWorkingCopy(
10023
			"/Completion/src3/test/p/ZZZ.java",
10024
			"package test.p;\n" +
10025
			"public class ZZZ {\n" +
10026
			"    public static int foo(){}\n" +
10027
			"}");
10028
	
10029
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
10030
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
10031
	
10032
	String str = this.workingCopies[0].getSource();
10033
	String completeBehind = "foo";
10034
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10035
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
10036
10037
	assertResults(
10038
			"foo[METHOD_REF]{test.p.ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED) + "}\n" +
10039
			"foo[LOCAL_VARIABLE_REF]{foo, null, I, foo, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
10040
			requestor.getResults());
10041
}
10042
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
10043
public void testFavoriteImports020() throws JavaModelException {
10044
	this.workingCopies = new ICompilationUnit[2];
10045
	this.workingCopies[0] = getWorkingCopy(
10046
			"/Completion/src3/test/Test.java",
10047
			"package test;\n" +
10048
			"public class Test {\n" +
10049
			"    public void method() {\n" +
10050
			"        foo\n" +
10051
			"    }\n" +
10052
			"}");
10053
	
10054
	this.workingCopies[1] = getWorkingCopy(
10055
			"/Completion/src3/test/p/ZZZ.java",
10056
			"package test.p;\n" +
10057
			"public class ZZZ {\n" +
10058
			"    public static int foo(){}\n" +
10059
			"    public static int foo(int i){}\n" +
10060
			"}");
10061
	
10062
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
10063
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.foo"});
10064
	
10065
	String str = this.workingCopies[0].getSource();
10066
	String completeBehind = "foo";
10067
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10068
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
10069
10070
	assertResults(
10071
			"foo[METHOD_REF]{test.p.ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED) + "}\n" +
10072
			"foo[METHOD_REF]{test.p.ZZZ.foo(), Ltest.p.ZZZ;, (I)I, foo, (i), "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED)+"}",
10073
			requestor.getResults());
10074
}
10075
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
10076
public void testFavoriteImports021() throws JavaModelException {
10077
	this.workingCopies = new ICompilationUnit[2];
10078
	this.workingCopies[0] = getWorkingCopy(
10079
			"/Completion/src3/test/Test.java",
10080
			"package test;\n" +
10081
			"public class Test {\n" +
10082
			"    public void method() {\n" +
10083
			"        <Object>foo\n" +
10084
			"    }\n" +
10085
			"}");
10086
	
10087
	this.workingCopies[1] = getWorkingCopy(
10088
			"/Completion/src3/test/p/ZZZ.java",
10089
			"package test.p;\n" +
10090
			"public class ZZZ {\n" +
10091
			"    public static <T> int foo(){}\n" +
10092
			"}");
10093
	
10094
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
10095
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.foo"});
10096
	
10097
	String str = this.workingCopies[0].getSource();
10098
	String completeBehind = "foo";
10099
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10100
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
10101
10102
	assertResults(
10103
			"foo[METHOD_REF]{test.p.ZZZ.foo(), Ltest.p.ZZZ;, <T:Ljava.lang.Object;>()I, foo, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED)+"}",
10104
			requestor.getResults());
10105
}
10106
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
10107
public void testFavoriteImports022() throws JavaModelException {
10108
	this.workingCopies = new ICompilationUnit[2];
10109
	this.workingCopies[0] = getWorkingCopy(
10110
			"/Completion/src3/test/Test.java",
10111
			"package test;\n" +
10112
			"public class Test {\n" +
10113
			"    public void method() {\n" +
10114
			"        foo();\n" +
10115
			"    }\n" +
10116
			"}");
10117
	
10118
	this.workingCopies[1] = getWorkingCopy(
10119
			"/Completion/src3/test/p/ZZZ.java",
10120
			"package test.p;\n" +
10121
			"public class ZZZ {\n" +
10122
			"    public static int foo(){}\n" +
10123
			"}");
10124
	
10125
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
10126
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.foo"});
10127
	
10128
	String str = this.workingCopies[0].getSource();
10129
	String completeBehind = "foo(";
10130
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10131
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
10132
10133
	assertResults(
10134
			"",
10135
			requestor.getResults());
10136
}
9428
}
10137
}

Return to bug 152123