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

Collapse All | Expand All

(-)search/org/eclipse/jdt/internal/core/index/DiskIndex.java (-1 / +1 lines)
Lines 46-52 Link Here
46
private int streamEnd; // used when writing data from the streamBuffer to the file
46
private int streamEnd; // used when writing data from the streamBuffer to the file
47
char separator = Index.DEFAULT_SEPARATOR;
47
char separator = Index.DEFAULT_SEPARATOR;
48
48
49
public static final String SIGNATURE= "INDEX VERSION 1.125"; //$NON-NLS-1$
49
public static final String SIGNATURE= "INDEX VERSION 1.126"; //$NON-NLS-1$
50
private static final char[] SIGNATURE_CHARS = SIGNATURE.toCharArray();
50
private static final char[] SIGNATURE_CHARS = SIGNATURE.toCharArray();
51
public static boolean DEBUG = false;
51
public static boolean DEBUG = false;
52
52
(-)codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java (+22 lines)
Lines 572-577 Link Here
572
		}
572
		}
573
	}
573
	}
574
}
574
}
575
public Object becomeSimpleParser() {
576
	CompletionScanner completionScanner = (CompletionScanner)this.scanner;
577
	int[] parserState = new int[] {this.cursorLocation, completionScanner.cursorLocation};
578
	
579
	this.cursorLocation = Integer.MAX_VALUE;
580
	completionScanner.cursorLocation = Integer.MAX_VALUE;
581
	
582
	return parserState;
583
}
575
private void buildMoreAnnotationCompletionContext(MemberValuePair memberValuePair) {
584
private void buildMoreAnnotationCompletionContext(MemberValuePair memberValuePair) {
576
	if(this.identifierPtr < 0 || this.identifierLengthPtr < 0 ) return;
585
	if(this.identifierPtr < 0 || this.identifierLengthPtr < 0 ) return;
577
586
Lines 1208-1213 Link Here
1208
			}
1217
			}
1209
			if(type instanceof CompletionOnSingleTypeReference) {
1218
			if(type instanceof CompletionOnSingleTypeReference) {
1210
				((CompletionOnSingleTypeReference)type).isConstructorType = true;
1219
				((CompletionOnSingleTypeReference)type).isConstructorType = true;
1220
			} else if (type instanceof CompletionOnQualifiedTypeReference) {
1221
				((CompletionOnQualifiedTypeReference)type).isConstructorType = true;
1211
			}
1222
			}
1212
			allocExpr.type = type;
1223
			allocExpr.type = type;
1213
			allocExpr.sourceStart = type.sourceStart;
1224
			allocExpr.sourceStart = type.sourceStart;
Lines 1227-1232 Link Here
1227
			} else {
1238
			} else {
1228
				type = getTypeReference(0);
1239
				type = getTypeReference(0);
1229
			}
1240
			}
1241
			if(type instanceof CompletionOnSingleTypeReference) {
1242
				((CompletionOnSingleTypeReference)type).isConstructorType = true;
1243
			}
1230
			allocExpr.type = type;
1244
			allocExpr.type = type;
1231
			allocExpr.enclosingInstance = this.expressionStack[this.qualifier];
1245
			allocExpr.enclosingInstance = this.expressionStack[this.qualifier];
1232
			allocExpr.sourceStart = this.intStack[this.intPtr--];
1246
			allocExpr.sourceStart = this.intStack[this.intPtr--];
Lines 4539-4544 Link Here
4539
	this.cursorLocation = 0;
4553
	this.cursorLocation = 0;
4540
	flushAssistState();
4554
	flushAssistState();
4541
}
4555
}
4556
public void restoreAssistParser(Object parserState) {
4557
	int[] state = (int[]) parserState;
4558
	
4559
	CompletionScanner completionScanner = (CompletionScanner)this.scanner;
4560
	
4561
	this.cursorLocation = state[0];
4562
	completionScanner.cursorLocation = state[1];
4563
}
4542
/*
4564
/*
4543
 * Reset context so as to resume to regular parse loop
4565
 * Reset context so as to resume to regular parse loop
4544
 * If unable to reset for resuming, answers false.
4566
 * If unable to reset for resuming, answers false.
(-)codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnQualifiedTypeReference.java (+3 lines)
Lines 35-40 Link Here
35
35
36
	private int kind = K_TYPE;
36
	private int kind = K_TYPE;
37
	public char[] completionIdentifier;
37
	public char[] completionIdentifier;
38
	
39
	public boolean isConstructorType;
40
	
38
public CompletionOnQualifiedTypeReference(char[][] previousIdentifiers, char[] completionIdentifier, long[] positions) {
41
public CompletionOnQualifiedTypeReference(char[][] previousIdentifiers, char[] completionIdentifier, long[] positions) {
39
	this(previousIdentifiers, completionIdentifier, positions, K_TYPE);
42
	this(previousIdentifiers, completionIdentifier, positions, K_TYPE);
40
}
43
}
(-)model/org/eclipse/jdt/internal/compiler/SourceElementNotifier.java (-7 / +16 lines)
Lines 13-18 Link Here
13
import java.util.ArrayList;
13
import java.util.ArrayList;
14
import java.util.Map;
14
import java.util.Map;
15
15
16
import org.eclipse.jdt.core.Signature;
16
import org.eclipse.jdt.core.compiler.CharOperation;
17
import org.eclipse.jdt.core.compiler.CharOperation;
17
import org.eclipse.jdt.internal.compiler.ISourceElementRequestor.TypeParameterInfo;
18
import org.eclipse.jdt.internal.compiler.ISourceElementRequestor.TypeParameterInfo;
18
import org.eclipse.jdt.internal.compiler.ast.ASTNode;
19
import org.eclipse.jdt.internal.compiler.ast.ASTNode;
Lines 54-59 Link Here
54
	 * An ast visitor that visits local type declarations.
55
	 * An ast visitor that visits local type declarations.
55
	 */
56
	 */
56
	public class LocalDeclarationVisitor extends ASTVisitor {
57
	public class LocalDeclarationVisitor extends ASTVisitor {
58
		public ImportReference currentPackage;
57
		ArrayList declaringTypes;
59
		ArrayList declaringTypes;
58
		public void pushDeclaringType(TypeDeclaration declaringType) {
60
		public void pushDeclaringType(TypeDeclaration declaringType) {
59
			if (this.declaringTypes == null) {
61
			if (this.declaringTypes == null) {
Lines 71-81 Link Here
71
			return (TypeDeclaration) this.declaringTypes.get(size-1);
73
			return (TypeDeclaration) this.declaringTypes.get(size-1);
72
		}
74
		}
73
		public boolean visit(TypeDeclaration typeDeclaration, BlockScope scope) {
75
		public boolean visit(TypeDeclaration typeDeclaration, BlockScope scope) {
74
			notifySourceElementRequestor(typeDeclaration, true, peekDeclaringType());
76
			notifySourceElementRequestor(typeDeclaration, true, peekDeclaringType(), this.currentPackage);
75
			return false; // don't visit members as this was done during notifySourceElementRequestor(...)
77
			return false; // don't visit members as this was done during notifySourceElementRequestor(...)
76
		}
78
		}
77
		public boolean visit(TypeDeclaration typeDeclaration, ClassScope scope) {
79
		public boolean visit(TypeDeclaration typeDeclaration, ClassScope scope) {
78
			notifySourceElementRequestor(typeDeclaration, true, peekDeclaringType());
80
			notifySourceElementRequestor(typeDeclaration, true, peekDeclaringType(), this.currentPackage);
79
			return false; // don't visit members as this was done during notifySourceElementRequestor(...)
81
			return false; // don't visit members as this was done during notifySourceElementRequestor(...)
80
		}
82
		}
81
	}
83
	}
Lines 215-221 Link Here
215
/*
217
/*
216
 * Update the bodyStart of the corresponding parse node
218
 * Update the bodyStart of the corresponding parse node
217
 */
219
 */
218
protected void notifySourceElementRequestor(AbstractMethodDeclaration methodDeclaration) {
220
protected void notifySourceElementRequestor(AbstractMethodDeclaration methodDeclaration, TypeDeclaration declaringType, ImportReference currentPackage) {
219
221
220
	// range check
222
	// range check
221
	boolean isInRange =
223
	boolean isInRange =
Lines 288-293 Link Here
288
			methodInfo.typeParameters = getTypeParameterInfos(methodDeclaration.typeParameters());
290
			methodInfo.typeParameters = getTypeParameterInfos(methodDeclaration.typeParameters());
289
			methodInfo.categories = (char[][]) this.nodesToCategories.get(methodDeclaration);
291
			methodInfo.categories = (char[][]) this.nodesToCategories.get(methodDeclaration);
290
			methodInfo.annotations = methodDeclaration.annotations;
292
			methodInfo.annotations = methodDeclaration.annotations;
293
			methodInfo.declaringPackageName = currentPackage == null ? CharOperation.NO_CHAR : CharOperation.concatWith(currentPackage.tokens, '.');
294
			methodInfo.declaringTypeModifiers = declaringType.modifiers;
295
			methodInfo.extraFlags = ExtraFlags.getExtraFlags(declaringType);
291
			methodInfo.node = methodDeclaration;
296
			methodInfo.node = methodDeclaration;
292
			this.requestor.enterConstructor(methodInfo);
297
			this.requestor.enterConstructor(methodInfo);
293
		}
298
		}
Lines 394-399 Link Here
394
			this.requestor.enterCompilationUnit();
399
			this.requestor.enterCompilationUnit();
395
		}
400
		}
396
		ImportReference currentPackage = parsedUnit.currentPackage;
401
		ImportReference currentPackage = parsedUnit.currentPackage;
402
		if (this.localDeclarationVisitor !=  null) {
403
			this.localDeclarationVisitor.currentPackage = currentPackage;
404
		}
397
		ImportReference[] imports = parsedUnit.imports;
405
		ImportReference[] imports = parsedUnit.imports;
398
		TypeDeclaration[] types = parsedUnit.types;
406
		TypeDeclaration[] types = parsedUnit.types;
399
		length =
407
		length =
Lines 429-435 Link Here
429
						notifySourceElementRequestor(importRef, false);
437
						notifySourceElementRequestor(importRef, false);
430
					}
438
					}
431
				} else { // instanceof TypeDeclaration
439
				} else { // instanceof TypeDeclaration
432
					notifySourceElementRequestor((TypeDeclaration)node, true, null);
440
					notifySourceElementRequestor((TypeDeclaration)node, true, null, currentPackage);
433
				}
441
				}
434
			}
442
			}
435
		}
443
		}
Lines 544-550 Link Here
544
			importReference.modifiers);
552
			importReference.modifiers);
545
	}
553
	}
546
}
554
}
547
protected void notifySourceElementRequestor(TypeDeclaration typeDeclaration, boolean notifyTypePresence, TypeDeclaration declaringType) {
555
protected void notifySourceElementRequestor(TypeDeclaration typeDeclaration, boolean notifyTypePresence, TypeDeclaration declaringType, ImportReference currentPackage) {
548
556
549
	if (CharOperation.equals(TypeConstants.PACKAGE_INFO_NAME, typeDeclaration.name)) return;
557
	if (CharOperation.equals(TypeConstants.PACKAGE_INFO_NAME, typeDeclaration.name)) return;
550
558
Lines 600-605 Link Here
600
			typeInfo.secondary = typeDeclaration.isSecondary();
608
			typeInfo.secondary = typeDeclaration.isSecondary();
601
			typeInfo.anonymousMember = typeDeclaration.allocation != null && typeDeclaration.allocation.enclosingInstance != null;
609
			typeInfo.anonymousMember = typeDeclaration.allocation != null && typeDeclaration.allocation.enclosingInstance != null;
602
			typeInfo.annotations = typeDeclaration.annotations;
610
			typeInfo.annotations = typeDeclaration.annotations;
611
			typeInfo.extraFlags = ExtraFlags.getExtraFlags(typeDeclaration);
603
			typeInfo.node = typeDeclaration;
612
			typeInfo.node = typeDeclaration;
604
			this.requestor.enterType(typeInfo);
613
			this.requestor.enterType(typeInfo);
605
			switch (kind) {
614
			switch (kind) {
Lines 663-673 Link Here
663
				break;
672
				break;
664
			case 1 :
673
			case 1 :
665
				methodIndex++;
674
				methodIndex++;
666
				notifySourceElementRequestor(nextMethodDeclaration);
675
				notifySourceElementRequestor(nextMethodDeclaration, typeDeclaration, currentPackage);
667
				break;
676
				break;
668
			case 2 :
677
			case 2 :
669
				memberTypeIndex++;
678
				memberTypeIndex++;
670
				notifySourceElementRequestor(nextMemberDeclaration, true, null);
679
				notifySourceElementRequestor(nextMemberDeclaration, true, null, currentPackage);
671
		}
680
		}
672
	}
681
	}
673
	if (notifyTypePresence){
682
	if (notifyTypePresence){
(-)model/org/eclipse/jdt/internal/compiler/ISourceElementRequestor.java (+4 lines)
Lines 59-64 Link Here
59
		public boolean secondary;
59
		public boolean secondary;
60
		public boolean anonymousMember;
60
		public boolean anonymousMember;
61
		public Annotation[] annotations;
61
		public Annotation[] annotations;
62
		public int extraFlags;
62
		public TypeDeclaration node;
63
		public TypeDeclaration node;
63
		public HashMap childrenCategories = new HashMap();
64
		public HashMap childrenCategories = new HashMap();
64
	}
65
	}
Lines 87-92 Link Here
87
		public TypeParameterInfo[] typeParameters;
88
		public TypeParameterInfo[] typeParameters;
88
		public char[][] categories;
89
		public char[][] categories;
89
		public Annotation[] annotations;
90
		public Annotation[] annotations;
91
		public char[] declaringPackageName;
92
		public int declaringTypeModifiers;
93
		public int extraFlags;
90
		public AbstractMethodDeclaration node;
94
		public AbstractMethodDeclaration node;
91
	}
95
	}
92
96
(-)search/org/eclipse/jdt/internal/core/search/indexing/SourceIndexerRequestor.java (-1 / +47 lines)
Lines 12-18 Link Here
12
12
13
import org.eclipse.jdt.core.Signature;
13
import org.eclipse.jdt.core.Signature;
14
import org.eclipse.jdt.core.compiler.*;
14
import org.eclipse.jdt.core.compiler.*;
15
import org.eclipse.jdt.internal.compiler.ExtraFlags;
15
import org.eclipse.jdt.internal.compiler.ISourceElementRequestor;
16
import org.eclipse.jdt.internal.compiler.ISourceElementRequestor;
17
import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
16
import org.eclipse.jdt.internal.compiler.ast.Expression;
18
import org.eclipse.jdt.internal.compiler.ast.Expression;
17
import org.eclipse.jdt.internal.compiler.ast.ImportReference;
19
import org.eclipse.jdt.internal.compiler.ast.ImportReference;
18
import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
20
import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
Lines 130-135 Link Here
130
public void acceptUnknownReference(char[] name, int sourcePosition) {
132
public void acceptUnknownReference(char[] name, int sourcePosition) {
131
	this.indexer.addNameReference(name);
133
	this.indexer.addNameReference(name);
132
}
134
}
135
136
private void addDefaultConstructorIfNecessary(TypeInfo typeInfo) {
137
	boolean hasConstructor = false;
138
	
139
	TypeDeclaration typeDeclaration = typeInfo.node;
140
	AbstractMethodDeclaration[] methods = typeDeclaration.methods;
141
	int methodCounter = methods == null ? 0 : methods.length;
142
	done : for (int i = 0; i < methodCounter; i++) {
143
		AbstractMethodDeclaration method = methods[i];
144
		if (method.isConstructor() && !method.isDefaultConstructor()) {
145
			hasConstructor = true;
146
			break done;
147
		}
148
	}
149
	
150
	if (!hasConstructor) {
151
		this.indexer.addDefaultConstructorDeclaration(
152
				typeInfo.name,
153
				this.packageName == null ? CharOperation.NO_CHAR : this.packageName,
154
				typeInfo.modifiers,
155
				getMoreExtraFlags(typeInfo.extraFlags));
156
	}
157
}
133
/*
158
/*
134
 * Rebuild the proper qualification for the current source type:
159
 * Rebuild the proper qualification for the current source type:
135
 *
160
 *
Lines 153-158 Link Here
153
		typeNames = enclosingTypeNames();
178
		typeNames = enclosingTypeNames();
154
	}
179
	}
155
	this.indexer.addAnnotationTypeDeclaration(typeInfo.modifiers, this.packageName, typeInfo.name, typeNames, typeInfo.secondary);
180
	this.indexer.addAnnotationTypeDeclaration(typeInfo.modifiers, this.packageName, typeInfo.name, typeNames, typeInfo.secondary);
181
	addDefaultConstructorIfNecessary(typeInfo);
156
	pushTypeName(typeInfo.name);
182
	pushTypeName(typeInfo.name);
157
}
183
}
158
184
Lines 187-192 Link Here
187
		}
213
		}
188
	}
214
	}
189
	this.indexer.addClassDeclaration(typeInfo.modifiers, this.packageName, typeInfo.name, typeNames, typeInfo.superclass, typeInfo.superinterfaces, typeParameterSignatures, typeInfo.secondary);
215
	this.indexer.addClassDeclaration(typeInfo.modifiers, this.packageName, typeInfo.name, typeNames, typeInfo.superclass, typeInfo.superinterfaces, typeParameterSignatures, typeInfo.secondary);
216
	addDefaultConstructorIfNecessary(typeInfo);
190
	pushTypeName(typeInfo.name);
217
	pushTypeName(typeInfo.name);
191
}
218
}
192
/**
219
/**
Lines 199-205 Link Here
199
 * @see ISourceElementRequestor#enterConstructor(ISourceElementRequestor.MethodInfo)
226
 * @see ISourceElementRequestor#enterConstructor(ISourceElementRequestor.MethodInfo)
200
 */
227
 */
201
public void enterConstructor(MethodInfo methodInfo) {
228
public void enterConstructor(MethodInfo methodInfo) {
202
	this.indexer.addConstructorDeclaration(methodInfo.name, methodInfo.parameterTypes, methodInfo.exceptionTypes);
229
	int argCount = methodInfo.parameterTypes == null ? 0 : methodInfo.parameterTypes.length;
230
	this.indexer.addConstructorDeclaration(
231
			methodInfo.name,
232
			argCount,
233
			null,
234
			methodInfo.parameterTypes,
235
			methodInfo.parameterNames,
236
			methodInfo.modifiers,
237
			methodInfo.declaringPackageName,
238
			methodInfo.declaringTypeModifiers,
239
			methodInfo.exceptionTypes,
240
			getMoreExtraFlags(methodInfo.extraFlags));
203
	this.methodDepth++;
241
	this.methodDepth++;
204
}
242
}
205
private void enterEnum(TypeInfo typeInfo) {
243
private void enterEnum(TypeInfo typeInfo) {
Lines 217-222 Link Here
217
	}
255
	}
218
	char[] superclass = typeInfo.superclass == null ? CharOperation.concatWith(TypeConstants.JAVA_LANG_ENUM, '.'): typeInfo.superclass;
256
	char[] superclass = typeInfo.superclass == null ? CharOperation.concatWith(TypeConstants.JAVA_LANG_ENUM, '.'): typeInfo.superclass;
219
	this.indexer.addEnumDeclaration(typeInfo.modifiers, this.packageName, typeInfo.name, typeNames, superclass, typeInfo.superinterfaces, typeInfo.secondary);
257
	this.indexer.addEnumDeclaration(typeInfo.modifiers, this.packageName, typeInfo.name, typeNames, superclass, typeInfo.superinterfaces, typeInfo.secondary);
258
	addDefaultConstructorIfNecessary(typeInfo);
220
	pushTypeName(typeInfo.name);
259
	pushTypeName(typeInfo.name);
221
}
260
}
222
/**
261
/**
Lines 255-260 Link Here
255
		}
294
		}
256
	}
295
	}
257
	this.indexer.addInterfaceDeclaration(typeInfo.modifiers, this.packageName, typeInfo.name, typeNames, typeInfo.superinterfaces, typeParameterSignatures, typeInfo.secondary);
296
	this.indexer.addInterfaceDeclaration(typeInfo.modifiers, this.packageName, typeInfo.name, typeNames, typeInfo.superinterfaces, typeParameterSignatures, typeInfo.secondary);
297
	addDefaultConstructorIfNecessary(typeInfo);
258
	pushTypeName(typeInfo.name);
298
	pushTypeName(typeInfo.name);
259
}
299
}
260
/**
300
/**
Lines 353-358 Link Here
353
	}
393
	}
354
	return  CharOperation.subarray(typeName, lastDot + 1, lastGenericStart);
394
	return  CharOperation.subarray(typeName, lastDot + 1, lastGenericStart);
355
}
395
}
396
private int getMoreExtraFlags(int extraFlags) {
397
	if (this.methodDepth > 0) {
398
		extraFlags |= ExtraFlags.IsLocalType;
399
	}
400
	return extraFlags;
401
}
356
public void popTypeName() {
402
public void popTypeName() {
357
	if (this.depth > 0) {
403
	if (this.depth > 0) {
358
		this.enclosingTypeNames[--this.depth] = null;
404
		this.enclosingTypeNames[--this.depth] = null;
(-)search/org/eclipse/jdt/internal/core/search/indexing/IIndexConstants.java (+3 lines)
Lines 23-34 Link Here
23
	char[] TYPE_DECL = "typeDecl".toCharArray(); //$NON-NLS-1$
23
	char[] TYPE_DECL = "typeDecl".toCharArray(); //$NON-NLS-1$
24
	char[] METHOD_DECL= "methodDecl".toCharArray(); //$NON-NLS-1$
24
	char[] METHOD_DECL= "methodDecl".toCharArray(); //$NON-NLS-1$
25
	char[] CONSTRUCTOR_DECL= "constructorDecl".toCharArray(); //$NON-NLS-1$
25
	char[] CONSTRUCTOR_DECL= "constructorDecl".toCharArray(); //$NON-NLS-1$
26
	char[] EXT_CONSTRUCTOR_DECL= "extConstructorDecl".toCharArray(); //$NON-NLS-1$
26
	char[] FIELD_DECL= "fieldDecl".toCharArray(); //$NON-NLS-1$
27
	char[] FIELD_DECL= "fieldDecl".toCharArray(); //$NON-NLS-1$
27
	char[] OBJECT = "Object".toCharArray(); //$NON-NLS-1$
28
	char[] OBJECT = "Object".toCharArray(); //$NON-NLS-1$
28
	char[][] COUNTS=
29
	char[][] COUNTS=
29
		new char[][] { new char[] {'/', '0'}, new char[] {'/', '1'}, new char[] {'/', '2'}, new char[] {'/', '3'}, new char[] {'/', '4'},
30
		new char[][] { new char[] {'/', '0'}, new char[] {'/', '1'}, new char[] {'/', '2'}, new char[] {'/', '3'}, new char[] {'/', '4'},
30
			new char[] {'/', '5'}, new char[] {'/', '6'}, new char[] {'/', '7'}, new char[] {'/', '8'}, new char[] {'/', '9'}
31
			new char[] {'/', '5'}, new char[] {'/', '6'}, new char[] {'/', '7'}, new char[] {'/', '8'}, new char[] {'/', '9'}
31
	};
32
	};
33
	char[] DEFAULT_CONSTRUCTOR = new char[]{'/', '#'};
32
	char CLASS_SUFFIX = 'C';
34
	char CLASS_SUFFIX = 'C';
33
	char INTERFACE_SUFFIX = 'I';
35
	char INTERFACE_SUFFIX = 'I';
34
	char ENUM_SUFFIX = 'E';
36
	char ENUM_SUFFIX = 'E';
Lines 38-43 Link Here
38
	char CLASS_AND_INTERFACE_SUFFIX = IJavaSearchConstants.CLASS_AND_INTERFACE;
40
	char CLASS_AND_INTERFACE_SUFFIX = IJavaSearchConstants.CLASS_AND_INTERFACE;
39
	char INTERFACE_AND_ANNOTATION_SUFFIX = IJavaSearchConstants.INTERFACE_AND_ANNOTATION;
41
	char INTERFACE_AND_ANNOTATION_SUFFIX = IJavaSearchConstants.INTERFACE_AND_ANNOTATION;
40
	char SEPARATOR= '/';
42
	char SEPARATOR= '/';
43
	char PARAMETER_SEPARATOR= ',';
41
	char SECONDARY_SUFFIX = 'S';
44
	char SECONDARY_SUFFIX = 'S';
42
45
43
	char[] ONE_STAR = new char[] {'*'};
46
	char[] ONE_STAR = new char[] {'*'};
(-)search/org/eclipse/jdt/internal/core/search/indexing/AbstractIndexer.java (-4 / +31 lines)
Lines 71-80 Link Here
71
			typeName = CharOperation.subarray(typeName, 0, genericStart);
71
			typeName = CharOperation.subarray(typeName, 0, genericStart);
72
		return typeName;
72
		return typeName;
73
	}
73
	}
74
	public void addConstructorDeclaration(char[] typeName, char[][] parameterTypes, char[][] exceptionTypes) {
74
	public void addConstructorDeclaration(
75
		int argCount = parameterTypes == null ? 0 : parameterTypes.length;
75
			char[] typeName,
76
		addIndexEntry(CONSTRUCTOR_DECL, ConstructorPattern.createIndexKey(CharOperation.lastSegment(typeName,'.'), argCount));
76
			int argCount,
77
77
			char[] signature,
78
			char[][] parameterTypes,
79
			char[][] parameterNames,
80
			int modifiers,
81
			char[] packageName,
82
			int typeModifiers,
83
			char[][] exceptionTypes,
84
			int extraFlags) {
85
		addIndexEntry(
86
				CONSTRUCTOR_DECL,
87
				ConstructorPattern.createDeclarationIndexKey(
88
						typeName,
89
						argCount,
90
						signature,
91
						parameterTypes,
92
						parameterNames,
93
						modifiers,
94
						packageName,
95
						typeModifiers,
96
						extraFlags));
97
		
78
		if (parameterTypes != null) {
98
		if (parameterTypes != null) {
79
			for (int i = 0; i < argCount; i++)
99
			for (int i = 0; i < argCount; i++)
80
				addTypeReference(parameterTypes[i]);
100
				addTypeReference(parameterTypes[i]);
Lines 91-96 Link Here
91
		if (innermostTypeName != simpleTypeName)
111
		if (innermostTypeName != simpleTypeName)
92
			addIndexEntry(CONSTRUCTOR_REF, ConstructorPattern.createIndexKey(innermostTypeName, argCount));
112
			addIndexEntry(CONSTRUCTOR_REF, ConstructorPattern.createIndexKey(innermostTypeName, argCount));
93
	}
113
	}
114
	public void addDefaultConstructorDeclaration(
115
			char[] typeName,
116
			char[] packageName,
117
			int typeModifiers,
118
			int extraFlags) {
119
		addIndexEntry(CONSTRUCTOR_DECL, ConstructorPattern.createDefaultDeclarationIndexKey(CharOperation.lastSegment(typeName,'.'), packageName, typeModifiers, extraFlags));
120
	}
94
	public void addEnumDeclaration(int modifiers, char[] packageName, char[] name, char[][] enclosingTypeNames, char[] superclass, char[][] superinterfaces, boolean secondary) {
121
	public void addEnumDeclaration(int modifiers, char[] packageName, char[] name, char[][] enclosingTypeNames, char[] superclass, char[][] superinterfaces, boolean secondary) {
95
		addTypeDeclaration(modifiers, packageName, name, enclosingTypeNames, secondary);
122
		addTypeDeclaration(modifiers, packageName, name, enclosingTypeNames, secondary);
96
123
(-)search/org/eclipse/jdt/internal/core/search/indexing/BinaryIndexer.java (-1 / +44 lines)
Lines 14-19 Link Here
14
import org.eclipse.jdt.core.Signature;
14
import org.eclipse.jdt.core.Signature;
15
import org.eclipse.jdt.core.compiler.CharOperation;
15
import org.eclipse.jdt.core.compiler.CharOperation;
16
import org.eclipse.jdt.core.search.SearchDocument;
16
import org.eclipse.jdt.core.search.SearchDocument;
17
import org.eclipse.jdt.internal.compiler.ExtraFlags;
17
import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
18
import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
18
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
19
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
19
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader;
20
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader;
Lines 700-708 Link Here
700
			if (tagBits != 0) {
701
			if (tagBits != 0) {
701
				addBinaryStandardAnnotations(tagBits);
702
				addBinaryStandardAnnotations(tagBits);
702
			}
703
			}
704
			
705
			int extraFlags = ExtraFlags.getExtraFlags(reader);
703
706
704
			// first reference all methods declarations and field declarations
707
			// first reference all methods declarations and field declarations
705
			MethodInfo[] methods = (MethodInfo[]) reader.getMethods();
708
			MethodInfo[] methods = (MethodInfo[]) reader.getMethods();
709
			boolean noConstructor = true;
706
			if (methods != null) {
710
			if (methods != null) {
707
				for (int i = 0, max = methods.length; i < max; i++) {
711
				for (int i = 0, max = methods.length; i < max; i++) {
708
					MethodInfo method = methods[i];
712
					MethodInfo method = methods[i];
Lines 712-718 Link Here
712
					char[] returnType = decodeReturnType(descriptor);
716
					char[] returnType = decodeReturnType(descriptor);
713
					char[][] exceptionTypes = replace('/', '.', method.getExceptionTypeNames());
717
					char[][] exceptionTypes = replace('/', '.', method.getExceptionTypeNames());
714
					if (isConstructor) {
718
					if (isConstructor) {
715
						addConstructorDeclaration(className, parameterTypes, exceptionTypes);
719
						noConstructor = false;
720
						char[] signature = method.getGenericSignature();
721
						if (signature == null) {
722
							if (reader.isNestedType() && ((modifiers & ClassFileConstants.AccStatic) == 0)) {
723
								signature = removeFirstSyntheticParameter(descriptor);
724
							} else {
725
								signature = descriptor;
726
							}
727
						}
728
						addConstructorDeclaration(
729
								name,
730
								parameterTypes == null ? 0 : parameterTypes.length,
731
								signature,	
732
								parameterTypes,
733
								method.getArgumentNames(),
734
								method.getModifiers(),
735
								packageName,
736
								modifiers,
737
								exceptionTypes,
738
								extraFlags);
716
					} else {
739
					} else {
717
						if (!method.isClinit()) {
740
						if (!method.isClinit()) {
718
							addMethodDeclaration(method.getSelector(), parameterTypes, returnType, exceptionTypes);
741
							addMethodDeclaration(method.getSelector(), parameterTypes, returnType, exceptionTypes);
Lines 732-737 Link Here
732
					}
755
					}
733
				}
756
				}
734
			}
757
			}
758
			if (noConstructor) {
759
				addDefaultConstructorDeclaration(className, packageName, modifiers, extraFlags);
760
			}
735
			FieldInfo[] fields = (FieldInfo[]) reader.getFields();
761
			FieldInfo[] fields = (FieldInfo[]) reader.getFields();
736
			if (fields != null) {
762
			if (fields != null) {
737
				for (int i = 0, max = fields.length; i < max; i++) {
763
				for (int i = 0, max = fields.length; i < max; i++) {
Lines 767-772 Link Here
767
			Util.log(IStatus.WARNING, "The Java indexing could not index " + this.document.getPath() + ". This .class file doesn't follow the class file format specification. Please report this issue against the .class file vendor"); //$NON-NLS-1$ //$NON-NLS-2$
793
			Util.log(IStatus.WARNING, "The Java indexing could not index " + this.document.getPath() + ". This .class file doesn't follow the class file format specification. Please report this issue against the .class file vendor"); //$NON-NLS-1$ //$NON-NLS-2$
768
		}
794
		}
769
	}
795
	}
796
	
797
	private char[] removeFirstSyntheticParameter(char[] descriptor) {
798
		if (descriptor == null) return null;
799
		if (descriptor.length < 3) return descriptor;
800
		if (descriptor[0] != '(') return descriptor;
801
		if (descriptor[1] != ')') {
802
			// remove the first synthetic parameter
803
			int start = Util.scanTypeSignature(descriptor, 1) + 1;
804
			int length = descriptor.length - start;
805
			char[] signature = new char[length + 1];
806
			signature[0] = descriptor[0];
807
			System.arraycopy(descriptor, start, signature, 1, length);
808
			return signature;
809
		} else {
810
			return descriptor;
811
		}
812
	}
770
	/*
813
	/*
771
	 * Modify the array by replacing all occurences of toBeReplaced with newChar
814
	 * Modify the array by replacing all occurences of toBeReplaced with newChar
772
	 */
815
	 */
(-)codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistParser.java (+15 lines)
Lines 85-90 Link Here
85
	setStatementsRecovery(false);
85
	setStatementsRecovery(false);
86
}
86
}
87
public abstract char[] assistIdentifier();
87
public abstract char[] assistIdentifier();
88
89
/**
90
 * The parser become a simple parser which behave like a Parser
91
 * @return the state of the assist parser to be able to restore the assist parser state
92
 */
93
public Object becomeSimpleParser() {
94
	return null;
95
}
96
/**
97
 * Restore the parser as an assist parser
98
 * @param parserState
99
 */
100
public void restoreAssistParser(Object parserState) {
101
	//Do nothing
102
}
88
public int bodyEnd(AbstractMethodDeclaration method){
103
public int bodyEnd(AbstractMethodDeclaration method){
89
	return method.bodyEnd;
104
	return method.bodyEnd;
90
}
105
}
(-)codeassist/org/eclipse/jdt/internal/codeassist/impl/Engine.java (-10 / +22 lines)
Lines 65-72 Link Here
65
	 */
65
	 */
