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[0];
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
}
(-)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 / +32 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(CONSTRUCTOR_DECL, ConstructorPattern.createIndexKey(CharOperation.lastSegment(typeName,'.'), argCount));
86
		addIndexEntry(
87
				CONSTRUCTOR_DECL,
88
				ConstructorPattern.createDeclarationIndexKey(
89
						typeName,
90
						argCount,
91
						signature,
92
						parameterTypes,
93
						parameterNames,
94
						modifiers,
95
						packageName,
96
						typeModifiers,
97
						extraFlags));
98
		
78
		if (parameterTypes != null) {
99
		if (parameterTypes != null) {
79
			for (int i = 0; i < argCount; i++)
100
			for (int i = 0; i < argCount; i++)
80
				addTypeReference(parameterTypes[i]);
101
				addTypeReference(parameterTypes[i]);
Lines 91-96 Link Here
91
		if (innermostTypeName != simpleTypeName)
112
		if (innermostTypeName != simpleTypeName)
92
			addIndexEntry(CONSTRUCTOR_REF, ConstructorPattern.createIndexKey(innermostTypeName, argCount));
113
			addIndexEntry(CONSTRUCTOR_REF, ConstructorPattern.createIndexKey(innermostTypeName, argCount));
93
	}
114
	}
115
	public void addDefaultConstructorDeclaration(
116
			char[] typeName,
117
			char[] packageName,
118
			int typeModifiers,
119
			int extraFlags) {
120
		addIndexEntry(CONSTRUCTOR_DECL, ConstructorPattern.createDefaultDeclarationIndexKey(CharOperation.lastSegment(typeName,'.'), packageName, typeModifiers, extraFlags));
121
	}
94
	public void addEnumDeclaration(int modifiers, char[] packageName, char[] name, char[][] enclosingTypeNames, char[] superclass, char[][] superinterfaces, boolean secondary) {
122
	public void addEnumDeclaration(int modifiers, char[] packageName, char[] name, char[][] enclosingTypeNames, char[] superclass, char[][] superinterfaces, boolean secondary) {
95
		addTypeDeclaration(modifiers, packageName, name, enclosingTypeNames, secondary);
123
		addTypeDeclaration(modifiers, packageName, name, enclosingTypeNames, secondary);
96
124
(-)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
	 */
(-)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.ast.ASTNode;
18
import org.eclipse.jdt.internal.compiler.ast.ASTNode;
18
import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
19
import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
Lines 53-58 Link Here
53
	 * An ast visitor that visits local type declarations.
54
	 * An ast visitor that visits local type declarations.
54
	 */
55
	 */
55
	public class LocalDeclarationVisitor extends ASTVisitor {
56
	public class LocalDeclarationVisitor extends ASTVisitor {
57
		public ImportReference currentPackage;
56
		ArrayList declaringTypes;
58
		ArrayList declaringTypes;
57
		public void pushDeclaringType(TypeDeclaration declaringType) {
59
		public void pushDeclaringType(TypeDeclaration declaringType) {
58
			if (this.declaringTypes == null) {
60
			if (this.declaringTypes == null) {
Lines 70-80 Link Here
70
			return (TypeDeclaration) this.declaringTypes.get(size-1);
72
			return (TypeDeclaration) this.declaringTypes.get(size-1);
71
		}
73
		}
72
		public boolean visit(TypeDeclaration typeDeclaration, BlockScope scope) {
74
		public boolean visit(TypeDeclaration typeDeclaration, BlockScope scope) {
73
			notifySourceElementRequestor(typeDeclaration, true, peekDeclaringType());
75
			notifySourceElementRequestor(typeDeclaration, true, peekDeclaringType(), this.currentPackage);
74
			return false; // don't visit members as this was done during notifySourceElementRequestor(...)
76
			return false; // don't visit members as this was done during notifySourceElementRequestor(...)
75
		}
77
		}
76
		public boolean visit(TypeDeclaration typeDeclaration, ClassScope scope) {
78
		public boolean visit(TypeDeclaration typeDeclaration, ClassScope scope) {
77
			notifySourceElementRequestor(typeDeclaration, true, peekDeclaringType());
79
			notifySourceElementRequestor(typeDeclaration, true, peekDeclaringType(), this.currentPackage);
78
			return false; // don't visit members as this was done during notifySourceElementRequestor(...)
80
			return false; // don't visit members as this was done during notifySourceElementRequestor(...)
79
		}
81
		}
80
	}
82
	}
Lines 214-220 Link Here
214
/*
216
/*
215
 * Update the bodyStart of the corresponding parse node
217
 * Update the bodyStart of the corresponding parse node
216
 */
218
 */
217
protected void notifySourceElementRequestor(AbstractMethodDeclaration methodDeclaration) {
219
protected void notifySourceElementRequestor(AbstractMethodDeclaration methodDeclaration, TypeDeclaration declaringType, ImportReference currentPackage) {
218
220
219
	// range check
221
	// range check
220
	boolean isInRange =
222
	boolean isInRange =
Lines 287-292 Link Here
287
			methodInfo.typeParameters = getTypeParameterInfos(methodDeclaration.typeParameters());
289
			methodInfo.typeParameters = getTypeParameterInfos(methodDeclaration.typeParameters());
288
			methodInfo.categories = (char[][]) this.nodesToCategories.get(methodDeclaration);
290
			methodInfo.categories = (char[][]) this.nodesToCategories.get(methodDeclaration);
289
			methodInfo.annotations = methodDeclaration.annotations;
291
			methodInfo.annotations = methodDeclaration.annotations;
292
			methodInfo.declaringPackageName = currentPackage == null ? CharOperation.NO_CHAR : CharOperation.concatWith(currentPackage.tokens, '.');
293
			methodInfo.declaringTypeModifiers = declaringType.modifiers;
294
			methodInfo.extraFlags = ExtraFlags.getExtraFlags(declaringType);
290
			methodInfo.node = methodDeclaration;
295
			methodInfo.node = methodDeclaration;
291
			this.requestor.enterConstructor(methodInfo);
296
			this.requestor.enterConstructor(methodInfo);
292
		}
297
		}
Lines 393-398 Link Here
393
			this.requestor.enterCompilationUnit();
398
			this.requestor.enterCompilationUnit();
394
		}
399
		}
395
		ImportReference currentPackage = parsedUnit.currentPackage;
400
		ImportReference currentPackage = parsedUnit.currentPackage;
401
		if (this.localDeclarationVisitor !=  null) {
402
			this.localDeclarationVisitor.currentPackage = currentPackage;
403
		}
396
		ImportReference[] imports = parsedUnit.imports;
404
		ImportReference[] imports = parsedUnit.imports;
397
		TypeDeclaration[] types = parsedUnit.types;
405
		TypeDeclaration[] types = parsedUnit.types;
398
		length =
406
		length =
Lines 428-434 Link Here
428
						notifySourceElementRequestor(importRef, false);
436
						notifySourceElementRequestor(importRef, false);
429
					}
437
					}
430
				} else { // instanceof TypeDeclaration
438
				} else { // instanceof TypeDeclaration
431
					notifySourceElementRequestor((TypeDeclaration)node, true, null);
439
					notifySourceElementRequestor((TypeDeclaration)node, true, null, currentPackage);
432
				}
440
				}
433
			}
441
			}
434
		}
442
		}
Lines 543-549 Link Here
543
			importReference.modifiers);
551
			importReference.modifiers);
544
	}
552
	}
545
}
553
}
546
protected void notifySourceElementRequestor(TypeDeclaration typeDeclaration, boolean notifyTypePresence, TypeDeclaration declaringType) {
554
protected void notifySourceElementRequestor(TypeDeclaration typeDeclaration, boolean notifyTypePresence, TypeDeclaration declaringType, ImportReference currentPackage) {
547
555
548
	if (CharOperation.equals(TypeConstants.PACKAGE_INFO_NAME, typeDeclaration.name)) return;
556
	if (CharOperation.equals(TypeConstants.PACKAGE_INFO_NAME, typeDeclaration.name)) return;
549
557
Lines 599-604 Link Here
599
			typeInfo.secondary = typeDeclaration.isSecondary();
607
			typeInfo.secondary = typeDeclaration.isSecondary();
600
			typeInfo.anonymousMember = typeDeclaration.allocation != null && typeDeclaration.allocation.enclosingInstance != null;
608
			typeInfo.anonymousMember = typeDeclaration.allocation != null && typeDeclaration.allocation.enclosingInstance != null;
601
			typeInfo.annotations = typeDeclaration.annotations;
609
			typeInfo.annotations = typeDeclaration.annotations;
610
			typeInfo.extraFlags = ExtraFlags.getExtraFlags(typeDeclaration);
602
			typeInfo.node = typeDeclaration;
611
			typeInfo.node = typeDeclaration;
603
			this.requestor.enterType(typeInfo);
612
			this.requestor.enterType(typeInfo);
604
			switch (kind) {
613
			switch (kind) {
Lines 662-672 Link Here
662
				break;
671
				break;
663
			case 1 :
672
			case 1 :
664
				methodIndex++;
673
				methodIndex++;
665
				notifySourceElementRequestor(nextMethodDeclaration);
674
				notifySourceElementRequestor(nextMethodDeclaration, typeDeclaration, currentPackage);
666
				break;
675
				break;
667
			case 2 :
676
			case 2 :
668
				memberTypeIndex++;
677
				memberTypeIndex++;
669
				notifySourceElementRequestor(nextMemberDeclaration, true, null);
678
				notifySourceElementRequestor(nextMemberDeclaration, true, null, currentPackage);
670
		}
679
		}
671
	}
680
	}
672
	if (notifyTypePresence){
681
	if (notifyTypePresence){
(-)model/org/eclipse/jdt/internal/compiler/ISourceElementRequestor.java (+4 lines)
Lines 57-62 Link Here
57
		public boolean secondary;
57
		public boolean secondary;
58
		public boolean anonymousMember;
58
		public boolean anonymousMember;
59
		public Annotation[] annotations;
59
		public Annotation[] annotations;
60
		public int extraFlags;
60
		public TypeDeclaration node;
61
		public TypeDeclaration node;
61
	}
62
	}
62
63
Lines 84-89 Link Here
84
		public TypeParameterInfo[] typeParameters;
85
		public TypeParameterInfo[] typeParameters;
85
		public char[][] categories;
86
		public char[][] categories;
86
		public Annotation[] annotations;
87
		public Annotation[] annotations;
88
		public char[] declaringPackageName;
89
		public int declaringTypeModifiers;
90
		public int extraFlags;
87
		public AbstractMethodDeclaration node;
91
		public AbstractMethodDeclaration node;
88
	}
92
	}
89
93
(-)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 / +1572 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
		return createTypeSignature(packageName, typeName);
286
	}
229
287
288
	public static char[][] createDefaultParameterNames(int length) {
289
		char[][] parameters;
290
		switch (length) {
291
			case 0 :
292
				parameters = new char[length][];
293
				break;
294
			case 1 :
295
				parameters = ARGS1;
296
				break;
297
			case 2 :
298
				parameters = ARGS2;
299
				break;
300
			case 3 :
301
				parameters = ARGS3;
302
				break;
303
			case 4 :
304
				parameters = ARGS4;
305
				break;
306
			default :
307
				parameters = new char[length][];
308
				for (int i = 0; i < length; i++) {
309
					parameters[i] = CharOperation.concat(ARG, String.valueOf(i).toCharArray());
310
				}
311
				break;
312
		}
313
		return parameters;
314
	}