66
	public void accept(ICompilationUnit sourceUnit, AccessRestriction accessRestriction) {
66
	public void accept(ICompilationUnit sourceUnit, AccessRestriction accessRestriction) {
67
		CompilationResult result = new CompilationResult(sourceUnit, 1, 1, this.compilerOptions.maxProblemsPerUnit);
67
		CompilationResult result = new CompilationResult(sourceUnit, 1, 1, this.compilerOptions.maxProblemsPerUnit);
68
		
69
		AssistParser assistParser = getParser();
70
		Object parserState = assistParser.becomeSimpleParser();
71
		
68
		CompilationUnitDeclaration parsedUnit =
72
		CompilationUnitDeclaration parsedUnit =
69
			getParser().dietParse(sourceUnit, result);
73
			assistParser.dietParse(sourceUnit, result);
74
		
75
		assistParser.restoreAssistParser(parserState);
70
76
71
		this.lookupEnvironment.buildTypeBindings(parsedUnit, accessRestriction);
77
		this.lookupEnvironment.buildTypeBindings(parsedUnit, accessRestriction);
72
		this.lookupEnvironment.completeTypeBindings(parsedUnit, true);
78
		this.lookupEnvironment.completeTypeBindings(parsedUnit, true);
Lines 97-114 Link Here
97
	public abstract AssistParser getParser();
103
	public abstract AssistParser getParser();
98
104
99
	public void initializeImportCaches() {
105
	public void initializeImportCaches() {
106
		if (this.currentPackageName == null) {
107
			initializePackageCache();
108
		}
109
		
100
		ImportBinding[] importBindings = this.unitScope.imports;
110
		ImportBinding[] importBindings = this.unitScope.imports;
101
		int length = importBindings == null ? 0 : importBindings.length;
111
		int length = importBindings == null ? 0 : importBindings.length;
102
112
103
		if (this.unitScope.fPackage != null) {
104
			this.currentPackageName = CharOperation.concatWith(this.unitScope.fPackage.compoundName, '.');
105
		} else if (this.unitScope.referenceContext != null &&
106
				this.unitScope.referenceContext.currentPackage != null) {
107
			this.currentPackageName = CharOperation.concatWith(this.unitScope.referenceContext.currentPackage.tokens, '.');
108
		} else {
109
			this.currentPackageName = CharOperation.NO_CHAR;
110
		}
111
112
		for (int i = 0; i < length; i++) {
113
		for (int i = 0; i < length; i++) {
113
			ImportBinding importBinding = importBindings[i];
114
			ImportBinding importBinding = importBindings[i];
114
			if(importBinding.onDemand) {
115
			if(importBinding.onDemand) {
Lines 133-138 Link Here
133
134
134
		this.importCachesInitialized = true;
135
		this.importCachesInitialized = true;
135
	}
136
	}
137
	
138
	public void initializePackageCache() {
139
		if (this.unitScope.fPackage != null) {
140
			this.currentPackageName = CharOperation.concatWith(this.unitScope.fPackage.compoundName, '.');
141
		} else if (this.unitScope.referenceContext != null &&
142
				this.unitScope.referenceContext.currentPackage != null) {
143
			this.currentPackageName = CharOperation.concatWith(this.unitScope.referenceContext.currentPackage.tokens, '.');
144
		} else {
145
			this.currentPackageName = CharOperation.NO_CHAR;
146
		}
147
	}
136
148
137
	protected boolean mustQualifyType(
149
	protected boolean mustQualifyType(
138
		char[] packageName,
150
		char[] packageName,
(-)codeassist/org/eclipse/jdt/internal/codeassist/MissingTypesGuesser.java (-1 / +14 lines)
Lines 462-468 Link Here
462
			isQualified ? CharOperation.concatWith(missingTypeName, '.') : null;
462
			isQualified ? CharOperation.concatWith(missingTypeName, '.') : null;
463
		final ArrayList results = new ArrayList();
463
		final ArrayList results = new ArrayList();
464
		ISearchRequestor storage = new ISearchRequestor() {
464
		ISearchRequestor storage = new ISearchRequestor() {
465
465
			public void acceptConstructor(
466
					int modifiers,
467
					char[] simpleTypeName,
468
					int parameterCount,
469
					char[] signature,
470
					char[][] parameterTypes,
471
					char[][] parameterNames,
472
					int typeModifiers,
473
					char[] packageName,
474
					int extraFlags,
475
					String path,
476
					AccessRestriction access) {
477
				// constructors aren't searched
478
			}
466
			public void acceptPackage(char[] packageName) {
479
			public void acceptPackage(char[] packageName) {
467
				// package aren't searched
480
				// package aren't searched
468
			}
481
			}
(-)codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java (-276 / +1584 lines)
Lines 40-45 Link Here
40
import org.eclipse.jdt.internal.codeassist.impl.Keywords;
40
import org.eclipse.jdt.internal.codeassist.impl.Keywords;
41
import org.eclipse.jdt.internal.compiler.CompilationResult;
41
import org.eclipse.jdt.internal.compiler.CompilationResult;
42
import org.eclipse.jdt.internal.compiler.DefaultErrorHandlingPolicies;
42
import org.eclipse.jdt.internal.compiler.DefaultErrorHandlingPolicies;
43
import org.eclipse.jdt.internal.compiler.ExtraFlags;
43
import org.eclipse.jdt.internal.compiler.ast.*;
44
import org.eclipse.jdt.internal.compiler.ast.*;
44
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
45
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
45
import org.eclipse.jdt.internal.compiler.env.*;
46
import org.eclipse.jdt.internal.compiler.env.*;
Lines 60-71 Link Here
60
import org.eclipse.jdt.internal.core.BasicCompilationUnit;
61
import org.eclipse.jdt.internal.core.BasicCompilationUnit;
61
import org.eclipse.jdt.internal.core.INamingRequestor;
62
import org.eclipse.jdt.internal.core.INamingRequestor;
62
import org.eclipse.jdt.internal.core.InternalNamingConventions;
63
import org.eclipse.jdt.internal.core.InternalNamingConventions;
64
import org.eclipse.jdt.internal.core.JavaModelManager;
63
import org.eclipse.jdt.internal.core.SourceMethod;
65
import org.eclipse.jdt.internal.core.SourceMethod;
64
import org.eclipse.jdt.internal.core.SourceMethodElementInfo;
66
import org.eclipse.jdt.internal.core.SourceMethodElementInfo;
65
import org.eclipse.jdt.internal.core.SourceType;
67
import org.eclipse.jdt.internal.core.SourceType;
66
import org.eclipse.jdt.internal.core.BinaryTypeConverter;
68
import org.eclipse.jdt.internal.core.BinaryTypeConverter;
67
import org.eclipse.jdt.internal.core.SearchableEnvironment;
69
import org.eclipse.jdt.internal.core.SearchableEnvironment;
68
import org.eclipse.jdt.internal.core.SourceTypeElementInfo;
70
import org.eclipse.jdt.internal.core.SourceTypeElementInfo;
71
import org.eclipse.jdt.internal.core.search.matching.JavaSearchNameEnvironment;
69
import org.eclipse.jdt.internal.core.util.Messages;
72
import org.eclipse.jdt.internal.core.util.Messages;
70
73
71
/**
74
/**
Lines 77-82 Link Here
77
	extends Engine
80
	extends Engine
78
	implements ISearchRequestor, TypeConstants , TerminalTokens , RelevanceConstants, SuffixConstants {
81
	implements ISearchRequestor, TypeConstants , TerminalTokens , RelevanceConstants, SuffixConstants {
79
	
82
	
83
	private static class AcceptedConstructor {
84
		public int modifiers;
85
		public char[] simpleTypeName;
86
		public int parameterCount;
87
		public char[] signature;
88
		public char[][] parameterTypes;
89
		public char[][] parameterNames;
90
		public int typeModifiers;
91
		public char[] packageName;
92
		public int extraFlags;
93
		public int accessibility;
94
		public boolean proposeType = false;
95
		public boolean proposeConstructor = false;
96
		public char[] fullyQualifiedName = null;
97
		
98
		public boolean mustBeQualified = false;
99
		
100
		public AcceptedConstructor(
101
				int modifiers,
102
				char[] simpleTypeName,
103
				int parameterCount,
104
				char[] signature,
105
				char[][] parameterTypes,
106
				char[][] parameterNames,
107
				int typeModifiers,
108
				char[] packageName,
109
				int extraFlags,
110
				int accessibility) {
111
			this.modifiers = modifiers;
112
			this.simpleTypeName = simpleTypeName;
113
			this.parameterCount = parameterCount;
114
			this.signature = signature;
115
			this.parameterTypes = parameterTypes;
116
			this.parameterNames = parameterNames;
117
			this.typeModifiers = typeModifiers;
118
			this.packageName = packageName;
119
			this.extraFlags = extraFlags;
120
			this.accessibility = accessibility;
121
		}
122
123
		public String toString() {
124
			StringBuffer buffer = new StringBuffer();
125
			buffer.append('{');
126
			buffer.append(this.packageName);
127
			buffer.append(',');
128
			buffer.append(this.simpleTypeName);
129
			buffer.append('}');
130
			return buffer.toString();
131
		}
132
	}
133
	
80
	private static class AcceptedType {
134
	private static class AcceptedType {
81
		public char[] packageName;
135
		public char[] packageName;
82
		public char[] simpleTypeName;
136
		public char[] simpleTypeName;
Lines 226-232 Link Here
226
			this.checkProblems = false;
280
			this.checkProblems = false;
227
		}
281
		}
228
	}
282
	}
283
	
284
	public static char[] createBindingKey(char[] packageName, char[] typeName) {
285
		char[] signature = createTypeSignature(packageName, typeName);
286
		CharOperation.replace(signature, '.', '/');
287
		return signature;
288
	}
229
289
290
	public static char[][] createDefaultParameterNames(int length) {
291
		char[][] parameters;
292
		switch (length) {
293
			case 0 :
294
				parameters = new char[length][];
295
				break;
296
			case 1 :
297
				parameters = ARGS1;
298
				break;
299
			case 2 :
300
				parameters = ARGS2;
301
				break;
302
			case 3 :
303
				parameters = ARGS3;
304
				break;
305
			case 4 :
306
				parameters = ARGS4;
307
				break;
308
			default :
309
				parameters = new char[length][];
310
				for (int i = 0; i < length; i++) {
311
					parameters[i] = CharOperation.concat(ARG, String.valueOf(i).toCharArray());
312
				}
313
				break;
314
		}
315
		return parameters;
316
	}
230
	public static char[] createMethodSignature(char[][] parameterPackageNames, char[][] parameterTypeNames, char[] returnTypeSignature) {
317
	public static char[] createMethodSignature(char[][] parameterPackageNames, char[][] parameterTypeNames, char[] returnTypeSignature) {
231
		char[][] parameterTypeSignature = new char[parameterTypeNames.length][];
318
		char[][] parameterTypeSignature = new char[parameterTypeNames.length][];
232
		for (int i = 0; i < parameterTypeSignature.length; i++) {
319
		for (int i = 0; i < parameterTypeSignature.length; i++) {
Lines 302-313 Link Here
302
		result = CharOperation.replaceOnCopy(result, '/', '.');
389
		result = CharOperation.replaceOnCopy(result, '/', '.');
303
		return result;
390
		return result;
304
	}
391
	}
392
	
393
	private static boolean hasStaticMemberTypes(ReferenceBinding typeBinding, SourceTypeBinding invocationType, CompilationUnitScope unitScope) {
394
		ReferenceBinding[] memberTypes = typeBinding.memberTypes();
395
		int length = memberTypes == null ? 0 : memberTypes.length;
396
		next : for (int i = 0; i < length; i++) {
397
			ReferenceBinding memberType = memberTypes[i];
398
			if (invocationType != null && !memberType.canBeSeenBy(typeBinding, invocationType)) {
399
				continue next;
400
			} else if(invocationType == null && !memberType.canBeSeenBy(unitScope.fPackage)) {
401
				continue next;
402
			}
403
			
404
			if ((memberType.modifiers & ClassFileConstants.AccStatic) != 0) {
405
				return true;
406
			}
407
		}
408
		return false;
409
	}
305
	public HashtableOfObject typeCache;
410
	public HashtableOfObject typeCache;
306
	
411
	
307
	public static boolean DEBUG = false;
412
	public static boolean DEBUG = false;
308
	public static boolean PERF = false;
413
	public static boolean PERF = false;
309
	
414
	
310
	private final static int CHECK_CANCEL_FREQUENCY_IN_FIND_TYPES = 50;
415
	private static final char[] KNOWN_TYPE_WITH_UNKNOWN_CONSTRUCTORS = new char[]{};
416
	private static final char[] KNOWN_TYPE_WITH_KNOWN_CONSTRUCTORS = new char[]{};
417
	
418
	private static final char[] ARG = "arg".toCharArray();  //$NON-NLS-1$
419
	private static final char[] ARG0 = "arg0".toCharArray();  //$NON-NLS-1$
420
	private static final char[] ARG1 = "arg1".toCharArray();  //$NON-NLS-1$
421
	private static final char[] ARG2 = "arg2".toCharArray();  //$NON-NLS-1$
422
	private static final char[] ARG3 = "arg3".toCharArray();  //$NON-NLS-1$
423
	private static final char[][] ARGS1 = new char[][]{ARG0};
424
	private static final char[][] ARGS2 = new char[][]{ARG0, ARG1};
425
	private static final char[][] ARGS3 = new char[][]{ARG0, ARG1, ARG2};
426
	private static final char[][] ARGS4 = new char[][]{ARG0, ARG1, ARG2, ARG3};
427
	
428
	private final static int CHECK_CANCEL_FREQUENCY = 50;
311
	
429
	
312
	// temporary constants to quickly disabled polish features if necessary
430
	// temporary constants to quickly disabled polish features if necessary
313
	public final static boolean NO_TYPE_COMPLETION_ON_EMPTY_TOKEN = false;
431
	public final static boolean NO_TYPE_COMPLETION_ON_EMPTY_TOKEN = false;
Lines 323-328 Link Here
323
	private final static char[] VALUE = "value".toCharArray();  //$NON-NLS-1$
441
	private final static char[] VALUE = "value".toCharArray();  //$NON-NLS-1$
324
	private final static char[] EXTENDS = "extends".toCharArray();  //$NON-NLS-1$
442
	private final static char[] EXTENDS = "extends".toCharArray();  //$NON-NLS-1$
325
	private final static char[] SUPER = "super".toCharArray();  //$NON-NLS-1$
443
	private final static char[] SUPER = "super".toCharArray();  //$NON-NLS-1$
444
	private final static char[] DEFAULT_CONSTRUCTOR_SIGNATURE = "()V".toCharArray();  //$NON-NLS-1$
326
	
445
	
327
	private final static char[] DOT = ".".toCharArray();  //$NON-NLS-1$
446
	private final static char[] DOT = ".".toCharArray();  //$NON-NLS-1$
328
447
Lines 374-379 Link Here
374
	CompletionRequestor requestor;
493
	CompletionRequestor requestor;
375
	CompletionProblemFactory problemFactory;
494
	CompletionProblemFactory problemFactory;
376
	ProblemReporter problemReporter;
495
	ProblemReporter problemReporter;
496
	private JavaSearchNameEnvironment noCacheNameEnvironment;
377
	char[] source;
497
	char[] source;
378
	char[] completionToken;
498
	char[] completionToken;
379
	char[] qualifiedCompletionToken;
499
	char[] qualifiedCompletionToken;
Lines 458-463 Link Here
458
578
459
	private int foundTypesCount;
579
	private int foundTypesCount;
460
	private ObjectVector acceptedTypes;
580
	private ObjectVector acceptedTypes;
581
	
582
	private int foundConstructorsCount;
583
	private ObjectVector acceptedConstructors;
461
584
462
	/**
585
	/**
463
	 * The CompletionEngine is responsible for computing source completions.
586
	 * The CompletionEngine is responsible for computing source completions.
Lines 510-515 Link Here
510
		this.owner = owner;
633
		this.owner = owner;
511
		this.monitor = monitor;
634
		this.monitor = monitor;
512
	}
635
	}
636
	
637
	public void acceptConstructor(
638
			int modifiers,
639
			char[] simpleTypeName,
640
			int parameterCount,
641
			char[] signature,
642
			char[][] parameterTypes,
643
			char[][] parameterNames,
644
			int typeModifiers,
645
			char[] packageName,
646
			int extraFlags,
647
			String path,
648
			AccessRestriction accessRestriction) {
649
		
650
		// does not check cancellation for every types to avoid performance loss
651
		if ((this.foundConstructorsCount % (CHECK_CANCEL_FREQUENCY)) == 0) checkCancel();
652
		this.foundConstructorsCount++;
653
		
654
		if ((typeModifiers & ClassFileConstants.AccEnum) != 0) return;
655
		
656
		if (this.options.checkDeprecation && (typeModifiers & ClassFileConstants.AccDeprecated) != 0) return;
657
658
		if (this.options.checkVisibility) {
659
			if((typeModifiers & ClassFileConstants.AccPublic) == 0) {
660
				if((typeModifiers & ClassFileConstants.AccPrivate) != 0) return;
661
662
				if (this.currentPackageName == null) {
663
					initializePackageCache();
664
				}
665
				
666
				if(!CharOperation.equals(packageName, this.currentPackageName)) return;
667
			}
668
		}
669
670
		int accessibility = IAccessRule.K_ACCESSIBLE;
671
		if(accessRestriction != null) {
672
			switch (accessRestriction.getProblemId()) {
673
				case IProblem.ForbiddenReference:
674
					if (this.options.checkForbiddenReference) {
675
						return;
676
					}
677
					accessibility = IAccessRule.K_NON_ACCESSIBLE;
678
					break;
679
				case IProblem.DiscouragedReference:
680
					if (this.options.checkDiscouragedReference) {
681
						return;
682
					}
683
					accessibility = IAccessRule.K_DISCOURAGED;
684
					break;
685
			}
686
		}
687
		
688
		if(this.acceptedConstructors == null) {
689
			this.acceptedConstructors = new ObjectVector();
690
		}
691
		this.acceptedConstructors.add(
692
				new AcceptedConstructor(
693
						modifiers,
694
						simpleTypeName,
695
						parameterCount,
696
						signature,
697
						parameterTypes,
698
						parameterNames,
699
						typeModifiers,
700
						packageName,
701
						extraFlags,
702
						accessibility));
703
	}
704
	
705
	private void acceptConstructors(Scope scope) {
706
		final boolean DEFER_QUALIFIED_PROPOSALS = false;
707
		
708
		this.checkCancel();
709
		
710
		if(this.acceptedConstructors == null) return;
711
712
		int length = this.acceptedConstructors.size();
713
714
		if(length == 0) return;
715
		
716
		HashtableOfObject onDemandFound = new HashtableOfObject();
717
		
718
		ArrayList deferredProposals = new ArrayList();
719
		
720
		try {
721
			next : for (int i = 0; i < length; i++) {
722
				
723
				// does not check cancellation for every types to avoid performance loss
724
				if ((i % CHECK_CANCEL_FREQUENCY) == 0) checkCancel();
725
				
726
				AcceptedConstructor acceptedConstructor = (AcceptedConstructor)this.acceptedConstructors.elementAt(i);
727
				final int typeModifiers = acceptedConstructor.typeModifiers;
728
				final char[] packageName = acceptedConstructor.packageName;
729
				final char[] simpleTypeName = acceptedConstructor.simpleTypeName;
730
				final int modifiers = acceptedConstructor.modifiers;
731
				final int parameterCount = acceptedConstructor.parameterCount;
732
				final char[] signature = acceptedConstructor.signature;
733
				final char[][] parameterTypes = acceptedConstructor.parameterTypes;
734
				final char[][] parameterNames = acceptedConstructor.parameterNames;
735
				final int extraFlags = acceptedConstructor.extraFlags;
736
				final int accessibility = acceptedConstructor.accessibility;
737
				
738
				boolean proposeType = (extraFlags & ExtraFlags.HasNonPrivateStaticMemberTypes) != 0;
739
				
740
				char[] fullyQualifiedName = CharOperation.concat(packageName, simpleTypeName, '.');
741
						
742
				Object knownTypeKind = this.knownTypes.get(fullyQualifiedName);
743
				if (knownTypeKind != null) {
744
					if (knownTypeKind == KNOWN_TYPE_WITH_KNOWN_CONSTRUCTORS) {
745
						// the type and its constructors are already accepted
746
						continue next;
747
					}
748
					// this type is already accepted
749
					proposeType = false;
750
				} else {
751
					this.knownTypes.put(fullyQualifiedName, KNOWN_TYPE_WITH_UNKNOWN_CONSTRUCTORS);
752
				}
753
				
754
				boolean proposeConstructor = true;
755
					
756
				if (this.options.checkVisibility) {
757
					if((modifiers & ClassFileConstants.AccPublic) == 0) {
758
						if((modifiers & ClassFileConstants.AccPrivate) != 0) {
759
							if (!proposeType) continue next;
760
							proposeConstructor = false;
761
						} else {
762
							if (this.currentPackageName == null) {
763
								initializePackageCache();
764
							}
765
							
766
							if(!CharOperation.equals(packageName, this.currentPackageName)) {
767
								if (!proposeType) continue next;
768
								proposeConstructor = false;
769
							}
770
						}
771
					}
772
				}
773
				
774
				acceptedConstructor.fullyQualifiedName = fullyQualifiedName;
775
				acceptedConstructor.proposeType = proposeType;
776
				acceptedConstructor.proposeConstructor = proposeConstructor;
777
				
778
				
779
				if(!this.importCachesInitialized) {
780
					initializeImportCaches();
781
				}
782
				
783
				for (int j = 0; j < this.importCacheCount; j++) {
784
					char[][] importName = this.importsCache[j];
785
					if(CharOperation.equals(simpleTypeName, importName[0])) {
786
						if (proposeType) {
787
							proposeType(
788
									packageName,
789
									simpleTypeName,
790
									typeModifiers,
791
									accessibility,
792
									simpleTypeName,
793
									fullyQualifiedName,
794
									!CharOperation.equals(fullyQualifiedName, importName[1]),
795
									scope);
796
						}
797
						
798
						if (proposeConstructor && !Flags.isEnum(typeModifiers)) {
799
							boolean isQualified = !CharOperation.equals(fullyQualifiedName, importName[1]);
800
							if (!isQualified) {
801
								proposeConstructor(
802
										simpleTypeName,
803
										parameterCount,
804
										signature,
805
										parameterTypes,
806
										parameterNames,
807
										modifiers,
808
										packageName,
809
										typeModifiers,
810
										accessibility,
811
										simpleTypeName,
812
										fullyQualifiedName,
813
										isQualified,
814
										scope,
815
										extraFlags);
816
							} else {
817
								acceptedConstructor.mustBeQualified = true;
818
								if (DEFER_QUALIFIED_PROPOSALS) {
819
									deferredProposals.add(acceptedConstructor);
820
								} else {
821
									proposeConstructor(acceptedConstructor, scope);
822
								}
823
							}
824
						}
825
						continue next;
826
					}
827
				}
828
829
830
				if (CharOperation.equals(this.currentPackageName, packageName)) {
831
					if (proposeType) {
832
						proposeType(
833
								packageName,
834
								simpleTypeName,
835
								typeModifiers,
836
								accessibility,
837
								simpleTypeName,
838
								fullyQualifiedName,
839
								false,
840
								scope);
841
					}
842
					
843
					if (proposeConstructor && !Flags.isEnum(typeModifiers)) {
844
						proposeConstructor(
845
								simpleTypeName,
846
								parameterCount,
847
								signature,
848
								parameterTypes,
849
								parameterNames,
850
								modifiers,
851
								packageName,
852
								typeModifiers,
853
								accessibility,
854
								simpleTypeName,
855
								fullyQualifiedName,
856
								false,
857
								scope,
858
								extraFlags);
859
					}
860
					continue next;
861
				} else {
862
					char[] fullyQualifiedEnclosingTypeOrPackageName = null;
863
864
					AcceptedConstructor foundConstructor = null;
865
					if((foundConstructor = (AcceptedConstructor)onDemandFound.get(simpleTypeName)) == null) {
866
						for (int j = 0; j < this.onDemandImportCacheCount; j++) {
867
							ImportBinding importBinding = this.onDemandImportsCache[j];
868
869
							char[][] importName = importBinding.compoundName;
870
							char[] importFlatName = CharOperation.concatWith(importName, '.');
871
872
							if(fullyQualifiedEnclosingTypeOrPackageName == null) {
873
								fullyQualifiedEnclosingTypeOrPackageName = packageName;
874
							}
875
							if(CharOperation.equals(fullyQualifiedEnclosingTypeOrPackageName, importFlatName)) {
876
								if(importBinding.isStatic()) {
877
									if((typeModifiers & ClassFileConstants.AccStatic) != 0) {
878
										onDemandFound.put(
879
												simpleTypeName,
880
												acceptedConstructor);
881
										continue next;
882
									}
883
								} else {
884
									onDemandFound.put(
885
											simpleTypeName,
886
											acceptedConstructor);
887
									continue next;
888
								}
889
							}
890
						}
891
					} else if(!foundConstructor.mustBeQualified){
892
						done : for (int j = 0; j < this.onDemandImportCacheCount; j++) {
893
							ImportBinding importBinding = this.onDemandImportsCache[j];
894
895
							char[][] importName = importBinding.compoundName;
896
							char[] importFlatName = CharOperation.concatWith(importName, '.');
897
898
							if(fullyQualifiedEnclosingTypeOrPackageName == null) {
899
								fullyQualifiedEnclosingTypeOrPackageName = packageName;
900
							}
901
							if(CharOperation.equals(fullyQualifiedEnclosingTypeOrPackageName, importFlatName)) {
902
								if(importBinding.isStatic()) {
903
									if((typeModifiers & ClassFileConstants.AccStatic) != 0) {
904
										foundConstructor.mustBeQualified = true;
905
										break done;
906
									}
907
								} else {
908
									foundConstructor.mustBeQualified = true;
909
									break done;
910
								}
911
							}
912
						}
913
					}
914
					if (proposeType) {
915
						proposeType(
916
								packageName,
917
								simpleTypeName,
918
								typeModifiers,
919
								accessibility,
920
								simpleTypeName,
921
								fullyQualifiedName,
922
								true,
923
								scope);
924
					}
925
					
926
					if (proposeConstructor && !Flags.isEnum(typeModifiers)) {
927
						acceptedConstructor.mustBeQualified = true;
928
						if (DEFER_QUALIFIED_PROPOSALS) {
929
							deferredProposals.add(acceptedConstructor);
930
						} else {
931
							proposeConstructor(acceptedConstructor, scope);
932
						}
933
					}
934
				}
935
			}
936
		
937
			char[][] keys = onDemandFound.keyTable;
938
			Object[] values = onDemandFound.valueTable;
939
			int max = keys.length;
940
			for (int i = 0; i < max; i++) {
941
				
942
				// does not check cancellation for every types to avoid performance loss
943
				if ((i % CHECK_CANCEL_FREQUENCY) == 0) checkCancel();
944
				
945
				if(keys[i] != null) {
946
					AcceptedConstructor value = (AcceptedConstructor) values[i];
947
					if(value != null) {
948
						if (value.proposeType) {
949
							proposeType(
950
									value.packageName,
951
									value.simpleTypeName,
952
									value.typeModifiers,
953
									value.accessibility,
954
									value.simpleTypeName,
955
									value.fullyQualifiedName,
956
									value.mustBeQualified,
957
									scope);
958
						}
959
						
960
						if (value.proposeConstructor && !Flags.isEnum(value.modifiers)) {
961
							if (!value.mustBeQualified) {
962
								proposeConstructor(
963
										value.simpleTypeName,
964
										value.parameterCount,
965
										value.signature,
966
										value.parameterTypes,
967
										value.parameterNames,
968
										value.modifiers,
969
										value.packageName,
970
										value.typeModifiers,
971
										value.accessibility,
972
										value.simpleTypeName,
973
										value.fullyQualifiedName,
974
										value.mustBeQualified,
975
										scope,
976
										value.extraFlags);
977
							} else {
978
								if (DEFER_QUALIFIED_PROPOSALS) {
979
									deferredProposals.add(value);
980
								} else {
981
									proposeConstructor(value, scope);
982
								}
983
							}
984
						}
985
					}
986
				}
987
			}
988
			
989
			if (DEFER_QUALIFIED_PROPOSALS) {
990
				int size = deferredProposals.size();
991
				for (int i = 0; i < size; i++) {
992
					
993
					// does not check cancellation for every types to avoid performance loss
994
					if ((i % CHECK_CANCEL_FREQUENCY) == 0) checkCancel();
995
				
996
					AcceptedConstructor deferredProposal = (AcceptedConstructor)deferredProposals.get(i);
997
					
998
					if (deferredProposal.proposeConstructor) {
999
						proposeConstructor(
1000
								deferredProposal.simpleTypeName,
1001
								deferredProposal.parameterCount,
1002
								deferredProposal.signature,
1003
								deferredProposal.parameterTypes,
1004
								deferredProposal.parameterNames,
1005
								deferredProposal.modifiers,
1006
								deferredProposal.packageName,
1007
								deferredProposal.typeModifiers,
1008
								deferredProposal.accessibility,
1009
								deferredProposal.simpleTypeName,
1010
								deferredProposal.fullyQualifiedName,
1011
								deferredProposal.mustBeQualified,
1012
								scope,
1013
								deferredProposal.extraFlags);
1014
					}
1015
				}
1016
			}
1017
		} finally {
1018
			this.acceptedTypes = null; // reset
1019
		}
1020
	}
513
1021
514
	/**
1022
	/**
515
	 * One result of the search consists of a new package.
1023
	 * One result of the search consists of a new package.
Lines 576-582 Link Here
576
		AccessRestriction accessRestriction) {
1084
		AccessRestriction accessRestriction) {
577
		
1085
		
578
		// does not check cancellation for every types to avoid performance loss
1086
		// does not check cancellation for every types to avoid performance loss
579
		if ((this.foundTypesCount % CHECK_CANCEL_FREQUENCY_IN_FIND_TYPES) == 0) checkCancel();
1087
		if ((this.foundTypesCount % CHECK_CANCEL_FREQUENCY) == 0) checkCancel();
580
		this.foundTypesCount++;
1088
		this.foundTypesCount++;
581
		
1089
		
582
		if (this.options.checkDeprecation && (modifiers & ClassFileConstants.AccDeprecated) != 0) return;
1090
		if (this.options.checkDeprecation && (modifiers & ClassFileConstants.AccDeprecated) != 0) return;
Lines 629-635 Link Here
629
			next : for (int i = 0; i < length; i++) {
1137
			next : for (int i = 0; i < length; i++) {
630
				
1138
				
631
				// does not check cancellation for every types to avoid performance loss
1139
				// does not check cancellation for every types to avoid performance loss
632
				if ((i % CHECK_CANCEL_FREQUENCY_IN_FIND_TYPES) == 0) checkCancel();
1140
				if ((i % CHECK_CANCEL_FREQUENCY) == 0) checkCancel();
633
				
1141
				
634
				AcceptedType acceptedType = (AcceptedType)this.acceptedTypes.elementAt(i);
1142
				AcceptedType acceptedType = (AcceptedType)this.acceptedTypes.elementAt(i);
635
				char[] packageName = acceptedType.packageName;
1143
				char[] packageName = acceptedType.packageName;
Lines 651-657 Link Here
651
	
1159
	
652
				if (this.knownTypes.containsKey(fullyQualifiedName)) continue next;
1160
				if (this.knownTypes.containsKey(fullyQualifiedName)) continue next;
653
	
1161
	
654
				this.knownTypes.put(fullyQualifiedName, this);
1162
				this.knownTypes.put(fullyQualifiedName, KNOWN_TYPE_WITH_UNKNOWN_CONSTRUCTORS);
655
	
1163
	
656
				if (this.resolvingImports) {
1164
				if (this.resolvingImports) {
657
					if(this.compilerOptions.complianceLevel >= ClassFileConstants.JDK1_4 && packageName.length == 0) {
1165
					if(this.compilerOptions.complianceLevel >= ClassFileConstants.JDK1_4 && packageName.length == 0) {
Lines 807-812 Link Here
807
			Object[] values = onDemandFound.valueTable;
1315
			Object[] values = onDemandFound.valueTable;
808
			int max = keys.length;
1316
			int max = keys.length;
809
			for (int i = 0; i < max; i++) {
1317
			for (int i = 0; i < max; i++) {
1318
				if ((i % CHECK_CANCEL_FREQUENCY) == 0) checkCancel();
810
				if(keys[i] != null) {
1319
				if(keys[i] != null) {
811
					AcceptedType value = (AcceptedType) values[i];
1320
					AcceptedType value = (AcceptedType) values[i];
812
					if(value != null) {
1321
					if(value != null) {
Lines 2447-2452 Link Here
2447
		this.assistNodeIsClass = ref.isClass();
2956
		this.assistNodeIsClass = ref.isClass();
2448
		this.assistNodeIsException = ref.isException();
2957
		this.assistNodeIsException = ref.isException();
2449
		this.assistNodeIsInterface = ref.isInterface();
2958
		this.assistNodeIsInterface = ref.isInterface();
2959
		this.assistNodeIsConstructor = ref.isConstructorType;
2450
		this.assistNodeIsSuperType = ref.isSuperType();
2960
		this.assistNodeIsSuperType = ref.isSuperType();
2451
2961
2452
		this.completionToken = ref.completionIdentifier;
2962
		this.completionToken = ref.completionIdentifier;
Lines 3200-3206 Link Here
3200
						TypeBinding caughtException = catchArguments[i].type.resolvedType;
3710
						TypeBinding caughtException = catchArguments[i].type.resolvedType;
3201
						if (caughtException != null) {
3711
						if (caughtException != null) {
3202
							addForbiddenBindings(caughtException);
3712
							addForbiddenBindings(caughtException);
3203
							this.knownTypes.put(CharOperation.concat(caughtException.qualifiedPackageName(), caughtException.qualifiedSourceName(), '.'), this);
3713
							this.knownTypes.put(CharOperation.concat(caughtException.qualifiedPackageName(), caughtException.qualifiedSourceName(), '.'), KNOWN_TYPE_WITH_KNOWN_CONSTRUCTORS);
3204
						}
3714
						}
3205
					}
3715
					}
3206
					this.forbbidenBindingsFilter = SUBTYPE;
3716
					this.forbbidenBindingsFilter = SUBTYPE;
Lines 3942-3986 Link Here
3942
		}
4452
		}
3943
	}
4453
	}
3944
	private void findAnonymousType(
4454
	private void findAnonymousType(
4455
			ReferenceBinding currentType,
4456
			TypeBinding[] argTypes,
4457
			Scope scope,
4458
			InvocationSite invocationSite) {
4459
		
4460
		int relevance = computeBaseRelevance();
4461
		relevance += computeRelevanceForResolution();
4462
		relevance += computeRelevanceForInterestingProposal();
4463
		relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE);
4464
		
4465
		findAnonymousType(currentType, argTypes, scope, invocationSite, true, false, relevance);
4466
	}
4467
	private void findAnonymousType(
3945
		ReferenceBinding currentType,
4468
		ReferenceBinding currentType,
3946
		TypeBinding[] argTypes,
4469
		TypeBinding[] argTypes,
3947
		Scope scope,
4470
		Scope scope,
3948
		InvocationSite invocationSite) {
4471
		InvocationSite invocationSite,
4472
		boolean exactMatch,
4473
		boolean isQualified,
4474
		int relevance) {
3949
4475
3950
		if (currentType.isInterface()) {
4476
		if (currentType.isInterface()) {
3951
			char[] completion = CharOperation.NO_CHAR;
4477
			char[] completion = CharOperation.NO_CHAR;
3952
			int relevance = computeBaseRelevance();
4478
			
3953
			relevance += computeRelevanceForResolution();
4479
			if (!exactMatch) {
3954
			relevance += computeRelevanceForInterestingProposal();
4480
				char[] typeName = 
3955
			relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE);
4481
					isQualified ?
4482
							CharOperation.concat(currentType.qualifiedPackageName(), currentType.qualifiedSourceName(), '.') :
4483
								currentType.sourceName();
4484
				completion = CharOperation.concat(typeName, new char[]{'(', ')'});
4485
			}
3956
4486
3957
			this.noProposal = false;
4487
			this.noProposal = false;
3958
			if(!this.requestor.isIgnored(CompletionProposal.ANONYMOUS_CLASS_DECLARATION)) {
4488
			if (!exactMatch) {
3959
				InternalCompletionProposal proposal = createProposal(CompletionProposal.ANONYMOUS_CLASS_DECLARATION, this.actualCompletionPosition);
4489
				if(!this.requestor.isIgnored(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION)) {
3960
				proposal.setDeclarationSignature(getSignature(currentType));
4490
					InternalCompletionProposal proposal = createProposal(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION, this.actualCompletionPosition);
3961
				proposal.setDeclarationKey(currentType.computeUniqueKey());
4491
					proposal.setDeclarationSignature(getSignature(currentType));
3962
				proposal.setSignature(
4492
					proposal.setDeclarationKey(currentType.computeUniqueKey());
3963
						createMethodSignature(
4493
					proposal.setSignature(
3964
								CharOperation.NO_CHAR_CHAR,
4494
							createMethodSignature(
3965
								CharOperation.NO_CHAR_CHAR,
4495
									CharOperation.NO_CHAR_CHAR,
3966
								CharOperation.NO_CHAR,
4496
									CharOperation.NO_CHAR_CHAR,
3967
								CharOperation.NO_CHAR));
4497
									CharOperation.NO_CHAR,
3968
				//proposal.setOriginalSignature(null);
4498
									CharOperation.NO_CHAR));
3969
				//proposal.setUniqueKey(null);
4499
					//proposal.setOriginalSignature(null);
3970
				proposal.setDeclarationPackageName(currentType.qualifiedPackageName());
4500
					//proposal.setUniqueKey(null);
3971
				proposal.setDeclarationTypeName(currentType.qualifiedSourceName());
4501
					proposal.setDeclarationPackageName(currentType.qualifiedPackageName());
3972
				//proposal.setParameterPackageNames(null);
4502
					proposal.setDeclarationTypeName(currentType.qualifiedSourceName());
3973
				//proposal.setParameterTypeNames(null);
4503
					//proposal.setParameterPackageNames(null);
3974
				//proposal.setPackageName(null);
4504
					//proposal.setParameterTypeNames(null);
3975
				//proposal.setTypeName(null);
4505
					//proposal.setPackageName(null);
3976
				proposal.setCompletion(completion);
4506
					//proposal.setTypeName(null);
3977
				proposal.setFlags(Flags.AccPublic);
4507
					proposal.setCompletion(completion);
3978
				proposal.setReplaceRange(this.endPosition - this.offset, this.endPosition - this.offset);
4508
					proposal.setFlags(Flags.AccPublic);
3979
				proposal.setTokenRange(this.tokenEnd - this.offset, this.tokenEnd - this.offset);
4509
					proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset);
3980
				proposal.setRelevance(relevance);
4510
					proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset);
3981
				this.requestor.accept(proposal);
4511
					proposal.setRelevance(relevance);
3982
				if(DEBUG) {
4512
					this.requestor.accept(proposal);
3983
					this.printDebug(proposal);
4513
					if(DEBUG) {
4514
						this.printDebug(proposal);
4515
					}
4516
				}
4517
			}  else {
4518
				if(!this.requestor.isIgnored(CompletionProposal.ANONYMOUS_CLASS_DECLARATION)) {
4519
					InternalCompletionProposal proposal = createProposal(CompletionProposal.ANONYMOUS_CLASS_DECLARATION, this.actualCompletionPosition);
4520
					proposal.setDeclarationSignature(getSignature(currentType));
4521
					proposal.setDeclarationKey(currentType.computeUniqueKey());
4522
					proposal.setSignature(
4523
							createMethodSignature(
4524
									CharOperation.NO_CHAR_CHAR,
4525
									CharOperation.NO_CHAR_CHAR,
4526
									CharOperation.NO_CHAR,
4527
									CharOperation.NO_CHAR));
4528
					//proposal.setOriginalSignature(null);
4529
					//proposal.setUniqueKey(null);
4530
					proposal.setDeclarationPackageName(currentType.qualifiedPackageName());
4531
					proposal.setDeclarationTypeName(currentType.qualifiedSourceName());
4532
					//proposal.setParameterPackageNames(null);
4533
					//proposal.setParameterTypeNames(null);
4534
					//proposal.setPackageName(null);
4535
					//proposal.setTypeName(null);
4536
					proposal.setCompletion(completion);
4537
					proposal.setFlags(Flags.AccPublic);
4538
					proposal.setReplaceRange(this.endPosition - this.offset, this.endPosition - this.offset);
4539
					proposal.setTokenRange(this.tokenEnd - this.offset, this.tokenEnd - this.offset);
4540
					proposal.setRelevance(relevance);
4541
					this.requestor.accept(proposal);
4542
					if(DEBUG) {
4543
						this.printDebug(proposal);
4544
					}
3984
				}
4545
				}
3985
			}
4546
			}
3986
		} else {
4547
		} else {
Lines 3989-3995 Link Here
3989
				argTypes,
4550
				argTypes,
3990
				scope,
4551
				scope,
3991
				invocationSite,
4552
				invocationSite,
3992
				true);
4553
				true,
4554
				exactMatch,
4555
				isQualified,
4556
				relevance);
3993
		}
4557
		}
3994
	}
4558
	}
3995
	private void findClassField(
4559
	private void findClassField(
Lines 4074-4079 Link Here
4074
		Scope scope,
4638
		Scope scope,
4075
		InvocationSite invocationSite,
4639
		InvocationSite invocationSite,
4076
		boolean forAnonymousType) {
4640
		boolean forAnonymousType) {
4641
		
4642
		int relevance = computeBaseRelevance();
4643
						relevance += computeRelevanceForResolution();
4644
						relevance += computeRelevanceForInterestingProposal();
4645
						relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE);
4646
		
4647
		findConstructors(currentType, argTypes, scope, invocationSite, forAnonymousType, true, false, relevance);
4648
	}
4649
		
4650
	private void findConstructors(
4651
		ReferenceBinding currentType,
4652
		TypeBinding[] argTypes,
4653
		Scope scope,
4654
		InvocationSite invocationSite,
4655
		boolean forAnonymousType,
4656
		boolean exactMatch,
4657
		boolean isQualified,
4658
		int relevance) {
4077
4659
4078
		// No visibility checks can be performed without the scope & invocationSite
4660
		// No visibility checks can be performed without the scope & invocationSite
4079
		MethodBinding[] methods = currentType.availableMethods();
4661
		MethodBinding[] methods = currentType.availableMethods();
Lines 4116-4161 Link Here
4116
					char[][] parameterNames = findMethodParameterNames(constructor,parameterTypeNames);
4698
					char[][] parameterNames = findMethodParameterNames(constructor,parameterTypeNames);
4117
4699
4118
					char[] completion = CharOperation.NO_CHAR;
4700
					char[] completion = CharOperation.NO_CHAR;
4701
					
4119
					if(forAnonymousType){
4702
					if(forAnonymousType){
4120
						int relevance = computeBaseRelevance();
4703
						if (!exactMatch) {
4121
						relevance += computeRelevanceForResolution();
4704
							char[] typeName = 
4122
						relevance += computeRelevanceForInterestingProposal();
4705
								isQualified ?
4123
						relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE);
4706
										CharOperation.concat(currentType.qualifiedPackageName(), currentType.qualifiedSourceName(), '.') :
4124
4707
											currentType.sourceName();
4708
							completion = CharOperation.concat(typeName, new char[]{'(', ')'});
4709
						}
4710
						
4125
						this.noProposal = false;
4711
						this.noProposal = false;
4126
						if(!this.requestor.isIgnored(CompletionProposal.ANONYMOUS_CLASS_DECLARATION)) {
4712
						if (!exactMatch) {
4127
							InternalCompletionProposal proposal = createProposal(CompletionProposal.ANONYMOUS_CLASS_DECLARATION, this.actualCompletionPosition);
4713
							if(!this.requestor.isIgnored(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION)) {
4128
							proposal.setDeclarationSignature(getSignature(currentType));
4714
								InternalCompletionProposal proposal = createProposal(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION, this.actualCompletionPosition);
4129
							proposal.setDeclarationKey(currentType.computeUniqueKey());
4715
								proposal.setDeclarationSignature(getSignature(currentType));
4130
							proposal.setSignature(getSignature(constructor));
4716
								proposal.setDeclarationKey(currentType.computeUniqueKey());
4131
							MethodBinding original = constructor.original();
4717
								proposal.setSignature(getSignature(constructor));
4132
							if(original != constructor) {
4718
								MethodBinding original = constructor.original();
4133
								proposal.setOriginalSignature(getSignature(original));
4719
								if(original != constructor) {
4720
									proposal.setOriginalSignature(getSignature(original));
4721
								}
4722
								proposal.setKey(constructor.computeUniqueKey());
4723
								proposal.setDeclarationPackageName(currentType.qualifiedPackageName());
4724
								proposal.setDeclarationTypeName(currentType.qualifiedSourceName());
4725
								proposal.setParameterPackageNames(parameterPackageNames);
4726
								proposal.setParameterTypeNames(parameterTypeNames);
4727
								//proposal.setPackageName(null);
4728
								//proposal.setTypeName(null);
4729
								proposal.setCompletion(completion);
4730
								proposal.setFlags(constructor.modifiers);
4731
								proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset);
4732
								proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset);
4733
								proposal.setRelevance(relevance);
4734
								if(parameterNames != null) proposal.setParameterNames(parameterNames);
4735
								this.requestor.accept(proposal);
4736
								if(DEBUG) {
4737
									this.printDebug(proposal);
4738
								}
4134
							}
4739
							}
4135
							proposal.setKey(constructor.computeUniqueKey());
4740
						} else {
4136
							proposal.setDeclarationPackageName(currentType.qualifiedPackageName());
4741
							if(!this.requestor.isIgnored(CompletionProposal.ANONYMOUS_CLASS_DECLARATION)) {
4137
							proposal.setDeclarationTypeName(currentType.qualifiedSourceName());
4742
								InternalCompletionProposal proposal = createProposal(CompletionProposal.ANONYMOUS_CLASS_DECLARATION, this.actualCompletionPosition);
4138
							proposal.setParameterPackageNames(parameterPackageNames);
4743
								proposal.setDeclarationSignature(getSignature(currentType));
4139
							proposal.setParameterTypeNames(parameterTypeNames);
4744
								proposal.setDeclarationKey(currentType.computeUniqueKey());
4140
							//proposal.setPackageName(null);
4745
								proposal.setSignature(getSignature(constructor));
4141
							//proposal.setTypeName(null);
4746
								MethodBinding original = constructor.original();
4142
							proposal.setCompletion(completion);
4747
								if(original != constructor) {
4143
							proposal.setFlags(constructor.modifiers);
4748
									proposal.setOriginalSignature(getSignature(original));
4144
							proposal.setReplaceRange(this.endPosition - this.offset, this.endPosition - this.offset);
4749
								}
4145
							proposal.setTokenRange(this.tokenEnd - this.offset, this.tokenEnd - this.offset);
4750
								proposal.setKey(constructor.computeUniqueKey());
4146
							proposal.setRelevance(relevance);
4751
								proposal.setDeclarationPackageName(currentType.qualifiedPackageName());
4147
							if(parameterNames != null) proposal.setParameterNames(parameterNames);
4752
								proposal.setDeclarationTypeName(currentType.qualifiedSourceName());
4148
							this.requestor.accept(proposal);
4753
								proposal.setParameterPackageNames(parameterPackageNames);
4149
							if(DEBUG) {
4754
								proposal.setParameterTypeNames(parameterTypeNames);
4150
								this.printDebug(proposal);
4755
								//proposal.setPackageName(null);
4756
								//proposal.setTypeName(null);
4757
								proposal.setCompletion(completion);
4758
								proposal.setFlags(constructor.modifiers);
4759
								proposal.setReplaceRange(this.endPosition - this.offset, this.endPosition - this.offset);
4760
								proposal.setTokenRange(this.tokenEnd - this.offset, this.tokenEnd - this.offset);
4761
								proposal.setRelevance(relevance);
4762
								if(parameterNames != null) proposal.setParameterNames(parameterNames);
4763
								this.requestor.accept(proposal);
4764
								if(DEBUG) {
4765
									this.printDebug(proposal);
4766
								}
4151
							}
4767
							}
4152
						}
4768
						}
4153
					} else {
4769
					} else {
4154
						int relevance = computeBaseRelevance();
4155
						relevance += computeRelevanceForResolution();
4156
						relevance += computeRelevanceForInterestingProposal();
4157
						relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE);
4158
4159
						// Special case for completion in javadoc
4770
						// Special case for completion in javadoc
4160
						if (this.assistNodeInJavadoc > 0) {
4771
						if (this.assistNodeInJavadoc > 0) {
4161
							Expression receiver = null;
4772
							Expression receiver = null;
Lines 4207-4277 Link Here
4207
								javadocCompletion.append(')');
4818
								javadocCompletion.append(')');
4208
								completion = javadocCompletion.toString().toCharArray();
4819
								completion = javadocCompletion.toString().toCharArray();
4209
							}
4820
							}
4821
						} else {
4822
							if (!exactMatch) {
4823
								char[] typeName = 
4824
									isQualified ?
4825
											CharOperation.concat(currentType.qualifiedPackageName(), currentType.qualifiedSourceName(), '.') :
4826
												currentType.sourceName();
4827
								completion = CharOperation.concat(typeName, new char[]{'(', ')'});
4828
							}
4210
						}
4829
						}
4211
4830
4212
						// Create standard proposal
4831
						// Create standard proposal
4213
						this.noProposal = false;
4832
						this.noProposal = false;
4214
						if(!this.requestor.isIgnored(CompletionProposal.METHOD_REF) && (this.assistNodeInJavadoc & CompletionOnJavadoc.ONLY_INLINE_TAG) == 0) {
4833
						if (!exactMatch) {
4215
							InternalCompletionProposal proposal =  createProposal(CompletionProposal.METHOD_REF, this.actualCompletionPosition);
4834
							if(!this.requestor.isIgnored(CompletionProposal.CONSTRUCTOR_INVOCATION)) {
4216
							proposal.setDeclarationSignature(getSignature(currentType));
4835
								InternalCompletionProposal proposal =  createProposal(CompletionProposal.CONSTRUCTOR_INVOCATION, this.actualCompletionPosition);
4217
							proposal.setSignature(getSignature(constructor));
4836
								proposal.setDeclarationSignature(getSignature(currentType));
4218
							MethodBinding original = constructor.original();
4837
								proposal.setSignature(getSignature(constructor));
4219
							if(original != constructor) {
4838
								MethodBinding original = constructor.original();
4220
								proposal.setOriginalSignature(getSignature(original));
4839
								if(original != constructor) {
4840
									proposal.setOriginalSignature(getSignature(original));
4841
								}
4842
								proposal.setDeclarationPackageName(currentType.qualifiedPackageName());
4843
								proposal.setDeclarationTypeName(currentType.qualifiedSourceName());
4844
								proposal.setParameterPackageNames(parameterPackageNames);
4845
								proposal.setParameterTypeNames(parameterTypeNames);
4846
								//proposal.setPackageName(null);
4847
								//proposal.setTypeName(null);
4848
								proposal.setName(currentType.sourceName());
4849
								proposal.setIsContructor(true);
4850
								proposal.setCompletion(completion);
4851
								proposal.setFlags(constructor.modifiers);
4852
								proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset);
4853
								proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset);
4854
								proposal.setRelevance(relevance);
4855
								if(parameterNames != null) proposal.setParameterNames(parameterNames);
4856
								this.requestor.accept(proposal);
4857
								if(DEBUG) {
4858
									this.printDebug(proposal);
4859
								}
4221
							}
4860
							}
4222
							proposal.setDeclarationPackageName(currentType.qualifiedPackageName());
4861
						} else {
4223
							proposal.setDeclarationTypeName(currentType.qualifiedSourceName());
4862
							if(!this.requestor.isIgnored(CompletionProposal.METHOD_REF) && (this.assistNodeInJavadoc & CompletionOnJavadoc.ONLY_INLINE_TAG) == 0) {
4224
							proposal.setParameterPackageNames(parameterPackageNames);
4863
								InternalCompletionProposal proposal =  createProposal(CompletionProposal.METHOD_REF, this.actualCompletionPosition);
4225
							proposal.setParameterTypeNames(parameterTypeNames);
4864
								proposal.setDeclarationSignature(getSignature(currentType));
4226
							//proposal.setPackageName(null);
4865
								proposal.setSignature(getSignature(constructor));
4227
							//proposal.setTypeName(null);
4866
								MethodBinding original = constructor.original();
4228
							proposal.setName(currentType.sourceName());
4867
								if(original != constructor) {
4229
							proposal.setIsContructor(true);
4868
									proposal.setOriginalSignature(getSignature(original));
4230
							proposal.setCompletion(completion);
4869
								}
4231
							proposal.setFlags(constructor.modifiers);
4870
								proposal.setDeclarationPackageName(currentType.qualifiedPackageName());
4232
							int start = (this.assistNodeInJavadoc > 0) ? this.startPosition : this.endPosition;
4871
								proposal.setDeclarationTypeName(currentType.qualifiedSourceName());
4233
							proposal.setReplaceRange(start - this.offset, this.endPosition - this.offset);
4872
								proposal.setParameterPackageNames(parameterPackageNames);
4234
							proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset);
4873
								proposal.setParameterTypeNames(parameterTypeNames);
4235
							proposal.setRelevance(relevance);
4874
								//proposal.setPackageName(null);
4236
							if(parameterNames != null) proposal.setParameterNames(parameterNames);
4875
								//proposal.setTypeName(null);
4237
							this.requestor.accept(proposal);
4876
								proposal.setName(currentType.sourceName());
4238
							if(DEBUG) {
4877
								proposal.setIsContructor(true);
4239
								this.printDebug(proposal);
4878
								proposal.setCompletion(completion);
4879
								proposal.setFlags(constructor.modifiers);
4880
								int start = (this.assistNodeInJavadoc > 0) ? this.startPosition : this.endPosition;
4881
								proposal.setReplaceRange(start - this.offset, this.endPosition - this.offset);
4882
								proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset);
4883
								proposal.setRelevance(relevance);
4884
								if(parameterNames != null) proposal.setParameterNames(parameterNames);
4885
								this.requestor.accept(proposal);
4886
								if(DEBUG) {
4887
									this.printDebug(proposal);
4888
								}
4240
							}
4889
							}
4241
						}
4890
							if ((this.assistNodeInJavadoc & CompletionOnJavadoc.TEXT) != 0 && !this.requestor.isIgnored(CompletionProposal.JAVADOC_METHOD_REF)) {
4242
						if ((this.assistNodeInJavadoc & CompletionOnJavadoc.TEXT) != 0 && !this.requestor.isIgnored(CompletionProposal.JAVADOC_METHOD_REF)) {
4891
								char[] javadocCompletion = inlineTagCompletion(completion, JavadocTagConstants.TAG_LINK);
4243
							char[] javadocCompletion = inlineTagCompletion(completion, JavadocTagConstants.TAG_LINK);
4892
								InternalCompletionProposal proposal =  createProposal(CompletionProposal.JAVADOC_METHOD_REF, this.actualCompletionPosition);
4244
							InternalCompletionProposal proposal =  createProposal(CompletionProposal.JAVADOC_METHOD_REF, this.actualCompletionPosition);
4893
								proposal.setDeclarationSignature(getSignature(currentType));
4245
							proposal.setDeclarationSignature(getSignature(currentType));
4894
								proposal.setSignature(getSignature(constructor));
4246
							proposal.setSignature(getSignature(constructor));
4895
								MethodBinding original = constructor.original();
4247
							MethodBinding original = constructor.original();
4896
								if(original != constructor) {
4248
							if(original != constructor) {
4897
									proposal.setOriginalSignature(getSignature(original));
4249
								proposal.setOriginalSignature(getSignature(original));
4898
								}
4899
								proposal.setDeclarationPackageName(currentType.qualifiedPackageName());
4900
								proposal.setDeclarationTypeName(currentType.qualifiedSourceName());
4901
								proposal.setParameterPackageNames(parameterPackageNames);
4902
								proposal.setParameterTypeNames(parameterTypeNames);
4903
								//proposal.setPackageName(null);
4904
								//proposal.setTypeName(null);
4905
								proposal.setName(currentType.sourceName());
4906
								proposal.setIsContructor(true);
4907
								proposal.setCompletion(javadocCompletion);
4908
								proposal.setFlags(constructor.modifiers);
4909
								int start = (this.assistNodeInJavadoc & CompletionOnJavadoc.REPLACE_TAG) != 0 ? this.javadocTagPosition : this.startPosition;
4910
								proposal.setReplaceRange(start - this.offset, this.endPosition - this.offset);
4911
								proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset);
4912
								proposal.setRelevance(relevance+R_INLINE_TAG);
4913
								if(parameterNames != null) proposal.setParameterNames(parameterNames);
4914
								this.requestor.accept(proposal);
4915
								if(DEBUG) {
4916
									this.printDebug(proposal);
4917
								}
4250
							}
4918
							}
4251
							proposal.setDeclarationPackageName(currentType.qualifiedPackageName());
4919
						}
4252
							proposal.setDeclarationTypeName(currentType.qualifiedSourceName());
4920
					}
4253
							proposal.setParameterPackageNames(parameterPackageNames);
4921
				}
4254
							proposal.setParameterTypeNames(parameterTypeNames);
4922
			}
4255
							//proposal.setPackageName(null);
4923
		}
4256
							//proposal.setTypeName(null);
4924
	}
4257
							proposal.setName(currentType.sourceName());
4925
	
4258
							proposal.setIsContructor(true);
4926
	private char[] getResolvedSignature(char[][] parameterTypes, char[] fullyQualifiedTypeName, int parameterCount, Scope scope) {
4259
							proposal.setCompletion(javadocCompletion);
4927
		char[][] cn = CharOperation.splitOn('.', fullyQualifiedTypeName);
4260
							proposal.setFlags(constructor.modifiers);
4928
4261
							int start = (this.assistNodeInJavadoc & CompletionOnJavadoc.REPLACE_TAG) != 0 ? this.javadocTagPosition : this.startPosition;
4929
		TypeReference ref;
4262
							proposal.setReplaceRange(start - this.offset, this.endPosition - this.offset);
4930
		if (cn.length == 1) {
4263
							proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset);
4931
			ref = new SingleTypeReference(cn[0], 0);
4264
							proposal.setRelevance(relevance+R_INLINE_TAG);
4932
		} else {
4265
							if(parameterNames != null) proposal.setParameterNames(parameterNames);
4933
			ref = new QualifiedTypeReference(cn,new long[cn.length]);
4266
							this.requestor.accept(proposal);
4934
		}
4267
							if(DEBUG) {
4935
		
4268
								this.printDebug(proposal);
4936
		TypeBinding guessedType = null;
4937
		INameEnvironment oldNameEnvironment = this.lookupEnvironment.nameEnvironment;
4938
		this.lookupEnvironment.nameEnvironment = getNoCacheNameEnvironment();
4939
		try {
4940
			switch (scope.kind) {
4941
				case Scope.METHOD_SCOPE :
4942
				case Scope.BLOCK_SCOPE :
4943
					guessedType = ref.resolveType((BlockScope)scope);
4944
					break;
4945
				case Scope.CLASS_SCOPE :
4946
					guessedType = ref.resolveType((ClassScope)scope);
4947
					break;
4948
			}
4949
		} finally {
4950
			this.lookupEnvironment.nameEnvironment = oldNameEnvironment;
4951
		}
4952
4953
		if (guessedType != null && guessedType.isValidBinding()) {
4954
			if (guessedType instanceof ReferenceBinding) {
4955
				ReferenceBinding refBinding = (ReferenceBinding) guessedType;
4956
				
4957
				MethodBinding bestConstructor = null;
4958
				int[] bestMatchingLengths = null;
4959
				
4960
				MethodBinding[] methods = refBinding.methods();
4961
				next : for (int i = 0; i < methods.length; i++) {
4962
					MethodBinding method = methods[i];
4963
					
4964
					if (!method.isConstructor()) break next;
4965
					
4966
					TypeBinding[] parameters = method.parameters;
4967
					//TODO take careful of member types
4968
					int parametersLength = parameters == null ? 0 : parameters.length;
4969
					if (parameterCount != parametersLength) continue next;
4970
					
4971
					int[] matchingLengths = new int[parameterCount];
4972
					for (int j = 0; j < parametersLength; j++) {
4973
						TypeBinding parameter = parameters[j];
4974
						
4975
						char[] parameterTypeName;
4976
						if (parameter instanceof ReferenceBinding) {
4977
							parameterTypeName = CharOperation.concatWith(((ReferenceBinding)parameter).compoundName, '.');
4978
						} else {
4979
							parameterTypeName = parameter.sourceName();
4980
						}
4981
						
4982
						if (!CharOperation.endsWith(parameterTypeName, parameterTypes[j])) {
4983
							break next;
4984
						}
4985
						
4986
						int matchingLength = parameterTypes[j].length;
4987
						
4988
						if (bestMatchingLengths != null) {
4989
							if (bestMatchingLengths[j] > matchingLength) {
4990
								continue next;
4269
							}
4991
							}
4270
						}
4992
						}
4993
						
4994
						matchingLengths[j] = matchingLength;
4271
					}
4995
					}
4996
					
4997
					
4998
					bestConstructor = method;
4999
					bestMatchingLengths = matchingLengths;
4272
				}
5000
				}
5001
				
5002
				if (bestConstructor == null) return null;
5003
				return getSignature(bestConstructor);
4273
			}
5004
			}
4274
		}
5005
		}
5006
		
5007
		return null;
5008
	}
5009
5010
	private void findConstructorsOrAnonymousTypes(
5011
			ReferenceBinding currentType,
5012
			Scope scope,
5013
			InvocationSite invocationSite,
5014
			boolean isQualified,
5015
			int relevance) {
5016
		
5017
		if (!this.requestor.isIgnored(CompletionProposal.CONSTRUCTOR_INVOCATION)
5018
				&& currentType.isClass()
5019
				&& !currentType.isAbstract()) {
5020
				findConstructors(
5021
					currentType,
5022
					null,
5023
					scope,
5024
					invocationSite,
5025
					false,
5026
					false,
5027
					isQualified,
5028
					relevance);
5029
		}
5030
		
5031
		// This code is disabled because there is too much proposals when constructors and anonymous are proposed
5032
		if (!this.requestor.isIgnored(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION)
5033
				&& !currentType.isFinal()
5034
				&& (currentType.isInterface() || (currentType.isClass() && currentType.isAbstract()))){
5035
			findAnonymousType(
5036
				currentType,
5037
				null,
5038
				scope,
5039
				invocationSite,
5040
				false,
5041
				isQualified,
5042
				relevance);
5043
		}
4275
	}
5044
	}
4276
	private char[][] findEnclosingTypeNames(Scope scope){
5045
	private char[][] findEnclosingTypeNames(Scope scope){
4277
		char[][] excludedNames = new char[10][];
5046
		char[][] excludedNames = new char[10][];
Lines 8229-8245 Link Here
8229
				relevance += computeRelevanceForMissingElements(missingElementsHaveProblems);
8998
				relevance += computeRelevanceForMissingElements(missingElementsHaveProblems);
8230
			}
8999
			}
8231
9000
9001
			boolean allowingLongComputationProposals = this.requestor.isAllowingLongComputationProposals();
9002
			
8232
			this.noProposal = false;
9003
			this.noProposal = false;
8233
			createTypeProposal(
9004
			if (!this.assistNodeIsConstructor || !allowingLongComputationProposals || hasStaticMemberTypes(memberType, invocationType, this.unitScope)) {
8234
					memberType,
9005
				createTypeProposal(
8235
					memberType.qualifiedSourceName(),
9006
						memberType,
8236
					IAccessRule.K_ACCESSIBLE,
9007
						memberType.qualifiedSourceName(),
8237
					completionName,
9008
						IAccessRule.K_ACCESSIBLE,
8238
					relevance,
9009
						completionName,
8239
					missingElements,
9010
						relevance,
8240
					missingElementsStarts,
9011
						missingElements,
8241
					missingElementsEnds,
9012
						missingElementsStarts,
8242
					missingElementsHaveProblems);
9013
						missingElementsEnds,
9014
						missingElementsHaveProblems);
9015
			}
9016
			
9017
			if (this.assistNodeIsConstructor && allowingLongComputationProposals) {
9018
				findConstructorsOrAnonymousTypes(
9019
						memberType,
9020
						scope,
9021
						FakeInvocationSite,
9022
						isQualified,
9023
						relevance);
9024
			}
8243
		}
9025
		}
8244
	}
9026
	}
8245
	private void findMemberTypesFromMissingType(
9027
	private void findMemberTypesFromMissingType(
Lines 8658-8675 Link Here
8658
								relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE); // no access restriction for nested type
9440
								relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE); // no access restriction for nested type
8659
								relevance += computeRelevanceForAnnotationTarget(localType);
9441
								relevance += computeRelevanceForAnnotationTarget(localType);
8660
9442
8661
								this.noProposal = false;
9443
								boolean allowingLongComputationProposals = this.requestor.isAllowingLongComputationProposals();
8662
								if(!this.requestor.isIgnored(CompletionProposal.TYPE_REF)) {
9444
								if (!this.assistNodeIsConstructor || !allowingLongComputationProposals) {
8663
									createTypeProposal(
9445
									this.noProposal = false;
9446
									if(!this.requestor.isIgnored(CompletionProposal.TYPE_REF)) {
9447
										createTypeProposal(
9448
												localType,
9449
												localType.sourceName,
9450
												IAccessRule.K_ACCESSIBLE,
9451
												localType.sourceName,
9452
												relevance,
9453
												null,
9454
												null,
9455
												null,
9456
												false);
9457
									}
9458
								}
9459
								
9460
								if (this.assistNodeIsConstructor && allowingLongComputationProposals) {
9461
									findConstructorsOrAnonymousTypes(
8664
											localType,
9462
											localType,
8665
											localType.sourceName,
9463
											blockScope,
8666
											IAccessRule.K_ACCESSIBLE,
9464
											FakeInvocationSite,
8667
											localType.sourceName,
9465
											false,
8668
											relevance,
9466
											relevance);
8669
											null,
8670
											null,
8671
											null,
8672
											false);
8673
								}
9467
								}
8674
							}
9468
							}
8675
						}
9469
						}
Lines 8917-8930 Link Here
8917
9711
8918
		if (token == null)
9712
		if (token == null)
8919
			return;
9713
			return;
8920
9714
		
9715
		boolean allowingLongComputationProposals = this.requestor.isAllowingLongComputationProposals();
9716
		
8921
		boolean proposeType =
9717
		boolean proposeType =
8922
			!this.requestor.isIgnored(CompletionProposal.TYPE_REF) ||
9718
			!this.requestor.isIgnored(CompletionProposal.TYPE_REF) ||
8923
			((this.assistNodeInJavadoc & CompletionOnJavadoc.TEXT) != 0 && !this.requestor.isIgnored(CompletionProposal.JAVADOC_TYPE_REF));
9719
			((this.assistNodeInJavadoc & CompletionOnJavadoc.TEXT) != 0 && !this.requestor.isIgnored(CompletionProposal.JAVADOC_TYPE_REF));
8924
9720
8925
		boolean proposeAllMemberTypes = !this.assistNodeIsConstructor;
9721
		boolean proposeAllMemberTypes = !this.assistNodeIsConstructor;
9722
		
9723
		boolean proposeConstructor =
9724
			allowingLongComputationProposals &&
9725
			this.assistNodeIsConstructor &&
9726
			(!this.requestor.isIgnored(CompletionProposal.CONSTRUCTOR_INVOCATION) || !this.requestor.isIgnored(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION));
9727
		
8926
9728
8927
		if (proposeType && scope.enclosingSourceType() != null) {
9729
		if ((proposeType || proposeConstructor) && scope.enclosingSourceType() != null) {
8928
			
9730
			
8929
			checkCancel();
9731
			checkCancel();
8930
			
9732
			
Lines 8943-8949 Link Here
8943
9745
8944
		boolean isEmptyPrefix = token.length == 0;
9746
		boolean isEmptyPrefix = token.length == 0;
8945
9747
8946
		if (proposeType && this.unitScope != null) {
9748
		if ((proposeType || proposeConstructor) && this.unitScope != null) {
8947
			
9749
			
8948
			ReferenceBinding outerInvocationType = scope.enclosingSourceType();
9750
			ReferenceBinding outerInvocationType = scope.enclosingSourceType();
8949
			if(outerInvocationType != null) {
9751
			if(outerInvocationType != null) {
Lines 8984-8990 Link Here
8984
				if (typeLength > sourceType.sourceName.length) continue next;
9786
				if (typeLength > sourceType.sourceName.length) continue next;
8985
9787
8986
				if (!CharOperation.prefixEquals(token, sourceType.sourceName, false)
9788
				if (!CharOperation.prefixEquals(token, sourceType.sourceName, false)
8987
						&& !(this.options.camelCaseMatch && CharOperation.camelCaseMatch(token, sourceType.sourceName))) continue;
9789
						&& !(this.options.camelCaseMatch && CharOperation.camelCaseMatch(token, sourceType.sourceName))) continue next;
8988
9790
8989
				if (this.assistNodeIsAnnotation && !hasPossibleAnnotationTarget(sourceType, scope)) {
9791
				if (this.assistNodeIsAnnotation && !hasPossibleAnnotationTarget(sourceType, scope)) {
8990
					continue next;
9792
					continue next;
Lines 8995-9002 Link Here
8995
9797
8996
					if (sourceType == otherType) continue next;
9798
					if (sourceType == otherType) continue next;
8997
				}
9799
				}
8998
9800
				
8999
				this.knownTypes.put(CharOperation.concat(sourceType.qualifiedPackageName(), sourceType.sourceName(), '.'), this);
9801
				typesFound.add(sourceType);
9000
9802
9001
				if(this.assistNodeIsClass) {
9803
				if(this.assistNodeIsClass) {
9002
					if(!sourceType.isClass()) continue next;
9804
					if(!sourceType.isClass()) continue next;
Lines 9027-9034 Link Here
9027
					relevance += computeRelevanceForClass();
9829
					relevance += computeRelevanceForClass();
9028
					relevance += computeRelevanceForException(sourceType.sourceName);
9830
					relevance += computeRelevanceForException(sourceType.sourceName);
9029
				}
9831
				}
9832
				
9833
				
9030
				this.noProposal = false;
9834
				this.noProposal = false;
9031
				if(proposeType) {
9835
				if(proposeType && (!this.assistNodeIsConstructor || !allowingLongComputationProposals || hasStaticMemberTypes(sourceType, null, this.unitScope))) {
9032
					char[] typeName = sourceType.sourceName();
9836
					char[] typeName = sourceType.sourceName();
9033
					createTypeProposal(
9837
					createTypeProposal(
9034
							sourceType,
9838
							sourceType,
Lines 9041-9181 Link Here
9041
							null,
9845
							null,
9042
							false);
9846
							false);
9043
				}
9847
				}
9848
				
9849
				if (proposeConstructor) {
9850
					findConstructorsOrAnonymousTypes(
9851
							sourceType,
9852
							scope,
9853
							FakeInvocationSite,
9854
							false,
9855
							relevance);
9856
				}
9044
			}
9857
			}
9045
		}
9858
		}
9046
9859
9047
		if(proposeType) {
9860
		if (proposeConstructor && !isEmptyPrefix) {
9861
			
9862
			checkCancel();
9863
			
9864
			findTypesFromImports(token, scope, proposeType, typesFound);
9865
		} else if(proposeType) {
9048
			
9866
			
9049
			checkCancel();
9867
			checkCancel();
9050
			
9868
			
9051
			findTypesFromStaticImports(token, scope, proposeAllMemberTypes, typesFound);
9869
			findTypesFromStaticImports(token, scope, proposeAllMemberTypes, typesFound);
9052
		}
9870
		}
9871
		
9872
		if (proposeConstructor) {
9873
			
9874
			checkCancel();
9875
			
9876
			findTypesFromExpectedTypes(token, scope, typesFound, proposeType, proposeConstructor);
9877
		}
9053
9878
9054
		if (isEmptyPrefix && !this.assistNodeIsAnnotation) {
9879
		if (isEmptyPrefix && !this.assistNodeIsAnnotation) {
9055
			if(proposeType && this.expectedTypesPtr > -1) {
9880
			if (!proposeConstructor) {
9056
				next : for (int i = 0; i <= this.expectedTypesPtr; i++) {
9881
				findTypesFromExpectedTypes(token, scope, typesFound, proposeType, proposeConstructor);
9057
					
9882
			}
9058
					checkCancel();
9883
		} else {
9059
					
9884
			if(!isEmptyPrefix && !this.requestor.isIgnored(CompletionProposal.KEYWORD)) {
9060
					if(this.expectedTypes[i] instanceof ReferenceBinding) {
9885
				if (this.assistNodeInJavadoc == 0 || (this.assistNodeInJavadoc & CompletionOnJavadoc.BASE_TYPES) != 0) {
9061
						ReferenceBinding refBinding = (ReferenceBinding)this.expectedTypes[i];
9886
					if (proposeBaseTypes) {
9062
9887
						if (proposeVoidType) {
9063
						if(refBinding.isTypeVariable() && this.assistNodeIsConstructor) {
9888
							findKeywords(token, BASE_TYPE_NAMES, false, false);
9064
							// don't propose type variable if the completion is a constructor ('new |')
9889
						} else {
9065
							continue next;
9890
							findKeywords(token, BASE_TYPE_NAMES_WITHOUT_VOID, false, false);
9066
						}
9067
						if (this.options.checkDeprecation &&
9068
								refBinding.isViewedAsDeprecated() &&
9069
								!scope.isDefinedInSameUnit(refBinding))
9070
							continue next;
9071
9072
						int accessibility = IAccessRule.K_ACCESSIBLE;
9073
						if(refBinding.hasRestrictedAccess()) {
9074
							AccessRestriction accessRestriction = this.lookupEnvironment.getAccessRestriction(refBinding);
9075
							if(accessRestriction != null) {
9076
								switch (accessRestriction.getProblemId()) {
9077
									case IProblem.ForbiddenReference:
9078
										if (this.options.checkForbiddenReference) {
9079
											continue next;
9080
										}
9081
										accessibility = IAccessRule.K_NON_ACCESSIBLE;
9082
										break;
9083
									case IProblem.DiscouragedReference:
9084
										if (this.options.checkDiscouragedReference) {
9085
											continue next;
9086
										}
9087
										accessibility = IAccessRule.K_DISCOURAGED;
9088
										break;
9089
								}
9090
							}
9091
						}
9092
9093
						for (int j = 0; j < typesFound.size(); j++) {
9094
							ReferenceBinding typeFound = (ReferenceBinding)typesFound.elementAt(j);
9095
							if (typeFound == refBinding) {
9096
								continue next;
9097
							}
9098
						}
9099
9100
						boolean inSameUnit = this.unitScope.isDefinedInSameUnit(refBinding);
9101
9102
						// top level types of the current unit are already proposed.
9103
						if(!inSameUnit || (inSameUnit && refBinding.isMemberType())) {
9104
							char[] packageName = refBinding.qualifiedPackageName();
9105
							char[] typeName = refBinding.sourceName();
9106
							char[] completionName = typeName;
9107
9108
							boolean isQualified = false;
9109
							if (!this.insideQualifiedReference && !refBinding.isMemberType()) {
9110
								if (mustQualifyType(packageName, typeName, null, refBinding.modifiers)) {
9111
									if (packageName == null || packageName.length == 0)
9112
										if (this.unitScope != null && this.unitScope.fPackage.compoundName != CharOperation.NO_CHAR_CHAR)
9113
											continue next; // ignore types from the default package from outside it
9114
									completionName = CharOperation.concat(packageName, typeName, '.');
9115
									isQualified = true;
9116
								}
9117
							}
9118
9119
							if(this.assistNodeIsClass) {
9120
								if(!refBinding.isClass()) continue next;
9121
							} else if(this.assistNodeIsInterface) {
9122
								if(!refBinding.isInterface() && !refBinding.isAnnotationType()) continue next;
9123
							} else if (this.assistNodeIsAnnotation) {
9124
								if(!refBinding.isAnnotationType()) continue next;
9125
							}
9126
9127
							int relevance = computeBaseRelevance();
9128
							relevance += computeRelevanceForResolution();
9129
							relevance += computeRelevanceForInterestingProposal();
9130
							relevance += computeRelevanceForCaseMatching(token, typeName);
9131
							relevance += computeRelevanceForExpectingType(refBinding);
9132
							relevance += computeRelevanceForQualification(isQualified);
9133
							relevance += computeRelevanceForRestrictions(accessibility);
9134
9135
							if(refBinding.isClass()) {
9136
								relevance += computeRelevanceForClass();
9137
								relevance += computeRelevanceForException(typeName);
9138
							} else if(refBinding.isEnum()) {
9139
								relevance += computeRelevanceForEnum();
9140
							} else if(refBinding.isInterface()) {
9141
								relevance += computeRelevanceForInterface();
9142
							}
9143
9144
							this.noProposal = false;
9145
							if(!this.requestor.isIgnored(CompletionProposal.TYPE_REF)) {
9146
								InternalCompletionProposal proposal =  createProposal(CompletionProposal.TYPE_REF, this.actualCompletionPosition);
9147
								proposal.setDeclarationSignature(packageName);
9148
								proposal.setSignature(getSignature(refBinding));
9149
								proposal.setPackageName(packageName);
9150
								proposal.setTypeName(typeName);
9151
								proposal.setCompletion(completionName);
9152
								proposal.setFlags(refBinding.modifiers);
9153
								proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset);
9154
								proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset);
9155
								proposal.setRelevance(relevance);
9156
								proposal.setAccessibility(accessibility);
9157
								this.requestor.accept(proposal);
9158
								if(DEBUG) {
9159
									this.printDebug(proposal);
9160
								}
9161
							}
9162
						}
9891
						}
9163
					}
9892
					}
9164
				}
9893
				}
9165
			}
9894
			}
9166
		} else {
9895
			
9167
			if(!isEmptyPrefix && !this.requestor.isIgnored(CompletionProposal.KEYWORD)) {
9896
			if (proposeConstructor) {
9168
				if (this.assistNodeInJavadoc == 0 || (this.assistNodeInJavadoc & CompletionOnJavadoc.BASE_TYPES) != 0) {
9897
				int l = typesFound.size();
9169
					if (proposeBaseTypes) {
9898
				for (int i = 0; i < l; i++) {
9170
						if (proposeVoidType) {
9899
					ReferenceBinding typeFound = (ReferenceBinding) typesFound.elementAt(i);
9171
							findKeywords(token, BASE_TYPE_NAMES, false, false);
9900
					char[] fullyQualifiedTypeName =
9172
						} else {
9901
						CharOperation.concat(
9173
							findKeywords(token, BASE_TYPE_NAMES_WITHOUT_VOID, false, false);
9902
								typeFound.qualifiedPackageName(),
9174
						}
9903
								typeFound.qualifiedSourceName(),
9175
					}
9904
								'.');
9905
					this.knownTypes.put(fullyQualifiedTypeName, KNOWN_TYPE_WITH_KNOWN_CONSTRUCTORS);
9176
				}
9906
				}
9177
			}
9907
				
9178
			if(proposeType) {
9908
				checkCancel();
9909
				
9910
				this.foundConstructorsCount = 0;
9911
				this.nameEnvironment.findConstructorDeclarations(
9912
						token,
9913
						this.options.camelCaseMatch,
9914
						this,
9915
						this.monitor);
9916
				acceptConstructors(scope);
9917
			} else if (proposeType) {
9179
				int l = typesFound.size();
9918
				int l = typesFound.size();
9180
				for (int i = 0; i < l; i++) {
9919
				for (int i = 0; i < l; i++) {
9181
					ReferenceBinding typeFound = (ReferenceBinding) typesFound.elementAt(i);
9920
					ReferenceBinding typeFound = (ReferenceBinding) typesFound.elementAt(i);
Lines 9184-9190 Link Here
9184
								typeFound.qualifiedPackageName(),
9923
								typeFound.qualifiedPackageName(),
9185
								typeFound.qualifiedSourceName(),
9924
								typeFound.qualifiedSourceName(),
9186
								'.');
9925
								'.');
9187
					this.knownTypes.put(fullyQualifiedTypeName, this);
9926
					this.knownTypes.put(fullyQualifiedTypeName, KNOWN_TYPE_WITH_KNOWN_CONSTRUCTORS);
9188
				}
9927
				}
9189
				int searchFor = IJavaSearchConstants.TYPE;
9928
				int searchFor = IJavaSearchConstants.TYPE;
9190
				if(this.assistNodeIsClass) {
9929
				if(this.assistNodeIsClass) {
Lines 9222-9231 Link Here
9222
		char[] token,
9961
		char[] token,
9223
		PackageBinding packageBinding,
9962
		PackageBinding packageBinding,
9224
		Scope scope) {
9963
		Scope scope) {
9964
		
9965
		boolean allowingLongComputationProposals = this.requestor.isAllowingLongComputationProposals();
9225
9966
9226
		boolean proposeType =
9967
		boolean proposeType =
9227
			!this.requestor.isIgnored(CompletionProposal.TYPE_REF) ||
9968
			!this.requestor.isIgnored(CompletionProposal.TYPE_REF) ||
9228
			((this.assistNodeInJavadoc & CompletionOnJavadoc.TEXT) != 0 && !this.requestor.isIgnored(CompletionProposal.JAVADOC_TYPE_REF));
9969
			((this.assistNodeInJavadoc & CompletionOnJavadoc.TEXT) != 0 && !this.requestor.isIgnored(CompletionProposal.JAVADOC_TYPE_REF));
9970
		
9971
		boolean proposeConstructor =
9972
			allowingLongComputationProposals &&
9973
			this.assistNodeIsConstructor &&
9974
			(!this.requestor.isIgnored(CompletionProposal.CONSTRUCTOR_INVOCATION) || !this.requestor.isIgnored(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION));
9229
9975
9230
		char[] qualifiedName =
9976
		char[] qualifiedName =
9231
			CharOperation.concatWith(packageBinding.compoundName, token, '.');
9977
			CharOperation.concatWith(packageBinding.compoundName, token, '.');
Lines 9243-9249 Link Here
9243
9989
9244
		this.qualifiedCompletionToken = qualifiedName;
9990
		this.qualifiedCompletionToken = qualifiedName;
9245
9991
9246
		if (proposeType && this.unitScope != null) {
9992
		if ((proposeType || proposeConstructor) && this.unitScope != null) {
9247
			int typeLength = qualifiedName.length;
9993
			int typeLength = qualifiedName.length;
9248
			SourceTypeBinding[] types = this.unitScope.topLevelTypes;
9994
			SourceTypeBinding[] types = this.unitScope.topLevelTypes;
9249
9995
Lines 9289-9295 Link Here
9289
					}
10035
					}
9290
				}
10036
				}
9291
10037
9292
				this.knownTypes.put(CharOperation.concat(sourceType.qualifiedPackageName(), sourceType.sourceName(), '.'), this);
10038
				this.knownTypes.put(CharOperation.concat(sourceType.qualifiedPackageName(), sourceType.sourceName(), '.'), KNOWN_TYPE_WITH_KNOWN_CONSTRUCTORS);
9293
10039
9294
				int relevance = computeBaseRelevance();
10040
				int relevance = computeBaseRelevance();
9295
				relevance += computeRelevanceForResolution();
10041
				relevance += computeRelevanceForResolution();
Lines 9307-9314 Link Here
9307
					relevance += computeRelevanceForClass();
10053
					relevance += computeRelevanceForClass();
9308
					relevance += computeRelevanceForException(sourceType.sourceName);
10054
					relevance += computeRelevanceForException(sourceType.sourceName);
9309
				}
10055
				}
10056
				
9310
				this.noProposal = false;
10057
				this.noProposal = false;
9311
				if(proposeType) {
10058
				if(proposeType && (!this.assistNodeIsConstructor || !allowingLongComputationProposals || hasStaticMemberTypes(sourceType, null, this.unitScope))) {
9312
					char[] typeName = sourceType.sourceName();
10059
					char[] typeName = sourceType.sourceName();
9313
					createTypeProposal(
10060
					createTypeProposal(
9314
							sourceType,
10061
							sourceType,
Lines 9321-9330 Link Here
9321
							null,
10068
							null,
9322
							false);
10069
							false);
9323
				}
10070
				}
10071
				
10072
				if (proposeConstructor) {
10073
					findConstructorsOrAnonymousTypes(
10074
							sourceType,
10075
							scope,
10076
							FakeInvocationSite,
10077
							false,
10078
							relevance);
10079
				}
9324
			}
10080
			}
9325
		}
10081
		}
9326
10082
9327
		if(proposeType) {
10083
		if (proposeConstructor) {
10084
10085
			
10086
			checkCancel();
10087
			
10088
			this.foundConstructorsCount = 0;
10089
			this.nameEnvironment.findConstructorDeclarations(
10090
					qualifiedName,
10091
					this.options.camelCaseMatch,
10092
					this,
10093
					this.monitor);
10094
			acceptConstructors(scope);
10095
		} if(proposeType) {
9328
			int searchFor = IJavaSearchConstants.TYPE;
10096
			int searchFor = IJavaSearchConstants.TYPE;
9329
			if(this.assistNodeIsClass) {
10097
			if(this.assistNodeIsClass) {
9330
				searchFor = IJavaSearchConstants.CLASS;
10098
				searchFor = IJavaSearchConstants.CLASS;
Lines 9348-9358 Link Here
9348
					this.monitor);
10116
					this.monitor);
9349
			acceptTypes(scope);
10117
			acceptTypes(scope);
9350
		}
10118
		}
10119
		
9351
		if(!this.requestor.isIgnored(CompletionProposal.PACKAGE_REF)) {
10120
		if(!this.requestor.isIgnored(CompletionProposal.PACKAGE_REF)) {
9352
			this.nameEnvironment.findPackages(qualifiedName, this);
10121
			this.nameEnvironment.findPackages(qualifiedName, this);
9353
		}
10122
		}
9354
	}
10123
	}
10124
	
10125
	private void findTypesFromExpectedTypes(char[] token, Scope scope, ObjectVector typesFound, boolean proposeType, boolean proposeConstructor) {
10126
		if(this.expectedTypesPtr > -1) {
10127
			boolean allowingLongComputationProposals = this.requestor.isAllowingLongComputationProposals();
10128
			
10129
			int typeLength = token == null ? 0 : token.length;
10130
			
10131
			next : for (int i = 0; i <= this.expectedTypesPtr; i++) {
10132
				
10133
				checkCancel();
10134
				
10135
				if(this.expectedTypes[i] instanceof ReferenceBinding) {
10136
					ReferenceBinding refBinding = (ReferenceBinding)this.expectedTypes[i];
10137
					
10138
					if (typeLength > 0) {
10139
						if (typeLength > refBinding.sourceName.length) continue next;
10140
	
10141
						if (!CharOperation.prefixEquals(token, refBinding.sourceName, false)
10142
								&& !(this.options.camelCaseMatch && CharOperation.camelCaseMatch(token, refBinding.sourceName))) continue next;
10143
					}
10144
10145
10146
					if(refBinding.isTypeVariable() && this.assistNodeIsConstructor) {
10147
						// don't propose type variable if the completion is a constructor ('new |')
10148
						continue next;
10149
					}
10150
					if (this.options.checkDeprecation &&
10151
							refBinding.isViewedAsDeprecated() &&
10152
							!scope.isDefinedInSameUnit(refBinding))
10153
						continue next;
10154
10155
					int accessibility = IAccessRule.K_ACCESSIBLE;
10156
					if(refBinding.hasRestrictedAccess()) {
10157
						AccessRestriction accessRestriction = this.lookupEnvironment.getAccessRestriction(refBinding);
10158
						if(accessRestriction != null) {
10159
							switch (accessRestriction.getProblemId()) {
10160
								case IProblem.ForbiddenReference:
10161
									if (this.options.checkForbiddenReference) {
10162
										continue next;
10163
									}
10164
									accessibility = IAccessRule.K_NON_ACCESSIBLE;
10165
									break;
10166
								case IProblem.DiscouragedReference:
10167
									if (this.options.checkDiscouragedReference) {
10168
										continue next;
10169
									}
10170
									accessibility = IAccessRule.K_DISCOURAGED;
10171
									break;
10172
							}
10173
						}
10174
					}
10175
10176
					for (int j = 0; j < typesFound.size(); j++) {
10177
						ReferenceBinding typeFound = (ReferenceBinding)typesFound.elementAt(j);
10178
						if (typeFound == refBinding) {
10179
							continue next;
10180
						}
10181
					}
10182
					
10183
					typesFound.add(refBinding);
10184
10185
					boolean inSameUnit = this.unitScope.isDefinedInSameUnit(refBinding);
10186
10187
					// top level types of the current unit are already proposed.
10188
					if(!inSameUnit || (inSameUnit && refBinding.isMemberType())) {
10189
						char[] packageName = refBinding.qualifiedPackageName();
10190
						char[] typeName = refBinding.sourceName();
10191
						char[] completionName = typeName;
10192
10193
						boolean isQualified = false;
10194
						if (!this.insideQualifiedReference && !refBinding.isMemberType()) {
10195
							if (mustQualifyType(packageName, typeName, null, refBinding.modifiers)) {
10196
								if (packageName == null || packageName.length == 0)
10197
									if (this.unitScope != null && this.unitScope.fPackage.compoundName != CharOperation.NO_CHAR_CHAR)
10198
										continue next; // ignore types from the default package from outside it
10199
								completionName = CharOperation.concat(packageName, typeName, '.');
10200
								isQualified = true;
10201
							}
10202
						}
10203
10204
						if(this.assistNodeIsClass) {
10205
							if(!refBinding.isClass()) continue next;
10206
						} else if(this.assistNodeIsInterface) {
10207
							if(!refBinding.isInterface() && !refBinding.isAnnotationType()) continue next;
10208
						} else if (this.assistNodeIsAnnotation) {
10209
							if(!refBinding.isAnnotationType()) continue next;
10210
						}
10211
10212
						int relevance = computeBaseRelevance();
10213
						relevance += computeRelevanceForResolution();
10214
						relevance += computeRelevanceForInterestingProposal();
10215
						relevance += computeRelevanceForCaseMatching(token, typeName);
10216
						relevance += computeRelevanceForExpectingType(refBinding);
10217
						relevance += computeRelevanceForQualification(isQualified);
10218
						relevance += computeRelevanceForRestrictions(accessibility);
10219
10220
						if(refBinding.isClass()) {
10221
							relevance += computeRelevanceForClass();
10222
							relevance += computeRelevanceForException(typeName);
10223
						} else if(refBinding.isEnum()) {
10224
							relevance += computeRelevanceForEnum();
10225
						} else if(refBinding.isInterface()) {
10226
							relevance += computeRelevanceForInterface();
10227
						}
10228
						
10229
						if (proposeType && (!this.assistNodeIsConstructor || !allowingLongComputationProposals || hasStaticMemberTypes(refBinding, scope.enclosingSourceType() ,this.unitScope))) {
10230
							this.noProposal = false;
10231
							if(!this.requestor.isIgnored(CompletionProposal.TYPE_REF)) {
10232
								InternalCompletionProposal proposal =  createProposal(CompletionProposal.TYPE_REF, this.actualCompletionPosition);
10233
								proposal.setDeclarationSignature(packageName);
10234
								proposal.setSignature(getSignature(refBinding));
10235
								proposal.setPackageName(packageName);
10236
								proposal.setTypeName(typeName);
10237
								proposal.setCompletion(completionName);
10238
								proposal.setFlags(refBinding.modifiers);
10239
								proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset);
10240
								proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset);
10241
								proposal.setRelevance(relevance);
10242
								proposal.setAccessibility(accessibility);
10243
								this.requestor.accept(proposal);
10244
								if(DEBUG) {
10245
									this.printDebug(proposal);
10246
								}
10247
							}
10248
						}
10249
						
10250
						if (proposeConstructor) {
10251
							findConstructorsOrAnonymousTypes(
10252
									refBinding,
10253
									scope,
10254
									FakeInvocationSite,
10255
									isQualified,
10256
									relevance);
10257
						}
10258
					}
10259
				}
10260
			}
10261
		}
10262
	}
9355
10263
10264
	private void findTypesFromImports(char[] token, Scope scope, boolean proposeType, ObjectVector typesFound) {
10265
		ImportBinding[] importBindings = scope.compilationUnitScope().imports;
10266
		next : for (int i = 0; i < importBindings.length; i++) {
10267
			ImportBinding importBinding = importBindings[i];
10268
			if(importBinding.isValidBinding()) {
10269
				Binding binding = importBinding.resolvedImport;
10270
				if(binding != null && binding.isValidBinding()) {
10271
					if(importBinding.onDemand) {
10272
						if (importBinding.isStatic()) {
10273
							if((binding.kind() & Binding.TYPE) != 0) {
10274
								this.findMemberTypes(
10275
										token,
10276
										(ReferenceBinding) binding,
10277
										scope,
10278
										scope.enclosingSourceType(),
10279
										true,
10280
										false,
10281
										true,
10282
										true,
10283
										false,
10284
										null,
10285
										typesFound,
10286
										null,
10287
										null,
10288
										null,
10289
										false);
10290
							}
10291
						}
10292
					} else {
10293
						if ((binding.kind() & Binding.TYPE) != 0) {
10294
							ReferenceBinding typeBinding = (ReferenceBinding) binding;
10295
							int typeLength = token.length;
10296
10297
							if (!typeBinding.isStatic()) continue next;
10298
10299
							if (typeLength > typeBinding.sourceName.length)	continue next;
10300
10301
							if (!CharOperation.prefixEquals(token, typeBinding.sourceName, false)
10302
									&& !(this.options.camelCaseMatch && CharOperation.camelCaseMatch(token, typeBinding.sourceName))) continue next;
10303
							
10304
							int accessibility = IAccessRule.K_ACCESSIBLE;
10305
							if(typeBinding.hasRestrictedAccess()) {
10306
								AccessRestriction accessRestriction = this.lookupEnvironment.getAccessRestriction(typeBinding);
10307
								if(accessRestriction != null) {
10308
									switch (accessRestriction.getProblemId()) {
10309
										case IProblem.ForbiddenReference:
10310
											if (this.options.checkForbiddenReference) {
10311
												continue next;
10312
											}
10313
											accessibility = IAccessRule.K_NON_ACCESSIBLE;
10314
											break;
10315
										case IProblem.DiscouragedReference:
10316
											if (this.options.checkDiscouragedReference) {
10317
												continue next;
10318
											}
10319
											accessibility = IAccessRule.K_DISCOURAGED;
10320
											break;
10321
									}
10322
								}
10323
							}
10324
							
10325
							if (typesFound.contains(typeBinding)) continue next;
10326
							
10327
							typesFound.add(typeBinding);
10328
							
10329
							if(this.assistNodeIsClass) {
10330
								if(!typeBinding.isClass()) continue;
10331
							} else if(this.assistNodeIsInterface) {
10332
								if(!typeBinding.isInterface() && !typeBinding.isAnnotationType()) continue;
10333
							} else if (this.assistNodeIsAnnotation) {
10334
								if(!typeBinding.isAnnotationType()) continue;
10335
							}
10336
							
10337
							int relevance = computeBaseRelevance();
10338
							relevance += computeRelevanceForResolution();
10339
							relevance += computeRelevanceForInterestingProposal();
10340
							relevance += computeRelevanceForCaseMatching(token, typeBinding.sourceName);
10341
							relevance += computeRelevanceForExpectingType(typeBinding);
10342
							relevance += computeRelevanceForQualification(false);
10343
							relevance += computeRelevanceForRestrictions(accessibility);
10344
			
10345
							if (typeBinding.isAnnotationType()) {
10346
								relevance += computeRelevanceForAnnotation();
10347
								relevance += computeRelevanceForAnnotationTarget(typeBinding);
10348
							} else if (typeBinding.isInterface()) {
10349
								relevance += computeRelevanceForInterface();
10350
							} else if(typeBinding.isClass()){
10351
								relevance += computeRelevanceForClass();
10352
								relevance += computeRelevanceForException(typeBinding.sourceName);
10353
							}
10354
							
10355
							if (proposeType && hasStaticMemberTypes(typeBinding, scope.enclosingSourceType(), this.unitScope)) {
10356
								this.noProposal = false;
10357
								if(!this.requestor.isIgnored(CompletionProposal.TYPE_REF)) {
10358
									InternalCompletionProposal proposal =  createProposal(CompletionProposal.TYPE_REF, this.actualCompletionPosition);
10359
									proposal.setDeclarationSignature(typeBinding.qualifiedPackageName());
10360
									proposal.setSignature(getSignature(typeBinding));
10361
									proposal.setPackageName(typeBinding.qualifiedPackageName());
10362
									proposal.setTypeName(typeBinding.qualifiedSourceName());
10363
									proposal.setCompletion(typeBinding.sourceName());
10364
									proposal.setFlags(typeBinding.modifiers);
10365
									proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset);
10366
									proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset);
10367
									proposal.setRelevance(relevance);
10368
									this.requestor.accept(proposal);
10369
									if(DEBUG) {
10370
										this.printDebug(proposal);
10371
									}
10372
								}
10373
							}
10374
							
10375
							findConstructorsOrAnonymousTypes(
10376
									typeBinding,
10377
									scope,
10378
									FakeInvocationSite,
10379
									false,
10380
									relevance);
10381
						}
10382
					}
10383
				}
10384
			}
10385
		}
10386
	}
10387
	
9356
	private void findTypesFromStaticImports(char[] token, Scope scope, boolean proposeAllMemberTypes, ObjectVector typesFound) {
10388
	private void findTypesFromStaticImports(char[] token, Scope scope, boolean proposeAllMemberTypes, ObjectVector typesFound) {
9357
		ImportBinding[] importBindings = scope.compilationUnitScope().imports;
10389
		ImportBinding[] importBindings = scope.compilationUnitScope().imports;
9358
		for (int i = 0; i < importBindings.length; i++) {
10390
		for (int i = 0; i < importBindings.length; i++) {
Lines 10205-10210 Link Here
10205
11237
10206
		return this.favoriteReferenceBindings = resolvedImports;
11238
		return this.favoriteReferenceBindings = resolvedImports;
10207
	}
11239
	}
11240
	
11241
	private INameEnvironment getNoCacheNameEnvironment() {
11242
		if (this.noCacheNameEnvironment == null) {
11243
			JavaModelManager.getJavaModelManager().cacheZipFiles();
11244
			this.noCacheNameEnvironment = new JavaSearchNameEnvironment(this.javaProject, this.owner == null ? null : JavaModelManager.getJavaModelManager().getWorkingCopies(this.owner, true/*add primary WCs*/));
11245
		}
11246
		return this.noCacheNameEnvironment;
11247
	}
10208
11248
10209
	public AssistParser getParser() {
11249
	public AssistParser getParser() {
10210
11250
Lines 10468-10473 Link Here
10468
			case CompletionProposal.TYPE_IMPORT :
11508
			case CompletionProposal.TYPE_IMPORT :
10469
				buffer.append("TYPE_IMPORT"); //$NON-NLS-1$
11509
				buffer.append("TYPE_IMPORT"); //$NON-NLS-1$
10470
				break;
11510
				break;
11511
			case CompletionProposal.CONSTRUCTOR_INVOCATION :
11512
				buffer.append("CONSTRUCTOR_INVOCATION"); //$NON-NLS-1$
11513
				break;
11514
			case CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION :
11515
				buffer.append("ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION"); //$NON-NLS-1$
11516
				break;
10471
			default :
11517
			default :
10472
				buffer.append("PROPOSAL"); //$NON-NLS-1$
11518
				buffer.append("PROPOSAL"); //$NON-NLS-1$
10473
				break;
11519
				break;
Lines 10539-10544 Link Here
10539
			buffer.append('\t');
11585
			buffer.append('\t');
10540
		}
11586
		}
10541
	}
11587
	}
11588
	
11589
	private void proposeConstructor(AcceptedConstructor deferredProposal, Scope scope) {
11590
		if (deferredProposal.proposeConstructor) {
11591
			proposeConstructor(
11592
					deferredProposal.simpleTypeName,
11593
					deferredProposal.parameterCount,
11594
					deferredProposal.signature,
11595
					deferredProposal.parameterTypes,
11596
					deferredProposal.parameterNames,
11597
					deferredProposal.modifiers,
11598
					deferredProposal.packageName,
11599
					deferredProposal.typeModifiers,
11600
					deferredProposal.accessibility,
11601
					deferredProposal.simpleTypeName,
11602
					deferredProposal.fullyQualifiedName,
11603
					deferredProposal.mustBeQualified,
11604
					scope,
11605
					deferredProposal.extraFlags);
11606
		}
11607
	}
11608
	
11609
	private void proposeConstructor(
11610
			char[] simpleTypeName,
11611
			int parameterCount,
11612
			char[] signature,
11613
			char[][] parameterTypes,
11614
			char[][] parameterNames,
11615
			int modifiers,
11616
			char[] packageName,
11617
			int typeModifiers,
11618
			int accessibility,
11619
			char[] typeName,
11620
			char[] fullyQualifiedName,
11621
			boolean isQualified,
11622
			Scope scope,
11623
			int extraFlags) {
11624
		char[] completionName = fullyQualifiedName;
11625
		if(isQualified) {
11626
			if (packageName == null || packageName.length == 0)
11627
				if (this.unitScope != null && this.unitScope.fPackage.compoundName != CharOperation.NO_CHAR_CHAR)
11628
					return; // ignore types from the default package from outside it
11629
		} else {
11630
			completionName = simpleTypeName;
11631
		}
11632
11633
		int relevance = computeBaseRelevance();
11634
		relevance += computeRelevanceForResolution();
11635
		relevance += computeRelevanceForInterestingProposal();
11636
		relevance += computeRelevanceForRestrictions(accessibility);
11637
		relevance += computeRelevanceForCaseMatching(this.completionToken, simpleTypeName);
11638
		relevance += computeRelevanceForExpectingType(packageName, simpleTypeName);
11639
		relevance += computeRelevanceForQualification(isQualified);
11640
11641
		boolean isInterface = false;
11642
		int kind = typeModifiers & (ClassFileConstants.AccInterface | ClassFileConstants.AccEnum | ClassFileConstants.AccAnnotation);
11643
		switch (kind) {
11644
			case ClassFileConstants.AccAnnotation:
11645
			case ClassFileConstants.AccAnnotation | ClassFileConstants.AccInterface:
11646
				relevance += computeRelevanceForAnnotation();
11647
				relevance += computeRelevanceForInterface();
11648
				isInterface = true;
11649
				break;
11650
			case ClassFileConstants.AccEnum:
11651
				relevance += computeRelevanceForEnum();
11652
				break;
11653
			case ClassFileConstants.AccInterface:
11654
				relevance += computeRelevanceForInterface();
11655
				isInterface = true;
11656
				break;
11657
			default:
11658
				relevance += computeRelevanceForClass();
11659
				relevance += computeRelevanceForException(simpleTypeName);
11660
				break;
11661
		}
11662
		
11663
		char[] completion;
11664
		if (this.source != null
11665
					&& this.source.length > this.endPosition
11666
					&& this.source[this.endPosition] == '(') {
11667
			completion = completionName;
11668
		} else {
11669
			completion = CharOperation.concat(completionName, new char[] { '(', ')' });
11670
		}
11671
		
11672
		switch (parameterCount) {
11673
			case -1: // default constructor
11674
				int flags = Flags.AccPublic;
11675
				if (Flags.isDeprecated(typeModifiers)) {
11676
					flags |= Flags.AccDeprecated;
11677
				}
11678
				
11679
				if (isInterface || (typeModifiers & ClassFileConstants.AccAbstract) != 0) {
11680
					this.noProposal = false;
11681
					if(!this.requestor.isIgnored(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION)) {
11682
						InternalCompletionProposal proposal = createProposal(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION, this.actualCompletionPosition);
11683
						proposal.setDeclarationSignature(createNonGenericTypeSignature(packageName, typeName));
11684
						proposal.setDeclarationKey(createBindingKey(packageName, typeName));
11685
						proposal.setSignature(DEFAULT_CONSTRUCTOR_SIGNATURE);
11686
						proposal.setDeclarationPackageName(packageName);
11687
						proposal.setDeclarationTypeName(typeName);
11688
						proposal.setParameterPackageNames(CharOperation.NO_CHAR_CHAR);
11689
						proposal.setParameterTypeNames(CharOperation.NO_CHAR_CHAR);
11690
						proposal.setParameterNames(CharOperation.NO_CHAR_CHAR);
11691
						proposal.setName(simpleTypeName);
11692
						proposal.setIsContructor(true);
11693
						proposal.setCompletion(completion);
11694
						proposal.setFlags(flags);
11695
						proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset);
11696
						proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset);
11697
						proposal.setRelevance(relevance);
11698
						this.requestor.accept(proposal);
11699
						if(DEBUG) {
11700
							this.printDebug(proposal);
11701
						}
11702
					}
11703
				} else {
11704
					this.noProposal = false;
11705
					if(!this.requestor.isIgnored(CompletionProposal.CONSTRUCTOR_INVOCATION)) {
11706
						InternalCompletionProposal proposal =  createProposal(CompletionProposal.CONSTRUCTOR_INVOCATION, this.actualCompletionPosition);
11707
						proposal.setDeclarationSignature(createNonGenericTypeSignature(packageName, typeName));
11708
						proposal.setSignature(DEFAULT_CONSTRUCTOR_SIGNATURE);
11709
						proposal.setDeclarationPackageName(packageName);
11710
						proposal.setDeclarationTypeName(typeName);
11711
						proposal.setParameterPackageNames(CharOperation.NO_CHAR_CHAR);
11712
						proposal.setParameterTypeNames(CharOperation.NO_CHAR_CHAR);
11713
						proposal.setParameterNames(CharOperation.NO_CHAR_CHAR);
11714
						proposal.setName(simpleTypeName);
11715
						proposal.setIsContructor(true);
11716
						proposal.setCompletion(completion);
11717
						proposal.setFlags(flags);
11718
						proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset);
11719
						proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset);
11720
						proposal.setRelevance(relevance);
11721
						this.requestor.accept(proposal);
11722
						if(DEBUG) {
11723
							this.printDebug(proposal);
11724
						}
11725
					}
11726
				}
11727
				break;
11728
			case 0: // constructor with no parameter
11729
				
11730
				if ((typeModifiers & ClassFileConstants.AccAbstract) != 0) {
11731
					this.noProposal = false;
11732
					if(!this.requestor.isIgnored(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION)) {
11733
						InternalCompletionProposal proposal = createProposal(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION, this.actualCompletionPosition);
11734
						proposal.setDeclarationSignature(createNonGenericTypeSignature(packageName, typeName));
11735
						proposal.setDeclarationKey(createBindingKey(packageName, typeName));
11736
						proposal.setSignature(DEFAULT_CONSTRUCTOR_SIGNATURE);
11737
						proposal.setDeclarationPackageName(packageName);
11738
						proposal.setDeclarationTypeName(typeName);
11739
						proposal.setParameterPackageNames(CharOperation.NO_CHAR_CHAR);
11740
						proposal.setParameterTypeNames(CharOperation.NO_CHAR_CHAR);
11741
						proposal.setParameterNames(CharOperation.NO_CHAR_CHAR);
11742
						proposal.setName(simpleTypeName);
11743
						proposal.setIsContructor(true);
11744
						proposal.setCompletion(completion);
11745
						proposal.setFlags(modifiers);
11746
						proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset);
11747
						proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset);
11748
						proposal.setRelevance(relevance);
11749
						this.requestor.accept(proposal);
11750
						if(DEBUG) {
11751
							this.printDebug(proposal);
11752
						}
11753
					}
11754
				} else {
11755
					this.noProposal = false;
11756
					if(!this.requestor.isIgnored(CompletionProposal.CONSTRUCTOR_INVOCATION)) {
11757
						InternalCompletionProposal proposal =  createProposal(CompletionProposal.CONSTRUCTOR_INVOCATION, this.actualCompletionPosition);
11758
						proposal.setDeclarationSignature(createNonGenericTypeSignature(packageName, typeName));
11759
						proposal.setSignature(DEFAULT_CONSTRUCTOR_SIGNATURE);
11760
						proposal.setDeclarationPackageName(packageName);
11761
						proposal.setDeclarationTypeName(typeName);
11762
						proposal.setParameterPackageNames(CharOperation.NO_CHAR_CHAR);
11763
						proposal.setParameterTypeNames(CharOperation.NO_CHAR_CHAR);
11764
						proposal.setParameterNames(CharOperation.NO_CHAR_CHAR);
11765
						proposal.setName(simpleTypeName);
11766
						proposal.setIsContructor(true);
11767
						proposal.setCompletion(completion);
11768
						proposal.setFlags(modifiers);
11769
						proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset);
11770
						proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset);
11771
						proposal.setRelevance(relevance);
11772
						this.requestor.accept(proposal);
11773
						if(DEBUG) {
11774
							this.printDebug(proposal);
11775
						}
11776
					}
11777
				}
11778
				break;
11779
			default: // constructor with parameter
11780
				if (signature == null) {
11781
					// resolve type to found parameter types
11782
					signature = getResolvedSignature(parameterTypes, fullyQualifiedName, parameterCount, scope);
11783
					if (signature == null) return;
11784
				} else {
11785
					signature = CharOperation.replaceOnCopy(signature, '/', '.');
11786
				}
11787
				
11788
				int parameterNamesLength = parameterNames == null ? 0 : parameterNames.length;
11789
				if (parameterCount != parameterNamesLength) {
11790
					parameterNames = createDefaultParameterNames(parameterCount);
11791
				}
11792
				
11793
				if ((typeModifiers & ClassFileConstants.AccAbstract) != 0) {
11794
					this.noProposal = false;
11795
					if(!this.requestor.isIgnored(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION)) {
11796
						InternalCompletionProposal proposal = createProposal(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION, this.actualCompletionPosition);
11797
						proposal.setDeclarationSignature(createNonGenericTypeSignature(packageName, typeName));
11798
						proposal.setDeclarationKey(createBindingKey(packageName, typeName));
11799
						proposal.setSignature(signature);
11800
						proposal.setDeclarationPackageName(packageName);
11801
						proposal.setDeclarationTypeName(typeName);
11802
						proposal.setParameterPackageNames(CharOperation.NO_CHAR_CHAR);
11803
						proposal.setParameterTypeNames(CharOperation.NO_CHAR_CHAR);
11804
						proposal.setParameterNames(parameterNames);
11805
						proposal.setName(simpleTypeName);
11806
						proposal.setIsContructor(true);
11807
						proposal.setCompletion(completion);
11808
						proposal.setFlags(modifiers);
11809
						proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset);
11810
						proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset);