230
	public static char[] createMethodSignature(char[][] parameterPackageNames, char[][] parameterTypeNames, char[] returnTypeSignature) {
315
	public static char[] createMethodSignature(char[][] parameterPackageNames, char[][] parameterTypeNames, char[] returnTypeSignature) {
231
		char[][] parameterTypeSignature = new char[parameterTypeNames.length][];
316
		char[][] parameterTypeSignature = new char[parameterTypeNames.length][];
232
		for (int i = 0; i < parameterTypeSignature.length; i++) {
317
		for (int i = 0; i < parameterTypeSignature.length; i++) {
Lines 302-313 Link Here
302
		result = CharOperation.replaceOnCopy(result, '/', '.');
387
		result = CharOperation.replaceOnCopy(result, '/', '.');
303
		return result;
388
		return result;
304
	}
389
	}
390
	
391
	private static boolean hasStaticMemberTypes(ReferenceBinding typeBinding, SourceTypeBinding invocationType, CompilationUnitScope unitScope) {
392
		ReferenceBinding[] memberTypes = typeBinding.memberTypes();
393
		int length = memberTypes == null ? 0 : memberTypes.length;
394
		next : for (int i = 0; i < length; i++) {
395
			ReferenceBinding memberType = memberTypes[i];
396
			if (invocationType != null && !memberType.canBeSeenBy(typeBinding, invocationType)) {
397
				continue next;
398
			} else if(invocationType == null && !memberType.canBeSeenBy(unitScope.fPackage)) {
399
				continue next;
400
			}
401
			
402
			if ((memberType.modifiers & ClassFileConstants.AccStatic) != 0) {
403
				return true;
404
			}
405
		}
406
		return false;
407
	}
305
	public HashtableOfObject typeCache;
408
	public HashtableOfObject typeCache;
306
	
409
	
307
	public static boolean DEBUG = false;
410
	public static boolean DEBUG = false;
308
	public static boolean PERF = false;
411
	public static boolean PERF = false;
309
	
412
	
310
	private final static int CHECK_CANCEL_FREQUENCY_IN_FIND_TYPES = 50;
413
	private static final char[] KNOWN_TYPE_WITH_UNKNOWN_CONSTRUCTORS = new char[]{};
414
	private static final char[] KNOWN_TYPE_WITH_KNOWN_CONSTRUCTORS = new char[]{};
415
	
416
	private static final char[] ARG = "arg".toCharArray();  //$NON-NLS-1$
417
	private static final char[] ARG0 = "arg0".toCharArray();  //$NON-NLS-1$
418
	private static final char[] ARG1 = "arg1".toCharArray();  //$NON-NLS-1$
419
	private static final char[] ARG2 = "arg2".toCharArray();  //$NON-NLS-1$
420
	private static final char[] ARG3 = "arg3".toCharArray();  //$NON-NLS-1$
421
	private static final char[][] ARGS1 = new char[][]{ARG0};
422
	private static final char[][] ARGS2 = new char[][]{ARG0, ARG1};
423
	private static final char[][] ARGS3 = new char[][]{ARG0, ARG1, ARG2};
424
	private static final char[][] ARGS4 = new char[][]{ARG0, ARG1, ARG2, ARG3};
425
	
426
	private final static int CHECK_CANCEL_FREQUENCY = 50;
311
	
427
	
312
	// temporary constants to quickly disabled polish features if necessary
428
	// temporary constants to quickly disabled polish features if necessary
313
	public final static boolean NO_TYPE_COMPLETION_ON_EMPTY_TOKEN = false;
429
	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$
439
	private final static char[] VALUE = "value".toCharArray();  //$NON-NLS-1$
324
	private final static char[] EXTENDS = "extends".toCharArray();  //$NON-NLS-1$
440
	private final static char[] EXTENDS = "extends".toCharArray();  //$NON-NLS-1$
325
	private final static char[] SUPER = "super".toCharArray();  //$NON-NLS-1$
441
	private final static char[] SUPER = "super".toCharArray();  //$NON-NLS-1$
442
	private final static char[] DEFAULT_CONSTRUCTOR_SIGNATURE = "()V".toCharArray();  //$NON-NLS-1$
326
	
443
	
327
	private final static char[] DOT = ".".toCharArray();  //$NON-NLS-1$
444
	private final static char[] DOT = ".".toCharArray();  //$NON-NLS-1$
328
445
Lines 374-379 Link Here
374
	CompletionRequestor requestor;
491
	CompletionRequestor requestor;
375
	CompletionProblemFactory problemFactory;
492
	CompletionProblemFactory problemFactory;
376
	ProblemReporter problemReporter;
493
	ProblemReporter problemReporter;
494
	private JavaSearchNameEnvironment noCacheNameEnvironment;
377
	char[] source;
495
	char[] source;
378
	char[] completionToken;
496
	char[] completionToken;
379
	char[] qualifiedCompletionToken;
497
	char[] qualifiedCompletionToken;
Lines 458-463 Link Here
458
576
459
	private int foundTypesCount;
577
	private int foundTypesCount;
460
	private ObjectVector acceptedTypes;
578
	private ObjectVector acceptedTypes;
579
	
580
	private int foundConstructorsCount;
581
	private ObjectVector acceptedConstructors;
461
582
462
	/**
583
	/**
463
	 * The CompletionEngine is responsible for computing source completions.
584
	 * The CompletionEngine is responsible for computing source completions.
Lines 510-515 Link Here
510
		this.owner = owner;
631
		this.owner = owner;
511
		this.monitor = monitor;
632
		this.monitor = monitor;
512
	}
633
	}
634
	
635
	public void acceptConstructor(
636
			int modifiers,
637
			char[] simpleTypeName,
638
			int parameterCount,
639
			char[] signature,
640
			char[][] parameterTypes,
641
			char[][] parameterNames,
642
			int typeModifiers,
643
			char[] packageName,
644
			int extraFlags,
645
			String path,
646
			AccessRestriction accessRestriction) {
647
		
648
		// does not check cancellation for every types to avoid performance loss
649
		if ((this.foundConstructorsCount % (CHECK_CANCEL_FREQUENCY)) == 0) checkCancel();
650
		this.foundConstructorsCount++;
651
		
652
		if ((typeModifiers & ClassFileConstants.AccEnum) != 0) return;
653
		
654
		if (this.options.checkDeprecation && (typeModifiers & ClassFileConstants.AccDeprecated) != 0) return;
655
656
		if (this.options.checkVisibility) {
657
			if((typeModifiers & ClassFileConstants.AccPublic) == 0) {
658
				if((typeModifiers & ClassFileConstants.AccPrivate) != 0) return;
659
660
				if (this.currentPackageName == null) {
661
					initializePackageCache();
662
				}
663
				
664
				if(!CharOperation.equals(packageName, this.currentPackageName)) return;
665
			}
666
		}
667
668
		int accessibility = IAccessRule.K_ACCESSIBLE;
669
		if(accessRestriction != null) {
670
			switch (accessRestriction.getProblemId()) {
671
				case IProblem.ForbiddenReference:
672
					if (this.options.checkForbiddenReference) {
673
						return;
674
					}
675
					accessibility = IAccessRule.K_NON_ACCESSIBLE;
676
					break;
677
				case IProblem.DiscouragedReference:
678
					if (this.options.checkDiscouragedReference) {
679
						return;
680
					}
681
					accessibility = IAccessRule.K_DISCOURAGED;
682
					break;
683
			}
684
		}
685
		
686
		if(this.acceptedConstructors == null) {
687
			this.acceptedConstructors = new ObjectVector();
688
		}
689
		this.acceptedConstructors.add(
690
				new AcceptedConstructor(
691
						modifiers,
692
						simpleTypeName,
693
						parameterCount,
694
						signature,
695
						parameterTypes,
696
						parameterNames,
697
						typeModifiers,
698
						packageName,
699
						extraFlags,
700
						accessibility));
701
	}
702
	
703
	private void acceptConstructors(Scope scope) {
704
		final boolean DEFER_QUALIFIED_PROPOSALS = false;
705
		
706
		this.checkCancel();
707
		
708
		if(this.acceptedConstructors == null) return;
709
710
		int length = this.acceptedConstructors.size();
711
712
		if(length == 0) return;
713
		
714
		HashtableOfObject onDemandFound = new HashtableOfObject();
715
		
716
		ArrayList deferredProposals = new ArrayList();
717
		
718
		try {
719
			next : for (int i = 0; i < length; i++) {
720
				
721
				// does not check cancellation for every types to avoid performance loss
722
				if ((i % CHECK_CANCEL_FREQUENCY) == 0) checkCancel();
723
				
724
				AcceptedConstructor acceptedConstructor = (AcceptedConstructor)this.acceptedConstructors.elementAt(i);
725
				final int typeModifiers = acceptedConstructor.typeModifiers;
726
				final char[] packageName = acceptedConstructor.packageName;
727
				final char[] simpleTypeName = acceptedConstructor.simpleTypeName;
728
				final int modifiers = acceptedConstructor.modifiers;
729
				final int parameterCount = acceptedConstructor.parameterCount;
730
				final char[] signature = acceptedConstructor.signature;
731
				final char[][] parameterTypes = acceptedConstructor.parameterTypes;
732
				final char[][] parameterNames = acceptedConstructor.parameterNames;
733
				final int extraFlags = acceptedConstructor.extraFlags;
734
				final int accessibility = acceptedConstructor.accessibility;
735
				
736
				boolean proposeType = (extraFlags & ExtraFlags.HasNonPrivateStaticMemberTypes) != 0;
737
				
738
				char[] fullyQualifiedName = CharOperation.concat(packageName, simpleTypeName, '.');
739
						
740
				Object knownTypeKind = this.knownTypes.get(fullyQualifiedName);
741
				if (knownTypeKind != null) {
742
					if (knownTypeKind == KNOWN_TYPE_WITH_KNOWN_CONSTRUCTORS) {
743
						// the type and its constructors are already accepted
744
						continue next;
745
					}
746
					// this type is already accepted
747
					proposeType = false;
748
				} else {
749
					this.knownTypes.put(fullyQualifiedName, KNOWN_TYPE_WITH_UNKNOWN_CONSTRUCTORS);
750
				}
751
				
752
				boolean proposeConstructor = true;
753
					
754
				if (this.options.checkVisibility) {
755
					if((modifiers & ClassFileConstants.AccPublic) == 0) {
756
						if((modifiers & ClassFileConstants.AccPrivate) != 0) {
757
							if (!proposeType) continue next;
758
							proposeConstructor = false;
759
						} else {
760
							if (this.currentPackageName == null) {
761
								initializePackageCache();
762
							}
763
							
764
							if(!CharOperation.equals(packageName, this.currentPackageName)) {
765
								if (!proposeType) continue next;
766
								proposeConstructor = false;
767
							}
768
						}
769
					}
770
				}
771
				
772
				acceptedConstructor.fullyQualifiedName = fullyQualifiedName;
773
				acceptedConstructor.proposeType = proposeType;
774
				acceptedConstructor.proposeConstructor = proposeConstructor;
775
				
776
				
777
				if(!this.importCachesInitialized) {
778
					initializeImportCaches();
779
				}
780
				
781
				for (int j = 0; j < this.importCacheCount; j++) {
782
					char[][] importName = this.importsCache[j];
783
					if(CharOperation.equals(simpleTypeName, importName[0])) {
784
						if (proposeType) {
785
							proposeType(
786
									packageName,
787
									simpleTypeName,
788
									typeModifiers,
789
									accessibility,
790
									simpleTypeName,
791
									fullyQualifiedName,
792
									!CharOperation.equals(fullyQualifiedName, importName[1]),
793
									scope);
794
						}
795
						
796
						if (proposeConstructor && !Flags.isEnum(typeModifiers)) {
797
							boolean isQualified = !CharOperation.equals(fullyQualifiedName, importName[1]);
798
							if (!isQualified) {
799
								proposeConstructor(
800
										simpleTypeName,
801
										parameterCount,
802
										signature,
803
										parameterTypes,
804
										parameterNames,
805
										modifiers,
806
										packageName,
807
										typeModifiers,
808
										accessibility,
809
										simpleTypeName,
810
										fullyQualifiedName,
811
										isQualified,
812
										scope,
813
										extraFlags);
814
							} else {
815
								acceptedConstructor.mustBeQualified = true;
816
								if (DEFER_QUALIFIED_PROPOSALS) {
817
									deferredProposals.add(acceptedConstructor);
818
								} else {
819
									proposeConstructor(acceptedConstructor, scope);
820
								}
821
							}
822
						}
823
						continue next;
824
					}
825
				}
826
827
828
				if (CharOperation.equals(this.currentPackageName, packageName)) {
829
					if (proposeType) {
830
						proposeType(
831
								packageName,
832
								simpleTypeName,
833
								typeModifiers,
834
								accessibility,
835
								simpleTypeName,
836
								fullyQualifiedName,
837
								false,
838
								scope);
839
					}
840
					
841
					if (proposeConstructor && !Flags.isEnum(typeModifiers)) {
842
						proposeConstructor(
843
								simpleTypeName,
844
								parameterCount,
845
								signature,
846
								parameterTypes,
847
								parameterNames,
848
								modifiers,
849
								packageName,
850
								typeModifiers,
851
								accessibility,
852
								simpleTypeName,
853
								fullyQualifiedName,
854
								false,
855
								scope,
856
								extraFlags);
857
					}
858
					continue next;
859
				} else {
860
					char[] fullyQualifiedEnclosingTypeOrPackageName = null;
861
862
					AcceptedConstructor foundConstructor = null;
863
					if((foundConstructor = (AcceptedConstructor)onDemandFound.get(simpleTypeName)) == null) {
864
						for (int j = 0; j < this.onDemandImportCacheCount; j++) {
865
							ImportBinding importBinding = this.onDemandImportsCache[j];
866
867
							char[][] importName = importBinding.compoundName;
868
							char[] importFlatName = CharOperation.concatWith(importName, '.');
869
870
							if(fullyQualifiedEnclosingTypeOrPackageName == null) {
871
								fullyQualifiedEnclosingTypeOrPackageName = packageName;
872
							}
873
							if(CharOperation.equals(fullyQualifiedEnclosingTypeOrPackageName, importFlatName)) {
874
								if(importBinding.isStatic()) {
875
									if((typeModifiers & ClassFileConstants.AccStatic) != 0) {
876
										onDemandFound.put(
877
												simpleTypeName,
878
												acceptedConstructor);
879
										continue next;
880
									}
881
								} else {
882
									onDemandFound.put(
883
											simpleTypeName,
884
											acceptedConstructor);
885
									continue next;
886
								}
887
							}
888
						}
889
					} else if(!foundConstructor.mustBeQualified){
890
						done : for (int j = 0; j < this.onDemandImportCacheCount; j++) {
891
							ImportBinding importBinding = this.onDemandImportsCache[j];
892
893
							char[][] importName = importBinding.compoundName;
894
							char[] importFlatName = CharOperation.concatWith(importName, '.');
895
896
							if(fullyQualifiedEnclosingTypeOrPackageName == null) {
897
								fullyQualifiedEnclosingTypeOrPackageName = packageName;
898
							}
899
							if(CharOperation.equals(fullyQualifiedEnclosingTypeOrPackageName, importFlatName)) {
900
								if(importBinding.isStatic()) {
901
									if((typeModifiers & ClassFileConstants.AccStatic) != 0) {
902
										foundConstructor.mustBeQualified = true;
903
										break done;
904
									}
905
								} else {
906
									foundConstructor.mustBeQualified = true;
907
									break done;
908
								}
909
							}
910
						}
911
					}
912
					if (proposeType) {
913
						proposeType(
914
								packageName,
915
								simpleTypeName,
916
								typeModifiers,
917
								accessibility,
918
								simpleTypeName,
919
								fullyQualifiedName,
920
								true,
921
								scope);
922
					}
923
					
924
					if (proposeConstructor && !Flags.isEnum(typeModifiers)) {
925
						acceptedConstructor.mustBeQualified = true;
926
						if (DEFER_QUALIFIED_PROPOSALS) {
927
							deferredProposals.add(acceptedConstructor);
928
						} else {
929
							proposeConstructor(acceptedConstructor, scope);
930
						}
931
					}
932
				}
933
			}
934
		
935
			char[][] keys = onDemandFound.keyTable;
936
			Object[] values = onDemandFound.valueTable;
937
			int max = keys.length;
938
			for (int i = 0; i < max; i++) {
939
				
940
				// does not check cancellation for every types to avoid performance loss
941
				if ((i % CHECK_CANCEL_FREQUENCY) == 0) checkCancel();
942
				
943
				if(keys[i] != null) {
944
					AcceptedConstructor value = (AcceptedConstructor) values[i];
945
					if(value != null) {
946
						if (value.proposeType) {
947
							proposeType(
948
									value.packageName,
949
									value.simpleTypeName,
950
									value.typeModifiers,
951
									value.accessibility,
952
									value.simpleTypeName,
953
									value.fullyQualifiedName,
954
									value.mustBeQualified,
955
									scope);
956
						}
957
						
958
						if (value.proposeConstructor && !Flags.isEnum(value.modifiers)) {
959
							if (!value.mustBeQualified) {
960
								proposeConstructor(
961
										value.simpleTypeName,
962
										value.parameterCount,
963
										value.signature,
964
										value.parameterTypes,
965
										value.parameterNames,
966
										value.modifiers,
967
										value.packageName,
968
										value.typeModifiers,
969
										value.accessibility,
970
										value.simpleTypeName,
971
										value.fullyQualifiedName,
972
										value.mustBeQualified,
973
										scope,
974
										value.extraFlags);
975
							} else {
976
								if (DEFER_QUALIFIED_PROPOSALS) {
977
									deferredProposals.add(value);
978
								} else {
979
									proposeConstructor(value, scope);
980
								}
981
							}
982
						}
983
					}
984
				}
985
			}
986
			
987
			if (DEFER_QUALIFIED_PROPOSALS) {
988
				int size = deferredProposals.size();
989
				for (int i = 0; i < size; i++) {
990
					
991
					// does not check cancellation for every types to avoid performance loss
992
					if ((i % CHECK_CANCEL_FREQUENCY) == 0) checkCancel();
993
				
994
					AcceptedConstructor deferredProposal = (AcceptedConstructor)deferredProposals.get(i);
995
					
996
					if (deferredProposal.proposeConstructor) {
997
						proposeConstructor(
998
								deferredProposal.simpleTypeName,
999
								deferredProposal.parameterCount,
1000
								deferredProposal.signature,
1001
								deferredProposal.parameterTypes,
1002
								deferredProposal.parameterNames,
1003
								deferredProposal.modifiers,
1004
								deferredProposal.packageName,
1005
								deferredProposal.typeModifiers,
1006
								deferredProposal.accessibility,
1007
								deferredProposal.simpleTypeName,
1008
								deferredProposal.fullyQualifiedName,
1009
								deferredProposal.mustBeQualified,
1010
								scope,
1011
								deferredProposal.extraFlags);
1012
					}
1013
				}
1014
			}
1015
		} finally {
1016
			this.acceptedTypes = null; // reset
1017
		}
1018
	}
513
1019
514
	/**
1020
	/**
515
	 * One result of the search consists of a new package.
1021
	 * One result of the search consists of a new package.
Lines 576-582 Link Here
576
		AccessRestriction accessRestriction) {
1082
		AccessRestriction accessRestriction) {
577
		
1083
		
578
		// does not check cancellation for every types to avoid performance loss
1084
		// does not check cancellation for every types to avoid performance loss
579
		if ((this.foundTypesCount % CHECK_CANCEL_FREQUENCY_IN_FIND_TYPES) == 0) checkCancel();
1085
		if ((this.foundTypesCount % CHECK_CANCEL_FREQUENCY) == 0) checkCancel();
580
		this.foundTypesCount++;
1086
		this.foundTypesCount++;
581
		
1087
		
582
		if (this.options.checkDeprecation && (modifiers & ClassFileConstants.AccDeprecated) != 0) return;
1088
		if (this.options.checkDeprecation && (modifiers & ClassFileConstants.AccDeprecated) != 0) return;
Lines 629-635 Link Here
629
			next : for (int i = 0; i < length; i++) {
1135
			next : for (int i = 0; i < length; i++) {
630
				
1136
				
631
				// does not check cancellation for every types to avoid performance loss
1137
				// does not check cancellation for every types to avoid performance loss
632
				if ((i % CHECK_CANCEL_FREQUENCY_IN_FIND_TYPES) == 0) checkCancel();
1138
				if ((i % CHECK_CANCEL_FREQUENCY) == 0) checkCancel();
633
				
1139
				
634
				AcceptedType acceptedType = (AcceptedType)this.acceptedTypes.elementAt(i);
1140
				AcceptedType acceptedType = (AcceptedType)this.acceptedTypes.elementAt(i);
635
				char[] packageName = acceptedType.packageName;
1141
				char[] packageName = acceptedType.packageName;
Lines 651-657 Link Here
651
	
1157
	
652
				if (this.knownTypes.containsKey(fullyQualifiedName)) continue next;
1158
				if (this.knownTypes.containsKey(fullyQualifiedName)) continue next;
653
	
1159
	
654
				this.knownTypes.put(fullyQualifiedName, this);
1160
				this.knownTypes.put(fullyQualifiedName, KNOWN_TYPE_WITH_UNKNOWN_CONSTRUCTORS);
655
	
1161
	
656
				if (this.resolvingImports) {
1162
				if (this.resolvingImports) {
657
					if(this.compilerOptions.complianceLevel >= ClassFileConstants.JDK1_4 && packageName.length == 0) {
1163
					if(this.compilerOptions.complianceLevel >= ClassFileConstants.JDK1_4 && packageName.length == 0) {
Lines 807-812 Link Here
807
			Object[] values = onDemandFound.valueTable;
1313
			Object[] values = onDemandFound.valueTable;
808
			int max = keys.length;
1314
			int max = keys.length;
809
			for (int i = 0; i < max; i++) {
1315
			for (int i = 0; i < max; i++) {
1316
				if ((i % CHECK_CANCEL_FREQUENCY) == 0) checkCancel();
810
				if(keys[i] != null) {
1317
				if(keys[i] != null) {
811
					AcceptedType value = (AcceptedType) values[i];
1318
					AcceptedType value = (AcceptedType) values[i];
812
					if(value != null) {
1319
					if(value != null) {
Lines 2447-2452 Link Here
2447
		this.assistNodeIsClass = ref.isClass();
2954
		this.assistNodeIsClass = ref.isClass();
2448
		this.assistNodeIsException = ref.isException();
2955
		this.assistNodeIsException = ref.isException();
2449
		this.assistNodeIsInterface = ref.isInterface();
2956
		this.assistNodeIsInterface = ref.isInterface();
2957
		this.assistNodeIsConstructor = ref.isConstructorType;
2450
		this.assistNodeIsSuperType = ref.isSuperType();
2958
		this.assistNodeIsSuperType = ref.isSuperType();
2451
2959
2452
		this.completionToken = ref.completionIdentifier;
2960
		this.completionToken = ref.completionIdentifier;
Lines 3200-3206 Link Here
3200
						TypeBinding caughtException = catchArguments[i].type.resolvedType;
3708
						TypeBinding caughtException = catchArguments[i].type.resolvedType;
3201
						if (caughtException != null) {
3709
						if (caughtException != null) {
3202
							addForbiddenBindings(caughtException);
3710
							addForbiddenBindings(caughtException);
3203
							this.knownTypes.put(CharOperation.concat(caughtException.qualifiedPackageName(), caughtException.qualifiedSourceName(), '.'), this);
3711
							this.knownTypes.put(CharOperation.concat(caughtException.qualifiedPackageName(), caughtException.qualifiedSourceName(), '.'), KNOWN_TYPE_WITH_KNOWN_CONSTRUCTORS);
3204
						}
3712
						}
3205
					}
3713
					}
3206
					this.forbbidenBindingsFilter = SUBTYPE;
3714
					this.forbbidenBindingsFilter = SUBTYPE;
Lines 3942-3986 Link Here
3942
		}
4450
		}
3943
	}
4451
	}
3944
	private void findAnonymousType(
4452
	private void findAnonymousType(
4453
			ReferenceBinding currentType,
4454
			TypeBinding[] argTypes,
4455
			Scope scope,
4456
			InvocationSite invocationSite) {
4457
		
4458
		int relevance = computeBaseRelevance();
4459
		relevance += computeRelevanceForResolution();
4460
		relevance += computeRelevanceForInterestingProposal();
4461
		relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE);
4462
		
4463
		findAnonymousType(currentType, argTypes, scope, invocationSite, true, false, relevance);
4464
	}
4465
	private void findAnonymousType(
3945
		ReferenceBinding currentType,
4466
		ReferenceBinding currentType,
3946
		TypeBinding[] argTypes,
4467
		TypeBinding[] argTypes,
3947
		Scope scope,
4468
		Scope scope,
3948
		InvocationSite invocationSite) {
4469
		InvocationSite invocationSite,
4470
		boolean exactMatch,
4471
		boolean isQualified,
4472
		int relevance) {
3949
4473
3950
		if (currentType.isInterface()) {
4474
		if (currentType.isInterface()) {
3951
			char[] completion = CharOperation.NO_CHAR;
4475
			char[] completion = CharOperation.NO_CHAR;
3952
			int relevance = computeBaseRelevance();
4476
			
3953
			relevance += computeRelevanceForResolution();
4477
			if (!exactMatch) {
3954
			relevance += computeRelevanceForInterestingProposal();
4478
				char[] typeName = 
3955
			relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE);
4479
					isQualified ?
4480
							CharOperation.concat(currentType.qualifiedPackageName(), currentType.qualifiedSourceName(), '.') :
4481
								currentType.sourceName();
4482
				completion = CharOperation.concat(typeName, new char[]{'(', ')'});
4483
			}
3956
4484
3957
			this.noProposal = false;
4485
			this.noProposal = false;
3958
			if(!this.requestor.isIgnored(CompletionProposal.ANONYMOUS_CLASS_DECLARATION)) {
4486
			if (!exactMatch) {
3959
				InternalCompletionProposal proposal = createProposal(CompletionProposal.ANONYMOUS_CLASS_DECLARATION, this.actualCompletionPosition);
4487
				if(!this.requestor.isIgnored(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION)) {
3960
				proposal.setDeclarationSignature(getSignature(currentType));
4488
					InternalCompletionProposal proposal = createProposal(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION, this.actualCompletionPosition);
3961
				proposal.setDeclarationKey(currentType.computeUniqueKey());
4489
					proposal.setDeclarationSignature(getSignature(currentType));
3962
				proposal.setSignature(
4490
					proposal.setDeclarationKey(currentType.computeUniqueKey());
3963
						createMethodSignature(
4491
					proposal.setSignature(
3964
								CharOperation.NO_CHAR_CHAR,
4492
							createMethodSignature(
3965
								CharOperation.NO_CHAR_CHAR,
4493
									CharOperation.NO_CHAR_CHAR,
3966
								CharOperation.NO_CHAR,
4494
									CharOperation.NO_CHAR_CHAR,
3967
								CharOperation.NO_CHAR));
4495
									CharOperation.NO_CHAR,
3968
				//proposal.setOriginalSignature(null);
4496
									CharOperation.NO_CHAR));
3969
				//proposal.setUniqueKey(null);
4497
					//proposal.setOriginalSignature(null);
3970
				proposal.setDeclarationPackageName(currentType.qualifiedPackageName());
4498
					//proposal.setUniqueKey(null);
3971
				proposal.setDeclarationTypeName(currentType.qualifiedSourceName());
4499
					proposal.setDeclarationPackageName(currentType.qualifiedPackageName());
3972
				//proposal.setParameterPackageNames(null);
4500
					proposal.setDeclarationTypeName(currentType.qualifiedSourceName());
3973
				//proposal.setParameterTypeNames(null);
4501
					//proposal.setParameterPackageNames(null);
3974
				//proposal.setPackageName(null);
4502
					//proposal.setParameterTypeNames(null);
3975
				//proposal.setTypeName(null);
4503
					//proposal.setPackageName(null);
3976
				proposal.setCompletion(completion);
4504
					//proposal.setTypeName(null);
3977
				proposal.setFlags(Flags.AccPublic);
4505
					proposal.setCompletion(completion);
3978
				proposal.setReplaceRange(this.endPosition - this.offset, this.endPosition - this.offset);
4506
					proposal.setFlags(Flags.AccPublic);
3979
				proposal.setTokenRange(this.tokenEnd - this.offset, this.tokenEnd - this.offset);
4507
					proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset);
3980
				proposal.setRelevance(relevance);
4508
					proposal.setTokenRange(this.tokenEnd - this.offset, this.tokenEnd - this.offset);
3981
				this.requestor.accept(proposal);
4509
					proposal.setRelevance(relevance);
3982
				if(DEBUG) {
4510
					this.requestor.accept(proposal);
3983
					this.printDebug(proposal);
4511
					if(DEBUG) {
4512
						this.printDebug(proposal);
4513
					}
4514
				}
4515
			}  else {
4516
				if(!this.requestor.isIgnored(CompletionProposal.ANONYMOUS_CLASS_DECLARATION)) {
4517
					InternalCompletionProposal proposal = createProposal(CompletionProposal.ANONYMOUS_CLASS_DECLARATION, this.actualCompletionPosition);
4518
					proposal.setDeclarationSignature(getSignature(currentType));
4519
					proposal.setDeclarationKey(currentType.computeUniqueKey());
4520
					proposal.setSignature(
4521
							createMethodSignature(
4522
									CharOperation.NO_CHAR_CHAR,
4523
									CharOperation.NO_CHAR_CHAR,
4524
									CharOperation.NO_CHAR,
4525
									CharOperation.NO_CHAR));
4526
					//proposal.setOriginalSignature(null);
4527
					//proposal.setUniqueKey(null);
4528
					proposal.setDeclarationPackageName(currentType.qualifiedPackageName());
4529
					proposal.setDeclarationTypeName(currentType.qualifiedSourceName());
4530
					//proposal.setParameterPackageNames(null);
4531
					//proposal.setParameterTypeNames(null);
4532
					//proposal.setPackageName(null);
4533
					//proposal.setTypeName(null);
4534
					proposal.setCompletion(completion);
4535
					proposal.setFlags(Flags.AccPublic);
4536
					proposal.setReplaceRange(this.endPosition - this.offset, this.endPosition - this.offset);
4537
					proposal.setTokenRange(this.tokenEnd - this.offset, this.tokenEnd - this.offset);
4538
					proposal.setRelevance(relevance);
4539
					this.requestor.accept(proposal);
4540
					if(DEBUG) {
4541
						this.printDebug(proposal);
4542
					}
3984
				}
4543
				}
3985
			}
4544
			}
3986
		} else {
4545
		} else {
Lines 3989-3995 Link Here
3989
				argTypes,
4548
				argTypes,
3990
				scope,
4549
				scope,
3991
				invocationSite,
4550
				invocationSite,
3992
				true);
4551
				true,
4552
				exactMatch,
4553
				isQualified,
4554
				relevance);
3993
		}
4555
		}
3994
	}
4556
	}
3995
	private void findClassField(
4557
	private void findClassField(
Lines 4074-4079 Link Here
4074
		Scope scope,
4636
		Scope scope,
4075
		InvocationSite invocationSite,
4637
		InvocationSite invocationSite,
4076
		boolean forAnonymousType) {
4638
		boolean forAnonymousType) {
4639
		
4640
		int relevance = computeBaseRelevance();
4641
						relevance += computeRelevanceForResolution();
4642
						relevance += computeRelevanceForInterestingProposal();
4643
						relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE);
4644
		
4645
		findConstructors(currentType, argTypes, scope, invocationSite, forAnonymousType, true, false, relevance);
4646
	}
4647
		
4648
	private void findConstructors(
4649
		ReferenceBinding currentType,
4650
		TypeBinding[] argTypes,
4651
		Scope scope,
4652
		InvocationSite invocationSite,
4653
		boolean forAnonymousType,
4654
		boolean exactMatch,
4655
		boolean isQualified,
4656
		int relevance) {
4077
4657
4078
		// No visibility checks can be performed without the scope & invocationSite
4658
		// No visibility checks can be performed without the scope & invocationSite
4079
		MethodBinding[] methods = currentType.availableMethods();
4659
		MethodBinding[] methods = currentType.availableMethods();
Lines 4116-4161 Link Here
4116
					char[][] parameterNames = findMethodParameterNames(constructor,parameterTypeNames);
4696
					char[][] parameterNames = findMethodParameterNames(constructor,parameterTypeNames);
4117
4697
4118
					char[] completion = CharOperation.NO_CHAR;
4698
					char[] completion = CharOperation.NO_CHAR;
4699
					
4119
					if(forAnonymousType){
4700
					if(forAnonymousType){
4120
						int relevance = computeBaseRelevance();
4701
						if (!exactMatch) {
4121
						relevance += computeRelevanceForResolution();
4702
							char[] typeName = 
4122
						relevance += computeRelevanceForInterestingProposal();
4703
								isQualified ?
4123
						relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE);
4704
										CharOperation.concat(currentType.qualifiedPackageName(), currentType.qualifiedSourceName(), '.') :
4124
4705
											currentType.sourceName();
4706
							completion = CharOperation.concat(typeName, new char[]{'(', ')'});
4707
						}
4708
						
4125
						this.noProposal = false;
4709
						this.noProposal = false;
4126
						if(!this.requestor.isIgnored(CompletionProposal.ANONYMOUS_CLASS_DECLARATION)) {
4710
						if (!exactMatch) {
4127
							InternalCompletionProposal proposal = createProposal(CompletionProposal.ANONYMOUS_CLASS_DECLARATION, this.actualCompletionPosition);
4711
							if(!this.requestor.isIgnored(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION)) {
4128
							proposal.setDeclarationSignature(getSignature(currentType));
4712
								InternalCompletionProposal proposal = createProposal(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION, this.actualCompletionPosition);
4129
							proposal.setDeclarationKey(currentType.computeUniqueKey());
4713
								proposal.setDeclarationSignature(getSignature(currentType));
4130
							proposal.setSignature(getSignature(constructor));
4714
								proposal.setDeclarationKey(currentType.computeUniqueKey());
4131
							MethodBinding original = constructor.original();
4715
								proposal.setSignature(getSignature(constructor));
4132
							if(original != constructor) {
4716
								MethodBinding original = constructor.original();
4133
								proposal.setOriginalSignature(getSignature(original));
4717
								if(original != constructor) {
4718
									proposal.setOriginalSignature(getSignature(original));
4719
								}
4720
								proposal.setKey(constructor.computeUniqueKey());
4721
								proposal.setDeclarationPackageName(currentType.qualifiedPackageName());
4722
								proposal.setDeclarationTypeName(currentType.qualifiedSourceName());
4723
								proposal.setParameterPackageNames(parameterPackageNames);
4724
								proposal.setParameterTypeNames(parameterTypeNames);
4725
								//proposal.setPackageName(null);
4726
								//proposal.setTypeName(null);
4727
								proposal.setCompletion(completion);
4728
								proposal.setFlags(constructor.modifiers);
4729
								proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset);
4730
								proposal.setTokenRange(this.tokenEnd - this.offset, this.tokenEnd - this.offset);
4731
								proposal.setRelevance(relevance);
4732
								if(parameterNames != null) proposal.setParameterNames(parameterNames);
4733
								this.requestor.accept(proposal);
4734
								if(DEBUG) {
4735
									this.printDebug(proposal);
4736
								}
4134
							}
4737
							}
4135
							proposal.setKey(constructor.computeUniqueKey());
4738
						} else {
4136
							proposal.setDeclarationPackageName(currentType.qualifiedPackageName());
4739
							if(!this.requestor.isIgnored(CompletionProposal.ANONYMOUS_CLASS_DECLARATION)) {
4137
							proposal.setDeclarationTypeName(currentType.qualifiedSourceName());
4740
								InternalCompletionProposal proposal = createProposal(CompletionProposal.ANONYMOUS_CLASS_DECLARATION, this.actualCompletionPosition);
4138
							proposal.setParameterPackageNames(parameterPackageNames);
4741
								proposal.setDeclarationSignature(getSignature(currentType));
4139
							proposal.setParameterTypeNames(parameterTypeNames);
4742
								proposal.setDeclarationKey(currentType.computeUniqueKey());
4140
							//proposal.setPackageName(null);
4743
								proposal.setSignature(getSignature(constructor));
4141
							//proposal.setTypeName(null);
4744
								MethodBinding original = constructor.original();
4142
							proposal.setCompletion(completion);
4745
								if(original != constructor) {
4143
							proposal.setFlags(constructor.modifiers);
4746
									proposal.setOriginalSignature(getSignature(original));
4144
							proposal.setReplaceRange(this.endPosition - this.offset, this.endPosition - this.offset);
4747
								}
4145
							proposal.setTokenRange(this.tokenEnd - this.offset, this.tokenEnd - this.offset);
4748
								proposal.setKey(constructor.computeUniqueKey());
4146
							proposal.setRelevance(relevance);
4749
								proposal.setDeclarationPackageName(currentType.qualifiedPackageName());
4147
							if(parameterNames != null) proposal.setParameterNames(parameterNames);
4750
								proposal.setDeclarationTypeName(currentType.qualifiedSourceName());
4148
							this.requestor.accept(proposal);
4751
								proposal.setParameterPackageNames(parameterPackageNames);
4149
							if(DEBUG) {
4752
								proposal.setParameterTypeNames(parameterTypeNames);
4150
								this.printDebug(proposal);
4753
								//proposal.setPackageName(null);
4754
								//proposal.setTypeName(null);
4755
								proposal.setCompletion(completion);
4756
								proposal.setFlags(constructor.modifiers);
4757
								proposal.setReplaceRange(this.endPosition - this.offset, this.endPosition - this.offset);
4758
								proposal.setTokenRange(this.tokenEnd - this.offset, this.tokenEnd - this.offset);
4759
								proposal.setRelevance(relevance);
4760
								if(parameterNames != null) proposal.setParameterNames(parameterNames);
4761
								this.requestor.accept(proposal);
4762
								if(DEBUG) {
4763
									this.printDebug(proposal);
4764
								}
4151
							}
4765
							}
4152
						}
4766
						}
4153
					} else {
4767
					} 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
4768
						// Special case for completion in javadoc
4160
						if (this.assistNodeInJavadoc > 0) {
4769
						if (this.assistNodeInJavadoc > 0) {
4161
							Expression receiver = null;
4770
							Expression receiver = null;
Lines 4207-4277 Link Here
4207
								javadocCompletion.append(')');
4816
								javadocCompletion.append(')');
4208
								completion = javadocCompletion.toString().toCharArray();
4817
								completion = javadocCompletion.toString().toCharArray();
4209
							}
4818
							}
4819
						} else {
4820
							if (!exactMatch) {
4821
								char[] typeName = 
4822
									isQualified ?
4823
											CharOperation.concat(currentType.qualifiedPackageName(), currentType.qualifiedSourceName(), '.') :
4824
												currentType.sourceName();
4825
								completion = CharOperation.concat(typeName, new char[]{'(', ')'});
4826
							}
4210
						}
4827
						}
4211
4828
4212
						// Create standard proposal
4829
						// Create standard proposal
4213
						this.noProposal = false;
4830
						this.noProposal = false;
4214
						if(!this.requestor.isIgnored(CompletionProposal.METHOD_REF) && (this.assistNodeInJavadoc & CompletionOnJavadoc.ONLY_INLINE_TAG) == 0) {
4831
						if (!exactMatch) {
4215
							InternalCompletionProposal proposal =  createProposal(CompletionProposal.METHOD_REF, this.actualCompletionPosition);
4832
							if(!this.requestor.isIgnored(CompletionProposal.CONSTRUCTOR_INVOCATION)) {
4216
							proposal.setDeclarationSignature(getSignature(currentType));
4833
								InternalCompletionProposal proposal =  createProposal(CompletionProposal.CONSTRUCTOR_INVOCATION, this.actualCompletionPosition);
4217
							proposal.setSignature(getSignature(constructor));
4834
								proposal.setDeclarationSignature(getSignature(currentType));
4218
							MethodBinding original = constructor.original();
4835
								proposal.setSignature(getSignature(constructor));
4219
							if(original != constructor) {
4836
								MethodBinding original = constructor.original();
4220
								proposal.setOriginalSignature(getSignature(original));
4837
								if(original != constructor) {
4838
									proposal.setOriginalSignature(getSignature(original));
4839
								}
4840
								proposal.setDeclarationPackageName(currentType.qualifiedPackageName());
4841
								proposal.setDeclarationTypeName(currentType.qualifiedSourceName());
4842
								proposal.setParameterPackageNames(parameterPackageNames);
4843
								proposal.setParameterTypeNames(parameterTypeNames);
4844
								//proposal.setPackageName(null);
4845
								//proposal.setTypeName(null);
4846
								proposal.setName(currentType.sourceName());
4847
								proposal.setIsContructor(true);
4848
								proposal.setCompletion(completion);
4849
								proposal.setFlags(constructor.modifiers);
4850
								proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset);
4851
								proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset);
4852
								proposal.setRelevance(relevance);
4853
								if(parameterNames != null) proposal.setParameterNames(parameterNames);
4854
								this.requestor.accept(proposal);
4855
								if(DEBUG) {
4856
									this.printDebug(proposal);
4857
								}
4221
							}
4858
							}
4222
							proposal.setDeclarationPackageName(currentType.qualifiedPackageName());
4859
						} else {
4223
							proposal.setDeclarationTypeName(currentType.qualifiedSourceName());
4860
							if(!this.requestor.isIgnored(CompletionProposal.METHOD_REF) && (this.assistNodeInJavadoc & CompletionOnJavadoc.ONLY_INLINE_TAG) == 0) {
4224
							proposal.setParameterPackageNames(parameterPackageNames);
4861
								InternalCompletionProposal proposal =  createProposal(CompletionProposal.METHOD_REF, this.actualCompletionPosition);
4225
							proposal.setParameterTypeNames(parameterTypeNames);
4862
								proposal.setDeclarationSignature(getSignature(currentType));
4226
							//proposal.setPackageName(null);
4863
								proposal.setSignature(getSignature(constructor));
4227
							//proposal.setTypeName(null);
4864
								MethodBinding original = constructor.original();
4228
							proposal.setName(currentType.sourceName());
4865
								if(original != constructor) {
4229
							proposal.setIsContructor(true);
4866
									proposal.setOriginalSignature(getSignature(original));
4230
							proposal.setCompletion(completion);
4867
								}
4231
							proposal.setFlags(constructor.modifiers);
4868
								proposal.setDeclarationPackageName(currentType.qualifiedPackageName());
4232
							int start = (this.assistNodeInJavadoc > 0) ? this.startPosition : this.endPosition;
4869
								proposal.setDeclarationTypeName(currentType.qualifiedSourceName());
4233
							proposal.setReplaceRange(start - this.offset, this.endPosition - this.offset);
4870
								proposal.setParameterPackageNames(parameterPackageNames);
4234
							proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset);
4871
								proposal.setParameterTypeNames(parameterTypeNames);
4235
							proposal.setRelevance(relevance);
4872
								//proposal.setPackageName(null);
4236
							if(parameterNames != null) proposal.setParameterNames(parameterNames);
4873
								//proposal.setTypeName(null);
4237
							this.requestor.accept(proposal);
4874
								proposal.setName(currentType.sourceName());
4238
							if(DEBUG) {
4875
								proposal.setIsContructor(true);
4239
								this.printDebug(proposal);
4876
								proposal.setCompletion(completion);
4877
								proposal.setFlags(constructor.modifiers);
4878
								int start = (this.assistNodeInJavadoc > 0) ? this.startPosition : this.endPosition;
4879
								proposal.setReplaceRange(start - this.offset, this.endPosition - this.offset);
4880
								proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset);
4881
								proposal.setRelevance(relevance);
4882
								if(parameterNames != null) proposal.setParameterNames(parameterNames);
4883
								this.requestor.accept(proposal);
4884
								if(DEBUG) {
4885
									this.printDebug(proposal);
4886
								}
4240
							}
4887
							}
4241
						}
4888
							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)) {
4889
								char[] javadocCompletion = inlineTagCompletion(completion, JavadocTagConstants.TAG_LINK);
4243
							char[] javadocCompletion = inlineTagCompletion(completion, JavadocTagConstants.TAG_LINK);
4890
								InternalCompletionProposal proposal =  createProposal(CompletionProposal.JAVADOC_METHOD_REF, this.actualCompletionPosition);
4244
							InternalCompletionProposal proposal =  createProposal(CompletionProposal.JAVADOC_METHOD_REF, this.actualCompletionPosition);
4891
								proposal.setDeclarationSignature(getSignature(currentType));
4245
							proposal.setDeclarationSignature(getSignature(currentType));
4892
								proposal.setSignature(getSignature(constructor));
4246
							proposal.setSignature(getSignature(constructor));
4893
								MethodBinding original = constructor.original();
4247
							MethodBinding original = constructor.original();
4894
								if(original != constructor) {
4248
							if(original != constructor) {
4895
									proposal.setOriginalSignature(getSignature(original));
4249
								proposal.setOriginalSignature(getSignature(original));
4896
								}
4897
								proposal.setDeclarationPackageName(currentType.qualifiedPackageName());
4898
								proposal.setDeclarationTypeName(currentType.qualifiedSourceName());
4899
								proposal.setParameterPackageNames(parameterPackageNames);
4900
								proposal.setParameterTypeNames(parameterTypeNames);
4901
								//proposal.setPackageName(null);
4902
								//proposal.setTypeName(null);
4903
								proposal.setName(currentType.sourceName());
4904
								proposal.setIsContructor(true);
4905
								proposal.setCompletion(javadocCompletion);
4906
								proposal.setFlags(constructor.modifiers);
4907
								int start = (this.assistNodeInJavadoc & CompletionOnJavadoc.REPLACE_TAG) != 0 ? this.javadocTagPosition : this.startPosition;
4908
								proposal.setReplaceRange(start - this.offset, this.endPosition - this.offset);
4909
								proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset);
4910
								proposal.setRelevance(relevance+R_INLINE_TAG);
4911
								if(parameterNames != null) proposal.setParameterNames(parameterNames);
4912
								this.requestor.accept(proposal);
4913
								if(DEBUG) {
4914
									this.printDebug(proposal);
4915
								}
4250
							}
4916
							}
4251
							proposal.setDeclarationPackageName(currentType.qualifiedPackageName());
4917
						}
4252
							proposal.setDeclarationTypeName(currentType.qualifiedSourceName());
4918
					}
4253
							proposal.setParameterPackageNames(parameterPackageNames);
4919
				}
4254
							proposal.setParameterTypeNames(parameterTypeNames);
4920
			}
4255
							//proposal.setPackageName(null);
4921
		}
4256
							//proposal.setTypeName(null);
4922
	}
4257
							proposal.setName(currentType.sourceName());
4923
	
4258
							proposal.setIsContructor(true);
4924
	private char[] getResolvedSignature(char[][] parameterTypes, char[] fullyQualifiedTypeName, int parameterCount, Scope scope) {
4259
							proposal.setCompletion(javadocCompletion);
4925
		char[][] cn = CharOperation.splitOn('.', fullyQualifiedTypeName);
4260
							proposal.setFlags(constructor.modifiers);
4926
4261
							int start = (this.assistNodeInJavadoc & CompletionOnJavadoc.REPLACE_TAG) != 0 ? this.javadocTagPosition : this.startPosition;
4927
		TypeReference ref;
4262
							proposal.setReplaceRange(start - this.offset, this.endPosition - this.offset);
4928
		if (cn.length == 1) {
4263
							proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset);
4929
			ref = new SingleTypeReference(cn[0], 0);
4264
							proposal.setRelevance(relevance+R_INLINE_TAG);
4930
		} else {
4265
							if(parameterNames != null) proposal.setParameterNames(parameterNames);
4931
			ref = new QualifiedTypeReference(cn,new long[cn.length]);
4266
							this.requestor.accept(proposal);
4932
		}
4267
							if(DEBUG) {
4933
		
4268
								this.printDebug(proposal);
4934
		TypeBinding guessedType = null;
4935
		INameEnvironment oldNameEnvironment = this.lookupEnvironment.nameEnvironment;
4936
		this.lookupEnvironment.nameEnvironment = getNoCacheNameEnvironment();
4937
		try {
4938
			switch (scope.kind) {
4939
				case Scope.METHOD_SCOPE :
4940
				case Scope.BLOCK_SCOPE :
4941
					guessedType = ref.resolveType((BlockScope)scope);
4942
					break;
4943
				case Scope.CLASS_SCOPE :
4944
					guessedType = ref.resolveType((ClassScope)scope);
4945
					break;
4946
			}
4947
		} finally {
4948
			this.lookupEnvironment.nameEnvironment = oldNameEnvironment;
4949
		}
4950
4951
		if (guessedType != null && guessedType.isValidBinding()) {
4952
			if (guessedType instanceof ReferenceBinding) {
4953
				ReferenceBinding refBinding = (ReferenceBinding) guessedType;
4954
				
4955
				MethodBinding bestConstructor = null;
4956
				int[] bestMatchingLengths = null;
4957
				
4958
				MethodBinding[] methods = refBinding.methods();
4959
				next : for (int i = 0; i < methods.length; i++) {
4960
					MethodBinding method = methods[i];
4961
					
4962
					if (!method.isConstructor()) break next;
4963
					
4964
					TypeBinding[] parameters = method.parameters;
4965
					//TODO take careful of member types
4966
					int parametersLength = parameters == null ? 0 : parameters.length;
4967
					if (parameterCount != parametersLength) continue next;
4968
					
4969
					int[] matchingLengths = new int[parameterCount];
4970
					for (int j = 0; j < parametersLength; j++) {
4971
						TypeBinding parameter = parameters[j];
4972
						
4973
						char[] parameterTypeName;
4974
						if (parameter instanceof ReferenceBinding) {
4975
							parameterTypeName = CharOperation.concatWith(((ReferenceBinding)parameter).compoundName, '.');
4976
						} else {
4977
							parameterTypeName = parameter.sourceName();
4978
						}
4979
						
4980
						if (!CharOperation.endsWith(parameterTypeName, parameterTypes[j])) {
4981
							break next;
4982
						}
4983
						
4984
						int matchingLength = parameterTypes[j].length;
4985
						
4986
						if (bestMatchingLengths != null) {
4987
							if (bestMatchingLengths[j] > matchingLength) {
4988
								continue next;
4269
							}
4989
							}
4270
						}
4990
						}
4991
						
4992
						matchingLengths[j] = matchingLength;
4271
					}
4993
					}
4994
					
4995
					
4996
					bestConstructor = method;
4997
					bestMatchingLengths = matchingLengths;
4272
				}
4998
				}
4999
				
5000
				if (bestConstructor == null) return null;
5001
				return getSignature(bestConstructor);
4273
			}
5002
			}
4274
		}
5003
		}
5004
		
5005
		return null;
5006
	}
5007
5008
	private void findConstructorsOrAnonymousTypes(
5009
			ReferenceBinding currentType,
5010
			Scope scope,
5011
			InvocationSite invocationSite,
5012
			boolean isQualified,
5013
			int relevance) {
5014
		
5015
		if (!this.requestor.isIgnored(CompletionProposal.CONSTRUCTOR_INVOCATION)
5016
				&& currentType.isClass()
5017
				&& !currentType.isAbstract()) {
5018
				findConstructors(
5019
					currentType,
5020
					null,
5021
					scope,
5022
					invocationSite,
5023
					false,
5024
					false,
5025
					isQualified,
5026
					relevance);
5027
		}
5028
		
5029
		// This code is disabled because there is too much proposals when constructors and anonymous are proposed
5030
		if (!this.requestor.isIgnored(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION)
5031
				&& !currentType.isFinal()
5032
				&& (currentType.isInterface() || (currentType.isClass() && currentType.isAbstract()))){
5033
			findAnonymousType(
5034
				currentType,
5035
				null,
5036
				scope,
5037
				invocationSite,
5038
				false,
5039
				isQualified,
5040
				relevance);
5041
		}
4275
	}
5042
	}
4276
	private char[][] findEnclosingTypeNames(Scope scope){
5043
	private char[][] findEnclosingTypeNames(Scope scope){
4277
		char[][] excludedNames = new char[10][];
5044
		char[][] excludedNames = new char[10][];
Lines 8229-8245 Link Here
8229
				relevance += computeRelevanceForMissingElements(missingElementsHaveProblems);
8996
				relevance += computeRelevanceForMissingElements(missingElementsHaveProblems);
8230
			}
8997
			}
8231
8998
8999
			boolean allowingLongComputationProposals = this.requestor.isAllowingLongComputationProposals();
9000
			
8232
			this.noProposal = false;
9001
			this.noProposal = false;
8233
			createTypeProposal(
9002
			if (!this.assistNodeIsConstructor || !allowingLongComputationProposals || hasStaticMemberTypes(memberType, invocationType, this.unitScope)) {
8234
					memberType,
9003
				createTypeProposal(
8235
					memberType.qualifiedSourceName(),
9004
						memberType,
8236
					IAccessRule.K_ACCESSIBLE,
9005
						memberType.qualifiedSourceName(),
8237
					completionName,
9006
						IAccessRule.K_ACCESSIBLE,
8238
					relevance,
9007
						completionName,
8239
					missingElements,
9008
						relevance,
8240
					missingElementsStarts,
9009
						missingElements,
8241
					missingElementsEnds,
9010
						missingElementsStarts,
8242
					missingElementsHaveProblems);
9011
						missingElementsEnds,
9012
						missingElementsHaveProblems);
9013
			}
9014
			
9015
			if (this.assistNodeIsConstructor && allowingLongComputationProposals) {
9016
				findConstructorsOrAnonymousTypes(
9017
						memberType,
9018
						scope,
9019
						FakeInvocationSite,
9020
						isQualified,
9021
						relevance);
9022
			}
8243
		}
9023
		}
8244
	}
9024
	}
8245
	private void findMemberTypesFromMissingType(
9025
	private void findMemberTypesFromMissingType(
Lines 8658-8675 Link Here
8658
								relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE); // no access restriction for nested type
9438
								relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE); // no access restriction for nested type
8659
								relevance += computeRelevanceForAnnotationTarget(localType);
9439
								relevance += computeRelevanceForAnnotationTarget(localType);
8660
9440
8661
								this.noProposal = false;
9441
								boolean allowingLongComputationProposals = this.requestor.isAllowingLongComputationProposals();
8662
								if(!this.requestor.isIgnored(CompletionProposal.TYPE_REF)) {
9442
								if (!this.assistNodeIsConstructor || !allowingLongComputationProposals) {
8663
									createTypeProposal(
9443
									this.noProposal = false;
9444
									if(!this.requestor.isIgnored(CompletionProposal.TYPE_REF)) {
9445
										createTypeProposal(
9446
												localType,
9447
												localType.sourceName,
9448
												IAccessRule.K_ACCESSIBLE,
9449
												localType.sourceName,
9450
												relevance,
9451
												null,
9452
												null,
9453
												null,
9454
												false);
9455
									}
9456
								}
9457
								
9458
								if (this.assistNodeIsConstructor && allowingLongComputationProposals) {
9459
									findConstructorsOrAnonymousTypes(
8664
											localType,
9460
											localType,
8665
											localType.sourceName,
9461
											blockScope,
8666
											IAccessRule.K_ACCESSIBLE,
9462
											FakeInvocationSite,
8667
											localType.sourceName,
9463
											false,
8668
											relevance,
9464
											relevance);
8669
											null,
8670
											null,
8671
											null,
8672
											false);
8673
								}
9465
								}
8674
							}
9466
							}
8675
						}
9467
						}
Lines 8917-8930 Link Here
8917
9709
8918
		if (token == null)
9710
		if (token == null)
8919
			return;
9711
			return;
8920
9712
		
9713
		boolean allowingLongComputationProposals = this.requestor.isAllowingLongComputationProposals();
9714
		
8921
		boolean proposeType =
9715
		boolean proposeType =
8922
			!this.requestor.isIgnored(CompletionProposal.TYPE_REF) ||
9716
			!this.requestor.isIgnored(CompletionProposal.TYPE_REF) ||
8923
			((this.assistNodeInJavadoc & CompletionOnJavadoc.TEXT) != 0 && !this.requestor.isIgnored(CompletionProposal.JAVADOC_TYPE_REF));
9717
			((this.assistNodeInJavadoc & CompletionOnJavadoc.TEXT) != 0 && !this.requestor.isIgnored(CompletionProposal.JAVADOC_TYPE_REF));
8924
9718
8925
		boolean proposeAllMemberTypes = !this.assistNodeIsConstructor;
9719
		boolean proposeAllMemberTypes = !this.assistNodeIsConstructor;
9720
		
9721
		boolean proposeConstructor =
9722
			allowingLongComputationProposals &&
9723
			this.assistNodeIsConstructor &&
9724
			(!this.requestor.isIgnored(CompletionProposal.CONSTRUCTOR_INVOCATION) || !this.requestor.isIgnored(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION));
9725
		
8926
9726
8927
		if (proposeType && scope.enclosingSourceType() != null) {
9727
		if ((proposeType || proposeConstructor) && scope.enclosingSourceType() != null) {
8928
			
9728
			
8929
			checkCancel();
9729
			checkCancel();
8930
			
9730
			
Lines 8943-8949 Link Here
8943
9743
8944
		boolean isEmptyPrefix = token.length == 0;
9744
		boolean isEmptyPrefix = token.length == 0;
8945
9745
8946
		if (proposeType && this.unitScope != null) {
9746
		if ((proposeType || proposeConstructor) && this.unitScope != null) {
8947
			
9747
			
8948
			ReferenceBinding outerInvocationType = scope.enclosingSourceType();
9748
			ReferenceBinding outerInvocationType = scope.enclosingSourceType();
8949
			if(outerInvocationType != null) {
9749
			if(outerInvocationType != null) {
Lines 8984-8990 Link Here
8984
				if (typeLength > sourceType.sourceName.length) continue next;
9784
				if (typeLength > sourceType.sourceName.length) continue next;
8985
9785
8986
				if (!CharOperation.prefixEquals(token, sourceType.sourceName, false)
9786
				if (!CharOperation.prefixEquals(token, sourceType.sourceName, false)
8987
						&& !(this.options.camelCaseMatch && CharOperation.camelCaseMatch(token, sourceType.sourceName))) continue;
9787
						&& !(this.options.camelCaseMatch && CharOperation.camelCaseMatch(token, sourceType.sourceName))) continue next;
8988
9788
8989
				if (this.assistNodeIsAnnotation && !hasPossibleAnnotationTarget(sourceType, scope)) {
9789
				if (this.assistNodeIsAnnotation && !hasPossibleAnnotationTarget(sourceType, scope)) {
8990
					continue next;
9790
					continue next;
Lines 8995-9002 Link Here
8995
9795
8996
					if (sourceType == otherType) continue next;
9796
					if (sourceType == otherType) continue next;
8997
				}
9797
				}
8998
9798
				
8999
				this.knownTypes.put(CharOperation.concat(sourceType.qualifiedPackageName(), sourceType.sourceName(), '.'), this);
9799
				typesFound.add(sourceType);
9000
9800
9001
				if(this.assistNodeIsClass) {
9801
				if(this.assistNodeIsClass) {
9002
					if(!sourceType.isClass()) continue next;
9802
					if(!sourceType.isClass()) continue next;
Lines 9027-9034 Link Here
9027
					relevance += computeRelevanceForClass();
9827
					relevance += computeRelevanceForClass();
9028
					relevance += computeRelevanceForException(sourceType.sourceName);
9828
					relevance += computeRelevanceForException(sourceType.sourceName);
9029
				}
9829
				}
9830
				
9831
				
9030
				this.noProposal = false;
9832
				this.noProposal = false;
9031
				if(proposeType) {
9833
				if(proposeType && (!this.assistNodeIsConstructor || !allowingLongComputationProposals || hasStaticMemberTypes(sourceType, null, this.unitScope))) {
9032
					char[] typeName = sourceType.sourceName();
9834
					char[] typeName = sourceType.sourceName();
9033
					createTypeProposal(
9835
					createTypeProposal(
9034
							sourceType,
9836
							sourceType,
Lines 9041-9181 Link Here
9041
							null,
9843
							null,
9042
							false);
9844
							false);
9043
				}
9845
				}
9846
				
9847
				if (proposeConstructor) {
9848
					findConstructorsOrAnonymousTypes(
9849
							sourceType,
9850
							scope,
9851
							FakeInvocationSite,
9852
							false,
9853
							relevance);
9854
				}
9044
			}
9855
			}
9045
		}
9856
		}
9046
9857
9047
		if(proposeType) {
9858
		if (proposeConstructor && !isEmptyPrefix) {
9859
			
9860
			checkCancel();
9861
			
9862
			findTypesFromImports(token, scope, proposeType, typesFound);
9863
		} else if(proposeType) {
9048
			
9864
			
9049
			checkCancel();
9865
			checkCancel();
9050
			
9866
			
9051
			findTypesFromStaticImports(token, scope, proposeAllMemberTypes, typesFound);
9867
			findTypesFromStaticImports(token, scope, proposeAllMemberTypes, typesFound);
9052
		}
9868
		}
9869
		
9870
		if (proposeConstructor) {
9871
			
9872
			checkCancel();
9873
			
9874
			findTypesFromExpectedTypes(token, scope, typesFound, proposeType, proposeConstructor);
9875
		}
9053
9876
9054
		if (isEmptyPrefix && !this.assistNodeIsAnnotation) {
9877
		if (isEmptyPrefix && !this.assistNodeIsAnnotation) {
9055
			if(proposeType && this.expectedTypesPtr > -1) {
9878
			if (!proposeConstructor) {
9056
				next : for (int i = 0; i <= this.expectedTypesPtr; i++) {
9879
				findTypesFromExpectedTypes(token, scope, typesFound, proposeType, proposeConstructor);
9057
					
9880
			}
9058
					checkCancel();
9881
		} else {
9059
					
9882
			if(!isEmptyPrefix && !this.requestor.isIgnored(CompletionProposal.KEYWORD)) {
9060
					if(this.expectedTypes[i] instanceof ReferenceBinding) {
9883
				if (this.assistNodeInJavadoc == 0 || (this.assistNodeInJavadoc & CompletionOnJavadoc.BASE_TYPES) != 0) {
9061
						ReferenceBinding refBinding = (ReferenceBinding)this.expectedTypes[i];
9884
					if (proposeBaseTypes) {
9062
9885
						if (proposeVoidType) {
9063
						if(refBinding.isTypeVariable() && this.assistNodeIsConstructor) {
9886
							findKeywords(token, BASE_TYPE_NAMES, false, false);
9064
							// don't propose type variable if the completion is a constructor ('new |')
9887
						} else {
9065
							continue next;
9888
							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
						}
9889
						}
9163
					}
9890
					}
9164
				}
9891
				}
9165
			}
9892
			}
9166
		} else {
9893
			
9167
			if(!isEmptyPrefix && !this.requestor.isIgnored(CompletionProposal.KEYWORD)) {
9894
			if (proposeConstructor) {
9168
				if (this.assistNodeInJavadoc == 0 || (this.assistNodeInJavadoc & CompletionOnJavadoc.BASE_TYPES) != 0) {
9895
				int l = typesFound.size();
9169
					if (proposeBaseTypes) {
9896
				for (int i = 0; i < l; i++) {
9170
						if (proposeVoidType) {
9897
					ReferenceBinding typeFound = (ReferenceBinding) typesFound.elementAt(i);
9171
							findKeywords(token, BASE_TYPE_NAMES, false, false);
9898
					char[] fullyQualifiedTypeName =
9172
						} else {
9899
						CharOperation.concat(
9173
							findKeywords(token, BASE_TYPE_NAMES_WITHOUT_VOID, false, false);
9900
								typeFound.qualifiedPackageName(),
9174
						}
9901
								typeFound.qualifiedSourceName(),
9175
					}
9902
								'.');
9903
					this.knownTypes.put(fullyQualifiedTypeName, KNOWN_TYPE_WITH_KNOWN_CONSTRUCTORS);
9176
				}
9904
				}
9177
			}
9905
				
9178
			if(proposeType) {
9906
				checkCancel();
9907
				
9908
				this.foundConstructorsCount = 0;
9909
				this.nameEnvironment.findConstructorDeclarations(
9910
						token,
9911
						this.options.camelCaseMatch,
9912
						this,
9913
						this.monitor);
9914
				acceptConstructors(scope);
9915
			} else if (proposeType) {
9179
				int l = typesFound.size();
9916
				int l = typesFound.size();
9180
				for (int i = 0; i < l; i++) {
9917
				for (int i = 0; i < l; i++) {
9181
					ReferenceBinding typeFound = (ReferenceBinding) typesFound.elementAt(i);
9918
					ReferenceBinding typeFound = (ReferenceBinding) typesFound.elementAt(i);
Lines 9184-9190 Link Here
9184
								typeFound.qualifiedPackageName(),
9921
								typeFound.qualifiedPackageName(),
9185
								typeFound.qualifiedSourceName(),
9922
								typeFound.qualifiedSourceName(),
9186
								'.');
9923
								'.');
9187
					this.knownTypes.put(fullyQualifiedTypeName, this);
9924
					this.knownTypes.put(fullyQualifiedTypeName, KNOWN_TYPE_WITH_KNOWN_CONSTRUCTORS);
9188
				}
9925
				}
9189
				int searchFor = IJavaSearchConstants.TYPE;
9926
				int searchFor = IJavaSearchConstants.TYPE;
9190
				if(this.assistNodeIsClass) {
9927
				if(this.assistNodeIsClass) {
Lines 9222-9231 Link Here
9222
		char[] token,
9959
		char[] token,
9223
		PackageBinding packageBinding,
9960
		PackageBinding packageBinding,
9224
		Scope scope) {
9961
		Scope scope) {
9962
		
9963
		boolean allowingLongComputationProposals = this.requestor.isAllowingLongComputationProposals();
9225
9964
9226
		boolean proposeType =
9965
		boolean proposeType =
9227
			!this.requestor.isIgnored(CompletionProposal.TYPE_REF) ||
9966
			!this.requestor.isIgnored(CompletionProposal.TYPE_REF) ||
9228
			((this.assistNodeInJavadoc & CompletionOnJavadoc.TEXT) != 0 && !this.requestor.isIgnored(CompletionProposal.JAVADOC_TYPE_REF));
9967
			((this.assistNodeInJavadoc & CompletionOnJavadoc.TEXT) != 0 && !this.requestor.isIgnored(CompletionProposal.JAVADOC_TYPE_REF));
9968
		
9969
		boolean proposeConstructor =
9970
			allowingLongComputationProposals &&
9971
			this.assistNodeIsConstructor &&
9972
			(!this.requestor.isIgnored(CompletionProposal.CONSTRUCTOR_INVOCATION) || !this.requestor.isIgnored(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION));
9229
9973
9230
		char[] qualifiedName =
9974
		char[] qualifiedName =
9231
			CharOperation.concatWith(packageBinding.compoundName, token, '.');
9975
			CharOperation.concatWith(packageBinding.compoundName, token, '.');
Lines 9243-9249 Link Here
9243
9987
9244
		this.qualifiedCompletionToken = qualifiedName;
9988
		this.qualifiedCompletionToken = qualifiedName;
9245
9989
9246
		if (proposeType && this.unitScope != null) {
9990
		if ((proposeType || proposeConstructor) && this.unitScope != null) {
9247
			int typeLength = qualifiedName.length;
9991
			int typeLength = qualifiedName.length;
9248
			SourceTypeBinding[] types = this.unitScope.topLevelTypes;
9992
			SourceTypeBinding[] types = this.unitScope.topLevelTypes;
9249
9993
Lines 9289-9295 Link Here
9289
					}
10033
					}
9290
				}
10034
				}
9291
10035
9292
				this.knownTypes.put(CharOperation.concat(sourceType.qualifiedPackageName(), sourceType.sourceName(), '.'), this);
10036
				this.knownTypes.put(CharOperation.concat(sourceType.qualifiedPackageName(), sourceType.sourceName(), '.'), KNOWN_TYPE_WITH_KNOWN_CONSTRUCTORS);
9293
10037
9294
				int relevance = computeBaseRelevance();
10038
				int relevance = computeBaseRelevance();
9295
				relevance += computeRelevanceForResolution();
10039
				relevance += computeRelevanceForResolution();
Lines 9307-9314 Link Here
9307
					relevance += computeRelevanceForClass();
10051
					relevance += computeRelevanceForClass();
9308
					relevance += computeRelevanceForException(sourceType.sourceName);
10052
					relevance += computeRelevanceForException(sourceType.sourceName);
9309
				}
10053
				}
10054
				
9310
				this.noProposal = false;
10055
				this.noProposal = false;
9311
				if(proposeType) {
10056
				if(proposeType && (!this.assistNodeIsConstructor || !allowingLongComputationProposals || hasStaticMemberTypes(sourceType, null, this.unitScope))) {
9312
					char[] typeName = sourceType.sourceName();
10057
					char[] typeName = sourceType.sourceName();
9313
					createTypeProposal(
10058
					createTypeProposal(
9314
							sourceType,
10059
							sourceType,
Lines 9321-9330 Link Here
9321
							null,
10066
							null,
9322
							false);
10067
							false);
9323
				}
10068
				}
10069
				
10070
				if (proposeConstructor) {
10071
					findConstructorsOrAnonymousTypes(
10072
							sourceType,
10073
							scope,
10074
							FakeInvocationSite,
10075
							false,
10076
							relevance);
10077
				}
9324
			}
10078
			}
9325
		}
10079
		}
9326
10080
9327
		if(proposeType) {
10081
		if (proposeConstructor) {
10082
10083
			
10084
			checkCancel();
10085
			
10086
			this.foundConstructorsCount = 0;
10087
			this.nameEnvironment.findConstructorDeclarations(
10088
					qualifiedName,
10089
					this.options.camelCaseMatch,
10090
					this,
10091
					this.monitor);
10092
			acceptConstructors(scope);
10093
		} if(proposeType) {
9328
			int searchFor = IJavaSearchConstants.TYPE;
10094
			int searchFor = IJavaSearchConstants.TYPE;
9329
			if(this.assistNodeIsClass) {
10095
			if(this.assistNodeIsClass) {
9330
				searchFor = IJavaSearchConstants.CLASS;
10096
				searchFor = IJavaSearchConstants.CLASS;
Lines 9348-9358 Link Here
9348
					this.monitor);
10114
					this.monitor);
9349
			acceptTypes(scope);
10115
			acceptTypes(scope);
9350
		}
10116
		}
10117
		
9351
		if(!this.requestor.isIgnored(CompletionProposal.PACKAGE_REF)) {
10118
		if(!this.requestor.isIgnored(CompletionProposal.PACKAGE_REF)) {
9352
			this.nameEnvironment.findPackages(qualifiedName, this);
10119
			this.nameEnvironment.findPackages(qualifiedName, this);
9353
		}
10120
		}
9354
	}
10121
	}
10122
	
10123
	private void findTypesFromExpectedTypes(char[] token, Scope scope, ObjectVector typesFound, boolean proposeType, boolean proposeConstructor) {
10124
		if(this.expectedTypesPtr > -1) {
10125
			boolean allowingLongComputationProposals = this.requestor.isAllowingLongComputationProposals();
10126
			
10127
			int typeLength = token == null ? 0 : token.length;
10128
			
10129
			next : for (int i = 0; i <= this.expectedTypesPtr; i++) {
10130
				
10131
				checkCancel();
10132
				
10133
				if(this.expectedTypes[i] instanceof ReferenceBinding) {
10134
					ReferenceBinding refBinding = (ReferenceBinding)this.expectedTypes[i];
10135
					
10136
					if (typeLength > 0) {
10137
						if (typeLength > refBinding.sourceName.length) continue next;
10138
	
10139
						if (!CharOperation.prefixEquals(token, refBinding.sourceName, false)
10140
								&& !(this.options.camelCaseMatch && CharOperation.camelCaseMatch(token, refBinding.sourceName))) continue next;
10141
					}
10142
10143
10144
					if(refBinding.isTypeVariable() && this.assistNodeIsConstructor) {
10145
						// don't propose type variable if the completion is a constructor ('new |')
10146
						continue next;
10147
					}
10148
					if (this.options.checkDeprecation &&
10149
							refBinding.isViewedAsDeprecated() &&
10150
							!scope.isDefinedInSameUnit(refBinding))
10151
						continue next;
10152
10153
					int accessibility = IAccessRule.K_ACCESSIBLE;
10154
					if(refBinding.hasRestrictedAccess()) {
10155
						AccessRestriction accessRestriction = this.lookupEnvironment.getAccessRestriction(refBinding);
10156
						if(accessRestriction != null) {
10157
							switch (accessRestriction.getProblemId()) {
10158
								case IProblem.ForbiddenReference:
10159
									if (this.options.checkForbiddenReference) {
10160
										continue next;
10161
									}
10162
									accessibility = IAccessRule.K_NON_ACCESSIBLE;
10163
									break;
10164
								case IProblem.DiscouragedReference:
10165
									if (this.options.checkDiscouragedReference) {
10166
										continue next;
10167
									}
10168
									accessibility = IAccessRule.K_DISCOURAGED;
10169
									break;
10170
							}
10171
						}
10172
					}
10173
10174
					for (int j = 0; j < typesFound.size(); j++) {
10175
						ReferenceBinding typeFound = (ReferenceBinding)typesFound.elementAt(j);
10176
						if (typeFound == refBinding) {
10177
							continue next;
10178
						}
10179
					}
10180
					
10181
					typesFound.add(refBinding);
10182
10183
					boolean inSameUnit = this.unitScope.isDefinedInSameUnit(refBinding);
10184
10185
					// top level types of the current unit are already proposed.
10186
					if(!inSameUnit || (inSameUnit && refBinding.isMemberType())) {
10187
						char[] packageName = refBinding.qualifiedPackageName();
10188
						char[] typeName = refBinding.sourceName();
10189
						char[] completionName = typeName;
10190
10191
						boolean isQualified = false;
10192
						if (!this.insideQualifiedReference && !refBinding.isMemberType()) {
10193
							if (mustQualifyType(packageName, typeName, null, refBinding.modifiers)) {
10194
								if (packageName == null || packageName.length == 0)
10195
									if (this.unitScope != null && this.unitScope.fPackage.compoundName != CharOperation.NO_CHAR_CHAR)
10196
										continue next; // ignore types from the default package from outside it
10197
								completionName = CharOperation.concat(packageName, typeName, '.');
10198
								isQualified = true;
10199
							}
10200
						}
10201
10202
						if(this.assistNodeIsClass) {
10203
							if(!refBinding.isClass()) continue next;
10204
						} else if(this.assistNodeIsInterface) {
10205
							if(!refBinding.isInterface() && !refBinding.isAnnotationType()) continue next;
10206
						} else if (this.assistNodeIsAnnotation) {
10207
							if(!refBinding.isAnnotationType()) continue next;
10208
						}
10209
10210
						int relevance = computeBaseRelevance();
10211
						relevance += computeRelevanceForResolution();
10212
						relevance += computeRelevanceForInterestingProposal();
10213
						relevance += computeRelevanceForCaseMatching(token, typeName);
10214
						relevance += computeRelevanceForExpectingType(refBinding);
10215
						relevance += computeRelevanceForQualification(isQualified);
10216
						relevance += computeRelevanceForRestrictions(accessibility);
10217
10218
						if(refBinding.isClass()) {
10219
							relevance += computeRelevanceForClass();
10220
							relevance += computeRelevanceForException(typeName);
10221
						} else if(refBinding.isEnum()) {
10222
							relevance += computeRelevanceForEnum();
10223
						} else if(refBinding.isInterface()) {
10224
							relevance += computeRelevanceForInterface();
10225
						}
10226
						
10227
						if (proposeType && (!this.assistNodeIsConstructor || !allowingLongComputationProposals || hasStaticMemberTypes(refBinding, scope.enclosingSourceType() ,this.unitScope))) {
10228
							this.noProposal = false;
10229
							if(!this.requestor.isIgnored(CompletionProposal.TYPE_REF)) {
10230
								InternalCompletionProposal proposal =  createProposal(CompletionProposal.TYPE_REF, this.actualCompletionPosition);
10231
								proposal.setDeclarationSignature(packageName);
10232
								proposal.setSignature(getSignature(refBinding));
10233
								proposal.setPackageName(packageName);
10234
								proposal.setTypeName(typeName);
10235
								proposal.setCompletion(completionName);
10236
								proposal.setFlags(refBinding.modifiers);
10237
								proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset);
10238
								proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset);
10239
								proposal.setRelevance(relevance);
10240
								proposal.setAccessibility(accessibility);
10241
								this.requestor.accept(proposal);
10242
								if(DEBUG) {
10243
									this.printDebug(proposal);
10244
								}
10245
							}
10246
						}
10247
						
10248
						if (proposeConstructor) {
10249
							findConstructorsOrAnonymousTypes(
10250
									refBinding,
10251
									scope,
10252
									FakeInvocationSite,
10253
									isQualified,
10254
									relevance);
10255
						}
10256
					}
10257
				}
10258
			}
10259
		}
10260
	}
10261
10262
	private void findTypesFromImports(char[] token, Scope scope, boolean proposeType, ObjectVector typesFound) {
10263
		ImportBinding[] importBindings = scope.compilationUnitScope().imports;
10264
		next : for (int i = 0; i < importBindings.length; i++) {
10265
			ImportBinding importBinding = importBindings[i];
10266
			if(importBinding.isValidBinding()) {
10267
				Binding binding = importBinding.resolvedImport;
10268
				if(binding != null && binding.isValidBinding()) {
10269
					if(importBinding.onDemand) {
10270
						if (importBinding.isStatic()) {
10271
							if((binding.kind() & Binding.TYPE) != 0) {
10272
								this.findMemberTypes(
10273
										token,
10274
										(ReferenceBinding) binding,
10275
										scope,
10276
										scope.enclosingSourceType(),
10277
										true,
10278
										false,
10279
										true,
10280
										true,
10281
										false,
10282
										null,
10283
										typesFound,
10284
										null,
10285
										null,
10286
										null,
10287
										false);
10288
							}
10289
						}
10290
					} else {
10291
						if ((binding.kind() & Binding.TYPE) != 0) {
10292
							ReferenceBinding typeBinding = (ReferenceBinding) binding;
10293
							int typeLength = token.length;
9355
10294
10295
							if (!typeBinding.isStatic()) continue next;
10296
10297
							if (typeLength > typeBinding.sourceName.length)	continue next;
10298
10299
							if (!CharOperation.prefixEquals(token, typeBinding.sourceName, false)
10300
									&& !(this.options.camelCaseMatch && CharOperation.camelCaseMatch(token, typeBinding.sourceName))) continue next;
10301
							
10302
							int accessibility = IAccessRule.K_ACCESSIBLE;
10303
							if(typeBinding.hasRestrictedAccess()) {
10304
								AccessRestriction accessRestriction = this.lookupEnvironment.getAccessRestriction(typeBinding);
10305
								if(accessRestriction != null) {
10306
									switch (accessRestriction.getProblemId()) {
10307
										case IProblem.ForbiddenReference:
10308
											if (this.options.checkForbiddenReference) {
10309
												continue next;
10310
											}
10311
											accessibility = IAccessRule.K_NON_ACCESSIBLE;
10312
											break;
10313
										case IProblem.DiscouragedReference:
10314
											if (this.options.checkDiscouragedReference) {
10315
												continue next;
10316
											}
10317
											accessibility = IAccessRule.K_DISCOURAGED;
10318
											break;
10319
									}
10320
								}
10321
							}
10322
							
10323
							if (typesFound.contains(typeBinding)) continue next;
10324
							
10325
							typesFound.add(typeBinding);
10326
							
10327
							if(this.assistNodeIsClass) {
10328
								if(!typeBinding.isClass()) continue;
10329
							} else if(this.assistNodeIsInterface) {
10330
								if(!typeBinding.isInterface() && !typeBinding.isAnnotationType()) continue;
10331
							} else if (this.assistNodeIsAnnotation) {
10332
								if(!typeBinding.isAnnotationType()) continue;
10333
							}
10334
							
10335
							int relevance = computeBaseRelevance();
10336
							relevance += computeRelevanceForResolution();
10337
							relevance += computeRelevanceForInterestingProposal();
10338
							relevance += computeRelevanceForCaseMatching(token, typeBinding.sourceName);
10339
							relevance += computeRelevanceForExpectingType(typeBinding);
10340
							relevance += computeRelevanceForQualification(false);
10341
							relevance += computeRelevanceForRestrictions(accessibility);
10342
			
10343
							if (typeBinding.isAnnotationType()) {
10344
								relevance += computeRelevanceForAnnotation();
10345
								relevance += computeRelevanceForAnnotationTarget(typeBinding);
10346
							} else if (typeBinding.isInterface()) {
10347
								relevance += computeRelevanceForInterface();
10348
							} else if(typeBinding.isClass()){
10349
								relevance += computeRelevanceForClass();
10350
								relevance += computeRelevanceForException(typeBinding.sourceName);
10351
							}
10352
							
10353
							if (proposeType && hasStaticMemberTypes(typeBinding, scope.enclosingSourceType(), this.unitScope)) {
10354
								this.noProposal = false;
10355
								if(!this.requestor.isIgnored(CompletionProposal.TYPE_REF)) {
10356
									InternalCompletionProposal proposal =  createProposal(CompletionProposal.TYPE_REF, this.actualCompletionPosition);
10357
									proposal.setDeclarationSignature(typeBinding.qualifiedPackageName());
10358
									proposal.setSignature(getSignature(typeBinding));
10359
									proposal.setPackageName(typeBinding.qualifiedPackageName());
10360
									proposal.setTypeName(typeBinding.qualifiedSourceName());
10361
									proposal.setCompletion(typeBinding.sourceName());
10362
									proposal.setFlags(typeBinding.modifiers);
10363
									proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset);
10364
									proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset);
10365
									proposal.setRelevance(relevance);
10366
									this.requestor.accept(proposal);
10367
									if(DEBUG) {
10368
										this.printDebug(proposal);
10369
									}
10370
								}
10371
							}
10372
							
10373
							findConstructorsOrAnonymousTypes(
10374
									typeBinding,
10375
									scope,
10376
									FakeInvocationSite,
10377
									false,
10378
									relevance);
10379
						}
10380
					}
10381
				}
10382
			}
10383
		}
10384
	}
10385
	
9356
	private void findTypesFromStaticImports(char[] token, Scope scope, boolean proposeAllMemberTypes, ObjectVector typesFound) {
10386
	private void findTypesFromStaticImports(char[] token, Scope scope, boolean proposeAllMemberTypes, ObjectVector typesFound) {
9357
		ImportBinding[] importBindings = scope.compilationUnitScope().imports;
10387
		ImportBinding[] importBindings = scope.compilationUnitScope().imports;
9358
		for (int i = 0; i < importBindings.length; i++) {
10388
		for (int i = 0; i < importBindings.length; i++) {
Lines 10205-10210 Link Here
10205
11235
10206
		return this.favoriteReferenceBindings = resolvedImports;
11236
		return this.favoriteReferenceBindings = resolvedImports;
10207
	}
11237
	}
11238
	
11239
	private INameEnvironment getNoCacheNameEnvironment() {
11240
		if (this.noCacheNameEnvironment == null) {
11241
			this.noCacheNameEnvironment = new JavaSearchNameEnvironment(this.javaProject, this.owner == null ? null : JavaModelManager.getJavaModelManager().getWorkingCopies(this.owner, true/*add primary WCs*/));