11811
						proposal.setRelevance(relevance);
11812
						this.requestor.accept(proposal);
11813
						if(DEBUG) {
11814
							this.printDebug(proposal);
11815
						}
11816
					}
11817
				} else {
11818
					this.noProposal = false;
11819
					if(!this.requestor.isIgnored(CompletionProposal.CONSTRUCTOR_INVOCATION)) {
11820
						InternalCompletionProposal proposal =  createProposal(CompletionProposal.CONSTRUCTOR_INVOCATION, this.actualCompletionPosition);
11821
						proposal.setDeclarationSignature(createNonGenericTypeSignature(packageName, typeName));
11822
						proposal.setSignature(signature);
11823
						proposal.setDeclarationPackageName(packageName);
11824
						proposal.setDeclarationTypeName(typeName);
11825
						proposal.setParameterPackageNames(CharOperation.NO_CHAR_CHAR);
11826
						proposal.setParameterTypeNames(CharOperation.NO_CHAR_CHAR);
11827
						proposal.setParameterNames(parameterNames);
11828
						proposal.setName(simpleTypeName);
11829
						proposal.setIsContructor(true);
11830
						proposal.setCompletion(completion);
11831
						proposal.setFlags(modifiers);
11832
						proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset);
11833
						proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset);
11834
						proposal.setRelevance(relevance);
11835
						
11836
						this.requestor.accept(proposal);
11837
						if(DEBUG) {
11838
							this.printDebug(proposal);
11839
						}
11840
					}
11841
				}
11842
				break;
11843
		}
11844
	}