11242
		}
11243
		return this.noCacheNameEnvironment;
11244
	}
10208
11245
10209
	public AssistParser getParser() {
11246
	public AssistParser getParser() {
10210
11247
Lines 10468-10473 Link Here
10468
			case CompletionProposal.TYPE_IMPORT :
11505
			case CompletionProposal.TYPE_IMPORT :
10469
				buffer.append("TYPE_IMPORT"); //$NON-NLS-1$
11506
				buffer.append("TYPE_IMPORT"); //$NON-NLS-1$
10470
				break;
11507
				break;
11508
			case CompletionProposal.CONSTRUCTOR_INVOCATION :
11509
				buffer.append("CONSTRUCTOR_INVOCATION"); //$NON-NLS-1$
11510
				break;
11511
			case CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION :
11512
				buffer.append("ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION"); //$NON-NLS-1$
11513
				break;
10471
			default :
11514
			default :
10472
				buffer.append("PROPOSAL"); //$NON-NLS-1$
11515
				buffer.append("PROPOSAL"); //$NON-NLS-1$
10473
				break;
11516
				break;
Lines 10539-10544 Link Here
10539
			buffer.append('\t');
11582
			buffer.append('\t');
10540
		}
11583
		}
10541
	}
11584
	}
11585
	
11586
	private void proposeConstructor(AcceptedConstructor deferredProposal, Scope scope) {
11587
		if (deferredProposal.proposeConstructor) {
11588
			proposeConstructor(
11589
					deferredProposal.simpleTypeName,
11590
					deferredProposal.parameterCount,
11591
					deferredProposal.signature,
11592
					deferredProposal.parameterTypes,
11593
					deferredProposal.parameterNames,
11594
					deferredProposal.modifiers,
11595
					deferredProposal.packageName,
11596
					deferredProposal.typeModifiers,
11597
					deferredProposal.accessibility,
11598
					deferredProposal.simpleTypeName,
11599
					deferredProposal.fullyQualifiedName,
11600
					deferredProposal.mustBeQualified,
11601
					scope,
11602
					deferredProposal.extraFlags);
11603
		}
11604
	}
11605
	
11606
	private void proposeConstructor(
11607
			char[] simpleTypeName,
11608
			int parameterCount,
11609
			char[] signature,
11610
			char[][] parameterTypes,
11611
			char[][] parameterNames,
11612
			int modifiers,
11613
			char[] packageName,
11614
			int typeModifiers,
11615
			int accessibility,
11616
			char[] typeName,
11617
			char[] fullyQualifiedName,
11618
			boolean isQualified,
11619
			Scope scope,
11620
			int extraFlags) {
11621
		char[] completionName = fullyQualifiedName;
11622
		if(isQualified) {
11623
			if (packageName == null || packageName.length == 0)
11624
				if (this.unitScope != null && this.unitScope.fPackage.compoundName != CharOperation.NO_CHAR_CHAR)
11625
					return; // ignore types from the default package from outside it
11626
		} else {
11627
			completionName = simpleTypeName;
11628
		}
11629
11630
		int relevance = computeBaseRelevance();
11631
		relevance += computeRelevanceForResolution();
11632
		relevance += computeRelevanceForInterestingProposal();
11633
		relevance += computeRelevanceForRestrictions(accessibility);
11634
		relevance += computeRelevanceForCaseMatching(this.completionToken, simpleTypeName);
11635
		relevance += computeRelevanceForExpectingType(packageName, simpleTypeName);
11636
		relevance += computeRelevanceForQualification(isQualified);
11637
11638
		boolean isInterface = false;
11639
		int kind = typeModifiers & (ClassFileConstants.AccInterface | ClassFileConstants.AccEnum | ClassFileConstants.AccAnnotation);
11640
		switch (kind) {
11641
			case ClassFileConstants.AccAnnotation:
11642
			case ClassFileConstants.AccAnnotation | ClassFileConstants.AccInterface:
11643
				relevance += computeRelevanceForAnnotation();
11644
				relevance += computeRelevanceForInterface();
11645
				isInterface = true;
11646
				break;
11647
			case ClassFileConstants.AccEnum:
11648
				relevance += computeRelevanceForEnum();
11649
				break;
11650
			case ClassFileConstants.AccInterface:
11651
				relevance += computeRelevanceForInterface();
11652
				isInterface = true;
11653
				break;
11654
			default:
11655
				relevance += computeRelevanceForClass();
11656
				relevance += computeRelevanceForException(simpleTypeName);
11657
				break;
11658
		}
11659
		
11660
		char[] completion;
11661
		if (this.source != null
11662
					&& this.source.length > this.endPosition
11663
					&& this.source[this.endPosition] == '(') {
11664
			completion = completionName;
11665
		} else {
11666
			completion = CharOperation.concat(completionName, new char[] { '(', ')' });
11667
		}
11668
		
11669
		switch (parameterCount) {
11670
			case -1: // default constructor
11671
				int flags = Flags.AccPublic;
11672
				if (Flags.isDeprecated(typeModifiers)) {
11673
					flags |= Flags.AccDeprecated;
11674
				}
11675
				
11676
				if (isInterface || (typeModifiers & ClassFileConstants.AccAbstract) != 0) {
11677
					this.noProposal = false;
11678
					if(!this.requestor.isIgnored(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION)) {
11679
						InternalCompletionProposal proposal = createProposal(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION, this.actualCompletionPosition);
11680
						proposal.setDeclarationSignature(createNonGenericTypeSignature(packageName, typeName));
11681
						proposal.setDeclarationKey(createBindingKey(packageName, typeName));
11682
						proposal.setSignature(DEFAULT_CONSTRUCTOR_SIGNATURE);
11683
						proposal.setDeclarationPackageName(packageName);
11684
						proposal.setDeclarationTypeName(typeName);
11685
						proposal.setParameterPackageNames(CharOperation.NO_CHAR_CHAR);
11686
						proposal.setParameterTypeNames(CharOperation.NO_CHAR_CHAR);
11687
						proposal.setName(simpleTypeName);
11688
						proposal.setIsContructor(true);
11689
						proposal.setCompletion(completion);
11690
						proposal.setFlags(flags);
11691
						proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset);
11692
						proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset);
11693
						proposal.setRelevance(relevance);
11694
						this.requestor.accept(proposal);
11695
						if(DEBUG) {
11696
							this.printDebug(proposal);
11697
						}
11698
					}
11699
				} else {
11700
					this.noProposal = false;
11701
					if(!this.requestor.isIgnored(CompletionProposal.CONSTRUCTOR_INVOCATION)) {
11702
						InternalCompletionProposal proposal =  createProposal(CompletionProposal.CONSTRUCTOR_INVOCATION, this.actualCompletionPosition);
11703
						proposal.setDeclarationSignature(createNonGenericTypeSignature(packageName, typeName));
11704
						proposal.setSignature(DEFAULT_CONSTRUCTOR_SIGNATURE);
11705
						proposal.setDeclarationPackageName(packageName);
11706
						proposal.setDeclarationTypeName(typeName);
11707
						proposal.setParameterPackageNames(CharOperation.NO_CHAR_CHAR);
11708
						proposal.setParameterTypeNames(CharOperation.NO_CHAR_CHAR);
11709
						proposal.setName(simpleTypeName);
11710
						proposal.setIsContructor(true);
11711
						proposal.setCompletion(completion);
11712
						proposal.setFlags(flags);
11713
						proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset);
11714
						proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset);