10542
11845
10543
	private void proposeNewMethod(char[] token, ReferenceBinding reference) {
11846
	private void proposeNewMethod(char[] token, ReferenceBinding reference) {
10544
		if(!this.requestor.isIgnored(CompletionProposal.POTENTIAL_METHOD_DECLARATION)) {
11847
		if(!this.requestor.isIgnored(CompletionProposal.POTENTIAL_METHOD_DECLARATION)) {
Lines 10661-10666 Link Here
10661
		super.reset(false);
11964
		super.reset(false);
10662
		this.knownPkgs = new HashtableOfObject(10);
11965
		this.knownPkgs = new HashtableOfObject(10);
10663
		this.knownTypes = new HashtableOfObject(10);
11966
		this.knownTypes = new HashtableOfObject(10);
11967
		if (this.noCacheNameEnvironment != null) {
11968
			this.noCacheNameEnvironment.cleanup();
11969
			this.noCacheNameEnvironment = null;
11970
			JavaModelManager.getJavaModelManager().flushZipFiles();
11971
		}
10664
	}
11972
	}
10665
11973
10666
	private void setSourceAndTokenRange(int start, int end) {
11974
	private void setSourceAndTokenRange(int start, int end) {
(-)codeassist/org/eclipse/jdt/internal/codeassist/InternalCompletionProposal.java (-41 / +12 lines)
Lines 33-47 Link Here
33
public class InternalCompletionProposal extends CompletionProposal {
33
public class InternalCompletionProposal extends CompletionProposal {
34
	private static Object NO_ATTACHED_SOURCE = new Object();
34
	private static Object NO_ATTACHED_SOURCE = new Object();
35
35
36
	static final char[] ARG = "arg".toCharArray();  //$NON-NLS-1$
36
37
	static final char[] ARG0 = "arg0".toCharArray();  //$NON-NLS-1$
38
	static final char[] ARG1 = "arg1".toCharArray();  //$NON-NLS-1$
39
	static final char[] ARG2 = "arg2".toCharArray();  //$NON-NLS-1$
40
	static final char[] ARG3 = "arg3".toCharArray();  //$NON-NLS-1$
41
	static final char[][] ARGS1 = new char[][]{ARG0};
42
	static final char[][] ARGS2 = new char[][]{ARG0, ARG1};
43
	static final char[][] ARGS3 = new char[][]{ARG0, ARG1, ARG2};
44
	static final char[][] ARGS4 = new char[][]{ARG0, ARG1, ARG2, ARG3};
45
37
46
	protected CompletionEngine completionEngine;
38
	protected CompletionEngine completionEngine;
47
	protected NameLookup nameLookup;
39
	protected NameLookup nameLookup;
Lines 179-212 Link Here
179
	 * Indicates whether parameter names have been computed.
171
	 * Indicates whether parameter names have been computed.
180
	 */
172
	 */
181
	private boolean parameterNamesComputed = false;
173
	private boolean parameterNamesComputed = false;
182
174
	
183
	protected char[][] createDefaultParameterNames(int length) {
184
		char[][] parameters;
185
		switch (length) {
186
			case 0 :
187
				parameters = new char[length][];
188
				break;
189
			case 1 :
190
				parameters = ARGS1;
191
				break;
192
			case 2 :
193
				parameters = ARGS2;
194
				break;
195
			case 3 :
196
				parameters = ARGS3;
197
				break;
198
			case 4 :
199
				parameters = ARGS4;
200
				break;
201
			default :
202
				parameters = new char[length][];
203
				for (int i = 0; i < length; i++) {
204
					parameters[i] = CharOperation.concat(ARG, String.valueOf(i).toCharArray());
205
				}
206
				break;
207
		}
208
		return parameters;
209
	}
210
	protected char[][] findMethodParameterNames(char[] declaringTypePackageName, char[] declaringTypeName, char[] selector, char[][] paramTypeNames){
175
	protected char[][] findMethodParameterNames(char[] declaringTypePackageName, char[] declaringTypeName, char[] selector, char[][] paramTypeNames){
211
		if(paramTypeNames == null || declaringTypeName == null) return null;
176
		if(paramTypeNames == null || declaringTypeName == null) return null;
212
177
Lines 257-263 Link Here
257
222
258
		// default parameters name
223
		// default parameters name
259
		if(parameters == null) {
224
		if(parameters == null) {
260
			parameters = createDefaultParameterNames(length);
225
			parameters = CompletionEngine.createDefaultParameterNames(length);
261
		}
226
		}
262
227
263
		return parameters;
228
		return parameters;
Lines 1312-1318 Link Here
1312
					} catch(IllegalArgumentException e) {
1277
					} catch(IllegalArgumentException e) {
1313
						// protection for invalid signature
1278
						// protection for invalid signature
1314
						if(this.parameterTypeNames != null) {
1279
						if(this.parameterTypeNames != null) {
1315
							this.parameterNames =  createDefaultParameterNames(this.parameterTypeNames.length);
1280
							this.parameterNames =  CompletionEngine.createDefaultParameterNames(this.parameterTypeNames.length);
1316
						} else {
1281
						} else {
1317
							this.parameterNames = null;
1282
							this.parameterNames = null;
1318
						}
1283
						}
Lines 1329-1335 Link Here
1329
					} catch(IllegalArgumentException e) {
1294
					} catch(IllegalArgumentException e) {
1330
						// protection for invalid signature
1295
						// protection for invalid signature
1331
						if(this.parameterTypeNames != null) {
1296
						if(this.parameterTypeNames != null) {
1332
							this.parameterNames =  createDefaultParameterNames(this.parameterTypeNames.length);
1297
							this.parameterNames =  CompletionEngine.createDefaultParameterNames(this.parameterTypeNames.length);
1333
						} else {
1298
						} else {
1334
							this.parameterNames = null;
1299
							this.parameterNames = null;
1335
						}
1300
						}
Lines 1345-1351 Link Here
1345
					} catch(IllegalArgumentException e) {
1310
					} catch(IllegalArgumentException e) {
1346
						// protection for invalid signature
1311
						// protection for invalid signature
1347
						if(this.parameterTypeNames != null) {
1312
						if(this.parameterTypeNames != null) {
1348
							this.parameterNames =  createDefaultParameterNames(this.parameterTypeNames.length);
1313
							this.parameterNames =  CompletionEngine.createDefaultParameterNames(this.parameterTypeNames.length);
1349
						} else {
1314
						} else {
1350
							this.parameterNames = null;
1315
							this.parameterNames = null;
1351
						}
1316
						}
Lines 1623-1628 Link Here
1623
			case CompletionProposal.FIELD_REF_WITH_CASTED_RECEIVER :
1588
			case CompletionProposal.FIELD_REF_WITH_CASTED_RECEIVER :
1624
				buffer.append("FIELD_REF_WITH_CASTED_RECEIVER"); //$NON-NLS-1$
1589
				buffer.append("FIELD_REF_WITH_CASTED_RECEIVER"); //$NON-NLS-1$
1625
				break;
1590
				break;
1591
			case CompletionProposal.CONSTRUCTOR_INVOCATION :
1592
				buffer.append("CONSTRUCTOR_INVOCATION"); //$NON-NLS-1$
1593
				break;
1594
			case CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION :
1595
				buffer.append("ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION"); //$NON-NLS-1$
1596
				break;
1626
			default :
1597
			default :
1627
				buffer.append("PROPOSAL"); //$NON-NLS-1$
1598
				buffer.append("PROPOSAL"); //$NON-NLS-1$
1628
				break;
1599
				break;
(-)codeassist/org/eclipse/jdt/internal/codeassist/ISearchRequestor.java (+12 lines)
Lines 20-25 Link Here
20
 * to the raw name environment results before answering them to the UI.
20
 * to the raw name environment results before answering them to the UI.
21
 */
21
 */
22
public interface ISearchRequestor {
22
public interface ISearchRequestor {
23
	public void acceptConstructor(
24
						int modifiers,
25
						char[] simpleTypeName,
26
						int parameterCount,
27
						char[] signature,
28
						char[][] parameterTypes,
29
						char[][] parameterNames,
30
						int typeModifiers,
31
						char[] packageName,
32
						int extraFlags,
33
						String path,
34
						AccessRestriction access);
23
	/**
35
	/**
24
	 * One result of the search consists of a new type.
36
	 * One result of the search consists of a new type.
25
	 *
37
	 *
(-)codeassist/org/eclipse/jdt/internal/codeassist/SelectionEngine.java (+15 lines)
Lines 269-274 Link Here
269
		this.parser = new SelectionParser(problemReporter);
269
		this.parser = new SelectionParser(problemReporter);
270
		this.owner = owner;
270
		this.owner = owner;
271
	}
271
	}
272
	
273
	public void acceptConstructor(
274
			int modifiers,
275
			char[] simpleTypeName,
276
			int parameterCount,
277
			char[] signature,
278
			char[][] parameterTypes,
279
			char[][] parameterNames,
280
			int typeModifiers,
281
			char[] packageName,
282
			int extraFlags,
283
			String path,
284
			AccessRestriction access) {
285
		// constructors aren't searched
286
	}
272
287
273
	public void acceptType(char[] packageName, char[] simpleTypeName, char[][] enclosingTypeNames, int modifiers, AccessRestriction accessRestriction) {
288
	public void acceptType(char[] packageName, char[] simpleTypeName, char[][] enclosingTypeNames, int modifiers, AccessRestriction accessRestriction) {
274
		char[] typeName = enclosingTypeNames == null ?
289
		char[] typeName = enclosingTypeNames == null ?
(-)codeassist/org/eclipse/jdt/internal/codeassist/CompletionElementNotifier.java (-4 / +4 lines)
Lines 182-192 Link Here
182
		return typeParameterBounds;
182
		return typeParameterBounds;
183
	}
183
	}
184
184
185
	protected void notifySourceElementRequestor(AbstractMethodDeclaration methodDeclaration) {
185
	protected void notifySourceElementRequestor(AbstractMethodDeclaration methodDeclaration, TypeDeclaration declaringType, ImportReference currentPackage) {
186
		if (methodDeclaration instanceof CompletionOnMethodReturnType) return;
186
		if (methodDeclaration instanceof CompletionOnMethodReturnType) return;
187
		if (methodDeclaration instanceof CompletionOnMethodTypeParameter) return;
187
		if (methodDeclaration instanceof CompletionOnMethodTypeParameter) return;
188
		if (methodDeclaration instanceof CompletionOnMethodName) return;
188
		if (methodDeclaration instanceof CompletionOnMethodName) return;
189
		super.notifySourceElementRequestor(methodDeclaration);
189
		super.notifySourceElementRequestor(methodDeclaration, declaringType, currentPackage);
190
	}
190
	}
191
191
192
	public void notifySourceElementRequestor(CompilationUnitDeclaration parsedUnit, int sourceStart, int sourceEnd, boolean reportReference, HashtableOfObjectToInt sourceEndsMap, Map nodesToCategoriesMap) {
192
	public void notifySourceElementRequestor(CompilationUnitDeclaration parsedUnit, int sourceStart, int sourceEnd, boolean reportReference, HashtableOfObjectToInt sourceEndsMap, Map nodesToCategoriesMap) {
Lines 209-216 Link Here
209
		super.notifySourceElementRequestor(importReference, isPackage);
209
		super.notifySourceElementRequestor(importReference, isPackage);
210
	}
210
	}
211
211
212
	protected void notifySourceElementRequestor(TypeDeclaration typeDeclaration, boolean notifyTypePresence, TypeDeclaration declaringType) {
212
	protected void notifySourceElementRequestor(TypeDeclaration typeDeclaration, boolean notifyTypePresence, TypeDeclaration declaringType, ImportReference currentPackage) {
213
		if (typeDeclaration instanceof CompletionOnAnnotationOfType) return;
213
		if (typeDeclaration instanceof CompletionOnAnnotationOfType) return;
214
		super.notifySourceElementRequestor(typeDeclaration, notifyTypePresence, declaringType);
214
		super.notifySourceElementRequestor(typeDeclaration, notifyTypePresence, declaringType, currentPackage);
215
	}
215
	}
216
}
216
}
(-)model/org/eclipse/jdt/core/CompletionProposal.java (-2 / +76 lines)
Lines 55-61 Link Here
55
	/**
55
	/**
56
	 * Completion is a declaration of an anonymous class.
56
	 * Completion is a declaration of an anonymous class.
57
	 * This kind of completion might occur in a context like
57
	 * This kind of completion might occur in a context like
58
	 * <code>"new List^;"</code> and complete it to
58
	 * <code>"new List(^;"</code> and complete it to
59
	 * <code>"new List() {}"</code>.
59
	 * <code>"new List() {}"</code>.
60
	 * <p>
60
	 * <p>
61
	 * The following additional context information is available
61
	 * The following additional context information is available
Lines 792-797 Link Here
792
	 * @since 3.4
792
	 * @since 3.4
793
	 */
793
	 */
794
	public static final int FIELD_REF_WITH_CASTED_RECEIVER = 25;
794
	public static final int FIELD_REF_WITH_CASTED_RECEIVER = 25;
795
	
796
	/**
797
	 * Completion is a reference to a constructor.
798
	 * This kind of completion might occur in a context like
799
	 * <code>"new Lis"</code> and complete it to
800
	 * <code>"new List();"</code>.
801
	 * <p>
802
	 * The following additional context information is available
803
	 * for this kind of completion proposal at little extra cost:
804
	 * <ul>
805
	 * <li>{@link #getDeclarationSignature()} -
806
	 * the type signature of the type that declares the constructor that is referenced
807
	 * </li>
808
	 * <li>{@link #getFlags()} -
809
	 * the modifiers flags of the constructor that is referenced
810
	 * </li>
811
	 * <li>{@link #getName()} -
812
	 * the simple name of the constructor that is referenced
813
	 * </li>
814
	 * <li>{@link #getSignature()} -
815
	 * the method signature of the constructor that is referenced
816
	 * </li>
817
	 * </ul>
818
	 * </p>
819
	 * <p>
820
	 * This kind of proposal could require a long computation, so they are computed only if 
821
	 * {@link CompletionRequestor#isAllowingLongComputationProposals()} return <code>true</code>.
822
	 * </p>
823
	 *
824
	 * @see #getKind()
825
	 * @see CompletionRequestor#isAllowingLongComputationProposals()
826
	 * 
827
	 * @since 3.5
828
	 */
829
	public static final int CONSTRUCTOR_INVOCATION = 26;
830
	
831
	/**
832
	 * Completion is a reference of a constructor of an anonymous class.
833
	 * This kind of completion might occur in a context like
834
	 * <code>"new Lis^;"</code> and complete it to
835
	 * <code>"new List() {}"</code>.
836
	 * <p>
837
	 * The following additional context information is available
838
	 * for this kind of completion proposal at little extra cost:
839
	 * <ul>
840
	 * <li>{@link #getDeclarationSignature()} -
841
	 * the type signature of the type being implemented or subclassed
842
	 * </li>
843
	 * <li>{@link #getDeclarationKey()} -
844
	 * the type unique key of the type being implemented or subclassed
845
	 * </li>
846
	 * <li>{@link #getSignature()} -
847
	 * the method signature of the constructor that is referenced
848
	 * </li>
849
	 * <li>{@link #getKey()} -
850
	 * the method unique key of the constructor that is referenced
851
	 * if the declaring type is not an interface
852
	 * </li>
853
	 * <li>{@link #getFlags()} -
854
	 * the modifiers flags of the constructor that is referenced
855
	 * </li>
856
	 * </ul>
857
	 * </p>
858
	 * <p>
859
	 * This kind of proposal could require a long computation, so they are computed only if 
860
	 * {@link CompletionRequestor#isAllowingLongComputationProposals()} return <code>true</code>.
861
	 * </p>
862
	 *
863
	 * @see #getKind()
864
	 * @see CompletionRequestor#isAllowingLongComputationProposals()
865
	 * 
866
	 * @since 3.5
867
	 */
868
	public static final int ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION = 27;
795
869
796
	/**
870
	/**
797
	 * First valid completion kind.
871
	 * First valid completion kind.
Lines 805-811 Link Here
805
	 *
879
	 *
806
	 * @since 3.1
880
	 * @since 3.1
807
	 */
881
	 */
808
	protected static final int LAST_KIND = FIELD_REF_WITH_CASTED_RECEIVER;
882
	protected static final int LAST_KIND = ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION;
809
883
810
	/**
884
	/**
811
	 * Creates a basic completion proposal. All instance
885
	 * Creates a basic completion proposal. All instance
(-)model/org/eclipse/jdt/core/CompletionRequestor.java (-1 / +61 lines)
Lines 70-75 Link Here
70
	private int requiredProposalAllowSet[] = null;
70
	private int requiredProposalAllowSet[] = null;
71
71
72
	private boolean requireExtendedContext = false;
72
	private boolean requireExtendedContext = false;
73
	
74
	private boolean allowsLongComputationProposals = false;
73
75
74
	/**
76
	/**
75
	 * Creates a new completion requestor.
77
	 * Creates a new completion requestor.
Lines 140-145 Link Here
140
			this.ignoreSet &= ~(1 << completionProposalKind);
142
			this.ignoreSet &= ~(1 << completionProposalKind);
141
		}
143
		}
142
	}
144
	}
145
	
146
	/**
147
	 * Returns whether proposals which could require long computation must be proposed.
148
	 * Proposals which could require long computation are among the following kinds
149
	 * <ul>
150
	 * <li><code>CONSTRUCTOR_INVOCATION</code></li>
151
	 * <li><code>ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION</code></li>
152
	 * </ul>
153
	 * 
154
	 * @return <code>true</code> proposals which could require long computation must be proposed
155
	 * , and <code>false</code> if it isn't of interest.
156
	 * 
157
	 * <p>
158
	 * By default, proposals which could require long computation aren't allowed.
159
	 * </p>
160
	 * 
161
	 * @see #setAllowsLongComputationProposals(boolean)
162
	 * @see ICodeAssist#codeComplete(int, CompletionRequestor, org.eclipse.core.runtime.IProgressMonitor)
163
	 *
164
	 * @since 3.5
165
	 */
166
	public boolean isAllowingLongComputationProposals() {
167
		return this.allowsLongComputationProposals;
168
	}
143
169
144
	/**
170
	/**
145
	 * Returns whether a proposal of a given kind with a required proposal
171
	 * Returns whether a proposal of a given kind with a required proposal
Lines 174-180 Link Here
174
200
175
		return 0 != (this.requiredProposalAllowSet[proposalKind] & (1 << requiredProposalKind));
201
		return 0 != (this.requiredProposalAllowSet[proposalKind] & (1 << requiredProposalKind));
176
	}
202
	}
177
203
	
204
	/**
205
	 * Sets whether proposals which could require long computation must be proposed.
206
	 * <p>
207
	 * Compute these proposals can be very long in some circumstance (eg. a workspace with lot of types).
208
	 * To avoid that the code assist operation take too much time you could call code assist operation
209
	 * with a progress monitor ({@link ICodeAssist#codeComplete(int, CompletionRequestor, org.eclipse.core.runtime.IProgressMonitor)}
210
	 * and automatically cancel the code assist operation when a specified amount of time is reached.
211
	 * 
212
	 * <pre>
213
	 * ICodeAssist var = ...;
214
	 * int offset = = ...;
215
	 * CompletionRequestor requestor = ...;
216
	 * var.codeComplete(offset, requestor, new IProgressMonitor() {
217
	 *     private long endTime;
218
	 *     public void beginTask(String name, int totalWork) {
219
	 *         fEndTime= System.currentTimeMillis() + timeout;
220
	 *     }
221
	 *     public boolean isCanceled() {
222
	 *         return endTime <= System.currentTimeMillis();
223
	 *     }
224
	 *     ...
225
	 * });
226
	 * </pre>
227
	 * <p>
228
	 * 
229
	 * @param allow <code>true</code> if  proposals which could require long computation must be proposed,
230
	 *  and <code>false</code> if it isn't of interest
231
	 * @see #isAllowingLongComputationProposals()
232
	 *
233
	 * @since 3.5
234
	 */
235
	public void setAllowsLongComputationProposals(boolean allow) {
236
		this.allowsLongComputationProposals = allow;
237
	}
178
	/**
238
	/**
179
	 * Sets whether a proposal of a given kind with a required proposal
239
	 * Sets whether a proposal of a given kind with a required proposal
180
	 * of the given kind is allowed.
240
	 * of the given kind is allowed.
(-)model/org/eclipse/jdt/internal/core/SearchableEnvironment.java (+146 lines)
Lines 23-28 Link Here
23
import org.eclipse.jdt.internal.compiler.env.ISourceType;
23
import org.eclipse.jdt.internal.compiler.env.ISourceType;
24
import org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer;
24
import org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer;
25
import org.eclipse.jdt.internal.core.search.BasicSearchEngine;
25
import org.eclipse.jdt.internal.core.search.BasicSearchEngine;
26
import org.eclipse.jdt.internal.core.search.IRestrictedAccessConstructorRequestor;
26
import org.eclipse.jdt.internal.core.search.IRestrictedAccessTypeRequestor;
27
import org.eclipse.jdt.internal.core.search.IRestrictedAccessTypeRequestor;
27
28
28
/**
29
/**
Lines 447-452 Link Here
447
				convertSearchFilterToModelFilter(searchFor));
448
				convertSearchFilterToModelFilter(searchFor));
448
		}
449
		}
449
	}
450
	}
451
	
452
	/**
453
	 * Must be used only by CompletionEngine.
454
	 * The progress monitor is used to be able to cancel completion operations
455
	 * 
456
	 * Find constructor declarations that are defined
457
	 * in the current environment and whose name starts with the
458
	 * given prefix. The prefix is a qualified name separated by periods
459
	 * or a simple name (ex. java.util.V or V).
460
	 *
461
	 * The constructors found are passed to one of the following methods:
462
	 *    ISearchRequestor.acceptConstructor(...)
463
	 */
464
	public void findConstructorDeclarations(char[] prefix, boolean camelCaseMatch, final ISearchRequestor storage, IProgressMonitor monitor) {
465
		try {
466
			final String excludePath;
467
			if (this.unitToSkip != null && this.unitToSkip instanceof IJavaElement) {
468
				excludePath = ((IJavaElement) this.unitToSkip).getPath().toString();
469
			} else {
470
				excludePath = null;
471
			}
472
			
473
			int lastDotIndex = CharOperation.lastIndexOf('.', prefix);
474
			char[] qualification, simpleName;
475
			if (lastDotIndex < 0) {
476
				qualification = null;
477
				if (camelCaseMatch) {
478
					simpleName = prefix;
479
				} else {
480
					simpleName = CharOperation.toLowerCase(prefix);
481
				}
482
			} else {
483
				qualification = CharOperation.subarray(prefix, 0, lastDotIndex);
484
				if (camelCaseMatch) {
485
					simpleName = CharOperation.subarray(prefix, lastDotIndex + 1, prefix.length);
486
				} else {
487
					simpleName =
488
						CharOperation.toLowerCase(
489
							CharOperation.subarray(prefix, lastDotIndex + 1, prefix.length));
490
				}
491
			}
492
493
			IProgressMonitor progressMonitor = new IProgressMonitor() {
494
				boolean isCanceled = false;
495
				public void beginTask(String name, int totalWork) {
496
					// implements interface method
497
				}
498
				public void done() {
499
					// implements interface method
500
				}
501
				public void internalWorked(double work) {
502
					// implements interface method
503
				}
504
				public boolean isCanceled() {
505
					return this.isCanceled;
506
				}
507
				public void setCanceled(boolean value) {
508
					this.isCanceled = value;
509
				}
510
				public void setTaskName(String name) {
511
					// implements interface method
512
				}
513
				public void subTask(String name) {
514
					// implements interface method
515
				}
516
				public void worked(int work) {
517
					// implements interface method
518
				}
519
			};
520
			
521
			IRestrictedAccessConstructorRequestor constructorRequestor = new IRestrictedAccessConstructorRequestor() {
522
				public void acceptConstructor(
523
						int modifiers,
524
						char[] simpleTypeName,
525
						int parameterCount,
526
						char[] signature,
527
						char[][] parameterTypes,
528
						char[][] parameterNames,
529
						int typeModifiers,
530
						char[] packageName,
531
						int extraFlags,
532
						String path,
533
						AccessRestriction access) {
534
					if (excludePath != null && excludePath.equals(path))
535
						return;
536
					
537
					storage.acceptConstructor(
538
							modifiers,
539
							simpleTypeName,
540
							parameterCount,
541
							signature,
542
							parameterTypes,
543
							parameterNames, 
544
							typeModifiers,
545
							packageName,
546
							extraFlags,
547
							path,
548
							access);
549
				}
550
			};
551
			
552
			int matchRule = SearchPattern.R_PREFIX_MATCH;
553
			if (camelCaseMatch) matchRule |= SearchPattern.R_CAMELCASE_MATCH;
554
			if (monitor != null) {
555
				found : while (true) { //the loop will finish if the search request ends or is cancelled
556
					try {
557
						new BasicSearchEngine(this.workingCopies).searchAllConstructorDeclarations(
558
								qualification,
559
								simpleName,
560
								matchRule,
561
								getSearchScope(),
562
								constructorRequestor,
563
								CANCEL_IF_NOT_READY_TO_SEARCH,
564
								progressMonitor);
565
						break found;
566
					} catch (OperationCanceledException e) {
567
						if (monitor.isCanceled()) {
568
							throw e;
569
						} else {
570
							try {
571
								Thread.sleep(50); // indexes are not ready. sleep 50ms and retry the search request
572
							} catch (InterruptedException e1) {
573
								// Do nothing
574
							}
575
						}
576
					}
577
				}
578
			} else {
579
				try {
580
					new BasicSearchEngine(this.workingCopies).searchAllConstructorDeclarations(
581
							qualification,
582
							simpleName,
583
							matchRule,
584
							getSearchScope(),
585
							constructorRequestor,
586
							CANCEL_IF_NOT_READY_TO_SEARCH,
587
							progressMonitor);
588
				} catch (OperationCanceledException e) {
589
					// Do nothing
590
				}
591
			}
592
		} catch (JavaModelException e) {
593
			// Do nothing
594
		}
595
	}
450
596
451
	/**
597
	/**
452
	 * Returns all types whose name starts with the given (qualified) <code>prefix</code>.
598
	 * Returns all types whose name starts with the given (qualified) <code>prefix</code>.
(-)search/org/eclipse/jdt/internal/core/search/BasicSearchEngine.java (+365 lines)
Lines 430-435 Link Here
430
		}
430
		}
431
		return true;
431
		return true;
432
	}
432
	}
433
	
434
	boolean match(char[] patternName, char[] patternPackageName, int matchRule, char[] name, char[] packageName) {
435
		
436
		boolean isCaseSensitive = (matchRule & SearchPattern.R_CASE_SENSITIVE) != 0;
437
		
438
		if (patternPackageName != null && !CharOperation.equals(patternPackageName, packageName, true))
439
			return false;
440
		
441
		if (patternName != null) {
442
			boolean isCamelCase = (matchRule & (SearchPattern.R_CAMELCASE_MATCH | SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH)) != 0;
443
			int matchMode = matchRule & JavaSearchPattern.MATCH_MODE_MASK;
444
			if (!isCaseSensitive && !isCamelCase) {
445
				patternName = CharOperation.toLowerCase(patternName);
446
			}
447
			boolean matchFirstChar = !isCaseSensitive || patternName[0] == name[0];
448
			switch(matchMode) {
449
				case SearchPattern.R_EXACT_MATCH :
450
					return matchFirstChar && CharOperation.equals(patternName, name, isCaseSensitive);
451
				case SearchPattern.R_PREFIX_MATCH :
452
					return matchFirstChar && CharOperation.prefixEquals(patternName, name, isCaseSensitive);
453
				case SearchPattern.R_PATTERN_MATCH :
454
					return CharOperation.match(patternName, name, isCaseSensitive);
455
				case SearchPattern.R_REGEXP_MATCH :
456
					// TODO (frederic) implement regular expression match
457
					break;
458
				case SearchPattern.R_CAMELCASE_MATCH:
459
					if (matchFirstChar && CharOperation.camelCaseMatch(patternName, name, false)) {
460
						return true;
461
					}
462
					return !isCaseSensitive && matchFirstChar && CharOperation.prefixEquals(patternName, name, false);
463
				case SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH:
464
					return matchFirstChar && CharOperation.camelCaseMatch(patternName, name, true);
465
			}
466
		}
467
		return true;
468
469
	}
433
470
434
	boolean match(char patternTypeSuffix, char[] patternPkg, char[] patternTypeName, int matchRule, int typeKind, char[] pkg, char[] typeName) {
471
	boolean match(char patternTypeSuffix, char[] patternPkg, char[] patternTypeName, int matchRule, int typeKind, char[] pkg, char[] typeName) {
435
		switch(patternTypeSuffix) {
472
		switch(patternTypeSuffix) {
Lines 505-510 Link Here
505
		}
542
		}
506
		findMatches(pattern, participants, scope, requestor, monitor);
543
		findMatches(pattern, participants, scope, requestor, monitor);
507
	}
544
	}
545
	
546
	public void searchAllConstructorDeclarations(
547
		final char[] packageName,
548
		final char[] typeName,
549
		final int typeMatchRule,
550
		IJavaSearchScope scope,
551
		final IRestrictedAccessConstructorRequestor nameRequestor,
552
		int waitingPolicy,
553
		IProgressMonitor progressMonitor)  throws JavaModelException {
554
555
		// Validate match rule first
556
		final int validatedTypeMatchRule = SearchPattern.validateMatchRule(typeName == null ? null : new String (typeName), typeMatchRule);
557
558
		// Debug
559
		if (VERBOSE) {
560
			Util.verbose("BasicSearchEngine.searchAllTypeNames(char[], char[], int, int, IJavaSearchScope, IRestrictedAccessTypeRequestor, int, IProgressMonitor)"); //$NON-NLS-1$
561
			Util.verbose("	- package name: "+(packageName==null?"null":new String(packageName))); //$NON-NLS-1$ //$NON-NLS-2$
562
			Util.verbose("	- type name: "+(typeName==null?"null":new String(typeName))); //$NON-NLS-1$ //$NON-NLS-2$
563
			Util.verbose("	- type match rule: "+getMatchRuleString(typeMatchRule)); //$NON-NLS-1$
564
			if (validatedTypeMatchRule != typeMatchRule) {
565
				Util.verbose("	- validated type match rule: "+getMatchRuleString(validatedTypeMatchRule)); //$NON-NLS-1$
566
			}
567
			Util.verbose("	- scope: "+scope); //$NON-NLS-1$
568
		}
569
		if (validatedTypeMatchRule == -1) return; // invalid match rule => return no results
570
571
		// Create pattern
572
		IndexManager indexManager = JavaModelManager.getIndexManager();
573
		final ConstructorDeclarationPattern pattern = new ConstructorDeclarationPattern(
574
				packageName,
575
				typeName,
576
				validatedTypeMatchRule);
577
578
		// Get working copy path(s). Store in a single string in case of only one to optimize comparison in requestor
579
		final HashSet workingCopyPaths = new HashSet();
580
		String workingCopyPath = null;
581
		ICompilationUnit[] copies = getWorkingCopies();
582
		final int copiesLength = copies == null ? 0 : copies.length;
583
		if (copies != null) {
584
			if (copiesLength == 1) {
585
				workingCopyPath = copies[0].getPath().toString();
586
			} else {
587
				for (int i = 0; i < copiesLength; i++) {
588
					ICompilationUnit workingCopy = copies[i];
589
					workingCopyPaths.add(workingCopy.getPath().toString());
590
				}
591
			}
592
		}
593
		final String singleWkcpPath = workingCopyPath;
594
595
		// Index requestor
596
		IndexQueryRequestor searchRequestor = new IndexQueryRequestor(){
597
			public boolean acceptIndexMatch(String documentPath, SearchPattern indexRecord, SearchParticipant participant, AccessRuleSet access) {
598
				// Filter unexpected types
599
				ConstructorDeclarationPattern record = (ConstructorDeclarationPattern)indexRecord;
600
				
601
				if ((record.extraFlags & ExtraFlags.IsMemberType) != 0) {
602
					return true; // filter out member classes
603
				}
604
				if ((record.extraFlags & ExtraFlags.IsLocalType) != 0) {
605
					return true; // filter out local and anonymous classes
606
				}
607
				switch (copiesLength) {
608
					case 0:
609
						break;
610
					case 1:
611
						if (singleWkcpPath.equals(documentPath)) {
612
							return true; // filter out *the* working copy
613
						}
614
						break;
615
					default:
616
						if (workingCopyPaths.contains(documentPath)) {
617
							return true; // filter out working copies
618
						}
619
						break;
620
				}
621
622
				// Accept document path
623
				AccessRestriction accessRestriction = null;
624
				if (access != null) {
625
					// Compute document relative path
626
					int pkgLength = (record.declaringPackageName==null || record.declaringPackageName.length==0) ? 0 : record.declaringPackageName.length+1;
627
					int nameLength = record.declaringSimpleName==null ? 0 : record.declaringSimpleName.length;
628
					char[] path = new char[pkgLength+nameLength];
629
					int pos = 0;
630
					if (pkgLength > 0) {
631
						System.arraycopy(record.declaringPackageName, 0, path, pos, pkgLength-1);
632
						CharOperation.replace(path, '.', '/');
633
						path[pkgLength-1] = '/';
634
						pos += pkgLength;
635
					}
636
					if (nameLength > 0) {
637
						System.arraycopy(record.declaringSimpleName, 0, path, pos, nameLength);
638
						pos += nameLength;
639
					}
640
					// Update access restriction if path is not empty
641
					if (pos > 0) {
642
						accessRestriction = access.getViolatedRestriction(path);
643
					}
644
				}
645
				nameRequestor.acceptConstructor(
646
						record.modifiers,
647
						record.declaringSimpleName,
648
						record.parameterCount,
649
						record.signature,
650
						record.parameterTypes,
651
						record.parameterNames,
652
						record.declaringTypeModifiers,
653
						record.declaringPackageName,
654
						record.extraFlags,
655
						documentPath,
656
						accessRestriction);
657
				return true;
658
			}
659
		};
660
661
		try {
662
			if (progressMonitor != null) {
663
				progressMonitor.beginTask(Messages.engine_searching, 1000);
664
			}
665
			// add type names from indexes
666
			indexManager.performConcurrentJob(
667
				new PatternSearchJob(
668
					pattern,
669
					getDefaultSearchParticipant(), // Java search only
670
					scope,
671
					searchRequestor),
672
				waitingPolicy,
673
				progressMonitor == null ? null : new SubProgressMonitor(progressMonitor, 1000-copiesLength));
674
675
			// add type names from working copies
676
			if (copies != null) {
677
				for (int i = 0; i < copiesLength; i++) {
678
					final ICompilationUnit workingCopy = copies[i];
679
					if (!scope.encloses(workingCopy)) continue;
680
					final String path = workingCopy.getPath().toString();
681
					if (workingCopy.isConsistent()) {
682
						IPackageDeclaration[] packageDeclarations = workingCopy.getPackageDeclarations();
683
						char[] packageDeclaration = packageDeclarations.length == 0 ? CharOperation.NO_CHAR : packageDeclarations[0].getElementName().toCharArray();
684
						IType[] allTypes = workingCopy.getAllTypes();
685
						for (int j = 0, allTypesLength = allTypes.length; j < allTypesLength; j++) {
686
							IType type = allTypes[j];
687
							char[] simpleName = type.getElementName().toCharArray();
688
							if (match(typeName, packageName, validatedTypeMatchRule, simpleName, packageDeclaration) && !type.isMember()) {
689
								
690
								int extraFlags = ExtraFlags.getExtraFlags(type);
691
								
692
								boolean hasConstructor = false;
693
								
694
								IMethod[] methods = type.getMethods();
695
								for (int k = 0; k < methods.length; k++) {
696
									IMethod method = methods[k];
697
									if (method.isConstructor()) {
698
										hasConstructor = true;
699
										
700
										String[] stringParameterNames = method.getParameterNames();
701
										String[] stringParameterTypes = method.getParameterTypes();
702
										int length = stringParameterNames.length;
703
										char[][] parameterNames = new char[length][];
704
										char[][] parameterTypes = new char[length][];
705
										for (int l = 0; l < length; l++) {
706
											parameterNames[l] = stringParameterNames[l].toCharArray();
707
											parameterTypes[l] = Signature.toCharArray(Signature.getTypeErasure(stringParameterTypes[l]).toCharArray());
708
										}
709
										
710
										nameRequestor.acceptConstructor(
711
												method.getFlags(),
712
												simpleName,
713
												parameterNames.length,
714
												null,// signature is not used for source type
715
												parameterTypes, 
716
												parameterNames,
717
												type.getFlags(),
718
												packageDeclaration,
719
												extraFlags,
720
												path,
721
												null);
722
									}
723
								}
724
								
725
								if (!hasConstructor) {
726
									nameRequestor.acceptConstructor(
727
											Flags.AccPublic,
728
											simpleName,
729
											-1,
730
											null, // signature is not used for source type
731
											CharOperation.NO_CHAR_CHAR,
732
											CharOperation.NO_CHAR_CHAR,
733
											type.getFlags(),
734
											packageDeclaration,
735
											extraFlags,
736
											path,
737
											null);
738
								}
739
							}
740
						}
741
					} else {
742
						Parser basicParser = getParser();
743
						org.eclipse.jdt.internal.compiler.env.ICompilationUnit unit = (org.eclipse.jdt.internal.compiler.env.ICompilationUnit) workingCopy;
744
						CompilationResult compilationUnitResult = new CompilationResult(unit, 0, 0, this.compilerOptions.maxProblemsPerUnit);
745
						CompilationUnitDeclaration parsedUnit = basicParser.dietParse(unit, compilationUnitResult);
746
						if (parsedUnit != null) {
747
							final char[] packageDeclaration = parsedUnit.currentPackage == null ? CharOperation.NO_CHAR : CharOperation.concatWith(parsedUnit.currentPackage.getImportName(), '.');
748
							class AllConstructorDeclarationsVisitor extends ASTVisitor {
749
								private TypeDeclaration[] declaringTypes = new TypeDeclaration[0];
750
								private int declaringTypesPtr = -1;
751
								
752
								private void endVisit(TypeDeclaration typeDeclaration) {
753
									if (!hasConstructor(typeDeclaration) && typeDeclaration.enclosingType == null) {
754
									
755
										if (match(typeName, packageName, validatedTypeMatchRule, typeDeclaration.name, packageDeclaration)) {
756
											nameRequestor.acceptConstructor(
757
													Flags.AccPublic,
758
													typeName,
759
													-1,
760
													null, // signature is not used for source type
761
													CharOperation.NO_CHAR_CHAR,
762
													CharOperation.NO_CHAR_CHAR,
763
													typeDeclaration.modifiers,
764
													packageDeclaration,
765
													ExtraFlags.getExtraFlags(typeDeclaration),
766
													path,
767
													null);
768
										}
769
									}
770
									
771
									this.declaringTypes[this.declaringTypesPtr] = null;
772
									this.declaringTypesPtr--;
773
								}
774
								
775
								public void endVisit(TypeDeclaration typeDeclaration, CompilationUnitScope s) {
776
									endVisit(typeDeclaration);
777
								}
778
								
779
								public void endVisit(TypeDeclaration memberTypeDeclaration, ClassScope s) {
780
									endVisit(memberTypeDeclaration);
781
								}
782
								
783
								private boolean hasConstructor(TypeDeclaration typeDeclaration) {
784
									AbstractMethodDeclaration[] methods = typeDeclaration.methods;
785
									int length = methods == null ? 0 : methods.length;
786
									for (int j = 0; j < length; j++) {
787
										if (methods[j].isConstructor()) {
788
											return true;
789
										}
790
									}
791
									
792
									return false;
793
								}
794
								public boolean visit(ConstructorDeclaration constructorDeclaration, ClassScope classScope) {
795
									TypeDeclaration typeDeclaration = this.declaringTypes[this.declaringTypesPtr];
796
									if (match(typeName, packageName, validatedTypeMatchRule, typeDeclaration.name, packageDeclaration)) {
797
										Argument[] arguments = constructorDeclaration.arguments;
798
										int length = arguments == null ? 0 : arguments.length;
799
										char[][] parameterNames = new char[length][];
800
										char[][] parameterTypes = new char[length][];
801
										for (int l = 0; l < length; l++) {
802
											Argument argument = arguments[l];
803
											parameterNames[l] = argument.name;
804
											if (argument.type instanceof SingleTypeReference) {
805
												parameterTypes[l] = ((SingleTypeReference)argument.type).token;
806
											} else {
807
												parameterTypes[l] = CharOperation.concatWith(((QualifiedTypeReference)argument.type).tokens, '.');
808
											}
809
										}
810
										
811
										TypeDeclaration enclosing = typeDeclaration.enclosingType;
812
										char[][] enclosingTypeNames = CharOperation.NO_CHAR_CHAR;
813
										while (enclosing != null) {
814
											enclosingTypeNames = CharOperation.arrayConcat(new char[][] {enclosing.name}, enclosingTypeNames);
815
											if ((enclosing.bits & ASTNode.IsMemberType) != 0) {
816
												enclosing = enclosing.enclosingType;
817
											} else {
818
												enclosing = null;
819
											}
820
										}
821
										
822
										nameRequestor.acceptConstructor(
823
												constructorDeclaration.modifiers,
824
												typeName,
825
												parameterNames.length,
826
												null, // signature is not used for source type
827
												parameterTypes,
828
												parameterNames,
829
												typeDeclaration.modifiers,
830
												packageDeclaration,
831
												ExtraFlags.getExtraFlags(typeDeclaration),
832
												path,
833
												null);
834
									}
835
									return false; // no need to find constructors from local/anonymous type
836
								}
837
								public boolean visit(TypeDeclaration typeDeclaration, BlockScope blockScope) {
838
									return false; 
839
								}
840
								
841
								private boolean visit(TypeDeclaration typeDeclaration) {
842
									if(this.declaringTypes.length <= ++this.declaringTypesPtr) {
843
										int length = this.declaringTypesPtr;
844
										System.arraycopy(this.declaringTypes, 0, this.declaringTypes = new TypeDeclaration[length * 2 + 1], 0, length);
845
									}
846
									this.declaringTypes[this.declaringTypesPtr] = typeDeclaration;
847
									return true;
848
								}
849
								
850
								public boolean visit(TypeDeclaration typeDeclaration, CompilationUnitScope s) {
851
									return visit(typeDeclaration);
852
								}
853
								
854
								public boolean visit(TypeDeclaration memberTypeDeclaration, ClassScope s) {
855
									return visit(memberTypeDeclaration);
856
								}
857
							}
858
							parsedUnit.traverse(new AllConstructorDeclarationsVisitor(), parsedUnit.scope);
859
						}
860
					}
861
					if (progressMonitor != null) {
862
						if (progressMonitor.isCanceled()) throw new OperationCanceledException();
863
						progressMonitor.worked(1);
864
					}
865
				}
866
			}
867
		} finally {
868
			if (progressMonitor != null) {
869
				progressMonitor.done();
870
			}
871
		}
872
	}
508
873
509
	/**
874
	/**
510
	 * Searches for all secondary types in the given scope.
875
	 * Searches for all secondary types in the given scope.
(-)search/org/eclipse/jdt/internal/core/search/matching/ConstructorPattern.java (-19 / +260 lines)
Lines 19-24 Link Here
19
import org.eclipse.jdt.core.compiler.CharOperation;
19
import org.eclipse.jdt.core.compiler.CharOperation;
20
import org.eclipse.jdt.core.search.IJavaSearchConstants;
20
import org.eclipse.jdt.core.search.IJavaSearchConstants;
21
import org.eclipse.jdt.core.search.SearchPattern;
21
import org.eclipse.jdt.core.search.SearchPattern;
22
import org.eclipse.jdt.internal.compiler.ExtraFlags;
23
import org.eclipse.jdt.internal.compiler.ast.ASTNode;
22
import org.eclipse.jdt.internal.core.index.EntryResult;
24
import org.eclipse.jdt.internal.core.index.EntryResult;
23
import org.eclipse.jdt.internal.core.index.Index;
25
import org.eclipse.jdt.internal.core.index.Index;
24
import org.eclipse.jdt.internal.core.util.Util;
26
import org.eclipse.jdt.internal.core.util.Util;
Lines 52-57 Link Here
52
	IJavaSearchConstants.THIS_REFERENCE |
54
	IJavaSearchConstants.THIS_REFERENCE |
53
	IJavaSearchConstants.IMPLICIT_THIS_REFERENCE;
55
	IJavaSearchConstants.IMPLICIT_THIS_REFERENCE;
54
56
57
58
/**
59
 * Constructor entries are encoded as described
60
 * 
61
 * Binary constructor for class
62
 * TypeName '/' Arity '/' TypeModifers '/' PackageName '/' Signature '/' ParameterNamesopt '/' Modifiers
63
 * Source constructor for class
64
 * TypeName '/' Arity '/' TypeModifers '/' PackageName '/' ParameterTypes '/' ParameterNamesopt
65
 * Constructor with 0 arity for class
66
 * TypeName '/' 0 '/' TypeModifers '/' PackageName '/' Modifiers
67
 * Constructor for enum, interface (annotation) and class with default constructor
68
 * TypeName '/' # '/' TypeModifers '/' PackageName
69
 * Constructor for member type
70
 * TypeName '/' Arity '/' TypeModifers
71
 * 
72
 * TypeModifiers contains some encoded extra information
73
 * 		{@link ExtraFlags#IsMemberType}
74
 * 		{@link ExtraFlags#HasNonPrivateStaticMemberTypes}
75
 * 		{@link ExtraFlags#ParameterTypesStoredAsSignature}
76
 */
77
public static char[] createDeclarationIndexKey(
78
		char[] typeName,
79
		int argCount,
80
		char[] signature,
81
		char[][] parameterTypes,
82
		char[][] parameterNames,
83
		int modifiers,
84
		char[] packageName,
85
		int typeModifiers,
86
		int extraFlags) {
87
	
88
	char[] countChars;
89
	char[] parameterTypesChars = null;
90
	char[] parameterNamesChars = null;
91
	
92
	if (argCount < 0) {
93
		countChars = DEFAULT_CONSTRUCTOR;
94
	} else {
95
		countChars = argCount < 10
96
		? COUNTS[argCount]
97
		: ("/" + String.valueOf(argCount)).toCharArray(); //$NON-NLS-1$
98
		
99
		if (argCount > 0) {
100
			if (signature == null) {
101
				if (parameterTypes != null && parameterTypes.length == argCount) {
102
					char[][] parameterTypeErasures = new char[argCount][];
103
					for (int i = 0; i < parameterTypes.length; i++) {
104
						parameterTypeErasures[i] = getTypeErasure(parameterTypes[i]);
105
					}
106
					parameterTypesChars = CharOperation.concatWith(parameterTypeErasures, PARAMETER_SEPARATOR);
107
				}
108
			} else {
109
				extraFlags |= ExtraFlags.ParameterTypesStoredAsSignature;
110
			}
111
			
112
			if (parameterNames != null && parameterNames.length == argCount) {
113
				parameterNamesChars = CharOperation.concatWith(parameterNames, PARAMETER_SEPARATOR);
114
			}
115
		}
116
	}
117
	
118
	boolean isMemberType = (extraFlags & ExtraFlags.IsMemberType) != 0;
119
	boolean hasStoredParameterTypesAsSignature = (extraFlags & ExtraFlags.ParameterTypesStoredAsSignature) != 0;
120
	
121
	int typeNameLength = typeName == null ? 0 : typeName.length;
122
	int packageNameLength = packageName == null ? 0 : packageName.length;
123
	int countCharsLength = countChars.length;
124
	int parameterTypesLength = signature == null ? (parameterTypesChars == null ? 0 : parameterTypesChars.length): signature.length;
125
	int parameterNamesLength = parameterNamesChars == null ? 0 : parameterNamesChars.length;
126
	
127
	int resultLength = typeNameLength + countCharsLength + 3; // SEPARATOR=1 + TypeModifers=2
128
	if (!isMemberType) {
129
		resultLength += packageNameLength + 1; // SEPARATOR=1
130
		if (argCount == 0 ||  hasStoredParameterTypesAsSignature) {
131
			resultLength += 3; // SEPARATOR=1 + Modifiers=2
132
		}
133
		
134
		if (argCount > 0) {
135
			resultLength += parameterTypesLength + parameterNamesLength + 2; //SEPARATOR=1 + SEPARATOR=1
136
		}
137
	}
138
	
139
	char[] result = new char[resultLength];
140
	
141
	int pos = 0;
142
	if (typeNameLength > 0) {
143
		System.arraycopy(typeName, 0, result, pos, typeNameLength);
144
		pos += typeNameLength;
145
	}
146
	
147
	if (countCharsLength > 0) {
148
		System.arraycopy(countChars, 0, result, pos, countCharsLength);
149
		pos += countCharsLength;
150
	}
151
	
152
	int typeModifiersWithExtraFlags = typeModifiers | encodeExtraFlags(extraFlags);
153
	result[pos++] = SEPARATOR;
154
	result[pos++] = (char) typeModifiersWithExtraFlags;
155
	result[pos++] = (char) (typeModifiersWithExtraFlags>>16);
156
	
157
	if (!isMemberType) {
158
		result[pos++] = SEPARATOR;
159
		if (packageNameLength > 0) {
160
			System.arraycopy(packageName, 0, result, pos, packageNameLength);
161
			pos += packageNameLength;
162
		}
163
		
164
		if (argCount == 0) {
165
			result[pos++] = SEPARATOR;
166
			result[pos++] = (char) modifiers;
167
			result[pos++] = (char) (modifiers>>16);
168
		} else if (argCount > 0) {
169
			result[pos++] = SEPARATOR;
170
			if (parameterTypesLength > 0) {
171
				if (signature == null) {
172
					System.arraycopy(parameterTypesChars, 0, result, pos, parameterTypesLength);
173
				} else {
174
					System.arraycopy(CharOperation.replaceOnCopy(signature, SEPARATOR, '\\'), 0, result, pos, parameterTypesLength);
175
				}
176
				pos += parameterTypesLength;
177
			}
178
			
179
			result[pos++] = SEPARATOR;
180
			if (parameterNamesLength > 0) {
181
				System.arraycopy(parameterNamesChars, 0, result, pos, parameterNamesLength);
182
				pos += parameterNamesLength;
183
			}
184
			
185
			if (hasStoredParameterTypesAsSignature) {
186
				result[pos++] = SEPARATOR;
187
				result[pos++] = (char) modifiers;
188
				result[pos++] = (char) (modifiers>>16);
189
			}
190
		}
191
		
192
	}
193
	
194
	return result;
195
}
196
public static char[] createDefaultDeclarationIndexKey(
197
		char[] typeName,
198
		char[] packageName,
199
		int typeModifiers,
200
		int extraFlags) {
201
	return createDeclarationIndexKey(
202
			typeName,
203
			-1, // used to identify default constructor
204
			null,
205
			null,
206
			null,
207
			0, //
208
			packageName,
209
			typeModifiers,
210
			extraFlags);
211
}
212
55
/**
213
/**
56
 * Constructor entries are encoded as TypeName '/' Arity:
214
 * Constructor entries are encoded as TypeName '/' Arity:
57
 * e.g. 'X/0'
215
 * e.g. 'X/0'
Lines 62-68 Link Here
62
		: ("/" + String.valueOf(argCount)).toCharArray(); //$NON-NLS-1$
220
		: ("/" + String.valueOf(argCount)).toCharArray(); //$NON-NLS-1$
63
	return CharOperation.concat(typeName, countChars);
221
	return CharOperation.concat(typeName, countChars);
64
}
222
}
65
223
static int decodeExtraFlags(int modifiersWithExtraFlags) {
224
	int extraFlags = 0;
225
	
226
	if ((modifiersWithExtraFlags & ASTNode.Bit28) != 0) {
227
		extraFlags |= ExtraFlags.ParameterTypesStoredAsSignature;
228
	}
229
	
230
	if ((modifiersWithExtraFlags & ASTNode.Bit29) != 0) {
231
		extraFlags |= ExtraFlags.IsLocalType;
232
	}
233
	
234
	if ((modifiersWithExtraFlags & ASTNode.Bit30) != 0) {
235
		extraFlags |= ExtraFlags.IsMemberType;
236
	}
237
	
238
	if ((modifiersWithExtraFlags & ASTNode.Bit31) != 0) {
239
		extraFlags |= ExtraFlags.HasNonPrivateStaticMemberTypes;
240
	}
241
	
242
	return extraFlags;
243
}
244
static int decodeModifers(int modifiersWithExtraFlags) {
245
	return modifiersWithExtraFlags & ~(ASTNode.Bit31 | ASTNode.Bit30 | ASTNode.Bit29 | ASTNode.Bit28);
246
}
247
private static int encodeExtraFlags(int extraFlags) {
248
	int encodedExtraFlags = 0;
249
	
250
	if ((extraFlags & ExtraFlags.ParameterTypesStoredAsSignature) != 0) {
251
		encodedExtraFlags |= ASTNode.Bit28;
252
	}
253
	
254
	if ((extraFlags & ExtraFlags.IsLocalType) != 0) {
255
		encodedExtraFlags |= ASTNode.Bit29;
256
	}
257
	
258
	if ((extraFlags & ExtraFlags.IsMemberType) != 0) {
259
		encodedExtraFlags |= ASTNode.Bit30;
260
	}
261
	if ((extraFlags & ExtraFlags.HasNonPrivateStaticMemberTypes) != 0) {
262
		encodedExtraFlags |= ASTNode.Bit31;
263
	}
264
	
265
	return encodedExtraFlags;
266
}
267
private static char[] getTypeErasure(char[] typeName) {
268
	int index;
269
	if ((index = CharOperation.indexOf('<', typeName)) == -1) return typeName;
270
	
271
	int length = typeName.length;
272
	char[] typeErasurename = new char[length - 2];
273
	
274
	System.arraycopy(typeName, 0, typeErasurename, 0, index);
275
	
276
	int depth = 1;
277
	for (int i = index + 1; i < length; i++) {
278
		switch (typeName[i]) {
279
			case '<':
280
				depth++;
281
				break;
282
			case '>':
283
				depth--;
284
				break;
285
			default:
286
				if (depth == 0) {
287
					typeErasurename[index++] = typeName[i];
288
				}
289
				break;
290
		}
291
	}
292
	
293
	System.arraycopy(typeErasurename, 0, typeErasurename = new char[index], 0, index);
294
	return typeErasurename;
295
}
66
ConstructorPattern(int matchRule) {
296
ConstructorPattern(int matchRule) {
67
	super(CONSTRUCTOR_PATTERN, matchRule);
297
	super(CONSTRUCTOR_PATTERN, matchRule);
68
}
298
}
Lines 225-245 Link Here
225
	}
455
	}
226
	if (hasConstructorArguments())  this.mustResolve = true;
456
	if (hasConstructorArguments())  this.mustResolve = true;
227
}
457
}
458
228
public void decodeIndexKey(char[] key) {
459
public void decodeIndexKey(char[] key) {
229
	int last = key.length - 1;
460
	int last = key.length - 1;
230
	this.parameterCount = 0;
461
	int slash = CharOperation.indexOf(SEPARATOR, key, 0);
231
	this.declaringSimpleName = null;
462
	this.declaringSimpleName = CharOperation.subarray(key, 0, slash);
232
	int power = 1;
463
	
233
	for (int i=last; i>=0; i--) {
464
	int start = slash + 1;
234
		if (key[i] == SEPARATOR) {
465
	slash = CharOperation.indexOf(SEPARATOR, key, start);
235
			System.arraycopy(key, 0, this.declaringSimpleName = new char[i], 0, i);
466
	if (slash != -1) {
236
			break;
467
		last = slash - 1;
237
		}
468
	}
238
		if (i == last) {
469
	
239
			this.parameterCount = key[i] - '0';
470
	boolean isDefaultConstructor = key[last] == '#';
240
		} else {
471
	if (isDefaultConstructor) {
241
			power *= 10;
472
		this.parameterCount = -1;
242
			this.parameterCount += power * (key[i] - '0');
473
	} else {
474
		this.parameterCount = 0;
475
		int power = 1;
476
		for (int i = last; i >= start; i--) {
477
			if (i == last) {
478
				this.parameterCount = key[i] - '0';
479
			} else {
480
				power *= 10;
481
				this.parameterCount += power * (key[i] - '0');
482
			}
243
		}
483
		}
244
	}
484
	}
245
}
485
}
Lines 262-268 Link Here
262
public boolean matchesDecodedKey(SearchPattern decodedPattern) {
502
public boolean matchesDecodedKey(SearchPattern decodedPattern) {
263
	ConstructorPattern pattern = (ConstructorPattern) decodedPattern;
503
	ConstructorPattern pattern = (ConstructorPattern) decodedPattern;
264
504
265
	return (this.parameterCount == pattern.parameterCount || this.parameterCount == -1 || this.varargs)
505
	return pattern.parameterCount != -1
506
		&& (this.parameterCount == pattern.parameterCount || this.parameterCount == -1 || this.varargs)
266
		&& matchesName(this.declaringSimpleName, pattern.declaringSimpleName);
507
		&& matchesName(this.declaringSimpleName, pattern.declaringSimpleName);
267
}
508
}
268
protected boolean mustResolve() {
509
protected boolean mustResolve() {
Lines 280-291 Link Here
280
521
281
	switch(getMatchMode()) {
522
	switch(getMatchMode()) {
282
		case R_EXACT_MATCH :
523
		case R_EXACT_MATCH :
283
			if (this.declaringSimpleName != null && this.parameterCount >= 0 && !this.varargs)
524
			if (this.declaringSimpleName != null && this.parameterCount >= 0 && !this.varargs) {
284
				key = createIndexKey(this.declaringSimpleName, this.parameterCount);
525
				key = createIndexKey(this.declaringSimpleName, this.parameterCount);
285
			else { // do a prefix query with the declaringSimpleName
286
				matchRule &= ~R_EXACT_MATCH;
287
				matchRule |= R_PREFIX_MATCH;
288
			}
526
			}
527
			matchRule &= ~R_EXACT_MATCH;
528
			matchRule |= R_PREFIX_MATCH;
289
			break;
529
			break;
290
		case R_PREFIX_MATCH :
530
		case R_PREFIX_MATCH :
291
			// do a prefix query with the declaringSimpleName
531
			// do a prefix query with the declaringSimpleName
Lines 295-300 Link Here
295
				key = createIndexKey(this.declaringSimpleName == null ? ONE_STAR : this.declaringSimpleName, this.parameterCount);
535
				key = createIndexKey(this.declaringSimpleName == null ? ONE_STAR : this.declaringSimpleName, this.parameterCount);
296
			else if (this.declaringSimpleName != null && this.declaringSimpleName[this.declaringSimpleName.length - 1] != '*')
536
			else if (this.declaringSimpleName != null && this.declaringSimpleName[this.declaringSimpleName.length - 1] != '*')
297
				key = CharOperation.concat(this.declaringSimpleName, ONE_STAR, SEPARATOR);
537
				key = CharOperation.concat(this.declaringSimpleName, ONE_STAR, SEPARATOR);
538
			key = CharOperation.concat(key, ONE_STAR);
298
			// else do a pattern query with just the declaringSimpleName
539
			// else do a pattern query with just the declaringSimpleName
299
			break;
540
			break;
300
		case R_REGEXP_MATCH :
541
		case R_REGEXP_MATCH :
(-)search/org/eclipse/jdt/internal/core/search/matching/ConstructorDeclarationPattern.java (+190 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.jdt.internal.core.search.matching;
12
13
import java.io.IOException;
14
15
import org.eclipse.jdt.core.compiler.CharOperation;
16
import org.eclipse.jdt.core.search.SearchPattern;
17
import org.eclipse.jdt.internal.compiler.ExtraFlags;
18
import org.eclipse.jdt.internal.core.index.EntryResult;
19
import org.eclipse.jdt.internal.core.index.Index;
20
21
public class ConstructorDeclarationPattern extends ConstructorPattern {
22
	private static final char[][] EXT_DECL_CATEGORIES = {CONSTRUCTOR_DECL};
23
	
24
	public int extraFlags;
25
	
26
	public int declaringTypeModifiers;
27
	public char[] declaringPackageName;
28
	
29
	public int modifiers;
30
	public char[] signature;
31
	public char[][] parameterTypes;
32
	public char[][] parameterNames;
33
34
public ConstructorDeclarationPattern(char[] declaringPackageName, char[] declaringSimpleName, int matchRule) {
35
	this(matchRule);
36
	this.declaringSimpleName = (this.isCaseSensitive || this.isCamelCase) ? declaringSimpleName : CharOperation.toLowerCase(declaringSimpleName);
37
	this.declaringPackageName = declaringPackageName;
38
	this.findDeclarations = true;
39
	this.findReferences = false;
40
	this.parameterCount = -1;
41
	this.mustResolve = false;
42
}
43
44
ConstructorDeclarationPattern(int matchRule) {
45
	super(matchRule);
46
}
47
public void decodeIndexKey(char[] key) {
48
	int last = key.length - 1;
49
	int slash = CharOperation.indexOf(SEPARATOR, key, 0);
50
	this.declaringSimpleName = CharOperation.subarray(key, 0, slash);
51
	
52
	int start = slash + 1;
53
	slash = CharOperation.indexOf(SEPARATOR, key, start);
54
	last = slash - 1;
55
	
56
	boolean isDefaultConstructor = key[last] == '#';
57
	if (isDefaultConstructor) {
58
		this.parameterCount = -1;
59
	} else {
60
		this.parameterCount = 0;
61
		int power = 1;
62
		for (int i = last; i >= start; i--) {
63
			if (i == last) {
64
				this.parameterCount = key[i] - '0';
65
			} else {
66
				power *= 10;
67
				this.parameterCount += power * (key[i] - '0');
68
			}
69
		}
70
	}
71
	
72
	slash = slash + 3;
73
	last = slash - 1;
74
	
75
	int typeModifiersWithExtraFlags = key[last-1] + (key[last]<<16);
76
	this.declaringTypeModifiers = decodeModifers(typeModifiersWithExtraFlags);
77
	this.extraFlags = decodeExtraFlags(typeModifiersWithExtraFlags);
78
	
79
	boolean isMemberType = (this.extraFlags & ExtraFlags.IsMemberType) != 0;
80
	
81
	if (!isMemberType) {
82
		start = slash + 1;
83
		if (this.parameterCount == -1) {
84
			slash = key.length;
85
			last = slash - 1;
86
		} else {
87
			slash = CharOperation.indexOf(SEPARATOR, key, start);
88
		}
89
		last = slash - 1;
90
		
91
		this.declaringPackageName = CharOperation.subarray(key, start, slash);
92
		
93
		start = slash + 1;
94
		if (this.parameterCount == 0) {
95
			slash = slash + 3;
96
			last = slash - 1;
97
			
98
			this.modifiers = key[last-1] + (key[last]<<16);
99
		} else if (this.parameterCount > 0){
100
			slash = CharOperation.indexOf(SEPARATOR, key, start);
101
			last = slash - 1;
102
			
103
			boolean hasParameterStoredAsSignature = (this.extraFlags & ExtraFlags.ParameterTypesStoredAsSignature) != 0;
104
			if (hasParameterStoredAsSignature) {
105
				this.signature  = CharOperation.subarray(key, start, slash);
106
				CharOperation.replace(this.signature , '\\', SEPARATOR);
107
				
108
				start = slash + 1;
109
				slash = CharOperation.indexOf(SEPARATOR, key, start);
110
			} else {
111
				this.parameterTypes = CharOperation.splitOn(PARAMETER_SEPARATOR, key, start, slash);
112
				
113
				start = slash + 1;
114
				slash = key.length;
115
			}
116
			last = slash - 1;
117
			
118
			if (slash != start) {
119
				this.parameterNames = CharOperation.splitOn(PARAMETER_SEPARATOR, key, start, slash);
120
			}
121
			
122
			if (hasParameterStoredAsSignature) {
123
				slash = slash + 3;
124
				last = slash - 1;
125
				
126
				this.modifiers = key[last-1] + (key[last]<<16);
127
			}
128
		}
129
	}
130
	
131
	removeInternalFlags(); // remove internal flags
132
}
133
134
public SearchPattern getBlankPattern() {
135
	return new ConstructorDeclarationPattern(R_EXACT_MATCH | R_CASE_SENSITIVE);
136
}
137
public char[][] getIndexCategories() {
138
	return EXT_DECL_CATEGORIES;
139
}
140
public boolean matchesDecodedKey(SearchPattern decodedPattern) {
141
	ConstructorDeclarationPattern pattern = (ConstructorDeclarationPattern) decodedPattern;
142
	
143
	// only top level types
144
	if ((pattern.extraFlags & ExtraFlags.IsMemberType) != 0) return false;
145
	
146
	// check package - exact match only
147
	if (this.declaringPackageName != null && !CharOperation.equals(this.declaringPackageName, pattern.declaringPackageName, true))
148
		return false;
149
150
	return (this.parameterCount == pattern.parameterCount || this.parameterCount == -1 || this.varargs)
151
		&& matchesName(this.declaringSimpleName, pattern.declaringSimpleName);
152
}
153
public EntryResult[] queryIn(Index index) throws IOException {
154
	char[] key = this.declaringSimpleName; // can be null
155
	int matchRule = getMatchRule();
156
157
	switch(getMatchMode()) {
158
		case R_EXACT_MATCH :
159
			if (this.declaringSimpleName != null && this.parameterCount >= 0 && !this.varargs) {
160
				key = createIndexKey(this.declaringSimpleName, this.parameterCount);
161
			} 
162
			matchRule &= ~R_EXACT_MATCH;
163
			matchRule |= R_PREFIX_MATCH;
164
			break;
165
		case R_PREFIX_MATCH :
166
			// do a prefix query with the declaringSimpleName
167
			break;
168
		case R_PATTERN_MATCH :
169
			if (this.parameterCount >= 0 && !this.varargs)
170
				key = createIndexKey(this.declaringSimpleName == null ? ONE_STAR : this.declaringSimpleName, this.parameterCount);
171
			else if (this.declaringSimpleName != null && this.declaringSimpleName[this.declaringSimpleName.length - 1] != '*')
172
				key = CharOperation.concat(this.declaringSimpleName, ONE_STAR, SEPARATOR);
173
			key = CharOperation.concat(key, ONE_STAR);
174
			// else do a pattern query with just the declaringSimpleName
175
			break;
176
		case R_REGEXP_MATCH :
177
			// TODO (frederic) implement regular expression match
178
			break;
179
		case R_CAMELCASE_MATCH:
180
		case R_CAMELCASE_SAME_PART_COUNT_MATCH:
181
			// do a prefix query with the declaringSimpleName
182
			break;
183
	}
184
185
	return index.query(getIndexCategories(), key, matchRule); // match rule is irrelevant when the key is null
186
}
187
private void removeInternalFlags() {
188
	this.extraFlags = this.extraFlags & ~ExtraFlags.ParameterTypesStoredAsSignature; // ParameterTypesStoredAsSignature is an internal flags only used to decode key
189
}
190
}
(-)search/org/eclipse/jdt/internal/core/search/IRestrictedAccessConstructorRequestor.java (+34 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.jdt.internal.core.search;
12
13
import org.eclipse.jdt.internal.compiler.env.AccessRestriction;
14
15
/**
16
 * A <code>IRestrictedAccessConstructorRequestor</code> collects search results from a <code>searchAllConstructorDeclarations</code>
17
 * query to a <code>SearchBasicEngine</code> providing restricted access information of declaring type when a constructor is accepted.
18
 */
19
public interface IRestrictedAccessConstructorRequestor {
20
21
	public void acceptConstructor(
22
			int modifiers,
23
			char[] simpleTypeName,
24
			int parameterCount,
25
			char[] signature,
26
			char[][] parameterTypes,
27
			char[][] parameterNames,
28
			int typeModifiers,
29
			char[] packageName,
30
			int extraFlags,
31
			String path,
32
			AccessRestriction access);
33
34
}
(-)model/org/eclipse/jdt/internal/compiler/ExtraFlags.java (+104 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.jdt.internal.compiler;
12
13
import org.eclipse.jdt.core.IType;
14
import org.eclipse.jdt.core.JavaModelException;
15
import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
16
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
17
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader;
18
import org.eclipse.jdt.internal.compiler.env.IBinaryNestedType;
19
20
public final class ExtraFlags {
21
	public final static int HasNonPrivateStaticMemberTypes = 0x0001;
22
	public final static int IsMemberType = 0x0002;
23
	public final static int IsLocalType = 0x0004;
24
	
25
	//internal flags
26
	public final static int ParameterTypesStoredAsSignature = 0x0010;
27
	
28
	public static int getExtraFlags(ClassFileReader reader) {
29
		int extraFlags = 0;
30
		
31
		if (reader.isNestedType()) {
32
			extraFlags |= ExtraFlags.IsMemberType;
33
		}
34
		
35
		if (reader.isLocal()) {
36
			extraFlags |= ExtraFlags.IsLocalType;
37
		}
38
		
39
		IBinaryNestedType[] memberTypes = reader.getMemberTypes();
40
		int memberTypeCounter = memberTypes == null ? 0 : memberTypes.length;
41
		if (memberTypeCounter > 0) {
42
			done : for (int i = 0; i < memberTypeCounter; i++) {
43
				int modifiers = memberTypes[i].getModifiers();
44
				// if the member type is static and not private
45
				if ((modifiers & ClassFileConstants.AccStatic) != 0 && (modifiers & ClassFileConstants.AccPrivate) == 0) {
46
					extraFlags |= ExtraFlags.HasNonPrivateStaticMemberTypes;
47
					break done;
48
				}
49
			}
50
			
51
		}
52
		
53
		return extraFlags;
54
	}
55
	
56
	public static int getExtraFlags(IType type) throws JavaModelException {
57
		int extraFlags = 0;
58
		
59
		if (type.isMember()) {
60
			extraFlags |= ExtraFlags.IsMemberType;
61
		}
62
		
63
		if (type.isLocal()) {
64
			extraFlags |= ExtraFlags.IsLocalType;
65
		}
66
		
67
		IType[] memberTypes = type.getTypes();
68
		int memberTypeCounter = memberTypes == null ? 0 : memberTypes.length;
69
		if (memberTypeCounter > 0) {
70
			done : for (int i = 0; i < memberTypeCounter; i++) {
71
				int flags = memberTypes[i].getFlags();
72
				// if the member type is static and not private
73
				if ((flags & ClassFileConstants.AccStatic) != 0 && (flags & ClassFileConstants.AccPrivate) == 0 ) {
74
					extraFlags |= ExtraFlags.HasNonPrivateStaticMemberTypes;
75
					break done;
76
				}
77
			}
78
		}
79
		
80
		return extraFlags;
81
	}
82
	
83
	public static int getExtraFlags(TypeDeclaration typeDeclaration) {
84
		int extraFlags = 0;
85
		
86
		if (typeDeclaration.enclosingType != null) {
87
			extraFlags |= ExtraFlags.IsMemberType;
88
		}
89
		TypeDeclaration[] memberTypes = typeDeclaration.memberTypes;
90
		int memberTypeCounter = memberTypes == null ? 0 : memberTypes.length;
91
		if (memberTypeCounter > 0) {
92
			done : for (int i = 0; i < memberTypeCounter; i++) {
93
				int modifiers = memberTypes[i].modifiers;
94
				// if the member type is static and not private
95
				if ((modifiers & ClassFileConstants.AccStatic) != 0 && (modifiers & ClassFileConstants.AccPrivate) == 0) {
96
					extraFlags |= ExtraFlags.HasNonPrivateStaticMemberTypes;
97
					break done;
98
				}
99
			}
100
		}
101
		
102
		return extraFlags;
103
	}
104
}
(-)src/org/eclipse/jdt/core/tests/model/CompletionTests2.java (+1626 lines)
Lines 417-422 Link Here
417
		this.deleteProject("P3");
417
		this.deleteProject("P3");
418
	}
418
	}
419
}
419
}
420
public void testBug6930_01() throws Exception {
421
	try {
422
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL_LIB"}, "bin");
423
		
424
		createFolder("/P/src/p6930");
425
		
426
		this.workingCopies = new ICompilationUnit[3];
427
		
428
		this.workingCopies[1] = getWorkingCopy("/P/src/p6930/AllConstructors01.java",
429
			"package p6930;\n" +
430
			"public class AllConstructors01 {\n" +
431
			"  public AllConstructors01() {}\n" +
432
			"  public AllConstructors01(Object o) {}\n" +
433
			"  public AllConstructors01(Object o, String s) {}\n" +
434
			"}\n"
435
		);
436
		
437
		this.workingCopies[2] = getWorkingCopy("/P/src/p6930/AllConstructors01b.java",
438
			"package p6930;\n" +
439
			"public class AllConstructors01b {\n" +
440
			"}\n"
441
		);
442
		
443
		refresh(p);
444
		
445
		waitUntilIndexesReady();
446
		
447
		this.workingCopies[0] = getWorkingCopy(
448
				"/P/src/test/Test.java",
449
				"package test;"+
450
				"public class Test {\n" +
451
				"  void foo() {\n" +
452
				"    new AllConstructors\n" +
453
				"  }\n" +
454
				"}");
455
456
		// do completion
457
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
458
		requestor.setAllowsLongComputationProposals(true);
459
460
	    String str = this.workingCopies[0].getSource();
461
	    String completeBehind = "AllConstructors";
462
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
463
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
464
	    
465
	    assertResults(
466
			"AllConstructors01[CONSTRUCTOR_INVOCATION]{p6930.AllConstructors01(), Lp6930.AllConstructors01;, ()V, AllConstructors01, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
467
			"AllConstructors01[CONSTRUCTOR_INVOCATION]{p6930.AllConstructors01(), Lp6930.AllConstructors01;, (Ljava.lang.Object;)V, AllConstructors01, (o), "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
468
			"AllConstructors01[CONSTRUCTOR_INVOCATION]{p6930.AllConstructors01(), Lp6930.AllConstructors01;, (Ljava.lang.Object;Ljava.lang.String;)V, AllConstructors01, (o, s), "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
469
			"AllConstructors01b[CONSTRUCTOR_INVOCATION]{p6930.AllConstructors01b(), Lp6930.AllConstructors01b;, ()V, AllConstructors01b, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}",
470
			requestor.getResults());
471
	} finally {
472
		deleteProject("P");
473
	}
474
}
475
public void testBug6930_02() throws Exception {
476
	try {
477
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL_LIB", "/P/lib6930.jar"}, "bin");
478
		
479
		createJar(new String[] {
480
			"p6930/AllConstructors02.java",
481
			"package p6930;\n" +
482
			"public class AllConstructors02 {\n" +
483
			"  public AllConstructors02() {}\n" +
484
			"  public AllConstructors02(Object o) {}\n" +
485
			"  public AllConstructors02(Object o, String s) {}\n" +
486
			"}",
487
			"p6930/AllConstructors02b.java",
488
			"package p6930;\n" +
489
			"public class AllConstructors02b {\n" +
490
			"}"
491
		}, p.getProject().getLocation().append("lib6930.jar").toOSString());
492
		
493
		refresh(p);
494
		
495
		waitUntilIndexesReady();
496
		
497
		this.workingCopies = new ICompilationUnit[1];
498
		this.workingCopies[0] = getWorkingCopy(
499
				"/P/src/test/Test.java",
500
				"package test;"+
501
				"public class Test {\n" +
502
				"  void foo() {\n" +
503
				"    new AllConstructors\n" +
504
				"  }\n" +
505
				"}");
506
507
		// do completion
508
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
509
		requestor.setAllowsLongComputationProposals(true);
510
511
	    String str = this.workingCopies[0].getSource();
512
	    String completeBehind = "AllConstructors";
513
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
514
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
515
	    
516
	    assertResults(
517
			"AllConstructors02[CONSTRUCTOR_INVOCATION]{p6930.AllConstructors02(), Lp6930.AllConstructors02;, ()V, AllConstructors02, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
518
			"AllConstructors02[CONSTRUCTOR_INVOCATION]{p6930.AllConstructors02(), Lp6930.AllConstructors02;, (Ljava.lang.Object;)V, AllConstructors02, (o), "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
519
			"AllConstructors02[CONSTRUCTOR_INVOCATION]{p6930.AllConstructors02(), Lp6930.AllConstructors02;, (Ljava.lang.Object;Ljava.lang.String;)V, AllConstructors02, (o, s), "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
520
			"AllConstructors02b[CONSTRUCTOR_INVOCATION]{p6930.AllConstructors02b(), Lp6930.AllConstructors02b;, ()V, AllConstructors02b, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}",
521
			requestor.getResults());
522
	} finally {
523
		deleteProject("P");
524
	}
525
}
526
public void testBug6930_03() throws Exception {
527
	try {
528
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL_LIB"}, "bin");
529
		
530
		createFolder("/P/src/p6930");
531
		
532
		createFile(
533
				"/P/src/p6930/AllConstructors03.java",
534
				"package p6930;\n" +
535
				"public class AllConstructors03 {\n" +
536
				"  public AllConstructors03() {}\n" +
537
				"  public AllConstructors03(Object o) {}\n" +
538
				"  public AllConstructors03(Object o, String s) {}\n" +
539
				"}");
540
		
541
		createFile(
542
				"/P/src/p6930/AllConstructors03b.java",
543
				"package p6930;\n" +
544
				"public class AllConstructors03b {\n" +
545
				"}");
546
		refresh(p);
547
		
548
		waitUntilIndexesReady();
549
		
550
		this.workingCopies = new ICompilationUnit[1];
551
		this.workingCopies[0] = getWorkingCopy(
552
				"/P/src/test/Test.java",
553
				"package test;"+
554
				"public class Test {\n" +
555
				"  void foo() {\n" +
556
				"    new AllConstructors\n" +
557
				"  }\n" +
558
				"}");
559
560
		// do completion
561
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
562
		requestor.setAllowsLongComputationProposals(true);
563
564
	    String str = this.workingCopies[0].getSource();
565
	    String completeBehind = "AllConstructors";
566
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
567
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
568
	    
569
	    assertResults(
570
			"AllConstructors03[CONSTRUCTOR_INVOCATION]{p6930.AllConstructors03(), Lp6930.AllConstructors03;, ()V, AllConstructors03, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
571
			"AllConstructors03[CONSTRUCTOR_INVOCATION]{p6930.AllConstructors03(), Lp6930.AllConstructors03;, (Ljava.lang.Object;)V, AllConstructors03, (o), "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
572
			"AllConstructors03[CONSTRUCTOR_INVOCATION]{p6930.AllConstructors03(), Lp6930.AllConstructors03;, (Ljava.lang.Object;Ljava.lang.String;)V, AllConstructors03, (o, s), "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
573
			"AllConstructors03b[CONSTRUCTOR_INVOCATION]{p6930.AllConstructors03b(), Lp6930.AllConstructors03b;, ()V, AllConstructors03b, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}",
574
			requestor.getResults());
575
	} finally {
576
		deleteProject("P");
577
	}
578
}
579
public void testBug6930_04() throws Exception {
580
	try {
581
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL_LIB"}, "bin");
582
		
583
		refresh(p);
584
		
585
		waitUntilIndexesReady();
586
		
587
		this.workingCopies = new ICompilationUnit[2];
588
		this.workingCopies[0] = getWorkingCopy(
589
				"/P/src/test/Test.java",
590
				"package test;"+
591
				"class AllConstructors04a {\n" +
592
				"  public class AllConstructors0b {\n" +
593
				"  }\n" +
594
				"}\n" +
595
				"public class Test {\n" +
596
				"  public class AllConstructors04c {\n" +
597
				"    public class AllConstructors04d {\n" +
598
				"    }\n" +
599
				"  }\n" +
600
				"  void foo() {\n" +
601
				"    class AllConstructors04e {\n" +
602
				"      class AllConstructors04f {\n" +
603
				"      }\n" +
604
				"    }\n" +
605
				"    new AllConstructors\n" +
606
				"  }\n" +
607
				"}");
608
		
609
		this.workingCopies[1] = getWorkingCopy(
610
				"/P/src/test/AllConstructors04g.java",
611
				"package test;"+
612
				"public class AllConstructors04g {\n" +
613
				"  public class AllConstructors0h {\n" +
614
				"  }\n" +
615
				"}");
616
617
		// do completion
618
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
619
		requestor.setAllowsLongComputationProposals(true);
620
621
	    String str = this.workingCopies[0].getSource();
622
	    String completeBehind = "AllConstructors";
623
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
624
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
625
	    
626
	    assertResults(
627
			"AllConstructors04a[CONSTRUCTOR_INVOCATION]{AllConstructors04a(), Ltest.AllConstructors04a;, ()V, AllConstructors04a, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
628
			"AllConstructors04c[CONSTRUCTOR_INVOCATION]{AllConstructors04c(), Ltest.Test$AllConstructors04c;, ()V, AllConstructors04c, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
629
			"AllConstructors04e[CONSTRUCTOR_INVOCATION]{AllConstructors04e(), LAllConstructors04e;, ()V, AllConstructors04e, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
630
			"AllConstructors04g[CONSTRUCTOR_INVOCATION]{AllConstructors04g(), Ltest.AllConstructors04g;, ()V, AllConstructors04g, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
631
			requestor.getResults());
632
	} finally {
633
		deleteProject("P");
634
	}
635
}
636
public void testBug6930_05() throws Exception {
637
	try {
638
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL_LIB"}, "bin");
639
		
640
		refresh(p);
641
		
642
		waitUntilIndexesReady();
643
		
644
		this.workingCopies = new ICompilationUnit[2];
645
		this.workingCopies[0] = getWorkingCopy(
646
				"/P/src/test/Test.java",
647
				"package test;"+
648
				"class AllConstructors05a {\n" +
649
				"  public static class AllConstructors0b {\n" +
650
				"  }\n" +
651
				"}\n" +
652
				"public class Test {\n" +
653
				"  public static class AllConstructors05c {\n" +
654
				"    public static class AllConstructors05d {\n" +
655
				"    }\n" +
656
				"  }\n" +
657
				"  void foo() {\n" +
658
				"    new AllConstructors\n" +
659
				"  }\n" +
660
				"}");
661
		
662
		this.workingCopies[1] = getWorkingCopy(
663
				"/P/src/test/AllConstructors05g.java",
664
				"package test;"+
665
				"public class AllConstructors05g {\n" +
666
				"  public static class AllConstructors0h {\n" +
667
				"  }\n" +
668
				"}");
669
670
		// do completion
671
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
672
		requestor.setAllowsLongComputationProposals(true);
673
674
	    String str = this.workingCopies[0].getSource();
675
	    String completeBehind = "AllConstructors";
676
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
677
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
678
	    
679
	    assertResults(
680
			"AllConstructors05a[TYPE_REF]{AllConstructors05a, test, Ltest.AllConstructors05a;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
681
			"AllConstructors05a[CONSTRUCTOR_INVOCATION]{AllConstructors05a(), Ltest.AllConstructors05a;, ()V, AllConstructors05a, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
682
			"AllConstructors05c[CONSTRUCTOR_INVOCATION]{AllConstructors05c(), Ltest.Test$AllConstructors05c;, ()V, AllConstructors05c, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
683
			"AllConstructors05g[TYPE_REF]{AllConstructors05g, test, Ltest.AllConstructors05g;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
684
			"AllConstructors05g[CONSTRUCTOR_INVOCATION]{AllConstructors05g(), Ltest.AllConstructors05g;, ()V, AllConstructors05g, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
685
			"Test.AllConstructors05c[TYPE_REF]{AllConstructors05c, test, Ltest.Test$AllConstructors05c;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
686
			requestor.getResults());
687
	} finally {
688
		deleteProject("P");
689
	}
690
}
691
public void testBug6930_06() throws Exception {
692
	try {
693
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL_LIB", "/P/lib6930.jar"}, "bin");
694
		
695
		createFolder("/P/src/p6930");
696
		
697
		createFile(
698
				"/P/src/p6930/AllConstructors06a.java",
699
				"package p6930;\n" +
700
				"public class AllConstructors06a {\n" +
701
				"}");
702
		
703
		createJar(new String[] {
704
			"p6930/AllConstructors06b.java",
705
			"package p6930;\n" +
706
			"public class AllConstructors06b {\n" +
707
			"}"
708
		}, p.getProject().getLocation().append("lib6930.jar").toOSString());
709
		
710
		refresh(p);
711
		
712
		waitUntilIndexesReady();
713
		
714
		this.workingCopies = new ICompilationUnit[2];
715
		this.workingCopies[0] = getWorkingCopy(
716
				"/P/src/test/Test.java",
717
				"package test;\n"+
718
				"import p6930.AllConstructors06a;\n"+
719
				"import p6930.AllConstructors06b;\n"+
720
				"import p6930.AllConstructors06c;\n"+
721
				"public class Test {\n" +
722
				"  void foo() {\n" +
723
				"    new AllConstructors\n" +
724
				"  }\n" +
725
				"}");
726
		
727
		this.workingCopies[1] = getWorkingCopy(
728
				"/P/src/p6930/AllConstructors06c.java",
729
				"package p6930;"+
730
				"public class AllConstructors06c {\n" +
731
				"}");
732
733
		// do completion
734
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
735
		requestor.setAllowsLongComputationProposals(true);
736
737
	    String str = this.workingCopies[0].getSource();
738
	    String completeBehind = "AllConstructors";
739
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
740
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
741
	    
742
	    assertResults(
743
			"AllConstructors06a[CONSTRUCTOR_INVOCATION]{AllConstructors06a(), Lp6930.AllConstructors06a;, ()V, AllConstructors06a, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
744
			"AllConstructors06b[CONSTRUCTOR_INVOCATION]{AllConstructors06b(), Lp6930.AllConstructors06b;, ()V, AllConstructors06b, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
745
			"AllConstructors06c[CONSTRUCTOR_INVOCATION]{AllConstructors06c(), Lp6930.AllConstructors06c;, ()V, AllConstructors06c, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
746
			requestor.getResults());
747
	} finally {
748
		deleteProject("P");
749
	}
750
}
751
public void testBug6930_07() throws Exception {
752
	try {
753
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL_LIB", "/P/lib6930.jar"}, "bin");
754
		
755
		createFolder("/P/src/p6930");
756
		
757
		createFile(
758
				"/P/src/p6930/AllConstructors07a.java",
759
				"package p6930;\n" +
760
				"public class AllConstructors07a {\n" +
761
				"  public class AllConstructors07b {\n" +
762
				"  }\n" +
763
				"  public static class AllConstructors07c {\n" +
764
				"  }\n" +
765
				"}");
766
		
767
		createFile(
768
				"/P/src/p6930/AllConstructors07d.java",
769
				"package p6930;\n" +
770
				"public class AllConstructors07d {\n" +
771
				"  public class AllConstructors07e {\n" +
772
				"  }\n" +
773
				"  public static class AllConstructors07f {\n" +
774
				"  }\n" +
775
				"}");
776
		
777
		refresh(p);
778
		
779
		waitUntilIndexesReady();
780
		
781
		this.workingCopies = new ICompilationUnit[1];
782
		this.workingCopies[0] = getWorkingCopy(
783
				"/P/src/test/Test.java",
784
				"package test;\n"+
785
				"import p6930.*;\n"+
786
				"public class Test {\n" +
787
				"  void foo() {\n" +
788
				"    new AllConstructors\n" +
789
				"  }\n" +
790
				"}");
791
792
		// do completion
793
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
794
		requestor.setAllowsLongComputationProposals(true);
795
796
	    String str = this.workingCopies[0].getSource();
797
	    String completeBehind = "AllConstructors";
798
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
799
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
800
	    
801
	    assertResults(
802
			"AllConstructors07a[TYPE_REF]{AllConstructors07a, p6930, Lp6930.AllConstructors07a;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
803
			"AllConstructors07a[CONSTRUCTOR_INVOCATION]{AllConstructors07a(), Lp6930.AllConstructors07a;, ()V, AllConstructors07a, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
804
			"AllConstructors07d[TYPE_REF]{AllConstructors07d, p6930, Lp6930.AllConstructors07d;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
805
			"AllConstructors07d[CONSTRUCTOR_INVOCATION]{AllConstructors07d(), Lp6930.AllConstructors07d;, ()V, AllConstructors07d, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
806
			requestor.getResults());
807
	} finally {
808
		deleteProject("P");
809
	}
810
}
811
public void testBug6930_08() throws Exception {
812
	try {
813
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL15_LIB", "/P/lib6930.jar"}, "bin", "1.5");
814
		
815
		createFolder("/P/src/p6930");
816
		
817
		createFile(
818
				"/P/src/p6930/AllConstructors08a.java",
819
				"package p6930;\n" +
820
				"public class AllConstructors08a {\n" +
821
				"  public class AllConstructors08b {\n" +
822
				"  }\n" +
823
				"  public static class AllConstructors08c {\n" +
824
				"  }\n" +
825
				"}");
826
		
827
		createFile(
828
				"/P/src/p6930/AllConstructors08d.java",
829
				"package p6930;\n" +
830
				"public class AllConstructors08d {\n" +
831
				"  public class AllConstructors08e {\n" +
832
				"  }\n" +
833
				"  public static class AllConstructors08f {\n" +
834
				"  }\n" +
835
				"}");
836
		
837
		refresh(p);
838
		
839
		waitUntilIndexesReady();
840
		
841
		this.workingCopies = new ICompilationUnit[1];
842
		this.workingCopies[0] = getWorkingCopy(
843
				"/P/src/test/Test.java",
844
				"package test;\n"+
845
				"import p6930.AllConstructors08a;\n"+
846
				"public class Test {\n" +
847
				"  void foo() {\n" +
848
				"    new AllConstructors\n" +
849
				"  }\n" +
850
				"}");
851
852
		// do completion
853
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
854
		requestor.setAllowsLongComputationProposals(true);
855
856
	    String str = this.workingCopies[0].getSource();
857
	    String completeBehind = "AllConstructors";
858
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
859
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
860
	    
861
	    assertResults(
862
			"AllConstructors08d[TYPE_REF]{p6930.AllConstructors08d, p6930, Lp6930.AllConstructors08d;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
863
			"AllConstructors08d[CONSTRUCTOR_INVOCATION]{p6930.AllConstructors08d(), Lp6930.AllConstructors08d;, ()V, AllConstructors08d, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
864
			"AllConstructors08a[TYPE_REF]{AllConstructors08a, p6930, Lp6930.AllConstructors08a;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
865
			"AllConstructors08a[CONSTRUCTOR_INVOCATION]{AllConstructors08a(), Lp6930.AllConstructors08a;, ()V, AllConstructors08a, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
866
			requestor.getResults());
867
	} finally {
868
		deleteProject("P");
869
	}
870
}
871
872
public void testBug6930_09() throws Exception {
873
	try {
874
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL15_LIB", "/P/lib6930.jar"}, "bin", "1.5");
875
		
876
		createFolder("/P/src/p6930");
877
		
878
		createFile(
879
				"/P/src/p6930/AllConstructors09a.java",
880
				"package p6930;\n" +
881
				"public class AllConstructors09a {\n" +
882
				"  public class AllConstructors09b {\n" +
883
				"  }\n" +
884
				"  public static class AllConstructors09c {\n" +
885
				"  }\n" +
886
				"}");
887
		
888
		createFile(
889
				"/P/src/p6930/AllConstructors09d.java",
890
				"package p6930;\n" +
891
				"public class AllConstructors09d {\n" +
892
				"  public class AllConstructors09e {\n" +
893
				"  }\n" +
894
				"  public static class AllConstructors09f {\n" +
895
				"    public static class AllConstructors09g {\n" +
896
				"    }\n" +
897
				"  }\n" +
898
				"}");
899
		
900
		refresh(p);
901
		
902
		waitUntilIndexesReady();
903
		
904
		this.workingCopies = new ICompilationUnit[1];
905
		this.workingCopies[0] = getWorkingCopy(
906
				"/P/src/test/Test.java",
907
				"package test;\n"+
908
				"import p6930.AllConstructors09a.*;\n"+
909
				"import static p6930.AllConstructors09d.*;\n"+
910
				"public class Test {\n" +
911
				"  void foo() {\n" +
912
				"    new AllConstructors\n" +
913
				"  }\n" +
914
				"}");
915
916
		// do completion
917
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
918
		requestor.setAllowsLongComputationProposals(true);
919
920
	    String str = this.workingCopies[0].getSource();
921
	    String completeBehind = "AllConstructors";
922
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
923
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
924
	    
925
	    assertResults(
926
			"AllConstructors09a[TYPE_REF]{p6930.AllConstructors09a, p6930, Lp6930.AllConstructors09a;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
927
			"AllConstructors09a[CONSTRUCTOR_INVOCATION]{p6930.AllConstructors09a(), Lp6930.AllConstructors09a;, ()V, AllConstructors09a, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
928
			"AllConstructors09d[TYPE_REF]{p6930.AllConstructors09d, p6930, Lp6930.AllConstructors09d;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
929
			"AllConstructors09d[CONSTRUCTOR_INVOCATION]{p6930.AllConstructors09d(), Lp6930.AllConstructors09d;, ()V, AllConstructors09d, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
930
			"AllConstructors09d.AllConstructors09f[TYPE_REF]{AllConstructors09f, p6930, Lp6930.AllConstructors09d$AllConstructors09f;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
931
			"AllConstructors09f[CONSTRUCTOR_INVOCATION]{AllConstructors09f(), Lp6930.AllConstructors09d$AllConstructors09f;, ()V, AllConstructors09f, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
932
			requestor.getResults());
933
	} finally {
934
		deleteProject("P");
935
	}
936
}
937
public void testBug6930_10() throws Exception {
938
	try {
939
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL15_LIB", "/P/lib6930.jar"}, "bin", "1.5");
940
		
941
		createFolder("/P/src/p6930");
942
		
943
		createFile(
944
				"/P/src/p6930/AllConstructors10a.java",
945
				"package p6930;\n" +
946
				"public class AllConstructors10a {\n" +
947
				"  public class AllConstructors10b {\n" +
948
				"    public static class AllConstructors10bs {\n" +
949
				"    }\n" +
950
				"  }\n" +
951
				"  public static class AllConstructors10c {\n" +
952
				"    public static class AllConstructors10cs {\n" +
953
				"    }\n" +
954
				"  }\n" +
955
				"}");
956
		
957
		createFile(
958
				"/P/src/p6930/AllConstructors10d.java",
959
				"package p6930;\n" +
960
				"public class AllConstructors10d {\n" +
961
				"  public class AllConstructors10e {\n" +
962
				"    public static class AllConstructors10es {\n" +
963
				"    }\n" +
964
				"  }\n" +
965
				"  public static class AllConstructors10f {\n" +
966
				"    public static class AllConstructors10fs {\n" +
967
				"    }\n" +
968
				"  }\n" +
969
				"}");
970
		
971
		refresh(p);
972
		
973
		waitUntilIndexesReady();
974
		
975
		this.workingCopies = new ICompilationUnit[1];
976
		this.workingCopies[0] = getWorkingCopy(
977
				"/P/src/test/Test.java",
978
				"package test;\n"+
979
				"import p6930.AllConstructors10a.AllConstructors10b;\n"+
980
				"import p6930.AllConstructors10a.AllConstructors10c;\n"+
981
				"import static p6930.AllConstructors10d.AllConstructors10e;\n"+
982
				"import static p6930.AllConstructors10d.AllConstructors10f;\n"+
983
				"public class Test {\n" +
984
				"  void foo() {\n" +
985
				"    new AllConstructors\n" +
986
				"  }\n" +
987
				"}");
988
989
		// do completion
990
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
991
		requestor.setAllowsLongComputationProposals(true);
992
993
	    String str = this.workingCopies[0].getSource();
994
	    String completeBehind = "AllConstructors";
995
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
996
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
997
	    
998
	    assertResults(
999
			"AllConstructors10a[TYPE_REF]{p6930.AllConstructors10a, p6930, Lp6930.AllConstructors10a;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1000
			"AllConstructors10a[CONSTRUCTOR_INVOCATION]{p6930.AllConstructors10a(), Lp6930.AllConstructors10a;, ()V, AllConstructors10a, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1001
			"AllConstructors10d[TYPE_REF]{p6930.AllConstructors10d, p6930, Lp6930.AllConstructors10d;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1002
			"AllConstructors10d[CONSTRUCTOR_INVOCATION]{p6930.AllConstructors10d(), Lp6930.AllConstructors10d;, ()V, AllConstructors10d, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1003
			"AllConstructors10a.AllConstructors10c[TYPE_REF]{AllConstructors10c, p6930, Lp6930.AllConstructors10a$AllConstructors10c;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
1004
			"AllConstructors10c[CONSTRUCTOR_INVOCATION]{AllConstructors10c(), Lp6930.AllConstructors10a$AllConstructors10c;, ()V, AllConstructors10c, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
1005
			"AllConstructors10d.AllConstructors10f[TYPE_REF]{AllConstructors10f, p6930, Lp6930.AllConstructors10d$AllConstructors10f;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
1006
			"AllConstructors10f[CONSTRUCTOR_INVOCATION]{AllConstructors10f(), Lp6930.AllConstructors10d$AllConstructors10f;, ()V, AllConstructors10f, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
1007
			requestor.getResults());
1008
	} finally {
1009
		deleteProject("P");
1010
	}
1011
}
1012
public void testBug6930_11() throws Exception {
1013
	try {
1014
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL_LIB", "/P/lib6930.jar"}, "bin");
1015
		
1016
		createFolder("/P/src/p6930");
1017
		
1018
		createFile(
1019
				"/P/src/p6930/AllConstructors11a.java",
1020
				"package p6930;\n" +
1021
				"public class AllConstructors11a {\n" +
1022
				"}");
1023
1024
		
1025
		refresh(p);
1026
		
1027
		waitUntilIndexesReady();
1028
		
1029
		this.workingCopies = new ICompilationUnit[1];
1030
		this.workingCopies[0] = getWorkingCopy(
1031
				"/P/src/test/Test.java",
1032
				"package test;\n"+
1033
				"public class Test {\n" +
1034
				"  void foo() {\n" +
1035
				"    p6930.AllConstructors11a a = new \n" +
1036
				"  }\n" +
1037
				"}");
1038
1039
		// do completion
1040
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
1041
		requestor.setAllowsLongComputationProposals(true);
1042
1043
	    String str = this.workingCopies[0].getSource();
1044
	    String completeBehind = "new ";
1045
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1046
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
1047
	    
1048
	    assertResults(
1049
			"Test[CONSTRUCTOR_INVOCATION]{Test(), Ltest.Test;, ()V, Test, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
1050
			"AllConstructors11a[CONSTRUCTOR_INVOCATION]{p6930.AllConstructors11a(), Lp6930.AllConstructors11a;, ()V, AllConstructors11a, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED)+"}",
1051
			requestor.getResults());
1052
	} finally {
1053
		deleteProject("P");
1054
	}
1055
}
1056
public void testBug6930_12() throws Exception {
1057
	try {
1058
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL_LIB", "/P/lib6930.jar"}, "bin");
1059
		
1060
		createFolder("/P/src/p6930");
1061
		
1062
		createFile(
1063
				"/P/src/p6930/AllConstructors12a.java",
1064
				"package p6930;\n" +
1065
				"public class AllConstructors12a {\n" +
1066
				"  public static class AllConstructors12b {\n" +
1067
				"  }\n" +
1068
				"}");
1069
		
1070
		refresh(p);
1071
		
1072
		waitUntilIndexesReady();
1073
		
1074
		this.workingCopies = new ICompilationUnit[1];
1075
		this.workingCopies[0] = getWorkingCopy(
1076
				"/P/src/test/Test.java",
1077
				"package test;\n"+
1078
				"public class Test {\n" +
1079
				"  void foo() {\n" +
1080
				"    p6930.AllConstructors12a a = new \n" +
1081
				"  }\n" +
1082
				"}");
1083
1084
		// do completion
1085
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
1086
		requestor.setAllowsLongComputationProposals(true);
1087
1088
	    String str = this.workingCopies[0].getSource();
1089
	    String completeBehind = "new ";
1090
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1091
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
1092
	    
1093
	    assertResults(
1094
			"Test[CONSTRUCTOR_INVOCATION]{Test(), Ltest.Test;, ()V, Test, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
1095
			"AllConstructors12a[TYPE_REF]{p6930.AllConstructors12a, p6930, Lp6930.AllConstructors12a;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED)+"}\n" +
1096
			"AllConstructors12a[CONSTRUCTOR_INVOCATION]{p6930.AllConstructors12a(), Lp6930.AllConstructors12a;, ()V, AllConstructors12a, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED)+"}",
1097
			requestor.getResults());
1098
	} finally {
1099
		deleteProject("P");
1100
	}
1101
}
1102
public void testBug6930_13() throws Exception {
1103
	try {
1104
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL_LIB", "/P/lib6930.jar"}, "bin");
1105
		
1106
		createFolder("/P/src/p6930");
1107
		
1108
		createFile(
1109
				"/P/src/p6930/AllConstructors13a.java",
1110
				"package p6930;\n" +
1111
				"public class AllConstructors13a {\n" +
1112
				"}");
1113
1114
		
1115
		refresh(p);
1116
		
1117
		waitUntilIndexesReady();
1118
		
1119
		this.workingCopies = new ICompilationUnit[1];
1120
		this.workingCopies[0] = getWorkingCopy(
1121
				"/P/src/test/Test.java",
1122
				"package test;\n"+
1123
				"public class Test {\n" +
1124
				"  void foo() {\n" +
1125
				"    p6930.AllConstructors13a a = new AllConstructors\n" +
1126
				"  }\n" +
1127
				"}");
1128
1129
		// do completion
1130
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
1131
		requestor.setAllowsLongComputationProposals(true);
1132
1133
	    String str = this.workingCopies[0].getSource();
1134
	    String completeBehind = "new AllConstructors";
1135
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1136
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
1137
	    
1138
	    assertResults(
1139
			"AllConstructors13a[CONSTRUCTOR_INVOCATION]{p6930.AllConstructors13a(), Lp6930.AllConstructors13a;, ()V, AllConstructors13a, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED)+"}",
1140
			requestor.getResults());
1141
	} finally {
1142
		deleteProject("P");
1143
	}
1144
}
1145
public void testBug6930_14() throws Exception {
1146
	try {
1147
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL_LIB", "/P/lib6930.jar"}, "bin");
1148
		
1149
		createFolder("/P/src/p6930");
1150
		
1151
		createFile(
1152
				"/P/src/p6930/AllConstructors14a.java",
1153
				"package p6930;\n" +
1154
				"public class AllConstructors14a {\n" +
1155
				"  public static class AllConstructors14b {\n" +
1156
				"  }\n" +
1157
				"}");
1158
		
1159
		refresh(p);
1160
		
1161
		waitUntilIndexesReady();
1162
		
1163
		this.workingCopies = new ICompilationUnit[1];
1164
		this.workingCopies[0] = getWorkingCopy(
1165
				"/P/src/test/Test.java",
1166
				"package test;\n"+
1167
				"public class Test {\n" +
1168
				"  void foo() {\n" +
1169
				"    p6930.AllConstructors14a a = new AllConstructors\n" +
1170
				"  }\n" +
1171
				"}");
1172
1173
		// do completion
1174
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
1175
		requestor.setAllowsLongComputationProposals(true);
1176
1177
	    String str = this.workingCopies[0].getSource();
1178
	    String completeBehind = "new AllConstructors";
1179
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1180
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
1181
	    
1182
	    assertResults(
1183
			"AllConstructors14a[TYPE_REF]{p6930.AllConstructors14a, p6930, Lp6930.AllConstructors14a;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED)+"}\n" +
1184
			"AllConstructors14a[CONSTRUCTOR_INVOCATION]{p6930.AllConstructors14a(), Lp6930.AllConstructors14a;, ()V, AllConstructors14a, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED)+"}",
1185
			requestor.getResults());
1186
	} finally {
1187
		deleteProject("P");
1188
	}
1189
}
1190
public void testBug6930_15() throws Exception {
1191
	try {
1192
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL15_LIB", "/P/lib6930.jar"}, "bin", "1.5");
1193
		
1194
		createFolder("/P/src/p6930");
1195
		
1196
		createFile(
1197
				"/P/src/p6930/AllConstructors15a.java",
1198
				"package p6930;\n" +
1199
				"public class AllConstructors15a<T> {\n" +
1200
				"}");
1201
		
1202
		createJar(
1203
				new String[] {
1204
					"p6930/AllConstructors15b.java",
1205
					"package p6930;\n" +
1206
					"public class AllConstructors15b<T> {\n" +
1207
					"}"
1208
				},
1209
				p.getProject().getLocation().append("lib6930.jar").toOSString(),
1210
				new String[]{getExternalJCLPathString("1.5")},
1211
				"1.5");
1212
		
1213
		refresh(p);
1214
		
1215
		waitUntilIndexesReady();
1216
		
1217
		this.workingCopies = new ICompilationUnit[2];
1218
		this.workingCopies[0] = getWorkingCopy(
1219
				"/P/src/test/Test.java",
1220
				"package test;\n"+
1221
				"public class Test {\n" +
1222
				"  void foo() {\n" +
1223
				"    new AllConstructors\n" +
1224
				"  }\n" +
1225
				"}");
1226
		
1227
		this.workingCopies[1] = getWorkingCopy(
1228
				"/P/src/p6930/AllConstructors15c.java",
1229
				"package p6930;"+
1230
				"public class AllConstructors15c<T> {\n" +
1231
				"}");
1232
1233
		// do completion
1234
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
1235
		requestor.setAllowsLongComputationProposals(true);
1236
1237
	    String str = this.workingCopies[0].getSource();
1238
	    String completeBehind = "AllConstructors";
1239
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1240
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
1241
	    
1242
	    assertResults(
1243
			"AllConstructors15a[CONSTRUCTOR_INVOCATION]{p6930.AllConstructors15a(), Lp6930.AllConstructors15a;, ()V, AllConstructors15a, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1244
			"AllConstructors15b[CONSTRUCTOR_INVOCATION]{p6930.AllConstructors15b(), Lp6930.AllConstructors15b;, ()V, AllConstructors15b, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1245
			"AllConstructors15c[CONSTRUCTOR_INVOCATION]{p6930.AllConstructors15c(), Lp6930.AllConstructors15c;, ()V, AllConstructors15c, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}",
1246
			requestor.getResults());
1247
	} finally {
1248
		deleteProject("P");
1249
	}
1250
}
1251
public void testBug6930_16() throws Exception {
1252
	try {
1253
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL15_LIB", "/P/lib6930.jar"}, "bin", "1.5");
1254
		
1255
		createFolder("/P/src/p6930");
1256
		
1257
		createFile(
1258
				"/P/src/p6930/AllConstructors16a.java",
1259
				"package p6930;\n" +
1260
				"public class AllConstructors16a{\n" +
1261
				"  public <T> AllConstructors16a(){}\n" +
1262
				"}");
1263
		
1264
		createJar(
1265
				new String[] {
1266
					"p6930/AllConstructors16b.java",
1267
					"package p6930;\n" +
1268
					"public class AllConstructors16b {\n" +
1269
					"  public <T> AllConstructors16b(){}\n" +
1270
					"}"
1271
				},
1272
				p.getProject().getLocation().append("lib6930.jar").toOSString(),
1273
				new String[]{getExternalJCLPathString("1.5")},
1274
				"1.5");
1275
		
1276
		refresh(p);
1277
		
1278
		waitUntilIndexesReady();
1279
		
1280
		this.workingCopies = new ICompilationUnit[2];
1281
		this.workingCopies[0] = getWorkingCopy(
1282
				"/P/src/test/Test.java",
1283
				"package test;\n"+
1284
				"public class Test {\n" +
1285
				"  void foo() {\n" +
1286
				"    new AllConstructors\n" +
1287
				"  }\n" +
1288
				"}");
1289
		
1290
		this.workingCopies[1] = getWorkingCopy(
1291
				"/P/src/p6930/AllConstructors16c.java",
1292
				"package p6930;"+
1293
				"public class AllConstructors16c {\n" +
1294
				"  public <T> AllConstructors16c(){}\n" +
1295
				"}");
1296
1297
		// do completion
1298
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
1299
		requestor.setAllowsLongComputationProposals(true);
1300
1301
	    String str = this.workingCopies[0].getSource();
1302
	    String completeBehind = "AllConstructors";
1303
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1304
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
1305
	    
1306
	    assertResults(
1307
			"AllConstructors16a[CONSTRUCTOR_INVOCATION]{p6930.AllConstructors16a(), Lp6930.AllConstructors16a;, ()V, AllConstructors16a, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1308
			"AllConstructors16b[CONSTRUCTOR_INVOCATION]{p6930.AllConstructors16b(), Lp6930.AllConstructors16b;, ()V, AllConstructors16b, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1309
			"AllConstructors16c[CONSTRUCTOR_INVOCATION]{p6930.AllConstructors16c(), Lp6930.AllConstructors16c;, ()V, AllConstructors16c, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}",
1310
			requestor.getResults());
1311
	} finally {
1312
		deleteProject("P");
1313
	}
1314
}
1315
public void testBug6930_17() throws Exception {
1316
	try {
1317
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL15_LIB", "/P/lib6930.jar"}, "bin", "1.5");
1318
		
1319
		createFolder("/P/src/p6930");
1320
		
1321
		createFile(
1322
				"/P/src/p6930/AllConstructors17a.java",
1323
				"package p6930;\n" +
1324
				"public class AllConstructors17a{\n" +
1325
				"  public AllConstructors17a(java.util.Collection<Object> o){}\n" +
1326
				"}");
1327
		
1328
		createJar(
1329
				new String[] {
1330
					"p6930/AllConstructors17b.java",
1331
					"package p6930;\n" +
1332
					"public class AllConstructors17b {\n" +
1333
					"  public AllConstructors17b(java.util.Collection<Object> o){}\n" +
1334
					"}"
1335
				},
1336
				p.getProject().getLocation().append("lib6930.jar").toOSString(),
1337
				new String[]{getExternalJCLPathString("1.5")},
1338
				"1.5");
1339
		
1340
		refresh(p);
1341
		
1342
		waitUntilIndexesReady();
1343
		
1344
		this.workingCopies = new ICompilationUnit[2];
1345
		this.workingCopies[0] = getWorkingCopy(
1346
				"/P/src/test/Test.java",
1347
				"package test;\n"+
1348
				"public class Test {\n" +
1349
				"  void foo() {\n" +
1350
				"    new AllConstructors\n" +
1351
				"  }\n" +
1352
				"}");
1353
		
1354
		this.workingCopies[1] = getWorkingCopy(
1355
				"/P/src/p6930/AllConstructors17c.java",
1356
				"package p6930;"+
1357
				"public class AllConstructors17c {\n" +
1358
				"  public AllConstructors17c(java.util.Collection<Object> o){}\n" +
1359
				"}");
1360
1361
		// do completion
1362
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
1363
		requestor.setAllowsLongComputationProposals(true);
1364
1365
	    String str = this.workingCopies[0].getSource();
1366
	    String completeBehind = "AllConstructors";
1367
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1368
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
1369
	    
1370
	    assertResults(
1371
			"AllConstructors17a[CONSTRUCTOR_INVOCATION]{p6930.AllConstructors17a(), Lp6930.AllConstructors17a;, (Ljava.util.Collection<Ljava.lang.Object;>;)V, AllConstructors17a, (o), "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1372
			"AllConstructors17b[CONSTRUCTOR_INVOCATION]{p6930.AllConstructors17b(), Lp6930.AllConstructors17b;, (Ljava.util.Collection<Ljava.lang.Object;>;)V, AllConstructors17b, (o), "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1373
			"AllConstructors17c[CONSTRUCTOR_INVOCATION]{p6930.AllConstructors17c(), Lp6930.AllConstructors17c;, (Ljava.util.Collection<Ljava.lang.Object;>;)V, AllConstructors17c, (o), "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}",
1374
			requestor.getResults());
1375
	} finally {
1376
		deleteProject("P");
1377
	}
1378
}
1379
public void testBug6930_18() throws Exception {
1380
	try {
1381
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL_LIB", "/P/lib6930.jar"}, "bin");
1382
		
1383
		createFolder("/P/src/p6930");
1384
		
1385
		createFile(
1386
				"/P/src/p6930/AllConstructors18a.java",
1387
				"package p6930;\n" +
1388
				"public interface AllConstructors18a {\n" +
1389
				"}");
1390
		
1391
		createJar(new String[] {
1392
			"p6930/AllConstructors18b.java",
1393
			"package p6930;\n" +
1394
			"public interface AllConstructors18b {\n" +
1395
			"}"
1396
		}, p.getProject().getLocation().append("lib6930.jar").toOSString());
1397
		
1398
		refresh(p);
1399
		
1400
		waitUntilIndexesReady();
1401
		
1402
		this.workingCopies = new ICompilationUnit[2];
1403
		this.workingCopies[0] = getWorkingCopy(
1404
				"/P/src/test/Test.java",
1405
				"package test;\n"+
1406
				"public class Test {\n" +
1407
				"  void foo() {\n" +
1408
				"    new AllConstructors\n" +
1409
				"  }\n" +
1410
				"}");
1411
		
1412
		this.workingCopies[1] = getWorkingCopy(
1413
				"/P/src/p6930/AllConstructors18c.java",
1414
				"package p6930;"+
1415
				"public interface AllConstructors18c {\n" +
1416
				"}");
1417
1418
		// do completion
1419
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
1420
		requestor.setAllowsLongComputationProposals(true);
1421
1422
	    String str = this.workingCopies[0].getSource();
1423
	    String completeBehind = "AllConstructors";
1424
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1425
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
1426
	    
1427
	    assertResults(
1428
			"AllConstructors18a[ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION]{p6930.AllConstructors18a(), Lp6930.AllConstructors18a;, ()V, AllConstructors18a, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1429
			"AllConstructors18b[ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION]{p6930.AllConstructors18b(), Lp6930.AllConstructors18b;, ()V, AllConstructors18b, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1430
			"AllConstructors18c[ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION]{p6930.AllConstructors18c(), Lp6930.AllConstructors18c;, ()V, AllConstructors18c, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}",
1431
			requestor.getResults());
1432
	} finally {
1433
		deleteProject("P");
1434
	}
1435
}
1436
public void testBug6930_19() throws Exception {
1437
	try {
1438
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL_LIB", "/P/lib6930.jar"}, "bin");
1439
		
1440
		createFolder("/P/src/p6930");
1441
		
1442
		createFile(
1443
				"/P/src/p6930/AllConstructors19a.java",
1444
				"package p6930;\n" +
1445
				"public interface AllConstructors19a {\n" +
1446
				"}");
1447
		
1448
		createJar(new String[] {
1449
			"p6930/AllConstructors19b.java",
1450
			"package p6930;\n" +
1451
			"public interface AllConstructors19b {\n" +
1452
			"}"
1453
		}, p.getProject().getLocation().append("lib6930.jar").toOSString());
1454
		
1455
		refresh(p);
1456
		
1457
		waitUntilIndexesReady();
1458
		
1459
		this.workingCopies = new ICompilationUnit[2];
1460
		this.workingCopies[0] = getWorkingCopy(
1461
				"/P/src/test/Test.java",
1462
				"package test;\n"+
1463
				"import p6930.AllConstructors19a;\n"+
1464
				"import p6930.AllConstructors19b;\n"+
1465
				"import p6930.AllConstructors19c;\n"+
1466
				"public class Test {\n" +
1467
				"  void foo() {\n" +
1468
				"    new AllConstructors\n" +
1469
				"  }\n" +
1470
				"}");
1471
		
1472
		this.workingCopies[1] = getWorkingCopy(
1473
				"/P/src/p6930/AllConstructors19c.java",
1474
				"package p6930;"+
1475
				"public interface AllConstructors19c {\n" +
1476
				"}");
1477
1478
		// do completion
1479
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
1480
		requestor.setAllowsLongComputationProposals(true);
1481
1482
	    String str = this.workingCopies[0].getSource();
1483
	    String completeBehind = "AllConstructors";
1484
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1485
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
1486
	    
1487
	    assertResults(
1488
			"AllConstructors19a[ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION]{AllConstructors19a(), Lp6930.AllConstructors19a;, ()V, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
1489
			"AllConstructors19b[ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION]{AllConstructors19b(), Lp6930.AllConstructors19b;, ()V, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
1490
			"AllConstructors19c[ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION]{AllConstructors19c(), Lp6930.AllConstructors19c;, ()V, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
1491
			requestor.getResults());
1492
	} finally {
1493
		deleteProject("P");
1494
	}
1495
}
1496
public void testBug6930_20() throws Exception {
1497
	try {
1498
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL15_LIB", "/P/lib6930.jar"}, "bin", "1.5");
1499
		
1500
		createFolder("/P/src/p6930");
1501
		
1502
		createFile(
1503
				"/P/src/p6930/AllConstructors20a.java",
1504
				"package p6930;\n" +
1505
				"public enum AllConstructors20a {\n" +
1506
				"	ZZZ;\n" +
1507
				"}");
1508
		
1509
		createJar(new String[] {
1510
				"p6930/AllConstructors20b.java",
1511
				"package p6930;\n" +
1512
				"public enum AllConstructors20b {\n" +
1513
				"	ZZZ;\n" +
1514
				"}"
1515
			},
1516
			p.getProject().getLocation().append("lib6930.jar").toOSString(),
1517
			new String[]{getExternalJCLPathString("1.5")},
1518
			"1.5");
1519
		
1520
		refresh(p);
1521
		
1522
		waitUntilIndexesReady();
1523
		
1524
		this.workingCopies = new ICompilationUnit[2];
1525
		this.workingCopies[0] = getWorkingCopy(
1526
				"/P/src/test/Test.java",
1527
				"package test;\n"+
1528
				"public class Test {\n" +
1529
				"  void foo() {\n" +
1530
				"    new AllConstructors\n" +
1531
				"  }\n" +
1532
				"}");
1533
		
1534
		this.workingCopies[1] = getWorkingCopy(
1535
				"/P/src/p6930/AllConstructors20c.java",
1536
				"package p6930;"+
1537
				"public enum AllConstructors20c {\n" +
1538
				"	ZZZ;\n" +
1539
				"}");
1540
1541
		// do completion
1542
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
1543
		requestor.setAllowsLongComputationProposals(true);
1544
1545
	    String str = this.workingCopies[0].getSource();
1546
	    String completeBehind = "AllConstructors";
1547
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1548
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
1549
	    
1550
	    assertResults(
1551
			"",
1552
			requestor.getResults());
1553
	} finally {
1554
		deleteProject("P");
1555
	}
1556
}
1557
public void testBug6930_21() throws Exception {
1558
	try {
1559
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL15_LIB", "/P/lib6930.jar"}, "bin", "1.5");
1560
		
1561
		createFolder("/P/src/p6930");
1562
		
1563
		createFile(
1564
				"/P/src/p6930/AllConstructors21a.java",
1565
				"package p6930;\n" +
1566
				"public enum AllConstructors21a {\n" +
1567
				"	ZZZ;\n" +
1568
				"}");
1569
		
1570
		createJar(
1571
				new String[] {
1572
					"p6930/AllConstructors21b.java",
1573
					"package p6930;\n" +
1574
					"public enum AllConstructors21b {\n" +
1575
					"	ZZZ;\n" +
1576
					"}"
1577
				},
1578
				p.getProject().getLocation().append("lib6930.jar").toOSString(),
1579
				new String[]{getExternalJCLPathString("1.5")},
1580
				"1.5");
1581
		
1582
		refresh(p);
1583
		
1584
		waitUntilIndexesReady();
1585
		
1586
		this.workingCopies = new ICompilationUnit[2];
1587
		this.workingCopies[0] = getWorkingCopy(
1588
				"/P/src/test/Test.java",
1589
				"package test;\n"+
1590
				"import p6930.AllConstructors21a;\n"+
1591
				"import p6930.AllConstructors21b;\n"+
1592
				"import p6930.AllConstructors21c;\n"+
1593
				"public class Test {\n" +
1594
				"  void foo() {\n" +
1595
				"    new AllConstructors\n" +
1596
				"  }\n" +
1597
				"}");
1598
		
1599
		this.workingCopies[1] = getWorkingCopy(
1600
				"/P/src/p6930/AllConstructors21c.java",
1601
				"package p6930;"+
1602
				"public enum AllConstructors21c {\n" +
1603
				"	ZZZ;\n" +
1604
				"}");
1605
1606
		// do completion
1607
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
1608
		requestor.setAllowsLongComputationProposals(true);
1609
1610
	    String str = this.workingCopies[0].getSource();
1611
	    String completeBehind = "AllConstructors";
1612
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1613
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
1614
	    
1615
	    assertResults(
1616
			"",
1617
			requestor.getResults());
1618
	} finally {
1619
		deleteProject("P");
1620
	}
1621
}
1622
public void testBug6930_22() throws Exception {
1623
	Hashtable oldOptions = JavaCore.getOptions();
1624
	try {
1625
		Hashtable options = new Hashtable(oldOptions);
1626
		options.put(JavaCore.CODEASSIST_VISIBILITY_CHECK, JavaCore.ENABLED);
1627
		JavaCore.setOptions(options);
1628
		
1629
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL_LIB", "/P/lib6930.jar"}, "bin");
1630
		
1631
		createFolder("/P/src/p6930");
1632
		
1633
		createFile(
1634
				"/P/src/p6930/AllConstructors22a.java",
1635
				"package p6930;\n" +
1636
				"public class AllConstructors22a {\n" +
1637
				"	private AllConstructors22a(){}\n" +
1638
				"	public static class AllConstructorsInner{}\n" +
1639
				"}");
1640
		
1641
		createJar(new String[] {
1642
			"p6930/AllConstructors22b.java",
1643
			"package p6930;\n" +
1644
			"public class AllConstructors22b {\n" +
1645
			"	private AllConstructors22b(){}\n" +
1646
			"	public static class AllConstructorsInner{}\n" +
1647
			"}"
1648
		}, p.getProject().getLocation().append("lib6930.jar").toOSString());
1649
		
1650
		refresh(p);
1651
		
1652
		waitUntilIndexesReady();
1653
		
1654
		this.workingCopies = new ICompilationUnit[2];
1655
		this.workingCopies[0] = getWorkingCopy(
1656
				"/P/src/test/Test.java",
1657
				"package test;\n"+
1658
				"public class Test {\n" +
1659
				"  void foo() {\n" +
1660
				"    new AllConstructors\n" +
1661
				"  }\n" +
1662
				"}");
1663
		
1664
		this.workingCopies[1] = getWorkingCopy(
1665
				"/P/src/p6930/AllConstructors22c.java",
1666
				"package p6930;"+
1667
				"public class AllConstructors22c {\n" +
1668
				"	private AllConstructors22c(){}\n" +
1669
				"	public static class AllConstructorsInner{}\n" +
1670
				"}");
1671
1672
		// do completion
1673
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
1674
		requestor.setAllowsLongComputationProposals(true);
1675
1676
	    String str = this.workingCopies[0].getSource();
1677
	    String completeBehind = "AllConstructors";
1678
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1679
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
1680
	    
1681
	    assertResults(
1682
			"AllConstructors22a[TYPE_REF]{p6930.AllConstructors22a, p6930, Lp6930.AllConstructors22a;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1683
			"AllConstructors22b[TYPE_REF]{p6930.AllConstructors22b, p6930, Lp6930.AllConstructors22b;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1684
			"AllConstructors22c[TYPE_REF]{p6930.AllConstructors22c, p6930, Lp6930.AllConstructors22c;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}",
1685
			requestor.getResults());
1686
	} finally {
1687
		deleteProject("P");
1688
		
1689
		JavaCore.setOptions(oldOptions);
1690
	}
1691
}
1692
public void testBug6930_23() throws Exception {
1693
	Hashtable oldOptions = JavaCore.getOptions();
1694
	try {
1695
		Hashtable options = new Hashtable(oldOptions);
1696
		options.put(JavaCore.CODEASSIST_VISIBILITY_CHECK, JavaCore.ENABLED);
1697
		JavaCore.setOptions(options);
1698
		
1699
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL_LIB", "/P/lib6930.jar"}, "bin");
1700
		
1701
		createFolder("/P/src/p6930");
1702
		
1703
		createFile(
1704
				"/P/src/p6930/AllConstructors23a.java",
1705
				"package p6930;\n" +
1706
				"public class AllConstructors23a {\n" +
1707
				"	private AllConstructors23a(){}\n" +
1708
				"	public static class AllConstructorsInner{}\n" +
1709
				"}");
1710
		
1711
		createJar(new String[] {
1712
			"p6930/AllConstructors23b.java",
1713
			"package p6930;\n" +
1714
			"public class AllConstructors23b {\n" +
1715
			"	private AllConstructors23b(){}\n" +
1716
			"	public static class AllConstructorsInner{}\n" +
1717
			"}"
1718
		}, p.getProject().getLocation().append("lib6930.jar").toOSString());
1719
		
1720
		refresh(p);
1721
		
1722
		waitUntilIndexesReady();
1723
		
1724
		this.workingCopies = new ICompilationUnit[2];
1725
		this.workingCopies[0] = getWorkingCopy(
1726
				"/P/src/test/Test.java",
1727
				"package test;\n"+
1728
				"import p6930.AllConstructors23a;\n"+
1729
				"import p6930.AllConstructors23b;\n"+
1730
				"import p6930.AllConstructors23c;\n"+
1731
				"public class Test {\n" +
1732
				"  void foo() {\n" +
1733
				"    new AllConstructors\n" +
1734
				"  }\n" +
1735
				"}");
1736
		
1737
		this.workingCopies[1] = getWorkingCopy(
1738
				"/P/src/p6930/AllConstructors23c.java",
1739
				"package p6930;"+
1740
				"public class AllConstructors23c {\n" +
1741
				"	private AllConstructors23c(){}\n" +
1742
				"	public static class AllConstructorsInner{}\n" +
1743
				"}");
1744
1745
		// do completion
1746
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
1747
		requestor.setAllowsLongComputationProposals(true);
1748
1749
	    String str = this.workingCopies[0].getSource();
1750
	    String completeBehind = "AllConstructors";
1751
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1752
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
1753
	    
1754
	    assertResults(
1755
			"AllConstructors23a[TYPE_REF]{AllConstructors23a, p6930, Lp6930.AllConstructors23a;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
1756
			"AllConstructors23b[TYPE_REF]{AllConstructors23b, p6930, Lp6930.AllConstructors23b;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
1757
			"AllConstructors23c[TYPE_REF]{AllConstructors23c, p6930, Lp6930.AllConstructors23c;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
1758
			requestor.getResults());
1759
	} finally {
1760
		deleteProject("P");
1761
		
1762
		JavaCore.setOptions(oldOptions);
1763
	}
1764
}
1765
public void testBug6930_24() throws Exception {
1766
	Hashtable oldOptions = JavaCore.getOptions();
1767
	try {
1768
		Hashtable options = new Hashtable(oldOptions);
1769
		options.put(JavaCore.CODEASSIST_VISIBILITY_CHECK, JavaCore.ENABLED);
1770
		JavaCore.setOptions(options);
1771
		
1772
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL_LIB", "/P/lib6930.jar"}, "bin");
1773
		
1774
		createFolder("/P/src/p6930");
1775
		
1776
		createFile(
1777
				"/P/src/p6930/AllConstructors24a.java",
1778
				"package p6930;\n" +
1779
				"public class AllConstructors24a {\n" +
1780
				"	public AllConstructors24a(){}\n" +
1781
				"	private static class AllConstructorsInner{}\n" +
1782
				"}");
1783
		
1784
		createJar(new String[] {
1785
			"p6930/AllConstructors24b.java",
1786
			"package p6930;\n" +
1787
			"public class AllConstructors24b {\n" +
1788
			"	public AllConstructors24b(){}\n" +
1789
			"	private static class AllConstructorsInner{}\n" +
1790
			"}"
1791
		}, p.getProject().getLocation().append("lib6930.jar").toOSString());
1792
		
1793
		refresh(p);
1794
		
1795
		waitUntilIndexesReady();
1796
		
1797
		this.workingCopies = new ICompilationUnit[2];
1798
		this.workingCopies[0] = getWorkingCopy(
1799
				"/P/src/test/Test.java",
1800
				"package test;\n"+
1801
				"public class Test {\n" +
1802
				"  void foo() {\n" +
1803
				"    new AllConstructors\n" +
1804
				"  }\n" +
1805
				"}");
1806
		
1807
		this.workingCopies[1] = getWorkingCopy(
1808
				"/P/src/p6930/AllConstructors24c.java",
1809
				"package p6930;"+
1810
				"public class AllConstructors24c {\n" +
1811
				"	public AllConstructors24c(){}\n" +
1812
				"	private static class AllConstructorsInner{}\n" +
1813
				"}");
1814
1815
		// do completion
1816
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
1817
		requestor.setAllowsLongComputationProposals(true);
1818
1819
	    String str = this.workingCopies[0].getSource();
1820
	    String completeBehind = "AllConstructors";
1821
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1822
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
1823
	    
1824
	    assertResults(
1825
			"AllConstructors24a[CONSTRUCTOR_INVOCATION]{p6930.AllConstructors24a(), Lp6930.AllConstructors24a;, ()V, AllConstructors24a, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1826
			"AllConstructors24b[CONSTRUCTOR_INVOCATION]{p6930.AllConstructors24b(), Lp6930.AllConstructors24b;, ()V, AllConstructors24b, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1827
			"AllConstructors24c[CONSTRUCTOR_INVOCATION]{p6930.AllConstructors24c(), Lp6930.AllConstructors24c;, ()V, AllConstructors24c, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}",
1828
			requestor.getResults());
1829
	} finally {
1830
		deleteProject("P");
1831
		
1832
		JavaCore.setOptions(oldOptions);
1833
	}
1834
}
1835
public void testBug6930_25() throws Exception {
1836
	Hashtable oldOptions = JavaCore.getOptions();
1837
	try {
1838
		Hashtable options = new Hashtable(oldOptions);
1839
		options.put(JavaCore.CODEASSIST_VISIBILITY_CHECK, JavaCore.ENABLED);
1840
		JavaCore.setOptions(options);
1841
		
1842
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL_LIB", "/P/lib6930.jar"}, "bin");
1843
		
1844
		createFolder("/P/src/p6930");
1845
		
1846
		createFile(
1847
				"/P/src/p6930/AllConstructors25a.java",
1848
				"package p6930;\n" +
1849
				"public class AllConstructors25a {\n" +
1850
				"	public AllConstructors25a(){}\n" +
1851
				"	private static class AllConstructorsInner{}\n" +
1852
				"}");
1853
		
1854
		createJar(new String[] {
1855
			"p6930/AllConstructors25b.java",
1856
			"package p6930;\n" +
1857
			"public class AllConstructors25b {\n" +
1858
			"	public AllConstructors25b(){}\n" +
1859
			"	private static class AllConstructorsInner{}\n" +
1860
			"}"
1861
		}, p.getProject().getLocation().append("lib6930.jar").toOSString());
1862
		
1863
		refresh(p);
1864
		
1865
		waitUntilIndexesReady();
1866
		
1867
		this.workingCopies = new ICompilationUnit[2];
1868
		this.workingCopies[0] = getWorkingCopy(
1869
				"/P/src/test/Test.java",
1870
				"package test;\n"+
1871
				"import p6930.AllConstructors25a;\n"+
1872
				"import p6930.AllConstructors25b;\n"+
1873
				"import p6930.AllConstructors25c;\n"+
1874
				"public class Test {\n" +
1875
				"  void foo() {\n" +
1876
				"    new AllConstructors\n" +
1877
				"  }\n" +
1878
				"}");
1879
		
1880
		this.workingCopies[1] = getWorkingCopy(
1881
				"/P/src/p6930/AllConstructors25c.java",
1882
				"package p6930;"+
1883
				"public class AllConstructors25c {\n" +
1884
				"	public AllConstructors25c(){}\n" +
1885
				"	private static class AllConstructorsInner{}\n" +
1886
				"}");
1887
1888
		// do completion
1889
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
1890
		requestor.setAllowsLongComputationProposals(true);
1891
1892
	    String str = this.workingCopies[0].getSource();
1893
	    String completeBehind = "AllConstructors";
1894
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1895
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
1896
	    
1897
	    assertResults(
1898
			"AllConstructors25a[CONSTRUCTOR_INVOCATION]{AllConstructors25a(), Lp6930.AllConstructors25a;, ()V, AllConstructors25a, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
1899
			"AllConstructors25b[CONSTRUCTOR_INVOCATION]{AllConstructors25b(), Lp6930.AllConstructors25b;, ()V, AllConstructors25b, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
1900
			"AllConstructors25c[CONSTRUCTOR_INVOCATION]{AllConstructors25c(), Lp6930.AllConstructors25c;, ()V, AllConstructors25c, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
1901
			requestor.getResults());
1902
	} finally {
1903
		deleteProject("P");
1904
		
1905
		JavaCore.setOptions(oldOptions);
1906
	}
1907
}
1908
public void testBug6930_26() throws Exception {
1909
	try {
1910
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL_LIB"}, "bin");
1911
		
1912
		refresh(p);
1913
		
1914
		waitUntilIndexesReady();
1915
		
1916
		this.workingCopies = new ICompilationUnit[2];
1917
		this.workingCopies[0] = getWorkingCopy(
1918
				"/P/src/test/Test.java",
1919
				"package test;\n"+
1920
				"public class Test {\n" +
1921
				"  void foo(p6930.AllConstructors26a var) {\n" +
1922
				"    var.new AllConstructors\n" +
1923
				"  }\n" +
1924
				"}");
1925
		
1926
		this.workingCopies[1] = getWorkingCopy(
1927
				"/P/src/p6930/AllConstructors26a.java",
1928
				"package p6930;"+
1929
				"public class AllConstructors26a {\n" +
1930
				"	public class AllConstructors26b {\n" +
1931
				"	  public AllConstructors26b(int i) {}\n" +
1932
				"	}\n" +
1933
				"}");
1934
1935
		// do completion
1936
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
1937
		requestor.setAllowsLongComputationProposals(true);
1938
1939
	    String str = this.workingCopies[0].getSource();
1940
	    String completeBehind = "AllConstructors";
1941
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1942
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
1943
	    
1944
	    assertResults(
1945
			"AllConstructors26b[CONSTRUCTOR_INVOCATION]{AllConstructors26b(), Lp6930.AllConstructors26a$AllConstructors26b;, (I)V, AllConstructors26b, (i), "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
1946
			requestor.getResults());
1947
	} finally {
1948
		deleteProject("P");
1949
	}
1950
}
1951
public void testBug6930_27() throws Exception {
1952
	try {
1953
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL_LIB"}, "bin");
1954
		
1955
		refresh(p);
1956
		
1957
		waitUntilIndexesReady();
1958
		
1959
		this.workingCopies = new ICompilationUnit[2];
1960
		this.workingCopies[0] = getWorkingCopy(
1961
				"/P/src/test/Test.java",
1962
				"package test;\n"+
1963
				"public class Test {\n" +
1964
				"  void foo() {\n" +
1965
				"    new p6930.AllConstructors27a.AllConstructors\n" +
1966
				"  }\n" +
1967
				"}");
1968
		
1969
		this.workingCopies[1] = getWorkingCopy(
1970
				"/P/src/p6930/AllConstructors27a.java",
1971
				"package p6930;"+
1972
				"public class AllConstructors27a {\n" +
1973
				"	public static class AllConstructors27b {\n" +
1974
				"	  public AllConstructors27b(int i) {}\n" +
1975
				"	}\n" +
1976
				"}");
1977
1978
		// do completion
1979
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
1980
		requestor.setAllowsLongComputationProposals(true);
1981
1982
	    String str = this.workingCopies[0].getSource();
1983
	    String completeBehind = "AllConstructors";
1984
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1985
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
1986
	    
1987
	    assertResults(
1988
			"AllConstructors27b[CONSTRUCTOR_INVOCATION]{AllConstructors27b(), Lp6930.AllConstructors27a$AllConstructors27b;, (I)V, AllConstructors27b, (i), "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}",
1989
			requestor.getResults());
1990
	} finally {
1991
		deleteProject("P");
1992
	}