11715
						proposal.setRelevance(relevance);
11716
						this.requestor.accept(proposal);
11717
						if(DEBUG) {
11718
							this.printDebug(proposal);
11719
						}
11720
					}
11721
				}
11722
				break;
11723
			case 0: // constructor with no parameter
11724
				
11725
				if ((typeModifiers & ClassFileConstants.AccAbstract) != 0) {
11726
					this.noProposal = false;
11727
					if(!this.requestor.isIgnored(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION)) {
11728
						InternalCompletionProposal proposal = createProposal(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION, this.actualCompletionPosition);
11729
						proposal.setDeclarationSignature(createNonGenericTypeSignature(packageName, typeName));
11730
						proposal.setDeclarationKey(createBindingKey(packageName, typeName));
11731
						proposal.setSignature(DEFAULT_CONSTRUCTOR_SIGNATURE);
11732
						proposal.setDeclarationPackageName(packageName);
11733
						proposal.setDeclarationTypeName(typeName);
11734
						proposal.setParameterPackageNames(CharOperation.NO_CHAR_CHAR);
11735
						proposal.setParameterTypeNames(CharOperation.NO_CHAR_CHAR);
11736
						proposal.setName(simpleTypeName);
11737
						proposal.setIsContructor(true);
11738
						proposal.setCompletion(completion);
11739
						proposal.setFlags(modifiers);
11740
						proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset);
11741
						proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset);
11742
						proposal.setRelevance(relevance);
11743
						this.requestor.accept(proposal);
11744
						if(DEBUG) {
11745
							this.printDebug(proposal);
11746
						}
11747
					}
11748
				} else {
11749
					this.noProposal = false;
11750
					if(!this.requestor.isIgnored(CompletionProposal.CONSTRUCTOR_INVOCATION)) {
11751
						InternalCompletionProposal proposal =  createProposal(CompletionProposal.CONSTRUCTOR_INVOCATION, this.actualCompletionPosition);
11752
						proposal.setDeclarationSignature(createNonGenericTypeSignature(packageName, typeName));
11753
						proposal.setSignature(DEFAULT_CONSTRUCTOR_SIGNATURE);
11754
						proposal.setDeclarationPackageName(packageName);
11755
						proposal.setDeclarationTypeName(typeName);
11756
						proposal.setParameterPackageNames(CharOperation.NO_CHAR_CHAR);
11757
						proposal.setParameterTypeNames(CharOperation.NO_CHAR_CHAR);
11758
						proposal.setName(simpleTypeName);
11759
						proposal.setIsContructor(true);
11760
						proposal.setCompletion(completion);
11761
						proposal.setFlags(modifiers);
11762
						proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset);
11763
						proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset);
11764
						proposal.setRelevance(relevance);
11765
						this.requestor.accept(proposal);
11766
						if(DEBUG) {
11767
							this.printDebug(proposal);
11768
						}
11769
					}
11770
				}
11771
				break;
11772
			default: // constructor with parameter
11773
				if (signature == null) {
11774
					// resolve type to found parameter types
11775
					signature = getResolvedSignature(parameterTypes, fullyQualifiedName, parameterCount, scope);
11776
					if (signature == null) return;
11777
				} else {
11778
					signature = CharOperation.replaceOnCopy(signature, '/', '.');
11779
				}
11780
				
11781
				int parameterNamesLength = parameterNames == null ? 0 : parameterNames.length;
11782
				if (parameterCount != parameterNamesLength) {
11783
					parameterNames = createDefaultParameterNames(parameterCount);
11784
				}
11785
				
11786
				if ((typeModifiers & ClassFileConstants.AccAbstract) != 0) {
11787
					this.noProposal = false;
11788
					if(!this.requestor.isIgnored(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION)) {
11789
						InternalCompletionProposal proposal = createProposal(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION, this.actualCompletionPosition);
11790
						proposal.setDeclarationSignature(createNonGenericTypeSignature(packageName, typeName));
11791
						proposal.setDeclarationKey(createBindingKey(packageName, typeName));
11792
						proposal.setSignature(signature);
11793
						proposal.setDeclarationPackageName(packageName);
11794
						proposal.setDeclarationTypeName(typeName);
11795
						proposal.setParameterPackageNames(CharOperation.NO_CHAR_CHAR);
11796
						proposal.setParameterTypeNames(CharOperation.NO_CHAR_CHAR);
11797
						proposal.setParameterNames(parameterNames);
11798
						proposal.setName(simpleTypeName);
11799
						proposal.setIsContructor(true);
11800
						proposal.setCompletion(completion);
11801
						proposal.setFlags(modifiers);
11802
						proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset);
11803
						proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset);
11804
						proposal.setRelevance(relevance);
11805
						this.requestor.accept(proposal);
11806
						if(DEBUG) {
11807
							this.printDebug(proposal);
11808
						}
11809
					}
11810
				} else {
11811
					this.noProposal = false;
11812
					if(!this.requestor.isIgnored(CompletionProposal.CONSTRUCTOR_INVOCATION)) {
11813
						InternalCompletionProposal proposal =  createProposal(CompletionProposal.CONSTRUCTOR_INVOCATION, this.actualCompletionPosition);
11814
						proposal.setDeclarationSignature(createNonGenericTypeSignature(packageName, typeName));
11815
						proposal.setSignature(signature);
11816
						proposal.setDeclarationPackageName(packageName);
11817
						proposal.setDeclarationTypeName(typeName);
11818
						proposal.setParameterPackageNames(CharOperation.NO_CHAR_CHAR);
11819
						proposal.setParameterTypeNames(CharOperation.NO_CHAR_CHAR);
11820
						proposal.setParameterNames(parameterNames);
11821
						proposal.setName(simpleTypeName);
11822
						proposal.setIsContructor(true);
11823
						proposal.setCompletion(completion);
11824
						proposal.setFlags(modifiers);
11825
						proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset);
11826
						proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset);