1993
}
1994
public void testBug6930_28() throws Exception {
1995
	try {
1996
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL_LIB"}, "bin");
1997
		
1998
		refresh(p);
1999
		
2000
		waitUntilIndexesReady();
2001
		
2002
		this.workingCopies = new ICompilationUnit[3];
2003
		this.workingCopies[0] = getWorkingCopy(
2004
				"/P/src/p6930/Test.java",
2005
				"package p6930;\n"+
2006
				"class AllConstructors28a {\n" +
2007
				"	public AllConstructors28a(int i) {}\n" +
2008
				"}\n" +
2009
				"public class Test {\n" +
2010
				"  void foo() {\n" +
2011
				"    new p6930.AllConstructors\n" +
2012
				"  }\n" +
2013
				"}");
2014
		
2015
		this.workingCopies[1] = getWorkingCopy(
2016
				"/P/src/p6930/AllConstructors28b.java",
2017
				"package p6930;"+
2018
				"public class AllConstructors28b {\n" +
2019
				"	public AllConstructors28b(int i) {}\n" +
2020
				"}");
2021
		
2022
		this.workingCopies[2] = getWorkingCopy(
2023
				"/P/src/p6930b/AllConstructors28c.java",
2024
				"package p6930b;"+
2025
				"public class AllConstructors28c {\n" +
2026
				"	public AllConstructors28c(int i) {}\n" +
2027
				"}");
2028
2029
		// do completion
2030
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
2031
		requestor.setAllowsLongComputationProposals(true);
2032
2033
	    String str = this.workingCopies[0].getSource();
2034
	    String completeBehind = "AllConstructors";
2035
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2036
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
2037
	    
2038
	    assertResults(
2039
			"AllConstructors28a[CONSTRUCTOR_INVOCATION]{AllConstructors28a(), Lp6930.AllConstructors28a;, (I)V, AllConstructors28a, (i), "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
2040
			"AllConstructors28b[CONSTRUCTOR_INVOCATION]{AllConstructors28b(), Lp6930.AllConstructors28b;, (I)V, AllConstructors28b, (i), "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}",
2041
			requestor.getResults());
2042
	} finally {
2043
		deleteProject("P");
2044
	}
2045
}
420
public void testBug79288() throws Exception {
2046
public void testBug79288() throws Exception {
421
	try {
2047
	try {
422
		// create variable
2048
		// create variable
(-)src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java (-1 / +151 lines)
Lines 160-165 Link Here
160
	);
160
	);
161
}
161
}
162
162
163
public void testBug6930_AllConstructorDeclarations01() throws Exception {
164
	this.workingCopies = new ICompilationUnit[2];
165
	this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/p6930/AllConstructorDeclarations01.java",
166
		"package p6930;\n" +
167
		"public class AllConstructorDeclarations01 {\n" +
168
		"  public AllConstructorDeclarations01() {}\n" +
169
		"  public AllConstructorDeclarations01(Object o) {}\n" +
170
		"  public AllConstructorDeclarations01(Object o, String s) {}\n" +
171
		"}\n"
172
	);
173
	
174
	this.workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/p6930/AllConstructorDeclarations01b.java",
175
		"package p6930;\n" +
176
		"public class AllConstructorDeclarations01b {\n" +
177
		"}\n"
178
	);
179
	
180
	ConstructorDeclarationsCollector requestor = new ConstructorDeclarationsCollector();
181
	searchAllConstructorDeclarations("AllConstructorDeclarations", SearchPattern.R_PREFIX_MATCH, requestor);