11827
						proposal.setRelevance(relevance);
11828
						
11829
						this.requestor.accept(proposal);
11830
						if(DEBUG) {
11831
							this.printDebug(proposal);
11832
						}
11833
					}
11834
				}
11835
				break;
11836
		}
11837
	}
10542
11838
10543
	private void proposeNewMethod(char[] token, ReferenceBinding reference) {
11839
	private void proposeNewMethod(char[] token, ReferenceBinding reference) {
10544
		if(!this.requestor.isIgnored(CompletionProposal.POTENTIAL_METHOD_DECLARATION)) {
11840
		if(!this.requestor.isIgnored(CompletionProposal.POTENTIAL_METHOD_DECLARATION)) {
(-)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.
(-)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.
(-)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/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) 2008 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) 2008 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) 2008IBM 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/JavaSearchBugsTests.java (-1 / +150 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
			"1.5");
274
		refresh(p);
275
		
276
		ConstructorDeclarationsCollector requestor = new ConstructorDeclarationsCollector();
277
		searchAllConstructorDeclarations("AllConstructorDeclarations", SearchPattern.R_PREFIX_MATCH, requestor);
278
		assertSearchResults(
279
			"p6930.AllConstructorDeclarations04#AllConstructorDeclarations04(java.util.Collection<java.lang.Object> c)",
280
			requestor
281
		);
282
	} finally {
283
		deleteProject("P");
284
	}
285
}
286
287
public void testBug6930_AllConstructorDeclarations05() throws Exception {
288
	try {
289
		IJavaProject p = createJavaProject("P", new String[] {}, new String[] {"/P/lib6930.jar"}, "");
290
		
291
		createJar(new String[] {
292
			"p6930/AllConstructorDeclarations05.java",
293
			"package p6930;\n" +
294
			"public class AllConstructorDeclarations05 {\n" +
295
			"  public class AllConstructorDeclarations05b {\n" +
296
			"    public AllConstructorDeclarations05b(Object o) {}\n" +
297
			"  }\n" +
298
			"}"
299
		}, p.getProject().getLocation().append("lib6930.jar").toOSString());
300
		refresh(p);
301
		
302
		ConstructorDeclarationsCollector requestor = new ConstructorDeclarationsCollector();
303
		searchAllConstructorDeclarations("AllConstructorDeclarations", SearchPattern.R_PREFIX_MATCH, requestor);
304
		assertSearchResults(
305
			"p6930.AllConstructorDeclarations05#AllConstructorDeclarations05()",
306
			requestor
307
		);
308
	} finally {
309
		deleteProject("P");
310
	}
311
}
312
163
/**
313
/**
164
 * @bug 70827: [Search] wrong reference match to private method of supertype
314
 * @bug 70827: [Search] wrong reference match to private method of supertype
165
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=70827"
315
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=70827"
Lines 10273-10277 Link Here
10273
		deleteProject("P");
10423
		deleteProject("P");
10274
	}
10424
	}
10275
}
10425
}
10276
10277
}
10426
}
(-)src/org/eclipse/jdt/core/tests/model/CompletionTests2.java (+1616 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
				"1.5");
1211
		
1212
		refresh(p);
1213
		
1214
		waitUntilIndexesReady();
1215
		
1216
		this.workingCopies = new ICompilationUnit[2];
1217
		this.workingCopies[0] = getWorkingCopy(
1218
				"/P/src/test/Test.java",
1219
				"package test;\n"+
1220
				"public class Test {\n" +
1221
				"  void foo() {\n" +
1222
				"    new AllConstructors\n" +
1223
				"  }\n" +
1224
				"}");
1225
		
1226
		this.workingCopies[1] = getWorkingCopy(
1227
				"/P/src/p6930/AllConstructors15c.java",
1228
				"package p6930;"+
1229
				"public class AllConstructors15c<T> {\n" +
1230
				"}");
1231
1232
		// do completion
1233
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
1234
		requestor.setAllowsLongComputationProposals(true);
1235
1236
	    String str = this.workingCopies[0].getSource();
1237
	    String completeBehind = "AllConstructors";
1238
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1239
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
1240
	    
1241
	    assertResults(
1242
			"AllConstructors15a[CONSTRUCTOR_INVOCATION]{p6930.AllConstructors15a(), Lp6930.AllConstructors15a;, ()V, AllConstructors15a, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1243
			"AllConstructors15b[CONSTRUCTOR_INVOCATION]{p6930.AllConstructors15b(), Lp6930.AllConstructors15b;, ()V, AllConstructors15b, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1244
			"AllConstructors15c[CONSTRUCTOR_INVOCATION]{p6930.AllConstructors15c(), Lp6930.AllConstructors15c;, ()V, AllConstructors15c, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}",
1245
			requestor.getResults());
1246
	} finally {
1247
		deleteProject("P");
1248
	}
1249
}
1250
public void testBug6930_16() throws Exception {
1251
	try {
1252
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL15_LIB", "/P/lib6930.jar"}, "bin", "1.5");
1253
		
1254
		createFolder("/P/src/p6930");
1255
		
1256
		createFile(
1257
				"/P/src/p6930/AllConstructors16a.java",
1258
				"package p6930;\n" +
1259
				"public class AllConstructors16a{\n" +
1260
				"  public <T> AllConstructors16a(){}\n" +
1261
				"}");
1262
		
1263
		createJar(
1264
				new String[] {
1265
					"p6930/AllConstructors16b.java",
1266
					"package p6930;\n" +
1267
					"public class AllConstructors16b {\n" +
1268
					"  public <T> AllConstructors16b(){}\n" +
1269
					"}"
1270
				},
1271
				p.getProject().getLocation().append("lib6930.jar").toOSString(),
1272
				"1.5");
1273
		
1274
		refresh(p);
1275
		
1276
		waitUntilIndexesReady();
1277
		
1278
		this.workingCopies = new ICompilationUnit[2];
1279
		this.workingCopies[0] = getWorkingCopy(
1280
				"/P/src/test/Test.java",
1281
				"package test;\n"+
1282
				"public class Test {\n" +
1283
				"  void foo() {\n" +
1284
				"    new AllConstructors\n" +
1285
				"  }\n" +
1286
				"}");
1287
		
1288
		this.workingCopies[1] = getWorkingCopy(
1289
				"/P/src/p6930/AllConstructors16c.java",
1290
				"package p6930;"+
1291
				"public class AllConstructors16c {\n" +
1292
				"  public <T> AllConstructors16c(){}\n" +
1293
				"}");
1294
1295
		// do completion
1296
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
1297
		requestor.setAllowsLongComputationProposals(true);
1298
1299
	    String str = this.workingCopies[0].getSource();
1300
	    String completeBehind = "AllConstructors";
1301
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1302
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
1303
	    
1304
	    assertResults(
1305
			"AllConstructors16a[CONSTRUCTOR_INVOCATION]{p6930.AllConstructors16a(), Lp6930.AllConstructors16a;, ()V, AllConstructors16a, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1306
			"AllConstructors16b[CONSTRUCTOR_INVOCATION]{p6930.AllConstructors16b(), Lp6930.AllConstructors16b;, ()V, AllConstructors16b, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1307
			"AllConstructors16c[CONSTRUCTOR_INVOCATION]{p6930.AllConstructors16c(), Lp6930.AllConstructors16c;, ()V, AllConstructors16c, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}",
1308
			requestor.getResults());
1309
	} finally {
1310
		deleteProject("P");
1311
	}
1312
}
1313
public void testBug6930_17() throws Exception {
1314
	try {
1315
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL15_LIB", "/P/lib6930.jar"}, "bin", "1.5");
1316
		
1317
		createFolder("/P/src/p6930");
1318
		
1319
		createFile(
1320
				"/P/src/p6930/AllConstructors17a.java",
1321
				"package p6930;\n" +
1322
				"public class AllConstructors17a{\n" +
1323
				"  public AllConstructors17a(java.util.Collection<Object> o){}\n" +
1324
				"}");
1325
		
1326
		createJar(
1327
				new String[] {
1328
					"p6930/AllConstructors17b.java",
1329
					"package p6930;\n" +
1330
					"public class AllConstructors17b {\n" +
1331
					"  public AllConstructors17b(java.util.Collection<Object> o){}\n" +
1332
					"}"
1333
				},
1334
				p.getProject().getLocation().append("lib6930.jar").toOSString(),
1335
				"1.5");
1336
		
1337
		refresh(p);
1338
		
1339
		waitUntilIndexesReady();
1340
		
1341
		this.workingCopies = new ICompilationUnit[2];
1342
		this.workingCopies[0] = getWorkingCopy(
1343
				"/P/src/test/Test.java",
1344
				"package test;\n"+
1345
				"public class Test {\n" +
1346
				"  void foo() {\n" +
1347
				"    new AllConstructors\n" +
1348
				"  }\n" +
1349
				"}");
1350
		
1351
		this.workingCopies[1] = getWorkingCopy(
1352
				"/P/src/p6930/AllConstructors17c.java",
1353
				"package p6930;"+
1354
				"public class AllConstructors17c {\n" +
1355
				"  public AllConstructors17c(java.util.Collection<Object> o){}\n" +
1356
				"}");
1357
1358
		// do completion
1359
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
1360
		requestor.setAllowsLongComputationProposals(true);
1361
1362
	    String str = this.workingCopies[0].getSource();
1363
	    String completeBehind = "AllConstructors";
1364
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1365
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
1366
	    
1367
	    assertResults(
1368
			"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" +
1369
			"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" +
1370
			"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)+"}",
1371
			requestor.getResults());
1372
	} finally {
1373
		deleteProject("P");
1374
	}
1375
}
1376
public void testBug6930_18() throws Exception {
1377
	try {
1378
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL_LIB", "/P/lib6930.jar"}, "bin");
1379
		
1380
		createFolder("/P/src/p6930");
1381
		
1382
		createFile(
1383
				"/P/src/p6930/AllConstructors18a.java",
1384
				"package p6930;\n" +
1385
				"public interface AllConstructors18a {\n" +
1386
				"}");
1387
		
1388
		createJar(new String[] {
1389
			"p6930/AllConstructors18b.java",
1390
			"package p6930;\n" +
1391
			"public interface AllConstructors18b {\n" +
1392
			"}"
1393
		}, p.getProject().getLocation().append("lib6930.jar").toOSString());
1394
		
1395
		refresh(p);
1396
		
1397
		waitUntilIndexesReady();
1398
		
1399
		this.workingCopies = new ICompilationUnit[2];
1400
		this.workingCopies[0] = getWorkingCopy(
1401
				"/P/src/test/Test.java",
1402
				"package test;\n"+
1403
				"public class Test {\n" +
1404
				"  void foo() {\n" +
1405
				"    new AllConstructors\n" +
1406
				"  }\n" +
1407
				"}");
1408
		
1409
		this.workingCopies[1] = getWorkingCopy(
1410
				"/P/src/p6930/AllConstructors18c.java",
1411
				"package p6930;"+
1412
				"public interface AllConstructors18c {\n" +
1413
				"}");
1414
1415
		// do completion
1416
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
1417
		requestor.setAllowsLongComputationProposals(true);
1418
1419
	    String str = this.workingCopies[0].getSource();
1420
	    String completeBehind = "AllConstructors";
1421
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1422
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
1423
	    
1424
	    assertResults(
1425
			"AllConstructors18a[ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION]{p6930.AllConstructors18a(), Lp6930.AllConstructors18a;, ()V, AllConstructors18a, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1426
			"AllConstructors18b[ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION]{p6930.AllConstructors18b(), Lp6930.AllConstructors18b;, ()V, AllConstructors18b, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1427
			"AllConstructors18c[ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION]{p6930.AllConstructors18c(), Lp6930.AllConstructors18c;, ()V, AllConstructors18c, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}",
1428
			requestor.getResults());
1429
	} finally {
1430
		deleteProject("P");
1431
	}
1432
}
1433
public void testBug6930_19() throws Exception {
1434
	try {
1435
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL_LIB", "/P/lib6930.jar"}, "bin");
1436
		
1437
		createFolder("/P/src/p6930");
1438
		
1439
		createFile(
1440
				"/P/src/p6930/AllConstructors19a.java",
1441
				"package p6930;\n" +
1442
				"public interface AllConstructors19a {\n" +
1443
				"}");
1444
		
1445
		createJar(new String[] {
1446
			"p6930/AllConstructors19b.java",
1447
			"package p6930;\n" +
1448
			"public interface AllConstructors19b {\n" +
1449
			"}"
1450
		}, p.getProject().getLocation().append("lib6930.jar").toOSString());
1451
		
1452
		refresh(p);
1453
		
1454
		waitUntilIndexesReady();
1455
		
1456
		this.workingCopies = new ICompilationUnit[2];
1457
		this.workingCopies[0] = getWorkingCopy(
1458
				"/P/src/test/Test.java",
1459
				"package test;\n"+
1460
				"import p6930.AllConstructors19a;\n"+
1461
				"import p6930.AllConstructors19b;\n"+
1462
				"import p6930.AllConstructors19c;\n"+
1463
				"public class Test {\n" +
1464
				"  void foo() {\n" +
1465
				"    new AllConstructors\n" +
1466
				"  }\n" +
1467
				"}");
1468
		
1469
		this.workingCopies[1] = getWorkingCopy(
1470
				"/P/src/p6930/AllConstructors19c.java",
1471
				"package p6930;"+
1472
				"public interface AllConstructors19c {\n" +
1473
				"}");
1474
1475
		// do completion
1476
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
1477
		requestor.setAllowsLongComputationProposals(true);
1478
1479
	    String str = this.workingCopies[0].getSource();
1480
	    String completeBehind = "AllConstructors";
1481
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1482
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
1483
	    
1484
	    assertResults(
1485
			"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" +
1486
			"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" +
1487
			"AllConstructors19c[ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION]{AllConstructors19c(), Lp6930.AllConstructors19c;, ()V, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
1488
			requestor.getResults());
1489
	} finally {
1490
		deleteProject("P");
1491
	}
1492
}
1493
public void testBug6930_20() throws Exception {
1494
	try {
1495
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL15_LIB", "/P/lib6930.jar"}, "bin", "1.5");
1496
		
1497
		createFolder("/P/src/p6930");
1498
		
1499
		createFile(
1500
				"/P/src/p6930/AllConstructors20a.java",
1501
				"package p6930;\n" +
1502
				"public enum AllConstructors20a {\n" +
1503
				"	ZZZ;\n" +
1504
				"}");
1505
		
1506
		createJar(new String[] {
1507
			"p6930/AllConstructors20b.java",
1508
			"package p6930;\n" +
1509
			"public enum AllConstructors20b {\n" +
1510
			"	ZZZ;\n" +
1511
			"}"
1512
		}, p.getProject().getLocation().append("lib6930.jar").toOSString(), "1.5");
1513
		
1514
		refresh(p);
1515
		
1516
		waitUntilIndexesReady();
1517
		
1518
		this.workingCopies = new ICompilationUnit[2];
1519
		this.workingCopies[0] = getWorkingCopy(
1520
				"/P/src/test/Test.java",
1521
				"package test;\n"+
1522
				"public class Test {\n" +
1523
				"  void foo() {\n" +
1524
				"    new AllConstructors\n" +
1525
				"  }\n" +
1526
				"}");
1527
		
1528
		this.workingCopies[1] = getWorkingCopy(
1529
				"/P/src/p6930/AllConstructors20c.java",
1530
				"package p6930;"+
1531
				"public enum AllConstructors20c {\n" +
1532
				"	ZZZ;\n" +
1533
				"}");
1534
1535
		// do completion
1536
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
1537
		requestor.setAllowsLongComputationProposals(true);
1538
1539
	    String str = this.workingCopies[0].getSource();
1540
	    String completeBehind = "AllConstructors";
1541
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1542
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
1543
	    
1544
	    assertResults(
1545
			"",
1546
			requestor.getResults());
1547
	} finally {
1548
		deleteProject("P");
1549
	}
1550
}
1551
public void testBug6930_21() throws Exception {
1552
	try {
1553
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL15_LIB", "/P/lib6930.jar"}, "bin", "1.5");
1554
		
1555
		createFolder("/P/src/p6930");
1556
		
1557
		createFile(
1558
				"/P/src/p6930/AllConstructors21a.java",
1559
				"package p6930;\n" +
1560
				"public enum AllConstructors21a {\n" +
1561
				"	ZZZ;\n" +
1562
				"}");
1563
		
1564
		createJar(new String[] {
1565
			"p6930/AllConstructors21b.java",
1566
			"package p6930;\n" +
1567
			"public enum AllConstructors21b {\n" +
1568
			"	ZZZ;\n" +
1569
			"}"
1570
		}, p.getProject().getLocation().append("lib6930.jar").toOSString(), "1.5");
1571
		
1572
		refresh(p);
1573
		
1574
		waitUntilIndexesReady();
1575
		
1576
		this.workingCopies = new ICompilationUnit[2];
1577
		this.workingCopies[0] = getWorkingCopy(
1578
				"/P/src/test/Test.java",
1579
				"package test;\n"+
1580
				"import p6930.AllConstructors21a;\n"+
1581
				"import p6930.AllConstructors21b;\n"+
1582
				"import p6930.AllConstructors21c;\n"+
1583
				"public class Test {\n" +
1584
				"  void foo() {\n" +
1585
				"    new AllConstructors\n" +
1586
				"  }\n" +
1587
				"}");
1588
		
1589
		this.workingCopies[1] = getWorkingCopy(
1590
				"/P/src/p6930/AllConstructors21c.java",
1591
				"package p6930;"+
1592
				"public enum AllConstructors21c {\n" +
1593
				"	ZZZ;\n" +
1594
				"}");
1595
1596
		// do completion
1597
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
1598
		requestor.setAllowsLongComputationProposals(true);
1599
1600
	    String str = this.workingCopies[0].getSource();
1601
	    String completeBehind = "AllConstructors";
1602
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1603
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
1604
	    
1605
	    assertResults(
1606
			"",
1607
			requestor.getResults());
1608
	} finally {
1609
		deleteProject("P");
1610
	}
1611
}
1612
public void testBug6930_22() throws Exception {
1613
	Hashtable oldOptions = JavaCore.getOptions();
1614
	try {
1615
		Hashtable options = new Hashtable(oldOptions);
1616
		options.put(JavaCore.CODEASSIST_VISIBILITY_CHECK, JavaCore.ENABLED);
1617
		JavaCore.setOptions(options);
1618
		
1619
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL_LIB", "/P/lib6930.jar"}, "bin");
1620
		
1621
		createFolder("/P/src/p6930");
1622
		
1623
		createFile(
1624
				"/P/src/p6930/AllConstructors22a.java",
1625
				"package p6930;\n" +
1626
				"public class AllConstructors22a {\n" +
1627
				"	private AllConstructors22a(){}\n" +
1628
				"	public static class AllConstructorsInner{}\n" +
1629
				"}");
1630
		
1631
		createJar(new String[] {
1632
			"p6930/AllConstructors22b.java",
1633
			"package p6930;\n" +
1634
			"public class AllConstructors22b {\n" +
1635
			"	private AllConstructors22b(){}\n" +
1636
			"	public static class AllConstructorsInner{}\n" +
1637
			"}"
1638
		}, p.getProject().getLocation().append("lib6930.jar").toOSString());
1639
		
1640
		refresh(p);
1641
		
1642
		waitUntilIndexesReady();
1643
		
1644
		this.workingCopies = new ICompilationUnit[2];
1645
		this.workingCopies[0] = getWorkingCopy(
1646
				"/P/src/test/Test.java",
1647
				"package test;\n"+
1648
				"public class Test {\n" +
1649
				"  void foo() {\n" +
1650
				"    new AllConstructors\n" +
1651
				"  }\n" +
1652
				"}");
1653
		
1654
		this.workingCopies[1] = getWorkingCopy(
1655
				"/P/src/p6930/AllConstructors22c.java",
1656
				"package p6930;"+
1657
				"public class AllConstructors22c {\n" +
1658
				"	private AllConstructors22c(){}\n" +
1659
				"	public static class AllConstructorsInner{}\n" +
1660
				"}");
1661
1662
		// do completion
1663
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
1664
		requestor.setAllowsLongComputationProposals(true);
1665
1666
	    String str = this.workingCopies[0].getSource();
1667
	    String completeBehind = "AllConstructors";
1668
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1669
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
1670
	    
1671
	    assertResults(
1672
			"AllConstructors22a[TYPE_REF]{p6930.AllConstructors22a, p6930, Lp6930.AllConstructors22a;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1673
			"AllConstructors22b[TYPE_REF]{p6930.AllConstructors22b, p6930, Lp6930.AllConstructors22b;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1674
			"AllConstructors22c[TYPE_REF]{p6930.AllConstructors22c, p6930, Lp6930.AllConstructors22c;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}",
1675
			requestor.getResults());
1676
	} finally {
1677
		deleteProject("P");
1678
		
1679
		JavaCore.setOptions(oldOptions);
1680
	}
1681
}
1682
public void testBug6930_23() throws Exception {
1683
	Hashtable oldOptions = JavaCore.getOptions();
1684
	try {
1685
		Hashtable options = new Hashtable(oldOptions);
1686
		options.put(JavaCore.CODEASSIST_VISIBILITY_CHECK, JavaCore.ENABLED);
1687
		JavaCore.setOptions(options);
1688
		
1689
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL_LIB", "/P/lib6930.jar"}, "bin");
1690
		
1691
		createFolder("/P/src/p6930");
1692
		
1693
		createFile(
1694
				"/P/src/p6930/AllConstructors23a.java",
1695
				"package p6930;\n" +
1696
				"public class AllConstructors23a {\n" +
1697
				"	private AllConstructors23a(){}\n" +
1698
				"	public static class AllConstructorsInner{}\n" +
1699
				"}");
1700
		
1701
		createJar(new String[] {
1702
			"p6930/AllConstructors23b.java",
1703
			"package p6930;\n" +
1704
			"public class AllConstructors23b {\n" +
1705
			"	private AllConstructors23b(){}\n" +
1706
			"	public static class AllConstructorsInner{}\n" +
1707
			"}"
1708
		}, p.getProject().getLocation().append("lib6930.jar").toOSString());
1709
		
1710
		refresh(p);
1711
		
1712
		waitUntilIndexesReady();
1713
		
1714
		this.workingCopies = new ICompilationUnit[2];
1715
		this.workingCopies[0] = getWorkingCopy(
1716
				"/P/src/test/Test.java",
1717
				"package test;\n"+
1718
				"import p6930.AllConstructors23a;\n"+
1719
				"import p6930.AllConstructors23b;\n"+
1720
				"import p6930.AllConstructors23c;\n"+
1721
				"public class Test {\n" +
1722
				"  void foo() {\n" +
1723
				"    new AllConstructors\n" +
1724
				"  }\n" +
1725
				"}");
1726
		
1727
		this.workingCopies[1] = getWorkingCopy(
1728
				"/P/src/p6930/AllConstructors23c.java",
1729
				"package p6930;"+
1730
				"public class AllConstructors23c {\n" +
1731
				"	private AllConstructors23c(){}\n" +
1732
				"	public static class AllConstructorsInner{}\n" +
1733
				"}");
1734
1735
		// do completion
1736
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
1737
		requestor.setAllowsLongComputationProposals(true);
1738
1739
	    String str = this.workingCopies[0].getSource();
1740
	    String completeBehind = "AllConstructors";
1741
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1742
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
1743
	    
1744
	    assertResults(
1745
			"AllConstructors23a[TYPE_REF]{AllConstructors23a, p6930, Lp6930.AllConstructors23a;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
1746
			"AllConstructors23b[TYPE_REF]{AllConstructors23b, p6930, Lp6930.AllConstructors23b;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
1747
			"AllConstructors23c[TYPE_REF]{AllConstructors23c, p6930, Lp6930.AllConstructors23c;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
1748
			requestor.getResults());
1749
	} finally {
1750
		deleteProject("P");
1751
		
1752
		JavaCore.setOptions(oldOptions);
1753
	}
1754
}
1755
public void testBug6930_24() throws Exception {
1756
	Hashtable oldOptions = JavaCore.getOptions();
1757
	try {
1758
		Hashtable options = new Hashtable(oldOptions);
1759
		options.put(JavaCore.CODEASSIST_VISIBILITY_CHECK, JavaCore.ENABLED);
1760
		JavaCore.setOptions(options);
1761
		
1762
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL_LIB", "/P/lib6930.jar"}, "bin");
1763
		
1764
		createFolder("/P/src/p6930");
1765
		
1766
		createFile(
1767
				"/P/src/p6930/AllConstructors24a.java",
1768
				"package p6930;\n" +
1769
				"public class AllConstructors24a {\n" +
1770
				"	public AllConstructors24a(){}\n" +
1771
				"	private static class AllConstructorsInner{}\n" +
1772
				"}");
1773
		
1774
		createJar(new String[] {
1775
			"p6930/AllConstructors24b.java",
1776
			"package p6930;\n" +
1777
			"public class AllConstructors24b {\n" +
1778
			"	public AllConstructors24b(){}\n" +
1779
			"	private static class AllConstructorsInner{}\n" +
1780
			"}"
1781
		}, p.getProject().getLocation().append("lib6930.jar").toOSString());
1782
		
1783
		refresh(p);
1784
		
1785
		waitUntilIndexesReady();
1786
		
1787
		this.workingCopies = new ICompilationUnit[2];
1788
		this.workingCopies[0] = getWorkingCopy(
1789
				"/P/src/test/Test.java",
1790
				"package test;\n"+
1791
				"public class Test {\n" +
1792
				"  void foo() {\n" +
1793
				"    new AllConstructors\n" +
1794
				"  }\n" +
1795
				"}");
1796
		
1797
		this.workingCopies[1] = getWorkingCopy(
1798
				"/P/src/p6930/AllConstructors24c.java",
1799
				"package p6930;"+
1800
				"public class AllConstructors24c {\n" +
1801
				"	public AllConstructors24c(){}\n" +
1802
				"	private static class AllConstructorsInner{}\n" +
1803
				"}");
1804
1805
		// do completion
1806
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
1807
		requestor.setAllowsLongComputationProposals(true);
1808
1809
	    String str = this.workingCopies[0].getSource();
1810
	    String completeBehind = "AllConstructors";
1811
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1812
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
1813
	    
1814
	    assertResults(
1815
			"AllConstructors24a[CONSTRUCTOR_INVOCATION]{p6930.AllConstructors24a(), Lp6930.AllConstructors24a;, ()V, AllConstructors24a, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1816
			"AllConstructors24b[CONSTRUCTOR_INVOCATION]{p6930.AllConstructors24b(), Lp6930.AllConstructors24b;, ()V, AllConstructors24b, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1817
			"AllConstructors24c[CONSTRUCTOR_INVOCATION]{p6930.AllConstructors24c(), Lp6930.AllConstructors24c;, ()V, AllConstructors24c, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}",
1818
			requestor.getResults());
1819
	} finally {
1820
		deleteProject("P");
1821
		
1822
		JavaCore.setOptions(oldOptions);
1823
	}
1824
}
1825
public void testBug6930_25() throws Exception {
1826
	Hashtable oldOptions = JavaCore.getOptions();
1827
	try {
1828
		Hashtable options = new Hashtable(oldOptions);
1829
		options.put(JavaCore.CODEASSIST_VISIBILITY_CHECK, JavaCore.ENABLED);
1830
		JavaCore.setOptions(options);
1831
		
1832
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL_LIB", "/P/lib6930.jar"}, "bin");
1833
		
1834
		createFolder("/P/src/p6930");
1835
		
1836
		createFile(
1837
				"/P/src/p6930/AllConstructors25a.java",
1838
				"package p6930;\n" +
1839
				"public class AllConstructors25a {\n" +
1840
				"	public AllConstructors25a(){}\n" +
1841
				"	private static class AllConstructorsInner{}\n" +
1842
				"}");
1843
		
1844
		createJar(new String[] {
1845
			"p6930/AllConstructors25b.java",
1846
			"package p6930;\n" +
1847
			"public class AllConstructors25b {\n" +
1848
			"	public AllConstructors25b(){}\n" +
1849
			"	private static class AllConstructorsInner{}\n" +
1850
			"}"
1851
		}, p.getProject().getLocation().append("lib6930.jar").toOSString());
1852
		
1853
		refresh(p);
1854
		
1855
		waitUntilIndexesReady();
1856
		
1857
		this.workingCopies = new ICompilationUnit[2];
1858
		this.workingCopies[0] = getWorkingCopy(
1859
				"/P/src/test/Test.java",
1860
				"package test;\n"+
1861
				"import p6930.AllConstructors25a;\n"+
1862
				"import p6930.AllConstructors25b;\n"+
1863
				"import p6930.AllConstructors25c;\n"+
1864
				"public class Test {\n" +
1865
				"  void foo() {\n" +
1866
				"    new AllConstructors\n" +
1867
				"  }\n" +
1868
				"}");
1869
		
1870
		this.workingCopies[1] = getWorkingCopy(
1871
				"/P/src/p6930/AllConstructors25c.java",
1872
				"package p6930;"+
1873
				"public class AllConstructors25c {\n" +
1874
				"	public AllConstructors25c(){}\n" +
1875
				"	private static class AllConstructorsInner{}\n" +
1876
				"}");
1877
1878
		// do completion
1879
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
1880
		requestor.setAllowsLongComputationProposals(true);
1881
1882
	    String str = this.workingCopies[0].getSource();
1883
	    String completeBehind = "AllConstructors";
1884
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1885
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
1886
	    
1887
	    assertResults(
1888
			"AllConstructors25a[CONSTRUCTOR_INVOCATION]{AllConstructors25a(), Lp6930.AllConstructors25a;, ()V, AllConstructors25a, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
1889
			"AllConstructors25b[CONSTRUCTOR_INVOCATION]{AllConstructors25b(), Lp6930.AllConstructors25b;, ()V, AllConstructors25b, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
1890
			"AllConstructors25c[CONSTRUCTOR_INVOCATION]{AllConstructors25c(), Lp6930.AllConstructors25c;, ()V, AllConstructors25c, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
1891
			requestor.getResults());
1892
	} finally {
1893
		deleteProject("P");
1894
		
1895
		JavaCore.setOptions(oldOptions);
1896
	}
1897
}
1898
public void testBug6930_26() throws Exception {
1899
	try {
1900
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL_LIB"}, "bin");
1901
		
1902
		refresh(p);
1903
		
1904
		waitUntilIndexesReady();
1905
		
1906
		this.workingCopies = new ICompilationUnit[2];
1907
		this.workingCopies[0] = getWorkingCopy(
1908
				"/P/src/test/Test.java",
1909
				"package test;\n"+
1910
				"public class Test {\n" +
1911
				"  void foo(p6930.AllConstructors26a var) {\n" +
1912
				"    var.new AllConstructors\n" +
1913
				"  }\n" +
1914
				"}");
1915
		
1916
		this.workingCopies[1] = getWorkingCopy(
1917
				"/P/src/p6930/AllConstructors26a.java",
1918
				"package p6930;"+
1919
				"public class AllConstructors26a {\n" +
1920
				"	public class AllConstructors26b {\n" +
1921
				"	  public AllConstructors26b(int i) {}\n" +
1922
				"	}\n" +
1923
				"}");
1924
1925
		// do completion
1926
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
1927
		requestor.setAllowsLongComputationProposals(true);
1928
1929
	    String str = this.workingCopies[0].getSource();
1930
	    String completeBehind = "AllConstructors";
1931
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1932
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
1933
	    
1934
	    assertResults(
1935
			"AllConstructors26b[CONSTRUCTOR_INVOCATION]{AllConstructors26b(), Lp6930.AllConstructors26a$AllConstructors26b;, (I)V, AllConstructors26b, (i), "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
1936
			requestor.getResults());
1937
	} finally {
1938
		deleteProject("P");
1939
	}
1940
}
1941
public void testBug6930_27() throws Exception {
1942
	try {
1943
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL_LIB"}, "bin");
1944
		
1945
		refresh(p);
1946
		
1947
		waitUntilIndexesReady();
1948
		
1949
		this.workingCopies = new ICompilationUnit[2];
1950
		this.workingCopies[0] = getWorkingCopy(
1951
				"/P/src/test/Test.java",
1952
				"package test;\n"+
1953
				"public class Test {\n" +
1954
				"  void foo() {\n" +
1955
				"    new p6930.AllConstructors27a.AllConstructors\n" +
1956
				"  }\n" +
1957
				"}");
1958
		
1959
		this.workingCopies[1] = getWorkingCopy(
1960
				"/P/src/p6930/AllConstructors27a.java",
1961
				"package p6930;"+
1962
				"public class AllConstructors27a {\n" +
1963
				"	public static class AllConstructors27b {\n" +
1964
				"	  public AllConstructors27b(int i) {}\n" +
1965
				"	}\n" +
1966
				"}");
1967
1968
		// do completion
1969
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
1970
		requestor.setAllowsLongComputationProposals(true);
1971
1972
	    String str = this.workingCopies[0].getSource();
1973
	    String completeBehind = "AllConstructors";
1974
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1975
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
1976
	    
1977
	    assertResults(
1978
			"AllConstructors27b[CONSTRUCTOR_INVOCATION]{AllConstructors27b(), Lp6930.AllConstructors27a$AllConstructors27b;, (I)V, AllConstructors27b, (i), "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}",
1979
			requestor.getResults());
1980
	} finally {
1981
		deleteProject("P");
1982
	}
1983
}
1984
public void testBug6930_28() throws Exception {
1985
	try {
1986
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL_LIB"}, "bin");
1987
		
1988
		refresh(p);
1989
		
1990
		waitUntilIndexesReady();
1991
		
1992
		this.workingCopies = new ICompilationUnit[3];
1993
		this.workingCopies[0] = getWorkingCopy(
1994
				"/P/src/p6930/Test.java",
1995
				"package p6930;\n"+
1996
				"class AllConstructors28a {\n" +
1997
				"	public AllConstructors28a(int i) {}\n" +
1998
				"}\n" +
1999
				"public class Test {\n" +
2000
				"  void foo() {\n" +
2001
				"    new p6930.AllConstructors\n" +
2002
				"  }\n" +
2003
				"}");
2004
		
2005
		this.workingCopies[1] = getWorkingCopy(
2006
				"/P/src/p6930/AllConstructors28b.java",
2007
				"package p6930;"+
2008
				"public class AllConstructors28b {\n" +
2009
				"	public AllConstructors28b(int i) {}\n" +
2010
				"}");
2011
		
2012
		this.workingCopies[2] = getWorkingCopy(
2013
				"/P/src/p6930b/AllConstructors28c.java",
2014
				"package p6930b;"+
2015
				"public class AllConstructors28c {\n" +
2016
				"	public AllConstructors28c(int i) {}\n" +
2017
				"}");
2018
2019
		// do completion
2020
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
2021
		requestor.setAllowsLongComputationProposals(true);
2022
2023
	    String str = this.workingCopies[0].getSource();
2024
	    String completeBehind = "AllConstructors";
2025
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2026
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
2027
	    
2028
	    assertResults(
2029
			"AllConstructors28a[CONSTRUCTOR_INVOCATION]{AllConstructors28a(), Lp6930.AllConstructors28a;, (I)V, AllConstructors28a, (i), "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
2030
			"AllConstructors28b[CONSTRUCTOR_INVOCATION]{AllConstructors28b(), Lp6930.AllConstructors28b;, (I)V, AllConstructors28b, (i), "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}",
2031
			requestor.getResults());
2032
	} finally {
2033
		deleteProject("P");
2034
	}
2035
}
420
public void testBug79288() throws Exception {
2036
public void testBug79288() throws Exception {
421
	try {
2037
	try {
422
		// create variable
2038
		// create variable
(-)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 compliance) throws IOException {
1133
		org.eclipse.jdt.core.tests.util.Util.createJar(javaPathsAndContents, jarPath, compliance);
1134
	}
1131
1135
1132
	/*
1136
	/*
1133
	}
1137
	}

Return to bug 6930