182
	assertSearchResults(
183
		"p6930.AllConstructorDeclarations01#AllConstructorDeclarations01()\n" + 
184
		"p6930.AllConstructorDeclarations01#AllConstructorDeclarations01(Object o)\n" + 
185
		"p6930.AllConstructorDeclarations01#AllConstructorDeclarations01(Object o,String s)\n" + 
186
		"p6930.AllConstructorDeclarations01b#AllConstructorDeclarations01b()*",
187
		requestor
188
	);
189
}
190
191
public void testBug6930_AllConstructorDeclarations02() throws Exception {
192
	try {
193
		IJavaProject p = createJavaProject("P", new String[] {}, new String[] {"/P/lib6930.jar"}, "");
194
		
195
		createJar(new String[] {
196
			"p6930/AllConstructorDeclarations02.java",
197
			"package p6930;\n" +
198
			"public class AllConstructorDeclarations02 {\n" +
199
			"  public AllConstructorDeclarations02() {}\n" +
200
			"  public AllConstructorDeclarations02(Object o) {}\n" +
201
			"  public AllConstructorDeclarations02(Object o, String s) {}\n" +
202
			"}",
203
			"p6930/AllConstructorDeclarations02b.java",
204
			"package p6930;\n" +
205
			"public class AllConstructorDeclarations02b {\n" +
206
			"}"
207
		}, p.getProject().getLocation().append("lib6930.jar").toOSString());
208
		refresh(p);
209
		
210
		ConstructorDeclarationsCollector requestor = new ConstructorDeclarationsCollector();
211
		searchAllConstructorDeclarations("AllConstructorDeclarations", SearchPattern.R_PREFIX_MATCH, requestor);
212
		assertSearchResults(
213
			"p6930.AllConstructorDeclarations02#AllConstructorDeclarations02()\n" + 
214
			"p6930.AllConstructorDeclarations02#AllConstructorDeclarations02(java.lang.Object o)\n" + 
215
			"p6930.AllConstructorDeclarations02#AllConstructorDeclarations02(java.lang.Object o,java.lang.String s)\n" + 
216
			"p6930.AllConstructorDeclarations02b#AllConstructorDeclarations02b()",
217
			requestor
218
		);
219
	} finally {
220
		deleteProject("P");
221
	}
222
}
223
224
public void testBug6930_AllConstructorDeclarations03() throws Exception {
225
	try {
226
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[] {}, "bin");
227
		
228
		createFolder("/P/src/p6930");
229
		
230
		createFile(
231
				"/P/src/p6930/AllConstructorDeclarations03.java",
232
				"package p6930;\n" +
233
				"public class AllConstructorDeclarations03 {\n" +
234
				"  public AllConstructorDeclarations03() {}\n" +
235
				"  public AllConstructorDeclarations03(Object o) {}\n" +
236
				"  public AllConstructorDeclarations03(Object o, String s) {}\n" +
237
				"}");
238
		
239
		createFile(
240
				"/P/src/p6930/AllConstructorDeclarations03b.java",
241
				"package p6930;\n" +
242
				"public class AllConstructorDeclarations03b {\n" +
243
				"}");
244
		refresh(p);
245
		
246
		ConstructorDeclarationsCollector requestor = new ConstructorDeclarationsCollector();
247
		searchAllConstructorDeclarations("AllConstructorDeclarations", SearchPattern.R_PREFIX_MATCH, requestor);
248
		assertSearchResults(
249
			"p6930.AllConstructorDeclarations03#AllConstructorDeclarations03()\n" + 
250
			"p6930.AllConstructorDeclarations03#AllConstructorDeclarations03(Object o)\n" + 
251
			"p6930.AllConstructorDeclarations03#AllConstructorDeclarations03(Object o,String s)\n" + 
252
			"p6930.AllConstructorDeclarations03b#AllConstructorDeclarations03b()*",
253
			requestor
254
		);
255
	} finally {
256
		deleteProject("P");
257
	}
258
}
259
260
public void testBug6930_AllConstructorDeclarations04() throws Exception {
261
	try {
262
		IJavaProject p = createJavaProject("P", new String[] {}, new String[] {"/P/lib6930.jar"}, "","1.5");
263
		
264
		createJar(
265
			new String[] {
266
				"p6930/AllConstructorDeclarations04.java",
267
				"package p6930;\n" +
268
				"public class AllConstructorDeclarations04 {\n" +
269
				"  public AllConstructorDeclarations04(java.util.Collection<Object> c) {}\n" +
270
				"}"
271
			},
272
			p.getProject().getLocation().append("lib6930.jar").toOSString(),
273
			new String[]{getExternalJCLPathString("1.5")},
274
			"1.5");
275
		refresh(p);
276
		
277
		ConstructorDeclarationsCollector requestor = new ConstructorDeclarationsCollector();
278
		searchAllConstructorDeclarations("AllConstructorDeclarations", SearchPattern.R_PREFIX_MATCH, requestor);
279
		assertSearchResults(
280
			"p6930.AllConstructorDeclarations04#AllConstructorDeclarations04(java.util.Collection<java.lang.Object> c)",
281
			requestor
282
		);
283
	} finally {
284
		deleteProject("P");
285
	}
286
}
287
288
public void testBug6930_AllConstructorDeclarations05() throws Exception {
289
	try {
290
		IJavaProject p = createJavaProject("P", new String[] {}, new String[] {"/P/lib6930.jar"}, "");
291
		
292
		createJar(new String[] {
293
			"p6930/AllConstructorDeclarations05.java",
294
			"package p6930;\n" +
295
			"public class AllConstructorDeclarations05 {\n" +
296
			"  public class AllConstructorDeclarations05b {\n" +
297
			"    public AllConstructorDeclarations05b(Object o) {}\n" +
298
			"  }\n" +
299
			"}"
300
		}, p.getProject().getLocation().append("lib6930.jar").toOSString());
301
		refresh(p);
302
		
303
		ConstructorDeclarationsCollector requestor = new ConstructorDeclarationsCollector();
304
		searchAllConstructorDeclarations("AllConstructorDeclarations", SearchPattern.R_PREFIX_MATCH, requestor);
305
		assertSearchResults(
306
			"p6930.AllConstructorDeclarations05#AllConstructorDeclarations05()",
307
			requestor
308
		);
309
	} finally {
310
		deleteProject("P");
311
	}
312
}
313
163
/**
314
/**
164
 * @bug 70827: [Search] wrong reference match to private method of supertype
315
 * @bug 70827: [Search] wrong reference match to private method of supertype
165
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=70827"
316
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=70827"
Lines 10273-10277 Link Here
10273
		deleteProject("P");
10424
		deleteProject("P");
10274
	}
10425
	}
10275
}
10426
}
10276
10277
}
10427
}
(-)src/org/eclipse/jdt/core/tests/model/CompletionTestsRequestor2.java (-3 / +11 lines)
Lines 84-90 Link Here
84
		this.shortContext = shortContext;
84
		this.shortContext = shortContext;
85
		this.showMissingTypes = showMissingTypes;
85
		this.showMissingTypes = showMissingTypes;
86
		this.showModifiers = showModifiers;
86
		this.showModifiers = showModifiers;
87
88
	}
87
	}
89
	public void acceptContext(CompletionContext cc) {
88
	public void acceptContext(CompletionContext cc) {
90
		this.context = cc;
89
		this.context = cc;
Lines 98-105 Link Here
98
	}
97
	}
99
98
100
	public void allowAllRequiredProposals() {
99
	public void allowAllRequiredProposals() {
101
		for (int i = CompletionProposal.ANONYMOUS_CLASS_DECLARATION; i <= CompletionProposal.TYPE_IMPORT; i++) {
100
		for (int i = CompletionProposal.ANONYMOUS_CLASS_DECLARATION; i <= CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION; i++) {
102
			for (int j = CompletionProposal.ANONYMOUS_CLASS_DECLARATION; j <= CompletionProposal.FIELD_REF_WITH_CASTED_RECEIVER; j++) {
101
			for (int j = CompletionProposal.ANONYMOUS_CLASS_DECLARATION; j <= CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION; j++) {
103
				setAllowsRequiredProposals(i, j, true);
102
				setAllowsRequiredProposals(i, j, true);
104
			}
103
			}
105
		}
104
		}
Lines 394-399 Link Here
394
			case CompletionProposal.TYPE_IMPORT :
393
			case CompletionProposal.TYPE_IMPORT :
395
				buffer.append("TYPE_IMPORT"); //$NON-NLS-1$
394
				buffer.append("TYPE_IMPORT"); //$NON-NLS-1$
396
				break;
395
				break;
396
			case CompletionProposal.CONSTRUCTOR_INVOCATION :
397
				buffer.append("CONSTRUCTOR_INVOCATION"); //$NON-NLS-1$
398
				break;
399
			case CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION :
400
				buffer.append("ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION"); //$NON-NLS-1$
401
				break;
397
			default :
402
			default :
398
				buffer.append("PROPOSAL"); //$NON-NLS-1$
403
				buffer.append("PROPOSAL"); //$NON-NLS-1$
399
				break;
404
				break;
Lines 547-552 Link Here
547
	protected String getElementName(CompletionProposal proposal) {
552
	protected String getElementName(CompletionProposal proposal) {
548
		switch(proposal.getKind()) {
553
		switch(proposal.getKind()) {
549
			case CompletionProposal.ANONYMOUS_CLASS_DECLARATION :
554
			case CompletionProposal.ANONYMOUS_CLASS_DECLARATION :
555
			case CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION :
550
				return new String(Signature.getSignatureSimpleName(proposal.getDeclarationSignature()));
556
				return new String(Signature.getSignatureSimpleName(proposal.getDeclarationSignature()));
551
			case CompletionProposal.TYPE_REF :
557
			case CompletionProposal.TYPE_REF :
552
			case CompletionProposal.TYPE_IMPORT :
558
			case CompletionProposal.TYPE_IMPORT :
Lines 572-577 Link Here
572
			case CompletionProposal.JAVADOC_VALUE_REF :
578
			case CompletionProposal.JAVADOC_VALUE_REF :
573
			case CompletionProposal.FIELD_IMPORT :
579
			case CompletionProposal.FIELD_IMPORT :
574
			case CompletionProposal.METHOD_IMPORT :
580
			case CompletionProposal.METHOD_IMPORT :
581
			case CompletionProposal.CONSTRUCTOR_INVOCATION :
582
			
575
				return new String(proposal.getName());
583
				return new String(proposal.getName());
576
			case CompletionProposal.PACKAGE_REF:
584
			case CompletionProposal.PACKAGE_REF:
577
				return new String(proposal.getDeclarationSignature());
585
				return new String(proposal.getDeclarationSignature());
(-)src/org/eclipse/jdt/core/tests/model/AbstractJavaSearchTests.java (+100 lines)
Lines 17-32 Link Here
17
import java.util.Collections;
17
import java.util.Collections;
18
import java.util.Comparator;
18
import java.util.Comparator;
19
import java.util.List;
19
import java.util.List;
20
import java.util.Vector;
20
21
21
import org.eclipse.core.resources.*;
22
import org.eclipse.core.resources.*;
22
import org.eclipse.core.runtime.*;
23
import org.eclipse.core.runtime.*;
23
import org.eclipse.jdt.core.*;
24
import org.eclipse.jdt.core.*;
24
import org.eclipse.jdt.core.compiler.CharOperation;
25
import org.eclipse.jdt.core.compiler.CharOperation;
25
import org.eclipse.jdt.core.search.*;
26
import org.eclipse.jdt.core.search.*;
27
import org.eclipse.jdt.internal.compiler.ExtraFlags;
28
import org.eclipse.jdt.internal.compiler.env.AccessRestriction;
26
import org.eclipse.jdt.internal.compiler.problem.AbortCompilationUnit;
29
import org.eclipse.jdt.internal.compiler.problem.AbortCompilationUnit;
27
import org.eclipse.jdt.internal.core.Member;
30
import org.eclipse.jdt.internal.core.Member;
28
import org.eclipse.jdt.internal.core.PackageFragment;
31
import org.eclipse.jdt.internal.core.PackageFragment;
29
import org.eclipse.jdt.internal.core.SourceRefElement;
32
import org.eclipse.jdt.internal.core.SourceRefElement;
33
import org.eclipse.jdt.internal.core.search.BasicSearchEngine;
34
import org.eclipse.jdt.internal.core.search.IRestrictedAccessConstructorRequestor;
30
import org.eclipse.jdt.internal.core.search.matching.PatternLocator;
35
import org.eclipse.jdt.internal.core.search.matching.PatternLocator;
31
36
32
/**
37
/**
Lines 60-65 Link Here
60
	static protected final int SHOW_MATCH_KIND	= 0x0200;
65
	static protected final int SHOW_MATCH_KIND	= 0x0200;
61
	static protected final int SHOW_JAR_FILE			= 0x0400;
66
	static protected final int SHOW_JAR_FILE			= 0x0400;
62
67
68
	public static class ConstructorDeclarationsCollector implements IRestrictedAccessConstructorRequestor {
69
		Vector results = new Vector();
70
		
71
		public void acceptConstructor(
72
				int modifiers,
73
				char[] simpleTypeName,
74
				int parameterCount,
75
				char[] signature,
76
				char[][] parameterTypes,
77
				char[][] parameterNames,
78
				int typeModifiers,
79
				char[] packageName,
80
				int extraFlags,
81
				String path,
82
				AccessRestriction access) {
83
			StringBuffer buffer = new StringBuffer();
84
			
85
			boolean isMemberType = (extraFlags & ExtraFlags.IsMemberType) != 0;
86
			
87
			buffer.append(packageName == null ? CharOperation.NO_CHAR : packageName);
88
			if (isMemberType) {
89
				buffer.append('.');
90
				buffer.append('?'); // enclosing type names are not stored in the indexes
91
				buffer.append('?');
92
				buffer.append('?');
93
			}
94
			buffer.append('.');
95
			buffer.append(simpleTypeName);
96
			buffer.append('#');
97
			buffer.append(simpleTypeName);
98
			buffer.append('(');
99
			
100
			parameterTypes = signature == null ? parameterTypes : Signature.getParameterTypes(signature);
101
			
102
			for (int i = 0; i < parameterCount; i++) {
103
				if (i != 0) buffer.append(',');
104
				
105
				if (parameterTypes != null) {
106
					char[] parameterType;
107
					if (signature != null) {
108
						parameterType = Signature.toCharArray(parameterTypes[i]);
109
						CharOperation.replace(parameterType, '/', '.');
110
					} else {
111
						parameterType = parameterTypes[i];
112
					}
113
					buffer.append(parameterType);
114
				} else {
115
					buffer.append('?'); // parameter type names are not stored in the indexes
116
					buffer.append('?');
117
					buffer.append('?');
118
				}
119
				buffer.append(' ');
120
				if (parameterNames != null) {
121
					buffer.append(parameterNames[i]);
122
				} else {
123
					buffer.append("arg"+i);
124
				}
125
			}
126
			buffer.append(')');
127
			
128
			if (parameterCount < 0) {
129
				buffer.append('*');
130
			}
131
			
132
			this.results.addElement(buffer.toString());
133
		}
134
		
135
		public String toString(){
136
			int length = this.results.size();
137
			String[] strings = new String[length];
138
			this.results.toArray(strings);
139
			org.eclipse.jdt.internal.core.util.Util.sort(strings);
140
			StringBuffer buffer = new StringBuffer(100);
141
			for (int i = 0; i < length; i++){
142
				buffer.append(strings[i]);
143
				if (i != length-1) {
144
					buffer.append('\n');
145
				}
146
			}
147
			return buffer.toString();
148
		}
149
		public int size() {
150
			return this.results.size();
151
		}
152
	}
63
	/**
153
	/**
64
	 * Collects results as a string.
154
	 * Collects results as a string.
65
	 */
155
	 */
Lines 767-772 Link Here
767
	protected void search(String patternString, int searchFor, int limitTo, int matchRule) throws CoreException {
857
	protected void search(String patternString, int searchFor, int limitTo, int matchRule) throws CoreException {
768
		search(patternString, searchFor, limitTo, matchRule, getJavaSearchScope(), this.resultCollector);
858
		search(patternString, searchFor, limitTo, matchRule, getJavaSearchScope(), this.resultCollector);
769
	}
859
	}
860
	protected void searchAllConstructorDeclarations(String pattern, int matchRule, IRestrictedAccessConstructorRequestor requestor) throws JavaModelException {
861
		new BasicSearchEngine(this.workingCopies).searchAllConstructorDeclarations(
862
				null,
863
				pattern.toCharArray(),
864
				matchRule,
865
				SearchEngine.createWorkspaceScope(),
866
				requestor,
867
				IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,
868
				null);
869
	}
770
	protected void searchAllTypeNames(String pattern, int matchRule, TypeNameRequestor requestor) throws JavaModelException {
870
	protected void searchAllTypeNames(String pattern, int matchRule, TypeNameRequestor requestor) throws JavaModelException {
771
		new SearchEngine(this.workingCopies).searchAllTypeNames(
871
		new SearchEngine(this.workingCopies).searchAllTypeNames(
772
			null,
872
			null,
(-)src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java (+4 lines)
Lines 1128-1133 Link Here
1128
	protected void createJar(String[] javaPathsAndContents, String jarPath) throws IOException {
1128
	protected void createJar(String[] javaPathsAndContents, String jarPath) throws IOException {
1129
		org.eclipse.jdt.core.tests.util.Util.createJar(javaPathsAndContents, jarPath, "1.4");
1129
		org.eclipse.jdt.core.tests.util.Util.createJar(javaPathsAndContents, jarPath, "1.4");
1130
	}
1130
	}
1131
	
1132
	protected void createJar(String[] javaPathsAndContents, String jarPath, String[] classpath, String compliance) throws IOException {
1133
		org.eclipse.jdt.core.tests.util.Util.createJar(javaPathsAndContents, null,jarPath, classpath, compliance);
1134
	}
1131
1135
1132
	/*
1136
	/*
1133
	}
1137
	}

Return to bug 6930