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

Collapse All | Expand All

(-)codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java (-1 / +23 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 572-577 Link Here
572
		}
572
		}
573
	}
573
	}
574
}
574
}
575
public Object becomeSimpleParser() {
576
	CompletionScanner completionScanner = (CompletionScanner)this.scanner;
577
	int[] parserState = new int[] {this.cursorLocation, completionScanner.cursorLocation};
578
	
579
	this.cursorLocation = Integer.MAX_VALUE;
580
	completionScanner.cursorLocation = Integer.MAX_VALUE;
581
	
582
	return parserState;
583
}
575
private void buildMoreAnnotationCompletionContext(MemberValuePair memberValuePair) {
584
private void buildMoreAnnotationCompletionContext(MemberValuePair memberValuePair) {
576
	if(this.identifierPtr < 0 || this.identifierLengthPtr < 0 ) return;
585
	if(this.identifierPtr < 0 || this.identifierLengthPtr < 0 ) return;
577
586
Lines 1208-1213 Link Here
1208
			}
1217
			}
1209
			if(type instanceof CompletionOnSingleTypeReference) {
1218
			if(type instanceof CompletionOnSingleTypeReference) {
1210
				((CompletionOnSingleTypeReference)type).isConstructorType = true;
1219
				((CompletionOnSingleTypeReference)type).isConstructorType = true;
1220
			} else if (type instanceof CompletionOnQualifiedTypeReference) {
1221
				((CompletionOnQualifiedTypeReference)type).isConstructorType = true;
1211
			}
1222
			}
1212
			allocExpr.type = type;
1223
			allocExpr.type = type;
1213
			allocExpr.sourceStart = type.sourceStart;
1224
			allocExpr.sourceStart = type.sourceStart;
Lines 1227-1232 Link Here
1227
			} else {
1238
			} else {
1228
				type = getTypeReference(0);
1239
				type = getTypeReference(0);
1229
			}
1240
			}
1241
			if(type instanceof CompletionOnSingleTypeReference) {
1242
				((CompletionOnSingleTypeReference)type).isConstructorType = true;
1243
			}
1230
			allocExpr.type = type;
1244
			allocExpr.type = type;
1231
			allocExpr.enclosingInstance = this.expressionStack[this.qualifier];
1245
			allocExpr.enclosingInstance = this.expressionStack[this.qualifier];
1232
			allocExpr.sourceStart = this.intStack[this.intPtr--];
1246
			allocExpr.sourceStart = this.intStack[this.intPtr--];
Lines 4539-4544 Link Here
4539
	this.cursorLocation = 0;
4553
	this.cursorLocation = 0;
4540
	flushAssistState();
4554
	flushAssistState();
4541
}
4555
}
4556
public void restoreAssistParser(Object parserState) {
4557
	int[] state = (int[]) parserState;
4558
	
4559
	CompletionScanner completionScanner = (CompletionScanner)this.scanner;
4560
	
4561
	this.cursorLocation = state[0];
4562
	completionScanner.cursorLocation = state[1];
4563
}
4542
/*
4564
/*
4543
 * Reset context so as to resume to regular parse loop
4565
 * Reset context so as to resume to regular parse loop
4544
 * If unable to reset for resuming, answers false.
4566
 * If unable to reset for resuming, answers false.
(-)codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnQualifiedTypeReference.java (-1 / +4 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
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/index/DiskIndex.java (-2 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2007 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
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
(-)model/org/eclipse/jdt/internal/compiler/SourceElementNotifier.java (-8 / +16 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
2
 * Copyright (c) 2008, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 54-59 Link Here
54
	 * An ast visitor that visits local type declarations.
54
	 * An ast visitor that visits local type declarations.
55
	 */
55
	 */
56
	public class LocalDeclarationVisitor extends ASTVisitor {
56
	public class LocalDeclarationVisitor extends ASTVisitor {
57
		public ImportReference currentPackage;
57
		ArrayList declaringTypes;
58
		ArrayList declaringTypes;
58
		public void pushDeclaringType(TypeDeclaration declaringType) {
59
		public void pushDeclaringType(TypeDeclaration declaringType) {
59
			if (this.declaringTypes == null) {
60
			if (this.declaringTypes == null) {
Lines 71-81 Link Here
71
			return (TypeDeclaration) this.declaringTypes.get(size-1);
72
			return (TypeDeclaration) this.declaringTypes.get(size-1);
72
		}
73
		}
73
		public boolean visit(TypeDeclaration typeDeclaration, BlockScope scope) {
74
		public boolean visit(TypeDeclaration typeDeclaration, BlockScope scope) {
74
			notifySourceElementRequestor(typeDeclaration, true, peekDeclaringType());
75
			notifySourceElementRequestor(typeDeclaration, true, peekDeclaringType(), this.currentPackage);
75
			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(...)
76
		}
77
		}
77
		public boolean visit(TypeDeclaration typeDeclaration, ClassScope scope) {
78
		public boolean visit(TypeDeclaration typeDeclaration, ClassScope scope) {
78
			notifySourceElementRequestor(typeDeclaration, true, peekDeclaringType());
79
			notifySourceElementRequestor(typeDeclaration, true, peekDeclaringType(), this.currentPackage);
79
			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(...)
80
		}
81
		}
81
	}
82
	}
Lines 215-221 Link Here
215
/*
216
/*
216
 * Update the bodyStart of the corresponding parse node
217
 * Update the bodyStart of the corresponding parse node
217
 */
218
 */
218
protected void notifySourceElementRequestor(AbstractMethodDeclaration methodDeclaration) {
219
protected void notifySourceElementRequestor(AbstractMethodDeclaration methodDeclaration, TypeDeclaration declaringType, ImportReference currentPackage) {
219
220
220
	// range check
221
	// range check
221
	boolean isInRange =
222
	boolean isInRange =
Lines 288-293 Link Here
288
			methodInfo.typeParameters = getTypeParameterInfos(methodDeclaration.typeParameters());
289
			methodInfo.typeParameters = getTypeParameterInfos(methodDeclaration.typeParameters());
289
			methodInfo.categories = (char[][]) this.nodesToCategories.get(methodDeclaration);
290
			methodInfo.categories = (char[][]) this.nodesToCategories.get(methodDeclaration);
290
			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);
291
			methodInfo.node = methodDeclaration;
295
			methodInfo.node = methodDeclaration;
292
			this.requestor.enterConstructor(methodInfo);
296
			this.requestor.enterConstructor(methodInfo);
293
		}
297
		}
Lines 394-399 Link Here
394
			this.requestor.enterCompilationUnit();
398
			this.requestor.enterCompilationUnit();
395
		}
399
		}
396
		ImportReference currentPackage = parsedUnit.currentPackage;
400
		ImportReference currentPackage = parsedUnit.currentPackage;
401
		if (this.localDeclarationVisitor !=  null) {
402
			this.localDeclarationVisitor.currentPackage = currentPackage;
403
		}
397
		ImportReference[] imports = parsedUnit.imports;
404
		ImportReference[] imports = parsedUnit.imports;
398
		TypeDeclaration[] types = parsedUnit.types;
405
		TypeDeclaration[] types = parsedUnit.types;
399
		length =
406
		length =
Lines 429-435 Link Here
429
						notifySourceElementRequestor(importRef, false);
436
						notifySourceElementRequestor(importRef, false);
430
					}
437
					}
431
				} else { // instanceof TypeDeclaration
438
				} else { // instanceof TypeDeclaration
432
					notifySourceElementRequestor((TypeDeclaration)node, true, null);
439
					notifySourceElementRequestor((TypeDeclaration)node, true, null, currentPackage);
433
				}
440
				}
434
			}
441
			}
435
		}
442
		}
Lines 544-550 Link Here
544
			importReference.modifiers);
551
			importReference.modifiers);
545
	}
552
	}
546
}
553
}
547
protected void notifySourceElementRequestor(TypeDeclaration typeDeclaration, boolean notifyTypePresence, TypeDeclaration declaringType) {
554
protected void notifySourceElementRequestor(TypeDeclaration typeDeclaration, boolean notifyTypePresence, TypeDeclaration declaringType, ImportReference currentPackage) {
548
555
549
	if (CharOperation.equals(TypeConstants.PACKAGE_INFO_NAME, typeDeclaration.name)) return;
556
	if (CharOperation.equals(TypeConstants.PACKAGE_INFO_NAME, typeDeclaration.name)) return;
550
557
Lines 600-605 Link Here
600
			typeInfo.secondary = typeDeclaration.isSecondary();
607
			typeInfo.secondary = typeDeclaration.isSecondary();
601
			typeInfo.anonymousMember = typeDeclaration.allocation != null && typeDeclaration.allocation.enclosingInstance != null;
608
			typeInfo.anonymousMember = typeDeclaration.allocation != null && typeDeclaration.allocation.enclosingInstance != null;
602
			typeInfo.annotations = typeDeclaration.annotations;
609
			typeInfo.annotations = typeDeclaration.annotations;
610
			typeInfo.extraFlags = ExtraFlags.getExtraFlags(typeDeclaration);
603
			typeInfo.node = typeDeclaration;
611
			typeInfo.node = typeDeclaration;
604
			this.requestor.enterType(typeInfo);
612
			this.requestor.enterType(typeInfo);
605
			switch (kind) {
613
			switch (kind) {
Lines 663-673 Link Here
663
				break;
671
				break;
664
			case 1 :
672
			case 1 :
665
				methodIndex++;
673
				methodIndex++;
666
				notifySourceElementRequestor(nextMethodDeclaration);
674
				notifySourceElementRequestor(nextMethodDeclaration, typeDeclaration, currentPackage);
667
				break;
675
				break;
668
			case 2 :
676
			case 2 :
669
				memberTypeIndex++;
677
				memberTypeIndex++;
670
				notifySourceElementRequestor(nextMemberDeclaration, true, null);
678
				notifySourceElementRequestor(nextMemberDeclaration, true, null, currentPackage);
671
		}
679
		}
672
	}
680
	}
673
	if (notifyTypePresence){
681
	if (notifyTypePresence){
(-)model/org/eclipse/jdt/internal/compiler/ISourceElementRequestor.java (-1 / +5 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 59-64 Link Here
59
		public boolean secondary;
59
		public boolean secondary;
60
		public boolean anonymousMember;
60
		public boolean anonymousMember;
61
		public Annotation[] annotations;
61
		public Annotation[] annotations;
62
		public int extraFlags;
62
		public TypeDeclaration node;
63
		public TypeDeclaration node;
63
		public HashMap childrenCategories = new HashMap();
64
		public HashMap childrenCategories = new HashMap();
64
	}
65
	}
Lines 87-92 Link Here
87
		public TypeParameterInfo[] typeParameters;
88
		public TypeParameterInfo[] typeParameters;
88
		public char[][] categories;
89
		public char[][] categories;
89
		public Annotation[] annotations;
90
		public Annotation[] annotations;
91
		public char[] declaringPackageName;
92
		public int declaringTypeModifiers;
93
		public int extraFlags;
90
		public AbstractMethodDeclaration node;
94
		public AbstractMethodDeclaration node;
91
	}
95
	}
92
96
(-)search/org/eclipse/jdt/internal/core/search/indexing/SourceIndexerRequestor.java (-2 / +48 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
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/AbstractIndexer.java (-5 / +32 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2007 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 71-80 Link Here
71
			typeName = CharOperation.subarray(typeName, 0, genericStart);
71
			typeName = CharOperation.subarray(typeName, 0, genericStart);
72
		return typeName;
72
		return typeName;
73
	}
73
	}
74
	public void addConstructorDeclaration(char[] typeName, char[][] parameterTypes, char[][] exceptionTypes) {
74
	public void addConstructorDeclaration(
75
		int argCount = parameterTypes == null ? 0 : parameterTypes.length;
75
			char[] typeName,
76
		addIndexEntry(CONSTRUCTOR_DECL, ConstructorPattern.createIndexKey(CharOperation.lastSegment(typeName,'.'), argCount));
76
			int argCount,
77
77
			char[] signature,
78
			char[][] parameterTypes,
79
			char[][] parameterNames,
80
			int modifiers,
81
			char[] packageName,
82
			int typeModifiers,
83
			char[][] exceptionTypes,
84
			int extraFlags) {
85
		addIndexEntry(
86
				CONSTRUCTOR_DECL,
87
				ConstructorPattern.createDeclarationIndexKey(
88
						typeName,
89
						argCount,
90
						signature,
91
						parameterTypes,
92
						parameterNames,
93
						modifiers,
94
						packageName,
95
						typeModifiers,
96
						extraFlags));
97
		
78
		if (parameterTypes != null) {
98
		if (parameterTypes != null) {
79
			for (int i = 0; i < argCount; i++)
99
			for (int i = 0; i < argCount; i++)
80
				addTypeReference(parameterTypes[i]);
100
				addTypeReference(parameterTypes[i]);
Lines 91-96 Link Here
91
		if (innermostTypeName != simpleTypeName)
111
		if (innermostTypeName != simpleTypeName)
92
			addIndexEntry(CONSTRUCTOR_REF, ConstructorPattern.createIndexKey(innermostTypeName, argCount));
112
			addIndexEntry(CONSTRUCTOR_REF, ConstructorPattern.createIndexKey(innermostTypeName, argCount));
93
	}
113
	}
114
	public void addDefaultConstructorDeclaration(
115
			char[] typeName,
116
			char[] packageName,
117
			int typeModifiers,
118
			int extraFlags) {
119
		addIndexEntry(CONSTRUCTOR_DECL, ConstructorPattern.createDefaultDeclarationIndexKey(CharOperation.lastSegment(typeName,'.'), packageName, typeModifiers, extraFlags));
120
	}
94
	public void addEnumDeclaration(int modifiers, char[] packageName, char[] name, char[][] enclosingTypeNames, char[] superclass, char[][] superinterfaces, boolean secondary) {
121
	public void addEnumDeclaration(int modifiers, char[] packageName, char[] name, char[][] enclosingTypeNames, char[] superclass, char[][] superinterfaces, boolean secondary) {
95
		addTypeDeclaration(modifiers, packageName, name, enclosingTypeNames, secondary);
122
		addTypeDeclaration(modifiers, packageName, name, enclosingTypeNames, secondary);
96
123
(-)search/org/eclipse/jdt/internal/core/search/indexing/IIndexConstants.java (-1 / +3 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 29-34 Link Here
29
		new char[][] { new char[] {'/', '0'}, new char[] {'/', '1'}, new char[] {'/', '2'}, new char[] {'/', '3'}, new char[] {'/', '4'},
29
		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'}
30
			new char[] {'/', '5'}, new char[] {'/', '6'}, new char[] {'/', '7'}, new char[] {'/', '8'}, new char[] {'/', '9'}
31
	};
31
	};
32
	char[] DEFAULT_CONSTRUCTOR = new char[]{'/', '#'};
32
	char CLASS_SUFFIX = 'C';
33
	char CLASS_SUFFIX = 'C';
33
	char INTERFACE_SUFFIX = 'I';
34
	char INTERFACE_SUFFIX = 'I';
34
	char ENUM_SUFFIX = 'E';
35
	char ENUM_SUFFIX = 'E';
Lines 38-43 Link Here
38
	char CLASS_AND_INTERFACE_SUFFIX = IJavaSearchConstants.CLASS_AND_INTERFACE;
39
	char CLASS_AND_INTERFACE_SUFFIX = IJavaSearchConstants.CLASS_AND_INTERFACE;
39
	char INTERFACE_AND_ANNOTATION_SUFFIX = IJavaSearchConstants.INTERFACE_AND_ANNOTATION;
40
	char INTERFACE_AND_ANNOTATION_SUFFIX = IJavaSearchConstants.INTERFACE_AND_ANNOTATION;
40
	char SEPARATOR= '/';
41
	char SEPARATOR= '/';
42
	char PARAMETER_SEPARATOR= ',';
41
	char SECONDARY_SUFFIX = 'S';
43
	char SECONDARY_SUFFIX = 'S';
42
44
43
	char[] ONE_STAR = new char[] {'*'};
45
	char[] ONE_STAR = new char[] {'*'};
(-)search/org/eclipse/jdt/internal/core/search/indexing/BinaryIndexer.java (-2 / +45 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2007 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 14-19 Link Here
14
import org.eclipse.jdt.core.Signature;
14
import org.eclipse.jdt.core.Signature;
15
import org.eclipse.jdt.core.compiler.CharOperation;
15
import org.eclipse.jdt.core.compiler.CharOperation;
16
import org.eclipse.jdt.core.search.SearchDocument;
16
import org.eclipse.jdt.core.search.SearchDocument;
17
import org.eclipse.jdt.internal.compiler.ExtraFlags;
17
import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
18
import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
18
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
19
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
19
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader;
20
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader;
Lines 700-708 Link Here
700
			if (tagBits != 0) {
701
			if (tagBits != 0) {
701
				addBinaryStandardAnnotations(tagBits);
702
				addBinaryStandardAnnotations(tagBits);
702
			}
703
			}
704
			
705
			int extraFlags = ExtraFlags.getExtraFlags(reader);
703
706
704
			// first reference all methods declarations and field declarations
707
			// first reference all methods declarations and field declarations
705
			MethodInfo[] methods = (MethodInfo[]) reader.getMethods();
708
			MethodInfo[] methods = (MethodInfo[]) reader.getMethods();
709
			boolean noConstructor = true;
706
			if (methods != null) {
710
			if (methods != null) {
707
				for (int i = 0, max = methods.length; i < max; i++) {
711
				for (int i = 0, max = methods.length; i < max; i++) {
708
					MethodInfo method = methods[i];
712
					MethodInfo method = methods[i];
Lines 712-718 Link Here
712
					char[] returnType = decodeReturnType(descriptor);
716
					char[] returnType = decodeReturnType(descriptor);
713
					char[][] exceptionTypes = replace('/', '.', method.getExceptionTypeNames());
717
					char[][] exceptionTypes = replace('/', '.', method.getExceptionTypeNames());
714
					if (isConstructor) {
718
					if (isConstructor) {
715
						addConstructorDeclaration(className, parameterTypes, exceptionTypes);
719
						noConstructor = false;
720
						char[] signature = method.getGenericSignature();
721
						if (signature == null) {
722
							if (reader.isNestedType() && ((modifiers & ClassFileConstants.AccStatic) == 0)) {
723
								signature = removeFirstSyntheticParameter(descriptor);
724
							} else {
725
								signature = descriptor;
726
							}
727
						}
728
						addConstructorDeclaration(
729
								name,
730
								parameterTypes == null ? 0 : parameterTypes.length,
731
								signature,	
732
								parameterTypes,
733
								method.getArgumentNames(),
734
								method.getModifiers(),
735
								packageName,
736
								modifiers,
737
								exceptionTypes,
738
								extraFlags);
716
					} else {
739
					} else {
717
						if (!method.isClinit()) {
740
						if (!method.isClinit()) {
718
							addMethodDeclaration(method.getSelector(), parameterTypes, returnType, exceptionTypes);
741
							addMethodDeclaration(method.getSelector(), parameterTypes, returnType, exceptionTypes);
Lines 732-737 Link Here
732
					}
755
					}
733
				}
756
				}
734
			}
757
			}
758
			if (noConstructor) {
759
				addDefaultConstructorDeclaration(className, packageName, modifiers, extraFlags);
760
			}
735
			FieldInfo[] fields = (FieldInfo[]) reader.getFields();
761
			FieldInfo[] fields = (FieldInfo[]) reader.getFields();
736
			if (fields != null) {
762
			if (fields != null) {
737
				for (int i = 0, max = fields.length; i < max; i++) {
763
				for (int i = 0, max = fields.length; i < max; i++) {
Lines 767-772 Link Here
767
			Util.log(IStatus.WARNING, "The Java indexing could not index " + this.document.getPath() + ". This .class file doesn't follow the class file format specification. Please report this issue against the .class file vendor"); //$NON-NLS-1$ //$NON-NLS-2$
793
			Util.log(IStatus.WARNING, "The Java indexing could not index " + this.document.getPath() + ". This .class file doesn't follow the class file format specification. Please report this issue against the .class file vendor"); //$NON-NLS-1$ //$NON-NLS-2$
768
		}
794
		}
769
	}
795
	}
796
	
797
	private char[] removeFirstSyntheticParameter(char[] descriptor) {
798
		if (descriptor == null) return null;
799
		if (descriptor.length < 3) return descriptor;
800
		if (descriptor[0] != '(') return descriptor;
801
		if (descriptor[1] != ')') {
802
			// remove the first synthetic parameter
803
			int start = Util.scanTypeSignature(descriptor, 1) + 1;
804
			int length = descriptor.length - start;
805
			char[] signature = new char[length + 1];
806
			signature[0] = descriptor[0];
807
			System.arraycopy(descriptor, start, signature, 1, length);
808
			return signature;
809
		} else {
810
			return descriptor;
811
		}
812
	}
770
	/*
813
	/*
771
	 * Modify the array by replacing all occurences of toBeReplaced with newChar
814
	 * Modify the array by replacing all occurences of toBeReplaced with newChar
772
	 */
815
	 */
(-)codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java (-276 / +1695 lines)
Lines 40-45 Link Here
40
import org.eclipse.jdt.internal.codeassist.impl.Keywords;
40
import org.eclipse.jdt.internal.codeassist.impl.Keywords;
41
import org.eclipse.jdt.internal.compiler.CompilationResult;
41
import org.eclipse.jdt.internal.compiler.CompilationResult;
42
import org.eclipse.jdt.internal.compiler.DefaultErrorHandlingPolicies;
42
import org.eclipse.jdt.internal.compiler.DefaultErrorHandlingPolicies;
43
import org.eclipse.jdt.internal.compiler.ExtraFlags;
43
import org.eclipse.jdt.internal.compiler.ast.*;
44
import org.eclipse.jdt.internal.compiler.ast.*;
44
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
45
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
45
import org.eclipse.jdt.internal.compiler.env.*;
46
import org.eclipse.jdt.internal.compiler.env.*;
Lines 60-71 Link Here
60
import org.eclipse.jdt.internal.core.BasicCompilationUnit;
61
import org.eclipse.jdt.internal.core.BasicCompilationUnit;
61
import org.eclipse.jdt.internal.core.INamingRequestor;
62
import org.eclipse.jdt.internal.core.INamingRequestor;
62
import org.eclipse.jdt.internal.core.InternalNamingConventions;
63
import org.eclipse.jdt.internal.core.InternalNamingConventions;
64
import org.eclipse.jdt.internal.core.JavaModelManager;
63
import org.eclipse.jdt.internal.core.SourceMethod;
65
import org.eclipse.jdt.internal.core.SourceMethod;
64
import org.eclipse.jdt.internal.core.SourceMethodElementInfo;
66
import org.eclipse.jdt.internal.core.SourceMethodElementInfo;
65
import org.eclipse.jdt.internal.core.SourceType;
67
import org.eclipse.jdt.internal.core.SourceType;
66
import org.eclipse.jdt.internal.core.BinaryTypeConverter;
68
import org.eclipse.jdt.internal.core.BinaryTypeConverter;
67
import org.eclipse.jdt.internal.core.SearchableEnvironment;
69
import org.eclipse.jdt.internal.core.SearchableEnvironment;
68
import org.eclipse.jdt.internal.core.SourceTypeElementInfo;
70
import org.eclipse.jdt.internal.core.SourceTypeElementInfo;
71
import org.eclipse.jdt.internal.core.search.matching.JavaSearchNameEnvironment;
69
import org.eclipse.jdt.internal.core.util.Messages;
72
import org.eclipse.jdt.internal.core.util.Messages;
70
73
71
/**
74
/**
Lines 77-82 Link Here
77
	extends Engine
80
	extends Engine
78
	implements ISearchRequestor, TypeConstants , TerminalTokens , RelevanceConstants, SuffixConstants {
81
	implements ISearchRequestor, TypeConstants , TerminalTokens , RelevanceConstants, SuffixConstants {
79
	
82
	
83
	private static class AcceptedConstructor {
84
		public int modifiers;
85
		public char[] simpleTypeName;
86
		public int parameterCount;
87
		public char[] signature;
88
		public char[][] parameterTypes;
89
		public char[][] parameterNames;
90
		public int typeModifiers;
91
		public char[] packageName;
92
		public int extraFlags;
93
		public int accessibility;
94
		public boolean proposeType = false;
95
		public boolean proposeConstructor = false;
96
		public char[] fullyQualifiedName = null;
97
		
98
		public boolean mustBeQualified = false;
99
		
100
		public AcceptedConstructor(
101
				int modifiers,
102
				char[] simpleTypeName,
103
				int parameterCount,
104
				char[] signature,
105
				char[][] parameterTypes,
106
				char[][] parameterNames,
107
				int typeModifiers,
108
				char[] packageName,
109
				int extraFlags,
110
				int accessibility) {
111
			this.modifiers = modifiers;
112
			this.simpleTypeName = simpleTypeName;
113
			this.parameterCount = parameterCount;
114
			this.signature = signature;
115
			this.parameterTypes = parameterTypes;
116
			this.parameterNames = parameterNames;
117
			this.typeModifiers = typeModifiers;
118
			this.packageName = packageName;
119
			this.extraFlags = extraFlags;
120
			this.accessibility = accessibility;
121
		}
122
123
		public String toString() {
124
			StringBuffer buffer = new StringBuffer();
125
			buffer.append('{');
126
			buffer.append(this.packageName);
127
			buffer.append(',');
128
			buffer.append(this.simpleTypeName);
129
			buffer.append('}');
130
			return buffer.toString();
131
		}
132
	}
133
	
80
	private static class AcceptedType {
134
	private static class AcceptedType {
81
		public char[] packageName;
135
		public char[] packageName;
82
		public char[] simpleTypeName;
136
		public char[] simpleTypeName;
Lines 226-232 Link Here
226
			this.checkProblems = false;
280
			this.checkProblems = false;
227
		}
281
		}
228
	}
282
	}
283
	
284
	public static char[] createBindingKey(char[] packageName, char[] typeName) {
285
		char[] signature = createTypeSignature(packageName, typeName);
286
		CharOperation.replace(signature, '.', '/');
287
		return signature;
288
	}
229
289
290
	public static char[][] createDefaultParameterNames(int length) {
291
		char[][] parameters;
292
		switch (length) {
293
			case 0 :
294
				parameters = new char[length][];
295
				break;
296
			case 1 :
297
				parameters = ARGS1;
298
				break;
299
			case 2 :
300
				parameters = ARGS2;
301
				break;
302
			case 3 :
303
				parameters = ARGS3;
304
				break;
305
			case 4 :
306
				parameters = ARGS4;
307
				break;
308
			default :
309
				parameters = new char[length][];
310
				for (int i = 0; i < length; i++) {
311
					parameters[i] = CharOperation.concat(ARG, String.valueOf(i).toCharArray());
312
				}
313
				break;
314
		}
315
		return parameters;
316
	}
230
	public static char[] createMethodSignature(char[][] parameterPackageNames, char[][] parameterTypeNames, char[] returnTypeSignature) {
317
	public static char[] createMethodSignature(char[][] parameterPackageNames, char[][] parameterTypeNames, char[] returnTypeSignature) {
231
		char[][] parameterTypeSignature = new char[parameterTypeNames.length][];
318
		char[][] parameterTypeSignature = new char[parameterTypeNames.length][];
232
		for (int i = 0; i < parameterTypeSignature.length; i++) {
319
		for (int i = 0; i < parameterTypeSignature.length; i++) {
Lines 302-313 Link Here
302
		result = CharOperation.replaceOnCopy(result, '/', '.');
389
		result = CharOperation.replaceOnCopy(result, '/', '.');
303
		return result;
390
		return result;
304
	}
391
	}
392
	
393
	private static boolean hasStaticMemberTypes(ReferenceBinding typeBinding, SourceTypeBinding invocationType, CompilationUnitScope unitScope) {
394
		ReferenceBinding[] memberTypes = typeBinding.memberTypes();
395
		int length = memberTypes == null ? 0 : memberTypes.length;
396
		next : for (int i = 0; i < length; i++) {
397
			ReferenceBinding memberType = memberTypes[i];
398
			if (invocationType != null && !memberType.canBeSeenBy(typeBinding, invocationType)) {
399
				continue next;
400
			} else if(invocationType == null && !memberType.canBeSeenBy(unitScope.fPackage)) {
401
				continue next;
402
			}
403
			
404
			if ((memberType.modifiers & ClassFileConstants.AccStatic) != 0) {
405
				return true;
406
			}
407
		}
408
		return false;
409
	}
305
	public HashtableOfObject typeCache;
410
	public HashtableOfObject typeCache;
411
	public int openedBinaryTypes; // used during InternalCompletionProposal#findConstructorParameterNames()
306
	
412
	
307
	public static boolean DEBUG = false;
413
	public static boolean DEBUG = false;
308
	public static boolean PERF = false;
414
	public static boolean PERF = false;
309
	
415
	
310
	private final static int CHECK_CANCEL_FREQUENCY_IN_FIND_TYPES = 50;
416
	private static final char[] KNOWN_TYPE_WITH_UNKNOWN_CONSTRUCTORS = new char[]{};
417
	private static final char[] KNOWN_TYPE_WITH_KNOWN_CONSTRUCTORS = new char[]{};
418
	
419
	private static final char[] ARG = "arg".toCharArray();  //$NON-NLS-1$
420
	private static final char[] ARG0 = "arg0".toCharArray();  //$NON-NLS-1$
421
	private static final char[] ARG1 = "arg1".toCharArray();  //$NON-NLS-1$
422
	private static final char[] ARG2 = "arg2".toCharArray();  //$NON-NLS-1$
423
	private static final char[] ARG3 = "arg3".toCharArray();  //$NON-NLS-1$
424
	private static final char[][] ARGS1 = new char[][]{ARG0};
425
	private static final char[][] ARGS2 = new char[][]{ARG0, ARG1};
426
	private static final char[][] ARGS3 = new char[][]{ARG0, ARG1, ARG2};
427
	private static final char[][] ARGS4 = new char[][]{ARG0, ARG1, ARG2, ARG3};
428
	
429
	private final static int CHECK_CANCEL_FREQUENCY = 50;
311
	
430
	
312
	// temporary constants to quickly disabled polish features if necessary
431
	// temporary constants to quickly disabled polish features if necessary
313
	public final static boolean NO_TYPE_COMPLETION_ON_EMPTY_TOKEN = false;
432
	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$
442
	private final static char[] VALUE = "value".toCharArray();  //$NON-NLS-1$
324
	private final static char[] EXTENDS = "extends".toCharArray();  //$NON-NLS-1$
443
	private final static char[] EXTENDS = "extends".toCharArray();  //$NON-NLS-1$
325
	private final static char[] SUPER = "super".toCharArray();  //$NON-NLS-1$
444
	private final static char[] SUPER = "super".toCharArray();  //$NON-NLS-1$
445
	private final static char[] DEFAULT_CONSTRUCTOR_SIGNATURE = "()V".toCharArray();  //$NON-NLS-1$
326
	
446
	
327
	private final static char[] DOT = ".".toCharArray();  //$NON-NLS-1$
447
	private final static char[] DOT = ".".toCharArray();  //$NON-NLS-1$
328
448
Lines 374-379 Link Here
374
	CompletionRequestor requestor;
494
	CompletionRequestor requestor;
375
	CompletionProblemFactory problemFactory;
495
	CompletionProblemFactory problemFactory;
376
	ProblemReporter problemReporter;
496
	ProblemReporter problemReporter;
497
	private JavaSearchNameEnvironment noCacheNameEnvironment;
377
	char[] source;
498
	char[] source;
378
	char[] completionToken;
499
	char[] completionToken;
379
	char[] qualifiedCompletionToken;
500
	char[] qualifiedCompletionToken;
Lines 459-464 Link Here
459
580
460
	private int foundTypesCount;
581
	private int foundTypesCount;
461
	private ObjectVector acceptedTypes;
582
	private ObjectVector acceptedTypes;
583
	
584
	private int foundConstructorsCount;
585
	private ObjectVector acceptedConstructors;
462
586
463
	/**
587
	/**
464
	 * The CompletionEngine is responsible for computing source completions.
588
	 * The CompletionEngine is responsible for computing source completions.
Lines 489-494 Link Here
489
		this.requestor = requestor;
613
		this.requestor = requestor;
490
		this.nameEnvironment = nameEnvironment;
614
		this.nameEnvironment = nameEnvironment;
491
		this.typeCache = new HashtableOfObject(5);
615
		this.typeCache = new HashtableOfObject(5);
616
		this.openedBinaryTypes = 0;
492
617
493
		this.problemFactory = new CompletionProblemFactory(Locale.getDefault());
618
		this.problemFactory = new CompletionProblemFactory(Locale.getDefault());
494
		this.problemReporter = new ProblemReporter(
619
		this.problemReporter = new ProblemReporter(
Lines 511-516 Link Here
511
		this.owner = owner;
636
		this.owner = owner;
512
		this.monitor = monitor;
637
		this.monitor = monitor;
513
	}
638
	}
639
	
640
	public void acceptConstructor(
641
			int modifiers,
642
			char[] simpleTypeName,
643
			int parameterCount,
644
			char[] signature,
645
			char[][] parameterTypes,
646
			char[][] parameterNames,
647
			int typeModifiers,
648
			char[] packageName,
649
			int extraFlags,
650
			String path,
651
			AccessRestriction accessRestriction) {
652
		
653
		// does not check cancellation for every types to avoid performance loss
654
		if ((this.foundConstructorsCount % (CHECK_CANCEL_FREQUENCY)) == 0) checkCancel();
655
		this.foundConstructorsCount++;
656
		
657
		if ((typeModifiers & ClassFileConstants.AccEnum) != 0) return;
658
		
659
		if (this.options.checkDeprecation && (typeModifiers & ClassFileConstants.AccDeprecated) != 0) return;
660
661
		if (this.options.checkVisibility) {
662
			if((typeModifiers & ClassFileConstants.AccPublic) == 0) {
663
				if((typeModifiers & ClassFileConstants.AccPrivate) != 0) return;
664
665
				if (this.currentPackageName == null) {
666
					initializePackageCache();
667
				}
668
				
669
				if(!CharOperation.equals(packageName, this.currentPackageName)) return;
670
			}
671
		}
672
673
		int accessibility = IAccessRule.K_ACCESSIBLE;
674
		if(accessRestriction != null) {
675
			switch (accessRestriction.getProblemId()) {
676
				case IProblem.ForbiddenReference:
677
					if (this.options.checkForbiddenReference) {
678
						return;
679
					}
680
					accessibility = IAccessRule.K_NON_ACCESSIBLE;
681
					break;
682
				case IProblem.DiscouragedReference:
683
					if (this.options.checkDiscouragedReference) {
684
						return;
685
					}
686
					accessibility = IAccessRule.K_DISCOURAGED;
687
					break;
688
			}
689
		}
690
		
691
		if(this.acceptedConstructors == null) {
692
			this.acceptedConstructors = new ObjectVector();
693
		}
694
		this.acceptedConstructors.add(
695
				new AcceptedConstructor(
696
						modifiers,
697
						simpleTypeName,
698
						parameterCount,
699
						signature,
700
						parameterTypes,
701
						parameterNames,
702
						typeModifiers,
703
						packageName,
704
						extraFlags,
705
						accessibility));
706
	}
707
	
708
	private void acceptConstructors(Scope scope) {
709
		final boolean DEFER_QUALIFIED_PROPOSALS = false;
710
		
711
		this.checkCancel();
712
		
713
		if(this.acceptedConstructors == null) return;
714
715
		int length = this.acceptedConstructors.size();
716
717
		if(length == 0) return;
718
		
719
		HashtableOfObject onDemandFound = new HashtableOfObject();
720
		
721
		ArrayList deferredProposals = new ArrayList();
722
		
723
		try {
724
			next : for (int i = 0; i < length; i++) {
725
				
726
				// does not check cancellation for every types to avoid performance loss
727
				if ((i % CHECK_CANCEL_FREQUENCY) == 0) checkCancel();
728
				
729
				AcceptedConstructor acceptedConstructor = (AcceptedConstructor)this.acceptedConstructors.elementAt(i);
730
				final int typeModifiers = acceptedConstructor.typeModifiers;
731
				final char[] packageName = acceptedConstructor.packageName;
732
				final char[] simpleTypeName = acceptedConstructor.simpleTypeName;
733
				final int modifiers = acceptedConstructor.modifiers;
734
				final int parameterCount = acceptedConstructor.parameterCount;
735
				final char[] signature = acceptedConstructor.signature;
736
				final char[][] parameterTypes = acceptedConstructor.parameterTypes;
737
				final char[][] parameterNames = acceptedConstructor.parameterNames;
738
				final int extraFlags = acceptedConstructor.extraFlags;
739
				final int accessibility = acceptedConstructor.accessibility;
740
				
741
				boolean proposeType = (extraFlags & ExtraFlags.HasNonPrivateStaticMemberTypes) != 0;
742
				
743
				char[] fullyQualifiedName = CharOperation.concat(packageName, simpleTypeName, '.');
744
						
745
				Object knownTypeKind = this.knownTypes.get(fullyQualifiedName);
746
				if (knownTypeKind != null) {
747
					if (knownTypeKind == KNOWN_TYPE_WITH_KNOWN_CONSTRUCTORS) {
748
						// the type and its constructors are already accepted
749
						continue next;
750
					}
751
					// this type is already accepted
752
					proposeType = false;
753
				} else {
754
					this.knownTypes.put(fullyQualifiedName, KNOWN_TYPE_WITH_UNKNOWN_CONSTRUCTORS);
755
				}
756
				
757
				boolean proposeConstructor = true;
758
					
759
				if (this.options.checkVisibility) {
760
					if((modifiers & ClassFileConstants.AccPublic) == 0) {
761
						if((modifiers & ClassFileConstants.AccPrivate) != 0) {
762
							if (!proposeType) continue next;
763
							proposeConstructor = false;
764
						} else {
765
							if (this.currentPackageName == null) {
766
								initializePackageCache();
767
							}
768
							
769
							if(!CharOperation.equals(packageName, this.currentPackageName)) {
770
								if (!proposeType) continue next;
771
								proposeConstructor = false;
772
							}
773
						}
774
					}
775
				}
776
				
777
				acceptedConstructor.fullyQualifiedName = fullyQualifiedName;
778
				acceptedConstructor.proposeType = proposeType;
779
				acceptedConstructor.proposeConstructor = proposeConstructor;
780
				
781
				
782
				if(!this.importCachesInitialized) {
783
					initializeImportCaches();
784
				}
785
				
786
				for (int j = 0; j < this.importCacheCount; j++) {
787
					char[][] importName = this.importsCache[j];
788
					if(CharOperation.equals(simpleTypeName, importName[0])) {
789
						if (proposeType) {
790
							proposeType(
791
									packageName,
792
									simpleTypeName,
793
									typeModifiers,
794
									accessibility,
795
									simpleTypeName,
796
									fullyQualifiedName,
797
									!CharOperation.equals(fullyQualifiedName, importName[1]),
798
									scope);
799
						}
800
						
801
						if (proposeConstructor && !Flags.isEnum(typeModifiers)) {
802
							boolean isQualified = !CharOperation.equals(fullyQualifiedName, importName[1]);
803
							if (!isQualified) {
804
								proposeConstructor(
805
										simpleTypeName,
806
										parameterCount,
807
										signature,
808
										parameterTypes,
809
										parameterNames,
810
										modifiers,
811
										packageName,
812
										typeModifiers,
813
										accessibility,
814
										simpleTypeName,
815
										fullyQualifiedName,
816
										isQualified,
817
										scope,
818
										extraFlags);
819
							} else {
820
								acceptedConstructor.mustBeQualified = true;
821
								if (DEFER_QUALIFIED_PROPOSALS) {
822
									deferredProposals.add(acceptedConstructor);
823
								} else {
824
									proposeConstructor(acceptedConstructor, scope);
825
								}
826
							}
827
						}
828
						continue next;
829
					}
830
				}
831
832
833
				if (CharOperation.equals(this.currentPackageName, packageName)) {
834
					if (proposeType) {
835
						proposeType(
836
								packageName,
837
								simpleTypeName,
838
								typeModifiers,
839
								accessibility,
840
								simpleTypeName,
841
								fullyQualifiedName,
842
								false,
843
								scope);
844
					}
845
					
846
					if (proposeConstructor && !Flags.isEnum(typeModifiers)) {
847
						proposeConstructor(
848
								simpleTypeName,
849
								parameterCount,
850
								signature,
851
								parameterTypes,
852
								parameterNames,
853
								modifiers,
854
								packageName,
855
								typeModifiers,
856
								accessibility,
857
								simpleTypeName,
858
								fullyQualifiedName,
859
								false,
860
								scope,
861
								extraFlags);
862
					}
863
					continue next;
864
				} else {
865
					char[] fullyQualifiedEnclosingTypeOrPackageName = null;
866
867
					AcceptedConstructor foundConstructor = null;
868
					if((foundConstructor = (AcceptedConstructor)onDemandFound.get(simpleTypeName)) == null) {
869
						for (int j = 0; j < this.onDemandImportCacheCount; j++) {
870
							ImportBinding importBinding = this.onDemandImportsCache[j];
871
872
							char[][] importName = importBinding.compoundName;
873
							char[] importFlatName = CharOperation.concatWith(importName, '.');
874
875
							if(fullyQualifiedEnclosingTypeOrPackageName == null) {
876
								fullyQualifiedEnclosingTypeOrPackageName = packageName;
877
							}
878
							if(CharOperation.equals(fullyQualifiedEnclosingTypeOrPackageName, importFlatName)) {
879
								if(importBinding.isStatic()) {
880
									if((typeModifiers & ClassFileConstants.AccStatic) != 0) {
881
										onDemandFound.put(
882
												simpleTypeName,
883
												acceptedConstructor);
884
										continue next;
885
									}
886
								} else {
887
									onDemandFound.put(
888
											simpleTypeName,
889
											acceptedConstructor);
890
									continue next;
891
								}
892
							}
893
						}
894
					} else if(!foundConstructor.mustBeQualified){
895
						done : for (int j = 0; j < this.onDemandImportCacheCount; j++) {
896
							ImportBinding importBinding = this.onDemandImportsCache[j];
897
898
							char[][] importName = importBinding.compoundName;
899
							char[] importFlatName = CharOperation.concatWith(importName, '.');
900
901
							if(fullyQualifiedEnclosingTypeOrPackageName == null) {
902
								fullyQualifiedEnclosingTypeOrPackageName = packageName;
903
							}
904
							if(CharOperation.equals(fullyQualifiedEnclosingTypeOrPackageName, importFlatName)) {
905
								if(importBinding.isStatic()) {
906
									if((typeModifiers & ClassFileConstants.AccStatic) != 0) {
907
										foundConstructor.mustBeQualified = true;
908
										break done;
909
									}
910
								} else {
911
									foundConstructor.mustBeQualified = true;
912
									break done;
913
								}
914
							}
915
						}
916
					}
917
					if (proposeType) {
918
						proposeType(
919
								packageName,
920
								simpleTypeName,
921
								typeModifiers,
922
								accessibility,
923
								simpleTypeName,
924
								fullyQualifiedName,
925
								true,
926
								scope);
927
					}
928
					
929
					if (proposeConstructor && !Flags.isEnum(typeModifiers)) {
930
						acceptedConstructor.mustBeQualified = true;
931
						if (DEFER_QUALIFIED_PROPOSALS) {
932
							deferredProposals.add(acceptedConstructor);
933
						} else {
934
							proposeConstructor(acceptedConstructor, scope);
935
						}
936
					}
937
				}
938
			}
939
		
940
			char[][] keys = onDemandFound.keyTable;
941
			Object[] values = onDemandFound.valueTable;
942
			int max = keys.length;
943
			for (int i = 0; i < max; i++) {
944
				
945
				// does not check cancellation for every types to avoid performance loss
946
				if ((i % CHECK_CANCEL_FREQUENCY) == 0) checkCancel();
947
				
948
				if(keys[i] != null) {
949
					AcceptedConstructor value = (AcceptedConstructor) values[i];
950
					if(value != null) {
951
						if (value.proposeType) {
952
							proposeType(
953
									value.packageName,
954
									value.simpleTypeName,
955
									value.typeModifiers,
956
									value.accessibility,
957
									value.simpleTypeName,
958
									value.fullyQualifiedName,
959
									value.mustBeQualified,
960
									scope);
961
						}
962
						
963
						if (value.proposeConstructor && !Flags.isEnum(value.modifiers)) {
964
							if (!value.mustBeQualified) {
965
								proposeConstructor(
966
										value.simpleTypeName,
967
										value.parameterCount,
968
										value.signature,
969
										value.parameterTypes,
970
										value.parameterNames,
971
										value.modifiers,
972
										value.packageName,
973
										value.typeModifiers,
974
										value.accessibility,
975
										value.simpleTypeName,
976
										value.fullyQualifiedName,
977
										value.mustBeQualified,
978
										scope,
979
										value.extraFlags);
980
							} else {
981
								if (DEFER_QUALIFIED_PROPOSALS) {
982
									deferredProposals.add(value);
983
								} else {
984
									proposeConstructor(value, scope);
985
								}
986
							}
987
						}
988
					}
989
				}
990
			}
991
			
992
			if (DEFER_QUALIFIED_PROPOSALS) {
993
				int size = deferredProposals.size();
994
				for (int i = 0; i < size; i++) {
995
					
996
					// does not check cancellation for every types to avoid performance loss
997
					if ((i % CHECK_CANCEL_FREQUENCY) == 0) checkCancel();
998
				
999
					AcceptedConstructor deferredProposal = (AcceptedConstructor)deferredProposals.get(i);
1000
					
1001
					if (deferredProposal.proposeConstructor) {
1002
						proposeConstructor(
1003
								deferredProposal.simpleTypeName,
1004
								deferredProposal.parameterCount,
1005
								deferredProposal.signature,
1006
								deferredProposal.parameterTypes,
1007
								deferredProposal.parameterNames,
1008
								deferredProposal.modifiers,
1009
								deferredProposal.packageName,
1010
								deferredProposal.typeModifiers,
1011
								deferredProposal.accessibility,
1012
								deferredProposal.simpleTypeName,
1013
								deferredProposal.fullyQualifiedName,
1014
								deferredProposal.mustBeQualified,
1015
								scope,
1016
								deferredProposal.extraFlags);
1017
					}
1018
				}
1019
			}
1020
		} finally {
1021
			this.acceptedTypes = null; // reset
1022
		}
1023
	}
514
1024
515
	/**
1025
	/**
516
	 * One result of the search consists of a new package.
1026
	 * One result of the search consists of a new package.
Lines 577-583 Link Here
577
		AccessRestriction accessRestriction) {
1087
		AccessRestriction accessRestriction) {
578
		
1088
		
579
		// does not check cancellation for every types to avoid performance loss
1089
		// does not check cancellation for every types to avoid performance loss
580
		if ((this.foundTypesCount % CHECK_CANCEL_FREQUENCY_IN_FIND_TYPES) == 0) checkCancel();
1090
		if ((this.foundTypesCount % CHECK_CANCEL_FREQUENCY) == 0) checkCancel();
581
		this.foundTypesCount++;
1091
		this.foundTypesCount++;
582
		
1092
		
583
		if (this.options.checkDeprecation && (modifiers & ClassFileConstants.AccDeprecated) != 0) return;
1093
		if (this.options.checkDeprecation && (modifiers & ClassFileConstants.AccDeprecated) != 0) return;
Lines 630-636 Link Here
630
			next : for (int i = 0; i < length; i++) {
1140
			next : for (int i = 0; i < length; i++) {
631
				
1141
				
632
				// does not check cancellation for every types to avoid performance loss
1142
				// does not check cancellation for every types to avoid performance loss
633
				if ((i % CHECK_CANCEL_FREQUENCY_IN_FIND_TYPES) == 0) checkCancel();
1143
				if ((i % CHECK_CANCEL_FREQUENCY) == 0) checkCancel();
634
				
1144
				
635
				AcceptedType acceptedType = (AcceptedType)this.acceptedTypes.elementAt(i);
1145
				AcceptedType acceptedType = (AcceptedType)this.acceptedTypes.elementAt(i);
636
				char[] packageName = acceptedType.packageName;
1146
				char[] packageName = acceptedType.packageName;
Lines 652-658 Link Here
652
	
1162
	
653
				if (this.knownTypes.containsKey(fullyQualifiedName)) continue next;
1163
				if (this.knownTypes.containsKey(fullyQualifiedName)) continue next;
654
	
1164
	
655
				this.knownTypes.put(fullyQualifiedName, this);
1165
				this.knownTypes.put(fullyQualifiedName, KNOWN_TYPE_WITH_UNKNOWN_CONSTRUCTORS);
656
	
1166
	
657
				if (this.resolvingImports) {
1167
				if (this.resolvingImports) {
658
					if(this.compilerOptions.complianceLevel >= ClassFileConstants.JDK1_4 && packageName.length == 0) {
1168
					if(this.compilerOptions.complianceLevel >= ClassFileConstants.JDK1_4 && packageName.length == 0) {
Lines 808-813 Link Here
808
			Object[] values = onDemandFound.valueTable;
1318
			Object[] values = onDemandFound.valueTable;
809
			int max = keys.length;
1319
			int max = keys.length;
810
			for (int i = 0; i < max; i++) {
1320
			for (int i = 0; i < max; i++) {
1321
				if ((i % CHECK_CANCEL_FREQUENCY) == 0) checkCancel();
811
				if(keys[i] != null) {
1322
				if(keys[i] != null) {
812
					AcceptedType value = (AcceptedType) values[i];
1323
					AcceptedType value = (AcceptedType) values[i];
813
					if(value != null) {
1324
					if(value != null) {
Lines 2448-2453 Link Here
2448
		this.assistNodeIsClass = ref.isClass();
2959
		this.assistNodeIsClass = ref.isClass();
2449
		this.assistNodeIsException = ref.isException();
2960
		this.assistNodeIsException = ref.isException();
2450
		this.assistNodeIsInterface = ref.isInterface();
2961
		this.assistNodeIsInterface = ref.isInterface();
2962
		this.assistNodeIsConstructor = ref.isConstructorType;
2451
		this.assistNodeIsSuperType = ref.isSuperType();
2963
		this.assistNodeIsSuperType = ref.isSuperType();
2452
2964
2453
		this.completionToken = ref.completionIdentifier;
2965
		this.completionToken = ref.completionIdentifier;
Lines 3201-3207 Link Here
3201
						TypeBinding caughtException = catchArguments[i].type.resolvedType;
3713
						TypeBinding caughtException = catchArguments[i].type.resolvedType;
3202
						if (caughtException != null) {
3714
						if (caughtException != null) {
3203
							addForbiddenBindings(caughtException);
3715
							addForbiddenBindings(caughtException);
3204
							this.knownTypes.put(CharOperation.concat(caughtException.qualifiedPackageName(), caughtException.qualifiedSourceName(), '.'), this);
3716
							this.knownTypes.put(CharOperation.concat(caughtException.qualifiedPackageName(), caughtException.qualifiedSourceName(), '.'), KNOWN_TYPE_WITH_KNOWN_CONSTRUCTORS);
3205
						}
3717
						}
3206
					}
3718
					}
3207
					this.forbbidenBindingsFilter = SUBTYPE;
3719
					this.forbbidenBindingsFilter = SUBTYPE;
Lines 3943-3987 Link Here
3943
		}
4455
		}
3944
	}
4456
	}
3945
	private void findAnonymousType(
4457
	private void findAnonymousType(
4458
			ReferenceBinding currentType,
4459
			TypeBinding[] argTypes,
4460
			Scope scope,
4461
			InvocationSite invocationSite) {
4462
		
4463
		int relevance = computeBaseRelevance();
4464
		relevance += computeRelevanceForResolution();
4465
		relevance += computeRelevanceForInterestingProposal();
4466
		relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE);
4467
		
4468
		findAnonymousType(currentType, argTypes, scope, invocationSite, true, false, relevance);
4469
	}
4470
	private void findAnonymousType(
3946
		ReferenceBinding currentType,
4471
		ReferenceBinding currentType,
3947
		TypeBinding[] argTypes,
4472
		TypeBinding[] argTypes,
3948
		Scope scope,
4473
		Scope scope,
3949
		InvocationSite invocationSite) {
4474
		InvocationSite invocationSite,
4475
		boolean exactMatch,
4476
		boolean isQualified,
4477
		int relevance) {
3950
4478
3951
		if (currentType.isInterface()) {
4479
		if (currentType.isInterface()) {
3952
			char[] completion = CharOperation.NO_CHAR;
4480
			char[] completion = CharOperation.NO_CHAR;
3953
			int relevance = computeBaseRelevance();
4481
			char[] typeCompletion = null;
3954
			relevance += computeRelevanceForResolution();
4482
			if (!exactMatch) {
3955
			relevance += computeRelevanceForInterestingProposal();
4483
				typeCompletion = 
3956
			relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE);
4484
					isQualified ?
4485
							CharOperation.concat(currentType.qualifiedPackageName(), currentType.qualifiedSourceName(), '.') :
4486
								currentType.sourceName();
4487
				if (this.source != null
4488
							&& this.source.length > this.endPosition
4489
							&& this.source[this.endPosition] == '(') {
4490
					completion = CharOperation.NO_CHAR;
4491
				} else {
4492
					completion = new char[] { '(', ')' };
4493
				}
4494
			}
3957
4495
3958
			this.noProposal = false;
4496
			this.noProposal = false;
3959
			if(!this.requestor.isIgnored(CompletionProposal.ANONYMOUS_CLASS_DECLARATION)) {
4497
			if (!exactMatch) {
3960
				InternalCompletionProposal proposal = createProposal(CompletionProposal.ANONYMOUS_CLASS_DECLARATION, this.actualCompletionPosition);
4498
				if(!isIgnored(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION, CompletionProposal.TYPE_REF)) {
3961
				proposal.setDeclarationSignature(getSignature(currentType));
4499
					char[] packageName = currentType.isLocalType() ? null : currentType.qualifiedPackageName();
3962
				proposal.setDeclarationKey(currentType.computeUniqueKey());
4500
					char[] typeName = currentType.qualifiedSourceName();
3963
				proposal.setSignature(
4501
					
3964
						createMethodSignature(
4502
					InternalCompletionProposal proposal = createProposal(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION, this.actualCompletionPosition);
3965
								CharOperation.NO_CHAR_CHAR,
4503
					proposal.setDeclarationSignature(getSignature(currentType));
3966
								CharOperation.NO_CHAR_CHAR,
4504
					proposal.setDeclarationKey(currentType.computeUniqueKey());
3967
								CharOperation.NO_CHAR,
4505
					proposal.setSignature(
3968
								CharOperation.NO_CHAR));
4506
							createMethodSignature(
3969
				//proposal.setOriginalSignature(null);
4507
									CharOperation.NO_CHAR_CHAR,
3970
				//proposal.setUniqueKey(null);
4508
									CharOperation.NO_CHAR_CHAR,
3971
				proposal.setDeclarationPackageName(currentType.qualifiedPackageName());
4509
									CharOperation.NO_CHAR,
3972
				proposal.setDeclarationTypeName(currentType.qualifiedSourceName());
4510
									CharOperation.NO_CHAR));
3973
				//proposal.setParameterPackageNames(null);
4511
					//proposal.setOriginalSignature(null);
3974
				//proposal.setParameterTypeNames(null);
4512
					//proposal.setUniqueKey(null);
3975
				//proposal.setPackageName(null);
4513
					proposal.setDeclarationPackageName(packageName);
3976
				//proposal.setTypeName(null);
4514
					proposal.setDeclarationTypeName(typeName);
3977
				proposal.setCompletion(completion);
4515
					//proposal.setParameterPackageNames(null);
3978
				proposal.setFlags(Flags.AccPublic);
4516
					//proposal.setParameterTypeNames(null);
3979
				proposal.setReplaceRange(this.endPosition - this.offset, this.endPosition - this.offset);
4517
					//proposal.setPackageName(null);
3980
				proposal.setTokenRange(this.tokenEnd - this.offset, this.tokenEnd - this.offset);
4518
					//proposal.setTypeName(null);
3981
				proposal.setRelevance(relevance);
4519
					proposal.setName(currentType.sourceName());
3982
				this.requestor.accept(proposal);
4520
					
3983
				if(DEBUG) {
4521
					InternalCompletionProposal typeProposal = createProposal(CompletionProposal.TYPE_REF, this.actualCompletionPosition);
3984
					this.printDebug(proposal);
4522
					typeProposal.nameLookup = this.nameEnvironment.nameLookup;
4523
					typeProposal.completionEngine = this;
4524
					typeProposal.setDeclarationSignature(packageName);
4525
					typeProposal.setSignature(getRequiredTypeSignature(currentType));
4526
					typeProposal.setPackageName(packageName);
4527
					typeProposal.setTypeName(typeName);
4528
					typeProposal.setCompletion(typeCompletion);
4529
					typeProposal.setFlags(currentType.modifiers);
4530
					typeProposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset);
4531
					typeProposal.setTokenRange(this.startPosition - this.offset, this.endPosition - this.offset);
4532
					typeProposal.setRelevance(relevance);
4533
					proposal.setRequiredProposals( new CompletionProposal[]{typeProposal});
4534
								
4535
					proposal.setCompletion(completion);
4536
					proposal.setFlags(Flags.AccPublic);
4537
					proposal.setReplaceRange(this.endPosition - this.offset, this.endPosition - this.offset);
4538
					proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset);
4539
					proposal.setRelevance(relevance);
4540
					this.requestor.accept(proposal);
4541
					if(DEBUG) {
4542
						this.printDebug(proposal);
4543
					}
4544
				}
4545
			}  else {
4546
				if(!this.requestor.isIgnored(CompletionProposal.ANONYMOUS_CLASS_DECLARATION)) {
4547
					InternalCompletionProposal proposal = createProposal(CompletionProposal.ANONYMOUS_CLASS_DECLARATION, this.actualCompletionPosition);
4548
					proposal.setDeclarationSignature(getSignature(currentType));
4549
					proposal.setDeclarationKey(currentType.computeUniqueKey());
4550
					proposal.setSignature(
4551
							createMethodSignature(
4552
									CharOperation.NO_CHAR_CHAR,
4553
									CharOperation.NO_CHAR_CHAR,
4554
									CharOperation.NO_CHAR,
4555
									CharOperation.NO_CHAR));
4556
					//proposal.setOriginalSignature(null);
4557
					//proposal.setUniqueKey(null);
4558
					proposal.setDeclarationPackageName(currentType.qualifiedPackageName());
4559
					proposal.setDeclarationTypeName(currentType.qualifiedSourceName());
4560
					//proposal.setParameterPackageNames(null);
4561
					//proposal.setParameterTypeNames(null);
4562
					//proposal.setPackageName(null);
4563
					//proposal.setTypeName(null);
4564
					proposal.setCompletion(completion);
4565
					proposal.setFlags(Flags.AccPublic);
4566
					proposal.setReplaceRange(this.endPosition - this.offset, this.endPosition - this.offset);
4567
					proposal.setTokenRange(this.tokenEnd - this.offset, this.tokenEnd - this.offset);
4568
					proposal.setRelevance(relevance);
4569
					this.requestor.accept(proposal);
4570
					if(DEBUG) {
4571
						this.printDebug(proposal);
4572
					}
3985
				}
4573
				}
3986
			}
4574
			}
3987
		} else {
4575
		} else {
Lines 3990-3996 Link Here
3990
				argTypes,
4578
				argTypes,
3991
				scope,
4579
				scope,
3992
				invocationSite,
4580
				invocationSite,
3993
				true);
4581
				true,
4582
				exactMatch,
4583
				isQualified,
4584
				relevance);
3994
		}
4585
		}
3995
	}
4586
	}
3996
	private void findClassField(
4587
	private void findClassField(
Lines 4075-4080 Link Here
4075
		Scope scope,
4666
		Scope scope,
4076
		InvocationSite invocationSite,
4667
		InvocationSite invocationSite,
4077
		boolean forAnonymousType) {
4668
		boolean forAnonymousType) {
4669
		
4670
		int relevance = computeBaseRelevance();
4671
						relevance += computeRelevanceForResolution();
4672
						relevance += computeRelevanceForInterestingProposal();
4673
						relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE);
4674
		
4675
		findConstructors(currentType, argTypes, scope, invocationSite, forAnonymousType, true, false, relevance);
4676
	}
4677
		
4678
	private void findConstructors(
4679
		ReferenceBinding currentType,
4680
		TypeBinding[] argTypes,
4681
		Scope scope,
4682
		InvocationSite invocationSite,
4683
		boolean forAnonymousType,
4684
		boolean exactMatch,
4685
		boolean isQualified,
4686
		int relevance) {
4078
4687
4079
		// No visibility checks can be performed without the scope & invocationSite
4688
		// No visibility checks can be performed without the scope & invocationSite
4080
		MethodBinding[] methods = currentType.availableMethods();
4689
		MethodBinding[] methods = currentType.availableMethods();
Lines 4117-4162 Link Here
4117
					char[][] parameterNames = findMethodParameterNames(constructor,parameterTypeNames);
4726
					char[][] parameterNames = findMethodParameterNames(constructor,parameterTypeNames);
4118
4727
4119
					char[] completion = CharOperation.NO_CHAR;
4728
					char[] completion = CharOperation.NO_CHAR;
4729
					
4120
					if(forAnonymousType){
4730
					if(forAnonymousType){
4121
						int relevance = computeBaseRelevance();
4731
						char[] typeCompletion = null;
4122
						relevance += computeRelevanceForResolution();
4732
						if (!exactMatch) {
4123
						relevance += computeRelevanceForInterestingProposal();
4733
							typeCompletion = 
4124
						relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE);
4734
								isQualified ?
4125
4735
										CharOperation.concat(currentType.qualifiedPackageName(), currentType.qualifiedSourceName(), '.') :
4736
											currentType.sourceName();
4737
							if (this.source != null
4738
										&& this.source.length > this.endPosition
4739
										&& this.source[this.endPosition] == '(') {
4740
								completion = CharOperation.NO_CHAR;
4741
							} else {
4742
								completion = new char[] { '(', ')' };
4743
							}
4744
						}
4745
						
4126
						this.noProposal = false;
4746
						this.noProposal = false;
4127
						if(!this.requestor.isIgnored(CompletionProposal.ANONYMOUS_CLASS_DECLARATION)) {
4747
						if (!exactMatch) {
4128
							InternalCompletionProposal proposal = createProposal(CompletionProposal.ANONYMOUS_CLASS_DECLARATION, this.actualCompletionPosition);
4748
							if(!isIgnored(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION, CompletionProposal.TYPE_REF)) {
4129
							proposal.setDeclarationSignature(getSignature(currentType));
4749
								char[] packageName = currentType.isLocalType() ? null : currentType.qualifiedPackageName();
4130
							proposal.setDeclarationKey(currentType.computeUniqueKey());
4750
								char[] typeName = currentType.qualifiedSourceName();
4131
							proposal.setSignature(getSignature(constructor));
4751
								
4132
							MethodBinding original = constructor.original();
4752
								InternalCompletionProposal proposal = createProposal(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION, this.actualCompletionPosition);
4133
							if(original != constructor) {
4753
								proposal.setDeclarationSignature(getSignature(currentType));
4134
								proposal.setOriginalSignature(getSignature(original));
4754
								proposal.setDeclarationKey(currentType.computeUniqueKey());
4755
								proposal.setSignature(getSignature(constructor));
4756
								MethodBinding original = constructor.original();
4757
								if(original != constructor) {
4758
									proposal.setOriginalSignature(getSignature(original));
4759
								}
4760
								proposal.setKey(constructor.computeUniqueKey());
4761
								proposal.setDeclarationPackageName(packageName);
4762
								proposal.setDeclarationTypeName(typeName);
4763
								proposal.setParameterPackageNames(parameterPackageNames);
4764
								proposal.setParameterTypeNames(parameterTypeNames);
4765
								//proposal.setPackageName(null);
4766
								//proposal.setTypeName(null);
4767
								proposal.setName(currentType.sourceName());
4768
								
4769
								InternalCompletionProposal typeProposal = createProposal(CompletionProposal.TYPE_REF, this.actualCompletionPosition);
4770
								typeProposal.nameLookup = this.nameEnvironment.nameLookup;
4771
								typeProposal.completionEngine = this;
4772
								typeProposal.setDeclarationSignature(packageName);
4773
								typeProposal.setSignature(getRequiredTypeSignature(currentType));
4774
								typeProposal.setPackageName(packageName);
4775
								typeProposal.setTypeName(typeName);
4776
								typeProposal.setCompletion(typeCompletion);
4777
								typeProposal.setFlags(currentType.modifiers);
4778
								typeProposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset);
4779
								typeProposal.setTokenRange(this.startPosition - this.offset, this.endPosition - this.offset);
4780
								typeProposal.setRelevance(relevance);
4781
								proposal.setRequiredProposals( new CompletionProposal[]{typeProposal});
4782
								
4783
								proposal.setCompletion(completion);
4784
								proposal.setFlags(constructor.modifiers);
4785
								proposal.setReplaceRange(this.endPosition - this.offset, this.endPosition - this.offset);
4786
								proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset);
4787
								proposal.setRelevance(relevance);
4788
								if(parameterNames != null) proposal.setParameterNames(parameterNames);
4789
								this.requestor.accept(proposal);
4790
								if(DEBUG) {
4791
									this.printDebug(proposal);
4792
								}
4135
							}
4793
							}
4136
							proposal.setKey(constructor.computeUniqueKey());
4794
						} else {
4137
							proposal.setDeclarationPackageName(currentType.qualifiedPackageName());
4795
							if(!this.requestor.isIgnored(CompletionProposal.ANONYMOUS_CLASS_DECLARATION)) {
4138
							proposal.setDeclarationTypeName(currentType.qualifiedSourceName());
4796
								InternalCompletionProposal proposal = createProposal(CompletionProposal.ANONYMOUS_CLASS_DECLARATION, this.actualCompletionPosition);
4139
							proposal.setParameterPackageNames(parameterPackageNames);
4797
								proposal.setDeclarationSignature(getSignature(currentType));
4140
							proposal.setParameterTypeNames(parameterTypeNames);
4798
								proposal.setDeclarationKey(currentType.computeUniqueKey());
4141
							//proposal.setPackageName(null);
4799
								proposal.setSignature(getSignature(constructor));
4142
							//proposal.setTypeName(null);
4800
								MethodBinding original = constructor.original();
4143
							proposal.setCompletion(completion);
4801
								if(original != constructor) {
4144
							proposal.setFlags(constructor.modifiers);
4802
									proposal.setOriginalSignature(getSignature(original));
4145
							proposal.setReplaceRange(this.endPosition - this.offset, this.endPosition - this.offset);
4803
								}
4146
							proposal.setTokenRange(this.tokenEnd - this.offset, this.tokenEnd - this.offset);
4804
								proposal.setKey(constructor.computeUniqueKey());
4147
							proposal.setRelevance(relevance);
4805
								proposal.setDeclarationPackageName(currentType.qualifiedPackageName());
4148
							if(parameterNames != null) proposal.setParameterNames(parameterNames);
4806
								proposal.setDeclarationTypeName(currentType.qualifiedSourceName());
4149
							this.requestor.accept(proposal);
4807
								proposal.setParameterPackageNames(parameterPackageNames);
4150
							if(DEBUG) {
4808
								proposal.setParameterTypeNames(parameterTypeNames);
4151
								this.printDebug(proposal);
4809
								//proposal.setPackageName(null);
4810
								//proposal.setTypeName(null);
4811
								proposal.setCompletion(completion);
4812
								proposal.setFlags(constructor.modifiers);
4813
								proposal.setReplaceRange(this.endPosition - this.offset, this.endPosition - this.offset);
4814
								proposal.setTokenRange(this.tokenEnd - this.offset, this.tokenEnd - this.offset);
4815
								proposal.setRelevance(relevance);
4816
								if(parameterNames != null) proposal.setParameterNames(parameterNames);
4817
								this.requestor.accept(proposal);
4818
								if(DEBUG) {
4819
									this.printDebug(proposal);
4820
								}
4152
							}
4821
							}
4153
						}
4822
						}
4154
					} else {
4823
					} else {
4155
						int relevance = computeBaseRelevance();
4824
						char[] typeCompletion = null;
4156
						relevance += computeRelevanceForResolution();
4157
						relevance += computeRelevanceForInterestingProposal();
4158
						relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE);
4159
4160
						// Special case for completion in javadoc
4825
						// Special case for completion in javadoc
4161
						if (this.assistNodeInJavadoc > 0) {
4826
						if (this.assistNodeInJavadoc > 0) {
4162
							Expression receiver = null;
4827
							Expression receiver = null;
Lines 4208-4278 Link Here
4208
								javadocCompletion.append(')');
4873
								javadocCompletion.append(')');
4209
								completion = javadocCompletion.toString().toCharArray();
4874
								completion = javadocCompletion.toString().toCharArray();
4210
							}
4875
							}
4876
						} else {
4877
							if (!exactMatch) {
4878
								typeCompletion = 
4879
									isQualified ?
4880
											CharOperation.concat(currentType.qualifiedPackageName(), currentType.qualifiedSourceName(), '.') :
4881
												currentType.sourceName();
4882
								
4883
								if (this.source != null
4884
											&& this.source.length > this.endPosition
4885
											&& this.source[this.endPosition] == '(') {
4886
									completion = CharOperation.NO_CHAR;
4887
								} else {
4888
									completion = new char[] { '(', ')' };
4889
								}
4890
							}
4211
						}
4891
						}
4212
4892
4213
						// Create standard proposal
4893
						// Create standard proposal
4214
						this.noProposal = false;
4894
						this.noProposal = false;
4215
						if(!this.requestor.isIgnored(CompletionProposal.METHOD_REF) && (this.assistNodeInJavadoc & CompletionOnJavadoc.ONLY_INLINE_TAG) == 0) {
4895
						if (!exactMatch) {
4216
							InternalCompletionProposal proposal =  createProposal(CompletionProposal.METHOD_REF, this.actualCompletionPosition);
4896
							if(!isIgnored(CompletionProposal.CONSTRUCTOR_INVOCATION, CompletionProposal.TYPE_REF)) {
4217
							proposal.setDeclarationSignature(getSignature(currentType));
4897
								char[] packageName = currentType.isLocalType() ? null : currentType.qualifiedPackageName();
4218
							proposal.setSignature(getSignature(constructor));
4898
								char[] typeName = currentType.qualifiedSourceName();
4219
							MethodBinding original = constructor.original();
4899
								
4220
							if(original != constructor) {
4900
								InternalCompletionProposal proposal =  createProposal(CompletionProposal.CONSTRUCTOR_INVOCATION, this.actualCompletionPosition);
4221
								proposal.setOriginalSignature(getSignature(original));
4901
								proposal.setDeclarationSignature(getSignature(currentType));
4902
								proposal.setSignature(getSignature(constructor));
4903
								MethodBinding original = constructor.original();
4904
								if(original != constructor) {
4905
									proposal.setOriginalSignature(getSignature(original));
4906
								}
4907
								proposal.setDeclarationPackageName(packageName);
4908
								proposal.setDeclarationTypeName(typeName);
4909
								proposal.setParameterPackageNames(parameterPackageNames);
4910
								proposal.setParameterTypeNames(parameterTypeNames);
4911
								//proposal.setPackageName(null);
4912
								//proposal.setTypeName(null);
4913
								proposal.setName(currentType.sourceName());
4914
					
4915
								InternalCompletionProposal typeProposal = createProposal(CompletionProposal.TYPE_REF, this.actualCompletionPosition);
4916
								typeProposal.nameLookup = this.nameEnvironment.nameLookup;
4917
								typeProposal.completionEngine = this;
4918
								typeProposal.setDeclarationSignature(packageName);
4919
								typeProposal.setSignature(getRequiredTypeSignature(currentType));
4920
								typeProposal.setPackageName(packageName);
4921
								typeProposal.setTypeName(typeName);
4922
								typeProposal.setCompletion(typeCompletion);
4923
								typeProposal.setFlags(currentType.modifiers);
4924
								typeProposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset);
4925
								typeProposal.setTokenRange(this.startPosition - this.offset, this.endPosition - this.offset);
4926
								typeProposal.setRelevance(relevance);
4927
								proposal.setRequiredProposals( new CompletionProposal[]{typeProposal});
4928
								
4929
								proposal.setIsContructor(true);
4930
								proposal.setCompletion(completion);
4931
								proposal.setFlags(constructor.modifiers);
4932
								proposal.setReplaceRange(this.endPosition - this.offset, this.endPosition - this.offset);
4933
								proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset);
4934
								proposal.setRelevance(relevance);
4935
								if(parameterNames != null) proposal.setParameterNames(parameterNames);
4936
								this.requestor.accept(proposal);
4937
								if(DEBUG) {
4938
									this.printDebug(proposal);
4939
								}
4222
							}
4940
							}
4223
							proposal.setDeclarationPackageName(currentType.qualifiedPackageName());
4941
						} else {
4224
							proposal.setDeclarationTypeName(currentType.qualifiedSourceName());
4942
							if(!this.requestor.isIgnored(CompletionProposal.METHOD_REF) && (this.assistNodeInJavadoc & CompletionOnJavadoc.ONLY_INLINE_TAG) == 0) {
4225
							proposal.setParameterPackageNames(parameterPackageNames);
4943
								InternalCompletionProposal proposal =  createProposal(CompletionProposal.METHOD_REF, this.actualCompletionPosition);
4226
							proposal.setParameterTypeNames(parameterTypeNames);
4944
								proposal.setDeclarationSignature(getSignature(currentType));
4227
							//proposal.setPackageName(null);
4945
								proposal.setSignature(getSignature(constructor));
4228
							//proposal.setTypeName(null);
4946
								MethodBinding original = constructor.original();
4229
							proposal.setName(currentType.sourceName());
4947
								if(original != constructor) {
4230
							proposal.setIsContructor(true);
4948
									proposal.setOriginalSignature(getSignature(original));
4231
							proposal.setCompletion(completion);
4949
								}
4232
							proposal.setFlags(constructor.modifiers);
4950
								proposal.setDeclarationPackageName(currentType.qualifiedPackageName());
4233
							int start = (this.assistNodeInJavadoc > 0) ? this.startPosition : this.endPosition;
4951
								proposal.setDeclarationTypeName(currentType.qualifiedSourceName());
4234
							proposal.setReplaceRange(start - this.offset, this.endPosition - this.offset);
4952
								proposal.setParameterPackageNames(parameterPackageNames);
4235
							proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset);
4953
								proposal.setParameterTypeNames(parameterTypeNames);
4236
							proposal.setRelevance(relevance);
4954
								//proposal.setPackageName(null);
4237
							if(parameterNames != null) proposal.setParameterNames(parameterNames);
4955
								//proposal.setTypeName(null);
4238
							this.requestor.accept(proposal);
4956
								proposal.setName(currentType.sourceName());
4239
							if(DEBUG) {
4957
								proposal.setIsContructor(true);
4240
								this.printDebug(proposal);
4958
								proposal.setCompletion(completion);
4959
								proposal.setFlags(constructor.modifiers);
4960
								int start = (this.assistNodeInJavadoc > 0) ? this.startPosition : this.endPosition;
4961
								proposal.setReplaceRange(start - this.offset, this.endPosition - this.offset);
4962
								proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset);
4963
								proposal.setRelevance(relevance);
4964
								if(parameterNames != null) proposal.setParameterNames(parameterNames);
4965
								this.requestor.accept(proposal);
4966
								if(DEBUG) {
4967
									this.printDebug(proposal);
4968
								}
4241
							}
4969
							}
4242
						}
4970
							if ((this.assistNodeInJavadoc & CompletionOnJavadoc.TEXT) != 0 && !this.requestor.isIgnored(CompletionProposal.JAVADOC_METHOD_REF)) {
4243
						if ((this.assistNodeInJavadoc & CompletionOnJavadoc.TEXT) != 0 && !this.requestor.isIgnored(CompletionProposal.JAVADOC_METHOD_REF)) {
4971
								char[] javadocCompletion = inlineTagCompletion(completion, JavadocTagConstants.TAG_LINK);
4244
							char[] javadocCompletion = inlineTagCompletion(completion, JavadocTagConstants.TAG_LINK);
4972
								InternalCompletionProposal proposal =  createProposal(CompletionProposal.JAVADOC_METHOD_REF, this.actualCompletionPosition);
4245
							InternalCompletionProposal proposal =  createProposal(CompletionProposal.JAVADOC_METHOD_REF, this.actualCompletionPosition);
4973
								proposal.setDeclarationSignature(getSignature(currentType));
4246
							proposal.setDeclarationSignature(getSignature(currentType));
4974
								proposal.setSignature(getSignature(constructor));
4247
							proposal.setSignature(getSignature(constructor));
4975
								MethodBinding original = constructor.original();
4248
							MethodBinding original = constructor.original();
4976
								if(original != constructor) {
4249
							if(original != constructor) {
4977
									proposal.setOriginalSignature(getSignature(original));
4250
								proposal.setOriginalSignature(getSignature(original));
4978
								}
4979
								proposal.setDeclarationPackageName(currentType.qualifiedPackageName());
4980
								proposal.setDeclarationTypeName(currentType.qualifiedSourceName());
4981
								proposal.setParameterPackageNames(parameterPackageNames);
4982
								proposal.setParameterTypeNames(parameterTypeNames);
4983
								//proposal.setPackageName(null);
4984
								//proposal.setTypeName(null);
4985
								proposal.setName(currentType.sourceName());
4986
								proposal.setIsContructor(true);
4987
								proposal.setCompletion(javadocCompletion);
4988
								proposal.setFlags(constructor.modifiers);
4989
								int start = (this.assistNodeInJavadoc & CompletionOnJavadoc.REPLACE_TAG) != 0 ? this.javadocTagPosition : this.startPosition;
4990
								proposal.setReplaceRange(start - this.offset, this.endPosition - this.offset);
4991
								proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset);
4992
								proposal.setRelevance(relevance+R_INLINE_TAG);
4993
								if(parameterNames != null) proposal.setParameterNames(parameterNames);
4994
								this.requestor.accept(proposal);
4995
								if(DEBUG) {
4996
									this.printDebug(proposal);
4997
								}
4251
							}
4998
							}
4252
							proposal.setDeclarationPackageName(currentType.qualifiedPackageName());
4999
						}
4253
							proposal.setDeclarationTypeName(currentType.qualifiedSourceName());
5000
					}
4254
							proposal.setParameterPackageNames(parameterPackageNames);
5001
				}
4255
							proposal.setParameterTypeNames(parameterTypeNames);
5002
			}
4256
							//proposal.setPackageName(null);
5003
		}
4257
							//proposal.setTypeName(null);
5004
	}
4258
							proposal.setName(currentType.sourceName());
5005
	
4259
							proposal.setIsContructor(true);
5006
	private char[] getResolvedSignature(char[][] parameterTypes, char[] fullyQualifiedTypeName, int parameterCount, Scope scope) {
4260
							proposal.setCompletion(javadocCompletion);
5007
		char[][] cn = CharOperation.splitOn('.', fullyQualifiedTypeName);
4261
							proposal.setFlags(constructor.modifiers);
5008
4262
							int start = (this.assistNodeInJavadoc & CompletionOnJavadoc.REPLACE_TAG) != 0 ? this.javadocTagPosition : this.startPosition;
5009
		TypeReference ref;
4263
							proposal.setReplaceRange(start - this.offset, this.endPosition - this.offset);
5010
		if (cn.length == 1) {
4264
							proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset);
5011
			ref = new SingleTypeReference(cn[0], 0);
4265
							proposal.setRelevance(relevance+R_INLINE_TAG);
5012
		} else {
4266
							if(parameterNames != null) proposal.setParameterNames(parameterNames);
5013
			ref = new QualifiedTypeReference(cn,new long[cn.length]);
4267
							this.requestor.accept(proposal);
5014
		}
4268
							if(DEBUG) {
5015
		
4269
								this.printDebug(proposal);
5016
		TypeBinding guessedType = null;
5017
		INameEnvironment oldNameEnvironment = this.lookupEnvironment.nameEnvironment;
5018
		this.lookupEnvironment.nameEnvironment = getNoCacheNameEnvironment();
5019
		try {
5020
			switch (scope.kind) {
5021
				case Scope.METHOD_SCOPE :
5022
				case Scope.BLOCK_SCOPE :
5023
					guessedType = ref.resolveType((BlockScope)scope);
5024
					break;
5025
				case Scope.CLASS_SCOPE :
5026
					guessedType = ref.resolveType((ClassScope)scope);
5027
					break;
5028
			}
5029
		} finally {
5030
			this.lookupEnvironment.nameEnvironment = oldNameEnvironment;
5031
		}
5032
5033
		if (guessedType != null && guessedType.isValidBinding()) {
5034
			if (guessedType instanceof ReferenceBinding) {
5035
				ReferenceBinding refBinding = (ReferenceBinding) guessedType;
5036
				
5037
				MethodBinding bestConstructor = null;
5038
				int[] bestMatchingLengths = null;
5039
				
5040
				MethodBinding[] methods = refBinding.methods();
5041
				next : for (int i = 0; i < methods.length; i++) {
5042
					MethodBinding method = methods[i];
5043
					
5044
					if (!method.isConstructor()) break next;
5045
					
5046
					TypeBinding[] parameters = method.parameters;
5047
					//TODO take careful of member types
5048
					int parametersLength = parameters == null ? 0 : parameters.length;
5049
					if (parameterCount != parametersLength) continue next;
5050
					
5051
					int[] matchingLengths = new int[parameterCount];
5052
					for (int j = 0; j < parametersLength; j++) {
5053
						TypeBinding parameter = parameters[j];
5054
						
5055
						char[] parameterTypeName;
5056
						if (parameter instanceof ReferenceBinding) {
5057
							parameterTypeName = CharOperation.concatWith(((ReferenceBinding)parameter).compoundName, '.');
5058
						} else {
5059
							parameterTypeName = parameter.sourceName();
5060
						}
5061
						
5062
						if (!CharOperation.endsWith(parameterTypeName, parameterTypes[j])) {
5063
							break next;
5064
						}
5065
						
5066
						int matchingLength = parameterTypes[j].length;
5067
						
5068
						if (bestMatchingLengths != null) {
5069
							if (bestMatchingLengths[j] > matchingLength) {
5070
								continue next;
4270
							}
5071
							}
4271
						}
5072
						}
5073
						
5074
						matchingLengths[j] = matchingLength;
4272
					}
5075
					}
5076
					
5077
					
5078
					bestConstructor = method;
5079
					bestMatchingLengths = matchingLengths;
4273
				}
5080
				}
5081
				
5082
				if (bestConstructor == null) return null;
5083
				return getSignature(bestConstructor);
4274
			}
5084
			}
4275
		}
5085
		}
5086
		
5087
		return null;
5088
	}
5089
5090
	private void findConstructorsOrAnonymousTypes(
5091
			ReferenceBinding currentType,
5092
			Scope scope,
5093
			InvocationSite invocationSite,
5094
			boolean isQualified,
5095
			int relevance) {
5096
		
5097
		if (!isIgnored(CompletionProposal.CONSTRUCTOR_INVOCATION, CompletionProposal.TYPE_REF)
5098
				&& currentType.isClass()
5099
				&& !currentType.isAbstract()) {
5100
				findConstructors(
5101
					currentType,
5102
					null,
5103
					scope,
5104
					invocationSite,
5105
					false,
5106
					false,
5107
					isQualified,
5108
					relevance);
5109
		}
5110
		
5111
		// This code is disabled because there is too much proposals when constructors and anonymous are proposed
5112
		if (!isIgnored(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION, CompletionProposal.TYPE_REF)
5113
				&& !currentType.isFinal()
5114
				&& (currentType.isInterface() || (currentType.isClass() && currentType.isAbstract()))){
5115
			findAnonymousType(
5116
				currentType,
5117
				null,
5118
				scope,
5119
				invocationSite,
5120
				false,
5121
				isQualified,
5122
				relevance);
5123
		}
4276
	}
5124
	}
4277
	private char[][] findEnclosingTypeNames(Scope scope){
5125
	private char[][] findEnclosingTypeNames(Scope scope){
4278
		char[][] excludedNames = new char[10][];
5126
		char[][] excludedNames = new char[10][];
Lines 8230-8246 Link Here
8230
				relevance += computeRelevanceForMissingElements(missingElementsHaveProblems);
9078
				relevance += computeRelevanceForMissingElements(missingElementsHaveProblems);
8231
			}
9079
			}
8232
9080
9081
			boolean allowingLongComputationProposals = isAllowingLongComputationProposals();
9082
			
8233
			this.noProposal = false;
9083
			this.noProposal = false;
8234
			createTypeProposal(
9084
			if (!this.assistNodeIsConstructor || !allowingLongComputationProposals || hasStaticMemberTypes(memberType, invocationType, this.unitScope)) {
8235
					memberType,
9085
				createTypeProposal(
8236
					memberType.qualifiedSourceName(),
9086
						memberType,
8237
					IAccessRule.K_ACCESSIBLE,
9087
						memberType.qualifiedSourceName(),
8238
					completionName,
9088
						IAccessRule.K_ACCESSIBLE,
8239
					relevance,
9089
						completionName,
8240
					missingElements,
9090
						relevance,
8241
					missingElementsStarts,
9091
						missingElements,
8242
					missingElementsEnds,
9092
						missingElementsStarts,
8243
					missingElementsHaveProblems);
9093
						missingElementsEnds,
9094
						missingElementsHaveProblems);
9095
			}
9096
			
9097
			if (this.assistNodeIsConstructor && allowingLongComputationProposals) {
9098
				findConstructorsOrAnonymousTypes(
9099
						memberType,
9100
						scope,
9101
						FakeInvocationSite,
9102
						isQualified,
9103
						relevance);
9104
			}
8244
		}
9105
		}
8245
	}
9106
	}
8246
	private void findMemberTypesFromMissingType(
9107
	private void findMemberTypesFromMissingType(
Lines 8659-8676 Link Here
8659
								relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE); // no access restriction for nested type
9520
								relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE); // no access restriction for nested type
8660
								relevance += computeRelevanceForAnnotationTarget(localType);
9521
								relevance += computeRelevanceForAnnotationTarget(localType);
8661
9522
8662
								this.noProposal = false;
9523
								boolean allowingLongComputationProposals = isAllowingLongComputationProposals();
8663
								if(!this.requestor.isIgnored(CompletionProposal.TYPE_REF)) {
9524
								if (!this.assistNodeIsConstructor || !allowingLongComputationProposals) {
8664
									createTypeProposal(
9525
									this.noProposal = false;
9526
									if(!this.requestor.isIgnored(CompletionProposal.TYPE_REF)) {
9527
										createTypeProposal(
9528
												localType,
9529
												localType.sourceName,
9530
												IAccessRule.K_ACCESSIBLE,
9531
												localType.sourceName,
9532
												relevance,
9533
												null,
9534
												null,
9535
												null,
9536
												false);
9537
									}
9538
								}
9539
								
9540
								if (this.assistNodeIsConstructor && allowingLongComputationProposals) {
9541
									findConstructorsOrAnonymousTypes(
8665
											localType,
9542
											localType,
8666
											localType.sourceName,
9543
											blockScope,
8667
											IAccessRule.K_ACCESSIBLE,
9544
											FakeInvocationSite,
8668
											localType.sourceName,
9545
											false,
8669
											relevance,
9546
											relevance);
8670
											null,
8671
											null,
8672
											null,
8673
											false);
8674
								}
9547
								}
8675
							}
9548
							}
8676
						}
9549
						}
Lines 8918-8931 Link Here
8918
9791
8919
		if (token == null)
9792
		if (token == null)
8920
			return;
9793
			return;
8921
9794
		
9795
		boolean allowingLongComputationProposals = isAllowingLongComputationProposals();
9796
		
8922
		boolean proposeType =
9797
		boolean proposeType =
8923
			!this.requestor.isIgnored(CompletionProposal.TYPE_REF) ||
9798
			!this.requestor.isIgnored(CompletionProposal.TYPE_REF) ||
8924
			((this.assistNodeInJavadoc & CompletionOnJavadoc.TEXT) != 0 && !this.requestor.isIgnored(CompletionProposal.JAVADOC_TYPE_REF));
9799
			((this.assistNodeInJavadoc & CompletionOnJavadoc.TEXT) != 0 && !this.requestor.isIgnored(CompletionProposal.JAVADOC_TYPE_REF));
8925
9800
8926
		boolean proposeAllMemberTypes = !this.assistNodeIsConstructor;
9801
		boolean proposeAllMemberTypes = !this.assistNodeIsConstructor;
9802
		
9803
		boolean proposeConstructor =
9804
			allowingLongComputationProposals &&
9805
			this.assistNodeIsConstructor &&
9806
			(!isIgnored(CompletionProposal.CONSTRUCTOR_INVOCATION, CompletionProposal.TYPE_REF) ||
9807
					!isIgnored(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION, CompletionProposal.TYPE_REF));
9808
		
8927
9809
8928
		if (proposeType && scope.enclosingSourceType() != null) {
9810
		if ((proposeType || proposeConstructor) && scope.enclosingSourceType() != null) {
8929
			
9811
			
8930
			checkCancel();
9812
			checkCancel();
8931
			
9813
			
Lines 8944-8950 Link Here
8944
9826
8945
		boolean isEmptyPrefix = token.length == 0;
9827
		boolean isEmptyPrefix = token.length == 0;
8946
9828
8947
		if (proposeType && this.unitScope != null) {
9829
		if ((proposeType || proposeConstructor) && this.unitScope != null) {
8948
			
9830
			
8949
			ReferenceBinding outerInvocationType = scope.enclosingSourceType();
9831
			ReferenceBinding outerInvocationType = scope.enclosingSourceType();
8950
			if(outerInvocationType != null) {
9832
			if(outerInvocationType != null) {
Lines 8985-8991 Link Here
8985
				if (typeLength > sourceType.sourceName.length) continue next;
9867
				if (typeLength > sourceType.sourceName.length) continue next;
8986
9868
8987
				if (!CharOperation.prefixEquals(token, sourceType.sourceName, false)
9869
				if (!CharOperation.prefixEquals(token, sourceType.sourceName, false)
8988
						&& !(this.options.camelCaseMatch && CharOperation.camelCaseMatch(token, sourceType.sourceName))) continue;
9870
						&& !(this.options.camelCaseMatch && CharOperation.camelCaseMatch(token, sourceType.sourceName))) continue next;
8989
9871
8990
				if (this.assistNodeIsAnnotation && !hasPossibleAnnotationTarget(sourceType, scope)) {
9872
				if (this.assistNodeIsAnnotation && !hasPossibleAnnotationTarget(sourceType, scope)) {
8991
					continue next;
9873
					continue next;
Lines 8996-9003 Link Here
8996
9878
8997
					if (sourceType == otherType) continue next;
9879
					if (sourceType == otherType) continue next;
8998
				}
9880
				}
8999
9881
				
9000
				this.knownTypes.put(CharOperation.concat(sourceType.qualifiedPackageName(), sourceType.sourceName(), '.'), this);
9882
				typesFound.add(sourceType);
9001
9883
9002
				if(this.assistNodeIsClass) {
9884
				if(this.assistNodeIsClass) {
9003
					if(!sourceType.isClass()) continue next;
9885
					if(!sourceType.isClass()) continue next;
Lines 9028-9035 Link Here
9028
					relevance += computeRelevanceForClass();
9910
					relevance += computeRelevanceForClass();
9029
					relevance += computeRelevanceForException(sourceType.sourceName);
9911
					relevance += computeRelevanceForException(sourceType.sourceName);
9030
				}
9912
				}
9913
				
9914
				
9031
				this.noProposal = false;
9915
				this.noProposal = false;
9032
				if(proposeType) {
9916
				if(proposeType && (!this.assistNodeIsConstructor || !allowingLongComputationProposals || hasStaticMemberTypes(sourceType, null, this.unitScope))) {
9033
					char[] typeName = sourceType.sourceName();
9917
					char[] typeName = sourceType.sourceName();
9034
					createTypeProposal(
9918
					createTypeProposal(
9035
							sourceType,
9919
							sourceType,
Lines 9042-9182 Link Here
9042
							null,
9926
							null,
9043
							false);
9927
							false);
9044
				}
9928
				}
9929
				
9930
				if (proposeConstructor) {
9931
					findConstructorsOrAnonymousTypes(
9932
							sourceType,
9933
							scope,
9934
							FakeInvocationSite,
9935
							false,
9936
							relevance);
9937
				}
9045
			}
9938
			}
9046
		}
9939
		}
9047
9940
9048
		if(proposeType) {
9941
		if (proposeConstructor && !isEmptyPrefix) {
9942
			
9943
			checkCancel();
9944
			
9945
			findTypesFromImports(token, scope, proposeType, typesFound);
9946
		} else if(proposeType) {
9049
			
9947
			
9050
			checkCancel();
9948
			checkCancel();
9051
			
9949
			
9052
			findTypesFromStaticImports(token, scope, proposeAllMemberTypes, typesFound);
9950
			findTypesFromStaticImports(token, scope, proposeAllMemberTypes, typesFound);
9053
		}
9951
		}
9952
		
9953
		if (proposeConstructor) {
9954
			
9955
			checkCancel();
9956
			
9957
			findTypesFromExpectedTypes(token, scope, typesFound, proposeType, proposeConstructor);
9958
		}
9054
9959
9055
		if (isEmptyPrefix && !this.assistNodeIsAnnotation) {
9960
		if (isEmptyPrefix && !this.assistNodeIsAnnotation) {
9056
			if(proposeType && this.expectedTypesPtr > -1) {
9961
			if (!proposeConstructor) {
9057
				next : for (int i = 0; i <= this.expectedTypesPtr; i++) {
9962
				findTypesFromExpectedTypes(token, scope, typesFound, proposeType, proposeConstructor);
9058
					
9963
			}
9059
					checkCancel();
9964
		} else {
9060
					
9965
			if(!isEmptyPrefix && !this.requestor.isIgnored(CompletionProposal.KEYWORD)) {
9061
					if(this.expectedTypes[i] instanceof ReferenceBinding) {
9966
				if (this.assistNodeInJavadoc == 0 || (this.assistNodeInJavadoc & CompletionOnJavadoc.BASE_TYPES) != 0) {
9062
						ReferenceBinding refBinding = (ReferenceBinding)this.expectedTypes[i];
9967
					if (proposeBaseTypes) {
9063
9968
						if (proposeVoidType) {
9064
						if(refBinding.isTypeVariable() && this.assistNodeIsConstructor) {
9969
							findKeywords(token, BASE_TYPE_NAMES, false, false);
9065
							// don't propose type variable if the completion is a constructor ('new |')
9970
						} else {
9066
							continue next;
9971
							findKeywords(token, BASE_TYPE_NAMES_WITHOUT_VOID, false, false);
9067
						}
9068
						if (this.options.checkDeprecation &&
9069
								refBinding.isViewedAsDeprecated() &&
9070
								!scope.isDefinedInSameUnit(refBinding))
9071
							continue next;
9072
9073
						int accessibility = IAccessRule.K_ACCESSIBLE;
9074
						if(refBinding.hasRestrictedAccess()) {
9075
							AccessRestriction accessRestriction = this.lookupEnvironment.getAccessRestriction(refBinding);
9076
							if(accessRestriction != null) {
9077
								switch (accessRestriction.getProblemId()) {
9078
									case IProblem.ForbiddenReference:
9079
										if (this.options.checkForbiddenReference) {
9080
											continue next;
9081
										}
9082
										accessibility = IAccessRule.K_NON_ACCESSIBLE;
9083
										break;
9084
									case IProblem.DiscouragedReference:
9085
										if (this.options.checkDiscouragedReference) {
9086
											continue next;
9087
										}
9088
										accessibility = IAccessRule.K_DISCOURAGED;
9089
										break;
9090
								}
9091
							}
9092
						}
9093
9094
						for (int j = 0; j < typesFound.size(); j++) {
9095
							ReferenceBinding typeFound = (ReferenceBinding)typesFound.elementAt(j);
9096
							if (typeFound == refBinding) {
9097
								continue next;
9098
							}
9099
						}
9100
9101
						boolean inSameUnit = this.unitScope.isDefinedInSameUnit(refBinding);
9102
9103
						// top level types of the current unit are already proposed.
9104
						if(!inSameUnit || (inSameUnit && refBinding.isMemberType())) {
9105
							char[] packageName = refBinding.qualifiedPackageName();
9106
							char[] typeName = refBinding.sourceName();
9107
							char[] completionName = typeName;
9108
9109
							boolean isQualified = false;
9110
							if (!this.insideQualifiedReference && !refBinding.isMemberType()) {
9111
								if (mustQualifyType(packageName, typeName, null, refBinding.modifiers)) {
9112
									if (packageName == null || packageName.length == 0)
9113
										if (this.unitScope != null && this.unitScope.fPackage.compoundName != CharOperation.NO_CHAR_CHAR)
9114
											continue next; // ignore types from the default package from outside it
9115
									completionName = CharOperation.concat(packageName, typeName, '.');
9116
									isQualified = true;
9117
								}
9118
							}
9119
9120
							if(this.assistNodeIsClass) {
9121
								if(!refBinding.isClass()) continue next;
9122
							} else if(this.assistNodeIsInterface) {
9123
								if(!refBinding.isInterface() && !refBinding.isAnnotationType()) continue next;
9124
							} else if (this.assistNodeIsAnnotation) {
9125
								if(!refBinding.isAnnotationType()) continue next;
9126
							}
9127
9128
							int relevance = computeBaseRelevance();
9129
							relevance += computeRelevanceForResolution();
9130
							relevance += computeRelevanceForInterestingProposal();
9131
							relevance += computeRelevanceForCaseMatching(token, typeName);
9132
							relevance += computeRelevanceForExpectingType(refBinding);
9133
							relevance += computeRelevanceForQualification(isQualified);
9134
							relevance += computeRelevanceForRestrictions(accessibility);
9135
9136
							if(refBinding.isClass()) {
9137
								relevance += computeRelevanceForClass();
9138
								relevance += computeRelevanceForException(typeName);
9139
							} else if(refBinding.isEnum()) {
9140
								relevance += computeRelevanceForEnum();
9141
							} else if(refBinding.isInterface()) {
9142
								relevance += computeRelevanceForInterface();
9143
							}
9144
9145
							this.noProposal = false;
9146
							if(!this.requestor.isIgnored(CompletionProposal.TYPE_REF)) {
9147
								InternalCompletionProposal proposal =  createProposal(CompletionProposal.TYPE_REF, this.actualCompletionPosition);
9148
								proposal.setDeclarationSignature(packageName);
9149
								proposal.setSignature(getSignature(refBinding));
9150
								proposal.setPackageName(packageName);
9151
								proposal.setTypeName(typeName);
9152
								proposal.setCompletion(completionName);
9153
								proposal.setFlags(refBinding.modifiers);
9154
								proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset);
9155
								proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset);
9156
								proposal.setRelevance(relevance);
9157
								proposal.setAccessibility(accessibility);
9158
								this.requestor.accept(proposal);
9159
								if(DEBUG) {
9160
									this.printDebug(proposal);
9161
								}
9162
							}
9163
						}
9972
						}
9164
					}
9973
					}
9165
				}
9974
				}
9166
			}
9975
			}
9167
		} else {
9976
			
9168
			if(!isEmptyPrefix && !this.requestor.isIgnored(CompletionProposal.KEYWORD)) {
9977
			if (proposeConstructor) {
9169
				if (this.assistNodeInJavadoc == 0 || (this.assistNodeInJavadoc & CompletionOnJavadoc.BASE_TYPES) != 0) {
9978
				int l = typesFound.size();
9170
					if (proposeBaseTypes) {
9979
				for (int i = 0; i < l; i++) {
9171
						if (proposeVoidType) {
9980
					ReferenceBinding typeFound = (ReferenceBinding) typesFound.elementAt(i);
9172
							findKeywords(token, BASE_TYPE_NAMES, false, false);
9981
					char[] fullyQualifiedTypeName =
9173
						} else {
9982
						CharOperation.concat(
9174
							findKeywords(token, BASE_TYPE_NAMES_WITHOUT_VOID, false, false);
9983
								typeFound.qualifiedPackageName(),
9175
						}
9984
								typeFound.qualifiedSourceName(),
9176
					}
9985
								'.');
9986
					this.knownTypes.put(fullyQualifiedTypeName, KNOWN_TYPE_WITH_KNOWN_CONSTRUCTORS);
9177
				}
9987
				}
9178
			}
9988
				
9179
			if(proposeType) {
9989
				checkCancel();
9990
				
9991
				this.foundConstructorsCount = 0;
9992
				this.nameEnvironment.findConstructorDeclarations(
9993
						token,
9994
						this.options.camelCaseMatch,
9995
						this,
9996
						this.monitor);
9997
				acceptConstructors(scope);
9998
			} else if (proposeType) {
9180
				int l = typesFound.size();
9999
				int l = typesFound.size();
9181
				for (int i = 0; i < l; i++) {
10000
				for (int i = 0; i < l; i++) {
9182
					ReferenceBinding typeFound = (ReferenceBinding) typesFound.elementAt(i);
10001
					ReferenceBinding typeFound = (ReferenceBinding) typesFound.elementAt(i);
Lines 9185-9191 Link Here
9185
								typeFound.qualifiedPackageName(),
10004
								typeFound.qualifiedPackageName(),
9186
								typeFound.qualifiedSourceName(),
10005
								typeFound.qualifiedSourceName(),
9187
								'.');
10006
								'.');
9188
					this.knownTypes.put(fullyQualifiedTypeName, this);
10007
					this.knownTypes.put(fullyQualifiedTypeName, KNOWN_TYPE_WITH_KNOWN_CONSTRUCTORS);
9189
				}
10008
				}
9190
				int searchFor = IJavaSearchConstants.TYPE;
10009
				int searchFor = IJavaSearchConstants.TYPE;
9191
				if(this.assistNodeIsClass) {
10010
				if(this.assistNodeIsClass) {
Lines 9223-9232 Link Here
9223
		char[] token,
10042
		char[] token,
9224
		PackageBinding packageBinding,
10043
		PackageBinding packageBinding,
9225
		Scope scope) {
10044
		Scope scope) {
10045
		
10046
		boolean allowingLongComputationProposals = isAllowingLongComputationProposals();
9226
10047
9227
		boolean proposeType =
10048
		boolean proposeType =
9228
			!this.requestor.isIgnored(CompletionProposal.TYPE_REF) ||
10049
			!this.requestor.isIgnored(CompletionProposal.TYPE_REF) ||
9229
			((this.assistNodeInJavadoc & CompletionOnJavadoc.TEXT) != 0 && !this.requestor.isIgnored(CompletionProposal.JAVADOC_TYPE_REF));
10050
			((this.assistNodeInJavadoc & CompletionOnJavadoc.TEXT) != 0 && !this.requestor.isIgnored(CompletionProposal.JAVADOC_TYPE_REF));
10051
		
10052
		boolean proposeConstructor =
10053
			allowingLongComputationProposals &&
10054
			this.assistNodeIsConstructor &&
10055
			(!isIgnored(CompletionProposal.CONSTRUCTOR_INVOCATION, CompletionProposal.TYPE_REF) ||
10056
					!isIgnored(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION, CompletionProposal.TYPE_REF));
9230
10057
9231
		char[] qualifiedName =
10058
		char[] qualifiedName =
9232
			CharOperation.concatWith(packageBinding.compoundName, token, '.');
10059
			CharOperation.concatWith(packageBinding.compoundName, token, '.');
Lines 9244-9250 Link Here
9244
10071
9245
		this.qualifiedCompletionToken = qualifiedName;
10072
		this.qualifiedCompletionToken = qualifiedName;
9246
10073
9247
		if (proposeType && this.unitScope != null) {
10074
		if ((proposeType || proposeConstructor) && this.unitScope != null) {
9248
			int typeLength = qualifiedName.length;
10075
			int typeLength = qualifiedName.length;
9249
			SourceTypeBinding[] types = this.unitScope.topLevelTypes;
10076
			SourceTypeBinding[] types = this.unitScope.topLevelTypes;
9250
10077
Lines 9290-9296 Link Here
9290
					}
10117
					}
9291
				}
10118
				}
9292
10119
9293
				this.knownTypes.put(CharOperation.concat(sourceType.qualifiedPackageName(), sourceType.sourceName(), '.'), this);
10120
				this.knownTypes.put(CharOperation.concat(sourceType.qualifiedPackageName(), sourceType.sourceName(), '.'), KNOWN_TYPE_WITH_KNOWN_CONSTRUCTORS);
9294
10121
9295
				int relevance = computeBaseRelevance();
10122
				int relevance = computeBaseRelevance();
9296
				relevance += computeRelevanceForResolution();
10123
				relevance += computeRelevanceForResolution();
Lines 9308-9315 Link Here
9308
					relevance += computeRelevanceForClass();
10135
					relevance += computeRelevanceForClass();
9309
					relevance += computeRelevanceForException(sourceType.sourceName);
10136
					relevance += computeRelevanceForException(sourceType.sourceName);
9310
				}
10137
				}
10138
				
9311
				this.noProposal = false;
10139
				this.noProposal = false;
9312
				if(proposeType) {
10140
				if(proposeType && (!this.assistNodeIsConstructor || !allowingLongComputationProposals || hasStaticMemberTypes(sourceType, null, this.unitScope))) {
9313
					char[] typeName = sourceType.sourceName();
10141
					char[] typeName = sourceType.sourceName();
9314
					createTypeProposal(
10142
					createTypeProposal(
9315
							sourceType,
10143
							sourceType,
Lines 9322-9331 Link Here
9322
							null,
10150
							null,
9323
							false);
10151
							false);
9324
				}
10152
				}
10153
				
10154
				if (proposeConstructor) {
10155
					findConstructorsOrAnonymousTypes(
10156
							sourceType,
10157
							scope,
10158
							FakeInvocationSite,
10159
							false,
10160
							relevance);
10161
				}
9325
			}
10162
			}
9326
		}
10163
		}
9327
10164
9328
		if(proposeType) {
10165
		if (proposeConstructor) {
10166
10167
			
10168
			checkCancel();
10169
			
10170
			this.foundConstructorsCount = 0;
10171
			this.nameEnvironment.findConstructorDeclarations(
10172
					qualifiedName,
10173
					this.options.camelCaseMatch,
10174
					this,
10175
					this.monitor);
10176
			acceptConstructors(scope);
10177
		} if(proposeType) {
9329
			int searchFor = IJavaSearchConstants.TYPE;
10178
			int searchFor = IJavaSearchConstants.TYPE;
9330
			if(this.assistNodeIsClass) {
10179
			if(this.assistNodeIsClass) {
9331
				searchFor = IJavaSearchConstants.CLASS;
10180
				searchFor = IJavaSearchConstants.CLASS;
Lines 9349-9359 Link Here
9349
					this.monitor);
10198
					this.monitor);
9350
			acceptTypes(scope);
10199
			acceptTypes(scope);
9351
		}
10200
		}
10201
		
9352
		if(!this.requestor.isIgnored(CompletionProposal.PACKAGE_REF)) {
10202
		if(!this.requestor.isIgnored(CompletionProposal.PACKAGE_REF)) {
9353
			this.nameEnvironment.findPackages(qualifiedName, this);
10203
			this.nameEnvironment.findPackages(qualifiedName, this);
9354
		}
10204
		}
9355
	}
10205
	}
10206
	
10207
	private void findTypesFromExpectedTypes(char[] token, Scope scope, ObjectVector typesFound, boolean proposeType, boolean proposeConstructor) {
10208
		if(this.expectedTypesPtr > -1) {
10209
			boolean allowingLongComputationProposals = isAllowingLongComputationProposals();
10210
			
10211
			int typeLength = token == null ? 0 : token.length;
10212
			
10213
			next : for (int i = 0; i <= this.expectedTypesPtr; i++) {
10214
				
10215
				checkCancel();
10216
				
10217
				if(this.expectedTypes[i] instanceof ReferenceBinding) {
10218
					ReferenceBinding refBinding = (ReferenceBinding)this.expectedTypes[i];
10219
					
10220
					if (typeLength > 0) {
10221
						if (typeLength > refBinding.sourceName.length) continue next;
10222
	
10223
						if (!CharOperation.prefixEquals(token, refBinding.sourceName, false)
10224
								&& !(this.options.camelCaseMatch && CharOperation.camelCaseMatch(token, refBinding.sourceName))) continue next;
10225
					}
10226
10227
10228
					if(refBinding.isTypeVariable() && this.assistNodeIsConstructor) {
10229
						// don't propose type variable if the completion is a constructor ('new |')
10230
						continue next;
10231
					}
10232
					if (this.options.checkDeprecation &&
10233
							refBinding.isViewedAsDeprecated() &&
10234
							!scope.isDefinedInSameUnit(refBinding))
10235
						continue next;
10236
10237
					int accessibility = IAccessRule.K_ACCESSIBLE;
10238
					if(refBinding.hasRestrictedAccess()) {
10239
						AccessRestriction accessRestriction = this.lookupEnvironment.getAccessRestriction(refBinding);
10240
						if(accessRestriction != null) {
10241
							switch (accessRestriction.getProblemId()) {
10242
								case IProblem.ForbiddenReference:
10243
									if (this.options.checkForbiddenReference) {
10244
										continue next;
10245
									}
10246
									accessibility = IAccessRule.K_NON_ACCESSIBLE;
10247
									break;
10248
								case IProblem.DiscouragedReference:
10249
									if (this.options.checkDiscouragedReference) {
10250
										continue next;
10251
									}
10252
									accessibility = IAccessRule.K_DISCOURAGED;
10253
									break;
10254
							}
10255
						}
10256
					}
10257
10258
					for (int j = 0; j < typesFound.size(); j++) {
10259
						ReferenceBinding typeFound = (ReferenceBinding)typesFound.elementAt(j);
10260
						if (typeFound == refBinding) {
10261
							continue next;
10262
						}
10263
					}
10264
					
10265
					typesFound.add(refBinding);
9356
10266
10267
					boolean inSameUnit = this.unitScope.isDefinedInSameUnit(refBinding);
10268
10269
					// top level types of the current unit are already proposed.
10270
					if(!inSameUnit || (inSameUnit && refBinding.isMemberType())) {
10271
						char[] packageName = refBinding.qualifiedPackageName();
10272
						char[] typeName = refBinding.sourceName();
10273
						char[] completionName = typeName;
10274
10275
						boolean isQualified = false;
10276
						if (!this.insideQualifiedReference && !refBinding.isMemberType()) {
10277
							if (mustQualifyType(packageName, typeName, null, refBinding.modifiers)) {
10278
								if (packageName == null || packageName.length == 0)
10279
									if (this.unitScope != null && this.unitScope.fPackage.compoundName != CharOperation.NO_CHAR_CHAR)
10280
										continue next; // ignore types from the default package from outside it
10281
								completionName = CharOperation.concat(packageName, typeName, '.');
10282
								isQualified = true;
10283
							}
10284
						}
10285
10286
						if(this.assistNodeIsClass) {
10287
							if(!refBinding.isClass()) continue next;
10288
						} else if(this.assistNodeIsInterface) {
10289
							if(!refBinding.isInterface() && !refBinding.isAnnotationType()) continue next;
10290
						} else if (this.assistNodeIsAnnotation) {
10291
							if(!refBinding.isAnnotationType()) continue next;
10292
						}
10293
10294
						int relevance = computeBaseRelevance();
10295
						relevance += computeRelevanceForResolution();
10296
						relevance += computeRelevanceForInterestingProposal();
10297
						relevance += computeRelevanceForCaseMatching(token, typeName);
10298
						relevance += computeRelevanceForExpectingType(refBinding);
10299
						relevance += computeRelevanceForQualification(isQualified);
10300
						relevance += computeRelevanceForRestrictions(accessibility);
10301
10302
						if(refBinding.isClass()) {
10303
							relevance += computeRelevanceForClass();
10304
							relevance += computeRelevanceForException(typeName);
10305
						} else if(refBinding.isEnum()) {
10306
							relevance += computeRelevanceForEnum();
10307
						} else if(refBinding.isInterface()) {
10308
							relevance += computeRelevanceForInterface();
10309
						}
10310
						
10311
						if (proposeType && (!this.assistNodeIsConstructor || !allowingLongComputationProposals || hasStaticMemberTypes(refBinding, scope.enclosingSourceType() ,this.unitScope))) {
10312
							this.noProposal = false;
10313
							if(!this.requestor.isIgnored(CompletionProposal.TYPE_REF)) {
10314
								InternalCompletionProposal proposal =  createProposal(CompletionProposal.TYPE_REF, this.actualCompletionPosition);
10315
								proposal.setDeclarationSignature(packageName);
10316
								proposal.setSignature(getSignature(refBinding));
10317
								proposal.setPackageName(packageName);
10318
								proposal.setTypeName(typeName);
10319
								proposal.setCompletion(completionName);
10320
								proposal.setFlags(refBinding.modifiers);
10321
								proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset);
10322
								proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset);
10323
								proposal.setRelevance(relevance);
10324
								proposal.setAccessibility(accessibility);
10325
								this.requestor.accept(proposal);
10326
								if(DEBUG) {
10327
									this.printDebug(proposal);
10328
								}
10329
							}
10330
						}
10331
						
10332
						if (proposeConstructor) {
10333
							findConstructorsOrAnonymousTypes(
10334
									refBinding,
10335
									scope,
10336
									FakeInvocationSite,
10337
									isQualified,
10338
									relevance);
10339
						}
10340
					}
10341
				}
10342
			}
10343
		}
10344
	}
10345
10346
	private void findTypesFromImports(char[] token, Scope scope, boolean proposeType, ObjectVector typesFound) {
10347
		ImportBinding[] importBindings = scope.compilationUnitScope().imports;
10348
		next : for (int i = 0; i < importBindings.length; i++) {
10349
			ImportBinding importBinding = importBindings[i];
10350
			if(importBinding.isValidBinding()) {
10351
				Binding binding = importBinding.resolvedImport;
10352
				if(binding != null && binding.isValidBinding()) {
10353
					if(importBinding.onDemand) {
10354
						if (importBinding.isStatic()) {
10355
							if((binding.kind() & Binding.TYPE) != 0) {
10356
								this.findMemberTypes(
10357
										token,
10358
										(ReferenceBinding) binding,
10359
										scope,
10360
										scope.enclosingSourceType(),
10361
										true,
10362
										false,
10363
										true,
10364
										true,
10365
										false,
10366
										null,
10367
										typesFound,
10368
										null,
10369
										null,
10370
										null,
10371
										false);
10372
							}
10373
						}
10374
					} else {
10375
						if ((binding.kind() & Binding.TYPE) != 0) {
10376
							ReferenceBinding typeBinding = (ReferenceBinding) binding;
10377
							int typeLength = token.length;
10378
10379
							if (!typeBinding.isStatic()) continue next;
10380
10381
							if (typeLength > typeBinding.sourceName.length)	continue next;
10382
10383
							if (!CharOperation.prefixEquals(token, typeBinding.sourceName, false)
10384
									&& !(this.options.camelCaseMatch && CharOperation.camelCaseMatch(token, typeBinding.sourceName))) continue next;
10385
							
10386
							int accessibility = IAccessRule.K_ACCESSIBLE;
10387
							if(typeBinding.hasRestrictedAccess()) {
10388
								AccessRestriction accessRestriction = this.lookupEnvironment.getAccessRestriction(typeBinding);
10389
								if(accessRestriction != null) {
10390
									switch (accessRestriction.getProblemId()) {
10391
										case IProblem.ForbiddenReference:
10392
											if (this.options.checkForbiddenReference) {
10393
												continue next;
10394
											}
10395
											accessibility = IAccessRule.K_NON_ACCESSIBLE;
10396
											break;
10397
										case IProblem.DiscouragedReference:
10398
											if (this.options.checkDiscouragedReference) {
10399
												continue next;
10400
											}
10401
											accessibility = IAccessRule.K_DISCOURAGED;
10402
											break;
10403
									}
10404
								}
10405
							}
10406
							
10407
							if (typesFound.contains(typeBinding)) continue next;
10408
							
10409
							typesFound.add(typeBinding);
10410
							
10411
							if(this.assistNodeIsClass) {
10412
								if(!typeBinding.isClass()) continue;
10413
							} else if(this.assistNodeIsInterface) {
10414
								if(!typeBinding.isInterface() && !typeBinding.isAnnotationType()) continue;
10415
							} else if (this.assistNodeIsAnnotation) {
10416
								if(!typeBinding.isAnnotationType()) continue;
10417
							}
10418
							
10419
							int relevance = computeBaseRelevance();
10420
							relevance += computeRelevanceForResolution();
10421
							relevance += computeRelevanceForInterestingProposal();
10422
							relevance += computeRelevanceForCaseMatching(token, typeBinding.sourceName);
10423
							relevance += computeRelevanceForExpectingType(typeBinding);
10424
							relevance += computeRelevanceForQualification(false);
10425
							relevance += computeRelevanceForRestrictions(accessibility);
10426
			
10427
							if (typeBinding.isAnnotationType()) {
10428
								relevance += computeRelevanceForAnnotation();
10429
								relevance += computeRelevanceForAnnotationTarget(typeBinding);
10430
							} else if (typeBinding.isInterface()) {
10431
								relevance += computeRelevanceForInterface();
10432
							} else if(typeBinding.isClass()){
10433
								relevance += computeRelevanceForClass();
10434
								relevance += computeRelevanceForException(typeBinding.sourceName);
10435
							}
10436
							
10437
							if (proposeType && hasStaticMemberTypes(typeBinding, scope.enclosingSourceType(), this.unitScope)) {
10438
								this.noProposal = false;
10439
								if(!this.requestor.isIgnored(CompletionProposal.TYPE_REF)) {
10440
									InternalCompletionProposal proposal =  createProposal(CompletionProposal.TYPE_REF, this.actualCompletionPosition);
10441
									proposal.setDeclarationSignature(typeBinding.qualifiedPackageName());
10442
									proposal.setSignature(getSignature(typeBinding));
10443
									proposal.setPackageName(typeBinding.qualifiedPackageName());
10444
									proposal.setTypeName(typeBinding.qualifiedSourceName());
10445
									proposal.setCompletion(typeBinding.sourceName());
10446
									proposal.setFlags(typeBinding.modifiers);
10447
									proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset);
10448
									proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset);
10449
									proposal.setRelevance(relevance);
10450
									this.requestor.accept(proposal);
10451
									if(DEBUG) {
10452
										this.printDebug(proposal);
10453
									}
10454
								}
10455
							}
10456
							
10457
							findConstructorsOrAnonymousTypes(
10458
									typeBinding,
10459
									scope,
10460
									FakeInvocationSite,
10461
									false,
10462
									relevance);
10463
						}
10464
					}
10465
				}
10466
			}
10467
		}
10468
	}
10469
	
9357
	private void findTypesFromStaticImports(char[] token, Scope scope, boolean proposeAllMemberTypes, ObjectVector typesFound) {
10470
	private void findTypesFromStaticImports(char[] token, Scope scope, boolean proposeAllMemberTypes, ObjectVector typesFound) {
9358
		ImportBinding[] importBindings = scope.compilationUnitScope().imports;
10471
		ImportBinding[] importBindings = scope.compilationUnitScope().imports;
9359
		for (int i = 0; i < importBindings.length; i++) {
10472
		for (int i = 0; i < importBindings.length; i++) {
Lines 10206-10211 Link Here
10206
11319
10207
		return this.favoriteReferenceBindings = resolvedImports;
11320
		return this.favoriteReferenceBindings = resolvedImports;
10208
	}
11321
	}
11322
	
11323
	private INameEnvironment getNoCacheNameEnvironment() {
11324
		if (this.noCacheNameEnvironment == null) {
11325
			JavaModelManager.getJavaModelManager().cacheZipFiles();
11326
			this.noCacheNameEnvironment = new JavaSearchNameEnvironment(this.javaProject, this.owner == null ? null : JavaModelManager.getJavaModelManager().getWorkingCopies(this.owner, true/*add primary WCs*/));
11327
		}
11328
		return this.noCacheNameEnvironment;
11329
	}
10209
11330
10210
	public AssistParser getParser() {
11331
	public AssistParser getParser() {
10211
11332
Lines 10256-10261 Link Here
10256
		inlineCompletion[inlineLength-1] = '}';
11377
		inlineCompletion[inlineLength-1] = '}';
10257
		return inlineCompletion;
11378
		return inlineCompletion;
10258
	}
11379
	}
11380
	private boolean isAllowingLongComputationProposals() {
11381
		return this.monitor != null;
11382
	}
10259
	private boolean isForbidden(Binding binding) {
11383
	private boolean isForbidden(Binding binding) {
10260
		for (int i = 0; i <= this.forbbidenBindingsPtr; i++) {
11384
		for (int i = 0; i <= this.forbbidenBindingsPtr; i++) {
10261
			if(this.forbbidenBindings[i] == binding) {
11385
			if(this.forbbidenBindings[i] == binding) {
Lines 10469-10474 Link Here
10469
			case CompletionProposal.TYPE_IMPORT :
11593
			case CompletionProposal.TYPE_IMPORT :
10470
				buffer.append("TYPE_IMPORT"); //$NON-NLS-1$
11594
				buffer.append("TYPE_IMPORT"); //$NON-NLS-1$
10471
				break;
11595
				break;
11596
			case CompletionProposal.CONSTRUCTOR_INVOCATION :
11597
				buffer.append("CONSTRUCTOR_INVOCATION"); //$NON-NLS-1$
11598
				break;
11599
			case CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION :
11600
				buffer.append("ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION"); //$NON-NLS-1$
11601
				break;
10472
			default :
11602
			default :
10473
				buffer.append("PROPOSAL"); //$NON-NLS-1$
11603
				buffer.append("PROPOSAL"); //$NON-NLS-1$
10474
				break;
11604
				break;
Lines 10540-10545 Link Here
10540
			buffer.append('\t');
11670
			buffer.append('\t');
10541
		}
11671
		}
10542
	}
11672
	}
11673
	
11674
	private void proposeConstructor(AcceptedConstructor deferredProposal, Scope scope) {
11675
		if (deferredProposal.proposeConstructor) {
11676
			proposeConstructor(
11677
					deferredProposal.simpleTypeName,
11678
					deferredProposal.parameterCount,
11679
					deferredProposal.signature,
11680
					deferredProposal.parameterTypes,
11681
					deferredProposal.parameterNames,
11682
					deferredProposal.modifiers,
11683
					deferredProposal.packageName,
11684
					deferredProposal.typeModifiers,
11685
					deferredProposal.accessibility,
11686
					deferredProposal.simpleTypeName,
11687
					deferredProposal.fullyQualifiedName,
11688
					deferredProposal.mustBeQualified,
11689
					scope,
11690
					deferredProposal.extraFlags);
11691
		}
11692
	}
11693
	
11694
	private void proposeConstructor(
11695
			char[] simpleTypeName,
11696
			int parameterCount,
11697
			char[] signature,
11698
			char[][] parameterTypes,
11699
			char[][] parameterNames,
11700
			int modifiers,
11701
			char[] packageName,
11702
			int typeModifiers,
11703
			int accessibility,
11704
			char[] typeName,
11705
			char[] fullyQualifiedName,
11706
			boolean isQualified,
11707
			Scope scope,
11708
			int extraFlags) {
11709
		char[] typeCompletion = fullyQualifiedName;
11710
		if(isQualified) {
11711
			if (packageName == null || packageName.length == 0)
11712
				if (this.unitScope != null && this.unitScope.fPackage.compoundName != CharOperation.NO_CHAR_CHAR)
11713
					return; // ignore types from the default package from outside it
11714
		} else {
11715
			typeCompletion = simpleTypeName;
11716
		}
11717
11718
		int relevance = computeBaseRelevance();
11719
		relevance += computeRelevanceForResolution();
11720
		relevance += computeRelevanceForInterestingProposal();
11721
		relevance += computeRelevanceForRestrictions(accessibility);
11722
		relevance += computeRelevanceForCaseMatching(this.completionToken, simpleTypeName);
11723
		relevance += computeRelevanceForExpectingType(packageName, simpleTypeName);
11724
		relevance += computeRelevanceForQualification(isQualified);
11725
11726
		boolean isInterface = false;
11727
		int kind = typeModifiers & (ClassFileConstants.AccInterface | ClassFileConstants.AccEnum | ClassFileConstants.AccAnnotation);
11728
		switch (kind) {
11729
			case ClassFileConstants.AccAnnotation:
11730
			case ClassFileConstants.AccAnnotation | ClassFileConstants.AccInterface:
11731
				relevance += computeRelevanceForAnnotation();
11732
				relevance += computeRelevanceForInterface();
11733
				isInterface = true;
11734
				break;
11735
			case ClassFileConstants.AccEnum:
11736
				relevance += computeRelevanceForEnum();
11737
				break;
11738
			case ClassFileConstants.AccInterface:
11739
				relevance += computeRelevanceForInterface();
11740
				isInterface = true;
11741
				break;
11742
			default:
11743
				relevance += computeRelevanceForClass();
11744
				relevance += computeRelevanceForException(simpleTypeName);
11745
				break;
11746
		}
11747
		
11748
		char[] completion;
11749
		if (this.source != null
11750
					&& this.source.length > this.endPosition
11751
					&& this.source[this.endPosition] == '(') {
11752
			completion = CharOperation.NO_CHAR;
11753
		} else {
11754
			completion = new char[] { '(', ')' };
11755
		}
11756
		
11757
		InternalCompletionProposal typeProposal = createProposal(CompletionProposal.TYPE_REF, this.actualCompletionPosition);
11758
		typeProposal.nameLookup = this.nameEnvironment.nameLookup;
11759
		typeProposal.completionEngine = this;
11760
		typeProposal.setDeclarationSignature(packageName);
11761
		typeProposal.setSignature(createNonGenericTypeSignature(packageName, typeName));
11762
		typeProposal.setPackageName(packageName);
11763
		typeProposal.setTypeName(typeName);
11764
		typeProposal.setCompletion(typeCompletion);
11765
		typeProposal.setFlags(typeModifiers);
11766
		typeProposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset);
11767
		typeProposal.setTokenRange(this.startPosition - this.offset, this.endPosition - this.offset);
11768
		typeProposal.setRelevance(relevance);
11769
		
11770
		switch (parameterCount) {
11771
			case -1: // default constructor
11772
				int flags = Flags.AccPublic;
11773
				if (Flags.isDeprecated(typeModifiers)) {
11774
					flags |= Flags.AccDeprecated;
11775
				}
11776
				
11777
				if (isInterface || (typeModifiers & ClassFileConstants.AccAbstract) != 0) {
11778
					this.noProposal = false;
11779
					if(!isIgnored(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION, CompletionProposal.TYPE_REF)) {
11780
						InternalCompletionProposal proposal = createProposal(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION, this.actualCompletionPosition);
11781
						proposal.setDeclarationSignature(createNonGenericTypeSignature(packageName, typeName));
11782
						proposal.setDeclarationKey(createBindingKey(packageName, typeName));
11783
						proposal.setSignature(DEFAULT_CONSTRUCTOR_SIGNATURE);
11784
						proposal.setDeclarationPackageName(packageName);
11785
						proposal.setDeclarationTypeName(typeName);
11786
						proposal.setParameterPackageNames(CharOperation.NO_CHAR_CHAR);
11787
						proposal.setParameterTypeNames(CharOperation.NO_CHAR_CHAR);
11788
						proposal.setParameterNames(CharOperation.NO_CHAR_CHAR);
11789
						proposal.setName(simpleTypeName);
11790
						proposal.setRequiredProposals(new CompletionProposal[]{typeProposal});
11791
						proposal.setIsContructor(true);
11792
						proposal.setCompletion(completion);
11793
						proposal.setFlags(flags);
11794
						proposal.setReplaceRange(this.endPosition - this.offset, this.endPosition - this.offset);
11795
						proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset);
11796
						proposal.setRelevance(relevance);
11797
						this.requestor.accept(proposal);
11798
						if(DEBUG) {
11799
							this.printDebug(proposal);
11800
						}
11801
					}
11802
				} else {
11803
					this.noProposal = false;
11804
					if(!isIgnored(CompletionProposal.CONSTRUCTOR_INVOCATION, CompletionProposal.TYPE_REF)) {
11805
						InternalCompletionProposal proposal =  createProposal(CompletionProposal.CONSTRUCTOR_INVOCATION, this.actualCompletionPosition);
11806
						proposal.setDeclarationSignature(createNonGenericTypeSignature(packageName, typeName));
11807
						proposal.setSignature(DEFAULT_CONSTRUCTOR_SIGNATURE);
11808
						proposal.setDeclarationPackageName(packageName);
11809
						proposal.setDeclarationTypeName(typeName);
11810
						proposal.setParameterPackageNames(CharOperation.NO_CHAR_CHAR);
11811
						proposal.setParameterTypeNames(CharOperation.NO_CHAR_CHAR);
11812
						proposal.setParameterNames(CharOperation.NO_CHAR_CHAR);
11813
						proposal.setName(simpleTypeName);
11814
						proposal.setRequiredProposals(new CompletionProposal[]{typeProposal});
11815
						proposal.setIsContructor(true);
11816
						proposal.setCompletion(completion);
11817
						proposal.setFlags(flags);
11818
						proposal.setReplaceRange(this.endPosition - this.offset, this.endPosition - this.offset);
11819
						proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset);
11820
						proposal.setRelevance(relevance);
11821
						this.requestor.accept(proposal);
11822
						if(DEBUG) {
11823
							this.printDebug(proposal);
11824
						}
11825
					}
11826
				}
11827
				break;
11828
			case 0: // constructor with no parameter
11829
				
11830
				if ((typeModifiers & ClassFileConstants.AccAbstract) != 0) {
11831
					this.noProposal = false;
11832
					if(!isIgnored(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION, CompletionProposal.TYPE_REF)) {
11833
						InternalCompletionProposal proposal = createProposal(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION, this.actualCompletionPosition);
11834
						proposal.setDeclarationSignature(createNonGenericTypeSignature(packageName, typeName));
11835
						proposal.setDeclarationKey(createBindingKey(packageName, typeName));
11836
						proposal.setSignature(DEFAULT_CONSTRUCTOR_SIGNATURE);
11837
						proposal.setDeclarationPackageName(packageName);
11838
						proposal.setDeclarationTypeName(typeName);
11839
						proposal.setParameterPackageNames(CharOperation.NO_CHAR_CHAR);
11840
						proposal.setParameterTypeNames(CharOperation.NO_CHAR_CHAR);
11841
						proposal.setParameterNames(CharOperation.NO_CHAR_CHAR);
11842
						proposal.setName(simpleTypeName);
11843
						proposal.setRequiredProposals(new CompletionProposal[]{typeProposal});
11844
						proposal.setIsContructor(true);
11845
						proposal.setCompletion(completion);
11846
						proposal.setFlags(modifiers);
11847
						proposal.setReplaceRange(this.endPosition - this.offset, this.endPosition - this.offset);
11848
						proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset);
11849
						proposal.setRelevance(relevance);
11850
						this.requestor.accept(proposal);
11851
						if(DEBUG) {
11852
							this.printDebug(proposal);
11853
						}
11854
					}
11855
				} else {
11856
					this.noProposal = false;
11857
					if(!isIgnored(CompletionProposal.CONSTRUCTOR_INVOCATION, CompletionProposal.TYPE_REF)) {
11858
						InternalCompletionProposal proposal =  createProposal(CompletionProposal.CONSTRUCTOR_INVOCATION, this.actualCompletionPosition);
11859
						proposal.setDeclarationSignature(createNonGenericTypeSignature(packageName, typeName));
11860
						proposal.setSignature(DEFAULT_CONSTRUCTOR_SIGNATURE);
11861
						proposal.setDeclarationPackageName(packageName);
11862
						proposal.setDeclarationTypeName(typeName);
11863
						proposal.setParameterPackageNames(CharOperation.NO_CHAR_CHAR);
11864
						proposal.setParameterTypeNames(CharOperation.NO_CHAR_CHAR);
11865
						proposal.setParameterNames(CharOperation.NO_CHAR_CHAR);
11866
						proposal.setName(simpleTypeName);
11867
						proposal.setRequiredProposals(new CompletionProposal[]{typeProposal});
11868
						proposal.setIsContructor(true);
11869
						proposal.setCompletion(completion);
11870
						proposal.setFlags(modifiers);
11871
						proposal.setReplaceRange(this.endPosition - this.offset, this.endPosition - this.offset);
11872
						proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset);
11873
						proposal.setRelevance(relevance);
11874
						this.requestor.accept(proposal);
11875
						if(DEBUG) {
11876
							this.printDebug(proposal);
11877
						}
11878
					}
11879
				}
11880
				break;
11881
			default: // constructor with parameter
11882
				if (signature == null) {
11883
					// resolve type to found parameter types
11884
					signature = getResolvedSignature(parameterTypes, fullyQualifiedName, parameterCount, scope);
11885
					if (signature == null) return;
11886
				} else {
11887
					signature = CharOperation.replaceOnCopy(signature, '/', '.');
11888
				}
11889
				
11890
				int parameterNamesLength = parameterNames == null ? 0 : parameterNames.length;
11891
				if (parameterCount != parameterNamesLength) {
11892
					parameterNames = null;
11893
				}
11894
				
11895
				if ((typeModifiers & ClassFileConstants.AccAbstract) != 0) {
11896
					this.noProposal = false;
11897
					if(!isIgnored(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION, CompletionProposal.TYPE_REF)) {
11898
						InternalCompletionProposal proposal = createProposal(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION, this.actualCompletionPosition);
11899
						proposal.setDeclarationSignature(createNonGenericTypeSignature(packageName, typeName));
11900
						proposal.setDeclarationKey(createBindingKey(packageName, typeName));
11901
						proposal.setSignature(signature);
11902
						proposal.setDeclarationPackageName(packageName);
11903
						proposal.setDeclarationTypeName(typeName);
11904
						proposal.setParameterPackageNames(CharOperation.NO_CHAR_CHAR);
11905
						proposal.setParameterTypeNames(CharOperation.NO_CHAR_CHAR);
11906
						if (parameterNames != null) {
11907
							proposal.setParameterNames(parameterNames);
11908
						} else {
11909
							proposal.setHasNoParameterNamesFromIndex(true);
11910
						}
11911
						proposal.setName(simpleTypeName);
11912
						proposal.setRequiredProposals(new CompletionProposal[]{typeProposal});
11913
						proposal.setIsContructor(true);
11914
						proposal.setCompletion(completion);
11915
						proposal.setFlags(modifiers);
11916
						proposal.setReplaceRange(this.endPosition - this.offset, this.endPosition - this.offset);
11917
						proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset);
11918
						proposal.setRelevance(relevance);
11919
						this.requestor.accept(proposal);
11920
						if(DEBUG) {
11921
							this.printDebug(proposal);
11922
						}
11923
					}
11924
				} else {
11925
					this.noProposal = false;
11926
					if(!isIgnored(CompletionProposal.CONSTRUCTOR_INVOCATION, CompletionProposal.TYPE_REF)) {
11927
						InternalCompletionProposal proposal =  createProposal(CompletionProposal.CONSTRUCTOR_INVOCATION, this.actualCompletionPosition);
11928
						proposal.setDeclarationSignature(createNonGenericTypeSignature(packageName, typeName));
11929
						proposal.setSignature(signature);
11930
						proposal.setDeclarationPackageName(packageName);
11931
						proposal.setDeclarationTypeName(typeName);
11932
						proposal.setParameterPackageNames(CharOperation.NO_CHAR_CHAR);
11933
						proposal.setParameterTypeNames(CharOperation.NO_CHAR_CHAR);
11934
						if (parameterNames != null) {
11935
							proposal.setParameterNames(parameterNames);
11936
						} else {
11937
							proposal.setHasNoParameterNamesFromIndex(true);
11938
						}
11939
						proposal.setName(simpleTypeName);
11940
						proposal.setRequiredProposals(new CompletionProposal[]{typeProposal});
11941
						proposal.setIsContructor(true);
11942
						proposal.setCompletion(completion);
11943
						proposal.setFlags(modifiers);
11944
						proposal.setReplaceRange(this.endPosition - this.offset, this.endPosition - this.offset);
11945
						proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset);
11946
						proposal.setRelevance(relevance);
11947
						
11948
						this.requestor.accept(proposal);
11949
						if(DEBUG) {
11950
							this.printDebug(proposal);
11951
						}
11952
					}
11953
				}
11954
				break;
11955
		}
11956
	}
10543
11957
10544
	private void proposeNewMethod(char[] token, ReferenceBinding reference) {
11958
	private void proposeNewMethod(char[] token, ReferenceBinding reference) {
10545
		if(!this.requestor.isIgnored(CompletionProposal.POTENTIAL_METHOD_DECLARATION)) {
11959
		if(!this.requestor.isIgnored(CompletionProposal.POTENTIAL_METHOD_DECLARATION)) {
Lines 10662-10667 Link Here
10662
		super.reset(false);
12076
		super.reset(false);
10663
		this.knownPkgs = new HashtableOfObject(10);
12077
		this.knownPkgs = new HashtableOfObject(10);
10664
		this.knownTypes = new HashtableOfObject(10);
12078
		this.knownTypes = new HashtableOfObject(10);
12079
		if (this.noCacheNameEnvironment != null) {
12080
			this.noCacheNameEnvironment.cleanup();
12081
			this.noCacheNameEnvironment = null;
12082
			JavaModelManager.getJavaModelManager().flushZipFiles();
12083
		}
10665
	}
12084
	}
10666
12085
10667
	private void setSourceAndTokenRange(int start, int end) {
12086
	private void setSourceAndTokenRange(int start, int end) {
(-)codeassist/org/eclipse/jdt/internal/codeassist/InternalCompletionProposal.java (-37 / +148 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2006 IBM Corporation and others.
2
 * Copyright (c) 2004, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 18-30 Link Here
18
import org.eclipse.jdt.core.IAccessRule;
18
import org.eclipse.jdt.core.IAccessRule;
19
import org.eclipse.jdt.core.ICodeAssist;
19
import org.eclipse.jdt.core.ICodeAssist;
20
import org.eclipse.jdt.core.ICompilationUnit;
20
import org.eclipse.jdt.core.ICompilationUnit;
21
import org.eclipse.jdt.core.IJavaElement;
21
import org.eclipse.jdt.core.IMethod;
22
import org.eclipse.jdt.core.IMethod;
23
import org.eclipse.jdt.core.IPackageFragmentRoot;
22
import org.eclipse.jdt.core.IType;
24
import org.eclipse.jdt.core.IType;
23
import org.eclipse.jdt.core.JavaModelException;
25
import org.eclipse.jdt.core.JavaModelException;
24
import org.eclipse.jdt.core.Signature;
26
import org.eclipse.jdt.core.Signature;
25
import org.eclipse.jdt.core.compiler.CharOperation;
27
import org.eclipse.jdt.core.compiler.CharOperation;
28
import org.eclipse.jdt.internal.compiler.env.IBinaryMethod;
29
import org.eclipse.jdt.internal.compiler.env.IBinaryType;
26
import org.eclipse.jdt.internal.core.BinaryType;
30
import org.eclipse.jdt.internal.core.BinaryType;
31
import org.eclipse.jdt.internal.core.JavaElement;
27
import org.eclipse.jdt.internal.core.NameLookup;
32
import org.eclipse.jdt.internal.core.NameLookup;
33
import org.eclipse.jdt.internal.core.SourceMapper;
28
34
29
/**
35
/**
30
 * Internal completion proposal
36
 * Internal completion proposal
Lines 32-47 Link Here
32
 */
38
 */
33
public class InternalCompletionProposal extends CompletionProposal {
39
public class InternalCompletionProposal extends CompletionProposal {
34
	private static Object NO_ATTACHED_SOURCE = new Object();
40
	private static Object NO_ATTACHED_SOURCE = new Object();
41
	private static final int OPENED_BYNARY_TYPES_THRESHOLD = 100; // threshold of opened binary to avoid to harm java model cache
35
42
36
	static final char[] ARG = "arg".toCharArray();  //$NON-NLS-1$
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
43
46
	protected CompletionEngine completionEngine;
44
	protected CompletionEngine completionEngine;
47
	protected NameLookup nameLookup;
45
	protected NameLookup nameLookup;
Lines 55-60 Link Here
55
53
56
	protected char[] originalSignature;
54
	protected char[] originalSignature;
57
55
56
	private boolean hasNoParameterNamesFromIndex = false;
58
	private boolean updateCompletion = false;
57
	private boolean updateCompletion = false;
59
58
60
	protected int accessibility = IAccessRule.K_ACCESSIBLE;
59
	protected int accessibility = IAccessRule.K_ACCESSIBLE;
Lines 179-212 Link Here
179
	 * Indicates whether parameter names have been computed.
178
	 * Indicates whether parameter names have been computed.
180
	 */
179
	 */
181
	private boolean parameterNamesComputed = false;
180
	private boolean parameterNamesComputed = false;
181
	
182
	protected char[][] findConstructorParameterNames(char[] declaringTypePackageName, char[] declaringTypeName, char[] selector, char[][] paramTypeNames){
183
		if(paramTypeNames == null || declaringTypeName == null) return null;
182
184
183
	protected char[][] createDefaultParameterNames(int length) {
185
		char[][] parameters = null;
184
		char[][] parameters;
186
		int length = paramTypeNames.length;
185
		switch (length) {
187
186
			case 0 :
188
		char[] tName = CharOperation.concat(declaringTypePackageName,declaringTypeName,'.');
187
				parameters = new char[length][];
189
		Object cachedType = this.completionEngine.typeCache.get(tName);
188
				break;
190
189
			case 1 :
191
		IType type = null;
190
				parameters = ARGS1;
192
		if(cachedType != null) {
191
				break;
193
			if(cachedType != NO_ATTACHED_SOURCE && cachedType instanceof BinaryType) {
192
			case 2 :
194
				type = (BinaryType)cachedType;
193
				parameters = ARGS2;
195
			}
194
				break;
196
		} else {
195
			case 3 :
197
			// TODO (david) shouldn't it be NameLookup.ACCEPT_ALL ?
196
				parameters = ARGS3;
198
			NameLookup.Answer answer = this.nameLookup.findType(new String(tName),
197
				break;
199
				false,
198
			case 4 :
200
				NameLookup.ACCEPT_CLASSES & NameLookup.ACCEPT_INTERFACES,
199
				parameters = ARGS4;
201
				true/* consider secondary types */,
200
				break;
202
				false/* do NOT wait for indexes */,
201
			default :
203
				false/*don't check restrictions*/,
202
				parameters = new char[length][];
204
				null);
203
				for (int i = 0; i < length; i++) {
205
			type = answer == null ? null : answer.type;
204
					parameters[i] = CharOperation.concat(ARG, String.valueOf(i).toCharArray());
206
			if(type instanceof BinaryType){
207
				this.completionEngine.typeCache.put(tName, type);
208
			} else {
209
				type = null;
210
			}
211
		}
212
213
		if(type != null) {
214
			String[] args = new String[length];
215
			for(int i = 0;	i< length ; i++){
216
				args[i] = new String(paramTypeNames[i]);
217
			}
218
			IMethod method = type.getMethod(new String(selector),args);
219
			
220
			if (this.hasNoParameterNamesFromIndex) {
221
				IPackageFragmentRoot packageFragmentRoot = (IPackageFragmentRoot)type.getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT);
222
				if (packageFragmentRoot.isArchive() ||
223
						this.completionEngine.openedBinaryTypes < OPENED_BYNARY_TYPES_THRESHOLD) {
224
					SourceMapper mapper = ((JavaElement)method).getSourceMapper();
225
					if (mapper != null) {
226
						try {
227
							char[][] paramNames = mapper.getMethodParameterNames(method);
228
					
229
							// map source and try to find parameter names
230
							if(paramNames == null) {
231
								this.completionEngine.openedBinaryTypes++;
232
								IBinaryType info = (IBinaryType) ((BinaryType) type).getElementInfo();
233
								char[] source = mapper.findSource(type, info);
234
								if (source != null){
235
									mapper.mapSource(type, source, info);
236
								}
237
								paramNames = mapper.getMethodParameterNames(method);
238
							}
239
							
240
							if(paramNames != null) {
241
								parameters = paramNames;
242
							}
243
						} catch(JavaModelException e){
244
							//parameters == null;
245
						}
246
					}
205
				}
247
				}
206
				break;
248
			} else {
249
				try{
250
					IBinaryMethod info = (IBinaryMethod) ((JavaElement)method).getElementInfo();
251
					char[][] argumentNames = info.getArgumentNames();
252
					if (argumentNames != null && argumentNames.length == length) {
253
						parameters = argumentNames;
254
					}
255
				} catch(JavaModelException e){
256
					//parameters == null;
257
				}
258
				
259
				try{
260
					parameters = new char[length][];
261
					String[] params = method.getParameterNames();
262
					for(int i = 0;	i< length ; i++){
263
						parameters[i] = params[i].toCharArray();
264
					}
265
				} catch(JavaModelException e){
266
					parameters = null;
267
				}
268
			}
269
		}
270
271
		// default parameters name
272
		if(parameters == null) {
273
			parameters = CompletionEngine.createDefaultParameterNames(length);
207
		}
274
		}
275
208
		return parameters;
276
		return parameters;
209
	}
277
	}
278
	
210
	protected char[][] findMethodParameterNames(char[] declaringTypePackageName, char[] declaringTypeName, char[] selector, char[][] paramTypeNames){
279
	protected char[][] findMethodParameterNames(char[] declaringTypePackageName, char[] declaringTypeName, char[] selector, char[][] paramTypeNames){
211
		if(paramTypeNames == null || declaringTypeName == null) return null;
280
		if(paramTypeNames == null || declaringTypeName == null) return null;
212
281
Lines 257-263 Link Here
257
326
258
		// default parameters name
327
		// default parameters name
259
		if(parameters == null) {
328
		if(parameters == null) {
260
			parameters = createDefaultParameterNames(length);
329
			parameters = CompletionEngine.createDefaultParameterNames(length);
261
		}
330
		}
262
331
263
		return parameters;
332
		return parameters;
Lines 1206-1211 Link Here
1206
	public void setFlags(int flags) {
1275
	public void setFlags(int flags) {
1207
		this.flags = flags;
1276
		this.flags = flags;
1208
	}
1277
	}
1278
	
1279
	public void setHasNoParameterNamesFromIndex(boolean hasNoParameterNamesFromIndex) {
1280
		this.hasNoParameterNamesFromIndex = hasNoParameterNamesFromIndex;
1281
	}
1209
1282
1210
	/**
1283
	/**
1211
	 * Returns the required completion proposals.
1284
	 * Returns the required completion proposals.
Lines 1312-1318 Link Here
1312
					} catch(IllegalArgumentException e) {
1385
					} catch(IllegalArgumentException e) {
1313
						// protection for invalid signature
1386
						// protection for invalid signature
1314
						if(this.parameterTypeNames != null) {
1387
						if(this.parameterTypeNames != null) {
1315
							this.parameterNames =  createDefaultParameterNames(this.parameterTypeNames.length);
1388
							this.parameterNames =  CompletionEngine.createDefaultParameterNames(this.parameterTypeNames.length);
1389
						} else {
1390
							this.parameterNames = null;
1391
						}
1392
					}
1393
					break;
1394
				case ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION:
1395
					try {
1396
						this.parameterNames = findConstructorParameterNames(
1397
								this.declarationPackageName,
1398
								this.declarationTypeName,
1399
								CharOperation.lastSegment(this.declarationTypeName, '.'),
1400
								Signature.getParameterTypes(this.originalSignature == null ? this.signature : this.originalSignature));
1401
					} catch(IllegalArgumentException e) {
1402
						// protection for invalid signature
1403
						if(this.parameterTypeNames != null) {
1404
							this.parameterNames =  CompletionEngine.createDefaultParameterNames(this.parameterTypeNames.length);
1316
						} else {
1405
						} else {
1317
							this.parameterNames = null;
1406
							this.parameterNames = null;
1318
						}
1407
						}
Lines 1329-1335 Link Here
1329
					} catch(IllegalArgumentException e) {
1418
					} catch(IllegalArgumentException e) {
1330
						// protection for invalid signature
1419
						// protection for invalid signature
1331
						if(this.parameterTypeNames != null) {
1420
						if(this.parameterTypeNames != null) {
1332
							this.parameterNames =  createDefaultParameterNames(this.parameterTypeNames.length);
1421
							this.parameterNames =  CompletionEngine.createDefaultParameterNames(this.parameterTypeNames.length);
1422
						} else {
1423
							this.parameterNames = null;
1424
						}
1425
					}
1426
					break;
1427
				case CONSTRUCTOR_INVOCATION:
1428
					try {
1429
						this.parameterNames = findConstructorParameterNames(
1430
								this.declarationPackageName,
1431
								this.declarationTypeName,
1432
								this.name,
1433
								Signature.getParameterTypes(this.originalSignature == null ? this.signature : this.originalSignature));
1434
					} catch(IllegalArgumentException e) {
1435
						// protection for invalid signature
1436
						if(this.parameterTypeNames != null) {
1437
							this.parameterNames =  CompletionEngine.createDefaultParameterNames(this.parameterTypeNames.length);
1333
						} else {
1438
						} else {
1334
							this.parameterNames = null;
1439
							this.parameterNames = null;
1335
						}
1440
						}
Lines 1345-1351 Link Here
1345
					} catch(IllegalArgumentException e) {
1450
					} catch(IllegalArgumentException e) {
1346
						// protection for invalid signature
1451
						// protection for invalid signature
1347
						if(this.parameterTypeNames != null) {
1452
						if(this.parameterTypeNames != null) {
1348
							this.parameterNames =  createDefaultParameterNames(this.parameterTypeNames.length);
1453
							this.parameterNames =  CompletionEngine.createDefaultParameterNames(this.parameterTypeNames.length);
1349
						} else {
1454
						} else {
1350
							this.parameterNames = null;
1455
							this.parameterNames = null;
1351
						}
1456
						}
Lines 1623-1628 Link Here
1623
			case CompletionProposal.FIELD_REF_WITH_CASTED_RECEIVER :
1728
			case CompletionProposal.FIELD_REF_WITH_CASTED_RECEIVER :
1624
				buffer.append("FIELD_REF_WITH_CASTED_RECEIVER"); //$NON-NLS-1$
1729
				buffer.append("FIELD_REF_WITH_CASTED_RECEIVER"); //$NON-NLS-1$
1625
				break;
1730
				break;
1731
			case CompletionProposal.CONSTRUCTOR_INVOCATION :
1732
				buffer.append("CONSTRUCTOR_INVOCATION"); //$NON-NLS-1$
1733
				break;
1734
			case CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION :
1735
				buffer.append("ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION"); //$NON-NLS-1$
1736
				break;
1626
			default :
1737
			default :
1627
				buffer.append("PROPOSAL"); //$NON-NLS-1$
1738
				buffer.append("PROPOSAL"); //$NON-NLS-1$
1628
				break;
1739
				break;
(-)codeassist/org/eclipse/jdt/internal/codeassist/ISearchRequestor.java (-1 / +13 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2006 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
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/MissingTypesGuesser.java (-2 / +15 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2006, 2007 IBM Corporation and others.
2
 * Copyright (c) 2006, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
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/SelectionEngine.java (-1 / +16 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
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 (-5 / +5 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
2
 * Copyright (c) 2008, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
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/ICodeAssist.java (+40 lines)
Lines 92-97 Link Here
92
	 * An <code>offset</code> of -1 indicates to code assist at the beginning of this
92
	 * An <code>offset</code> of -1 indicates to code assist at the beginning of this
93
	 * compilation unit.
93
	 * compilation unit.
94
	 * <p>
94
	 * <p>
95
	 * <p>
96
	 * If {@link IProgressMonitor} is not <code>null</code> then some proposals which
97
	 * can be very long to compute are proposed. To avoid that the code assist operation
98
	 * take too much time a {@link IProgressMonitor} which automatically cancel the code
99
	 * assist operation when a specified amount of time is reached could be used.
100
	 * 
101
	 * <pre>
102
	 * new IProgressMonitor() {
103
	 *     private final static int TIMEOUT = 500; //ms
104
	 *     private long endTime;
105
	 *     public void beginTask(String name, int totalWork) {
106
	 *         fEndTime= System.currentTimeMillis() + TIMEOUT;
107
	 *     }
108
	 *     public boolean isCanceled() {
109
	 *         return endTime <= System.currentTimeMillis();
110
	 *     }
111
	 *     ...
112
	 * };
113
	 * </pre>
114
	 * <p>
95
	 *
115
	 *
96
	 * @param offset the given offset position
116
	 * @param offset the given offset position
97
	 * @param requestor the given completion requestor
117
	 * @param requestor the given completion requestor
Lines 180-185 Link Here
180
	 * Note that if a working copy is empty, it will be as if the original compilation
200
	 * Note that if a working copy is empty, it will be as if the original compilation
181
	 * unit had been deleted.
201
	 * unit had been deleted.
182
	 * </p>
202
	 * </p>
203
	 * <p>
204
	 * If {@link IProgressMonitor} is not <code>null</code> then some proposals which
205
	 * can be very long to compute are proposed. To avoid that the code assist operation
206
	 * take too much time a {@link IProgressMonitor} which automatically cancel the code
207
	 * assist operation when a specified amount of time is reached could be used.
208
	 * 
209
	 * <pre>
210
	 * new IProgressMonitor() {
211
	 *     private final static int TIMEOUT = 500; //ms
212
	 *     private long endTime;
213
	 *     public void beginTask(String name, int totalWork) {
214
	 *         fEndTime= System.currentTimeMillis() + TIMEOUT;
215
	 *     }
216
	 *     public boolean isCanceled() {
217
	 *         return endTime <= System.currentTimeMillis();
218
	 *     }
219
	 *     ...
220
	 * };
221
	 * </pre>
222
	 * <p>
183
	 *
223
	 *
184
	 * @param offset the given offset position
224
	 * @param offset the given offset position
185
	 * @param requestor the given completion requestor
225
	 * @param requestor the given completion requestor
(-)model/org/eclipse/jdt/core/IType.java (+40 lines)
Lines 161-166 Link Here
161
	 * If the type has access to its source code and the insertion position is valid,
161
	 * If the type has access to its source code and the insertion position is valid,
162
	 * then completion is performed against the source. Otherwise the completion is performed
162
	 * then completion is performed against the source. Otherwise the completion is performed
163
	 * against the type structure and the given locals variables.
163
	 * against the type structure and the given locals variables.
164
	 * <p>
165
	 * If {@link IProgressMonitor} is not <code>null</code> then some proposals which
166
	 * can be very long to compute are proposed. To avoid that the code assist operation
167
	 * take too much time a {@link IProgressMonitor} which automatically cancel the code
168
	 * assist operation when a specified amount of time is reached could be used.
169
	 * 
170
	 * <pre>
171
	 * new IProgressMonitor() {
172
	 *     private final static int TIMEOUT = 500; //ms
173
	 *     private long endTime;
174
	 *     public void beginTask(String name, int totalWork) {
175
	 *         fEndTime= System.currentTimeMillis() + TIMEOUT;
176
	 *     }
177
	 *     public boolean isCanceled() {
178
	 *         return endTime <= System.currentTimeMillis();
179
	 *     }
180
	 *     ...
181
	 * };
182
	 * </pre>
183
	 * <p>
164
	 *
184
	 *
165
	 * @param snippet the code snippet
185
	 * @param snippet the code snippet
166
	 * @param insertion the position with in source where the snippet
186
	 * @param insertion the position with in source where the snippet
Lines 251-256 Link Here
251
	 * then completion is performed against the source. Otherwise the completion is performed
271
	 * then completion is performed against the source. Otherwise the completion is performed
252
	 * against the type structure and the given locals variables.
272
	 * against the type structure and the given locals variables.
253
	 * </p>
273
	 * </p>
274
	 * <p>
275
	 * If {@link IProgressMonitor} is not <code>null</code> then some proposals which
276
	 * can be very long to compute are proposed. To avoid that the code assist operation
277
	 * take too much time a {@link IProgressMonitor} which automatically cancel the code
278
	 * assist operation when a specified amount of time is reached could be used.
279
	 * 
280
	 * <pre>
281
	 * new IProgressMonitor() {
282
	 *     private final static int TIMEOUT = 500; //ms
283
	 *     private long endTime;
284
	 *     public void beginTask(String name, int totalWork) {
285
	 *         fEndTime= System.currentTimeMillis() + TIMEOUT;
286
	 *     }
287
	 *     public boolean isCanceled() {
288
	 *         return endTime <= System.currentTimeMillis();
289
	 *     }
290
	 *     ...
291
	 * };
292
	 * </pre>
293
	 * <p>
254
	 *
294
	 *
255
	 * @param snippet the code snippet
295
	 * @param snippet the code snippet
256
	 * @param insertion the position with in source where the snippet
296
	 * @param insertion the position with in source where the snippet
(-)model/org/eclipse/jdt/core/CompletionProposal.java (-3 / +85 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2008 IBM Corporation and others.
2
 * Copyright (c) 2004, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
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> if List is a class that is not abstract.
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 completion operation is called with a {@link IProgressMonitor}
821
	 * (eg. {@link ICodeAssist#codeComplete(int, CompletionRequestor, IProgressMonitor)})
822
	 * </p>
823
	 *
824
	 * @see #getKind()
825
	 * 
826
	 * @since 3.5
827
	 */
828
	public static final int CONSTRUCTOR_INVOCATION = 26;
829
	
830
	/**
831
	 * Completion is a reference of a constructor of an anonymous class.
832
	 * This kind of completion might occur in a context like
833
	 * <code>"new Lis^;"</code> and complete it to
834
	 * <code>"new List() {}"</code> if List is an interface or abstract class.
835
	 * <p>
836
	 * The following additional context information is available
837
	 * for this kind of completion proposal at little extra cost:
838
	 * <ul>
839
	 * <li>{@link #getDeclarationSignature()} -
840
	 * the type signature of the type being implemented or subclassed
841
	 * </li>
842
	 * <li>{@link #getDeclarationKey()} -
843
	 * the type unique key of the type being implemented or subclassed
844
	 * </li>
845
	 * <li>{@link #getSignature()} -
846
	 * the method signature of the constructor that is referenced
847
	 * </li>
848
	 * <li>{@link #getKey()} -
849
	 * the method unique key of the constructor that is referenced
850
	 * if the declaring type is not an interface
851
	 * </li>
852
	 * <li>{@link #getFlags()} -
853
	 * the modifiers flags of the constructor that is referenced
854
	 * </li>
855
	 * </ul>
856
	 * </p>
857
	 * <p>
858
	 * This kind of proposal could require a long computation, so they are computed only if completion operation is called with a {@link IProgressMonitor}
859
	 * (eg. {@link ICodeAssist#codeComplete(int, CompletionRequestor, IProgressMonitor)})
860
	 * </p>
861
	 *
862
	 * @see #getKind()
863
	 * 
864
	 * @since 3.5
865
	 */
866
	public static final int ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION = 27;
795
867
796
	/**
868
	/**
797
	 * First valid completion kind.
869
	 * First valid completion kind.
Lines 805-811 Link Here
805
	 *
877
	 *
806
	 * @since 3.1
878
	 * @since 3.1
807
	 */
879
	 */
808
	protected static final int LAST_KIND = FIELD_REF_WITH_CASTED_RECEIVER;
880
	protected static final int LAST_KIND = ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION;
809
881
810
	/**
882
	/**
811
	 * Creates a basic completion proposal. All instance
883
	 * Creates a basic completion proposal. All instance
Lines 1463-1468 Link Here
1463
	 *    <li><code>TYPE_REF</code></li>
1535
	 *    <li><code>TYPE_REF</code></li>
1464
	 *   </ul>
1536
	 *   </ul>
1465
	 *  </li>
1537
	 *  </li>
1538
	 *  <li><code>CONSTRUCTOR_INVOCATION</code> - The allowed required proposals for this kind are:
1539
	 *   <ul>
1540
	 *    <li><code>TYPE_REF</code></li>
1541
	 *   </ul>
1542
	 *  </li>
1543
	 *  <li><code>ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION</code> - The allowed required proposals for this kind are:
1544
	 *   <ul>
1545
	 *    <li><code>TYPE_REF</code></li>
1546
	 *   </ul>
1547
	 *  </li>
1466
	 * </ul>
1548
	 * </ul>
1467
	 * </p>
1549
	 * </p>
1468
	 * <p>
1550
	 * <p>
(-)model/org/eclipse/jdt/core/CompletionRequestor.java (-2 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2008 IBM Corporation and others.
2
 * Copyright (c) 2004, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 174-180 Link Here
174
174
175
		return 0 != (this.requiredProposalAllowSet[proposalKind] & (1 << requiredProposalKind));
175
		return 0 != (this.requiredProposalAllowSet[proposalKind] & (1 << requiredProposalKind));
176
	}
176
	}
177
177
	
178
	/**
178
	/**
179
	 * Sets whether a proposal of a given kind with a required proposal
179
	 * Sets whether a proposal of a given kind with a required proposal
180
	 * of the given kind is allowed.
180
	 * of the given kind is allowed.
(-)codeassist/org/eclipse/jdt/internal/codeassist/impl/Engine.java (-11 / +23 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
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/impl/AssistParser.java (-1 / +16 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
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
}
(-)model/org/eclipse/jdt/core/eval/IEvaluationContext.java (+40 lines)
Lines 184-189 Link Here
184
	 * <p>
184
	 * <p>
185
	 * Note that code completion does not involve evaluation.
185
	 * Note that code completion does not involve evaluation.
186
	 * <p>
186
	 * <p>
187
	 * <p>
188
	 * If {@link IProgressMonitor} is not <code>null</code> then some proposals which
189
	 * can be very long to compute are proposed. To avoid that the code assist operation
190
	 * take too much time a {@link IProgressMonitor} which automatically cancel the code
191
	 * assist operation when a specified amount of time is reached could be used.
192
	 * 
193
	 * <pre>
194
	 * new IProgressMonitor() {
195
	 *     private final static int TIMEOUT = 500; //ms
196
	 *     private long endTime;
197
	 *     public void beginTask(String name, int totalWork) {
198
	 *         fEndTime= System.currentTimeMillis() + TIMEOUT;
199
	 *     }
200
	 *     public boolean isCanceled() {
201
	 *         return endTime <= System.currentTimeMillis();
202
	 *     }
203
	 *     ...
204
	 * };
205
	 * </pre>
206
	 * <p>
187
	 *
207
	 *
188
	 * @param codeSnippet the code snippet to complete in
208
	 * @param codeSnippet the code snippet to complete in
189
	 * @param position the character position in the code snippet to complete at,
209
	 * @param position the character position in the code snippet to complete at,
Lines 252-257 Link Here
252
	 * <p>
272
	 * <p>
253
	 * Note that code completion does not involve evaluation.
273
	 * Note that code completion does not involve evaluation.
254
	 * <p>
274
	 * <p>
275
	 * <p>
276
	 * If {@link IProgressMonitor} is not <code>null</code> then some proposals which
277
	 * can be very long to compute are proposed. To avoid that the code assist operation
278
	 * take too much time a {@link IProgressMonitor} which automatically cancel the code
279
	 * assist operation when a specified amount of time is reached could be used.
280
	 * 
281
	 * <pre>
282
	 * new IProgressMonitor() {
283
	 *     private final static int TIMEOUT = 500; //ms
284
	 *     private long endTime;
285
	 *     public void beginTask(String name, int totalWork) {
286
	 *         fEndTime= System.currentTimeMillis() + TIMEOUT;
287
	 *     }
288
	 *     public boolean isCanceled() {
289
	 *         return endTime <= System.currentTimeMillis();
290
	 *     }
291
	 *     ...
292
	 * };
293
	 * </pre>
294
	 * <p>
255
	 *
295
	 *
256
	 * @param codeSnippet the code snippet to complete in
296
	 * @param codeSnippet the code snippet to complete in
257
	 * @param position the character position in the code snippet to complete at,
297
	 * @param position the character position in the code snippet to complete at,
(-)model/org/eclipse/jdt/internal/core/SearchableEnvironment.java (-1 / +147 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 23-28 Link Here
23
import org.eclipse.jdt.internal.compiler.env.ISourceType;
23
import org.eclipse.jdt.internal.compiler.env.ISourceType;
24
import org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer;
24
import org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer;
25
import org.eclipse.jdt.internal.core.search.BasicSearchEngine;
25
import org.eclipse.jdt.internal.core.search.BasicSearchEngine;
26
import org.eclipse.jdt.internal.core.search.IRestrictedAccessConstructorRequestor;
26
import org.eclipse.jdt.internal.core.search.IRestrictedAccessTypeRequestor;
27
import org.eclipse.jdt.internal.core.search.IRestrictedAccessTypeRequestor;
27
28
28
/**
29
/**
Lines 447-452 Link Here
447
				convertSearchFilterToModelFilter(searchFor));
448
				convertSearchFilterToModelFilter(searchFor));
448
		}
449
		}
449
	}
450
	}
451
	
452
	/**
453
	 * Must be used only by CompletionEngine.
454
	 * The progress monitor is used to be able to cancel completion operations
455
	 * 
456
	 * Find constructor declarations that are defined
457
	 * in the current environment and whose name starts with the
458
	 * given prefix. The prefix is a qualified name separated by periods
459
	 * or a simple name (ex. java.util.V or V).
460
	 *
461
	 * The constructors found are passed to one of the following methods:
462
	 *    ISearchRequestor.acceptConstructor(...)
463
	 */
464
	public void findConstructorDeclarations(char[] prefix, boolean camelCaseMatch, final ISearchRequestor storage, IProgressMonitor monitor) {
465
		try {
466
			final String excludePath;
467
			if (this.unitToSkip != null && this.unitToSkip instanceof IJavaElement) {
468
				excludePath = ((IJavaElement) this.unitToSkip).getPath().toString();
469
			} else {
470
				excludePath = null;
471
			}
472
			
473
			int lastDotIndex = CharOperation.lastIndexOf('.', prefix);
474
			char[] qualification, simpleName;
475
			if (lastDotIndex < 0) {
476
				qualification = null;
477
				if (camelCaseMatch) {
478
					simpleName = prefix;
479
				} else {
480
					simpleName = CharOperation.toLowerCase(prefix);
481
				}
482
			} else {
483
				qualification = CharOperation.subarray(prefix, 0, lastDotIndex);
484
				if (camelCaseMatch) {
485
					simpleName = CharOperation.subarray(prefix, lastDotIndex + 1, prefix.length);
486
				} else {
487
					simpleName =
488
						CharOperation.toLowerCase(
489
							CharOperation.subarray(prefix, lastDotIndex + 1, prefix.length));
490
				}
491
			}
492
493
			IProgressMonitor progressMonitor = new IProgressMonitor() {
494
				boolean isCanceled = false;
495
				public void beginTask(String name, int totalWork) {
496
					// implements interface method
497
				}
498
				public void done() {
499
					// implements interface method
500
				}
501
				public void internalWorked(double work) {
502
					// implements interface method
503
				}
504
				public boolean isCanceled() {
505
					return this.isCanceled;
506
				}
507
				public void setCanceled(boolean value) {
508
					this.isCanceled = value;
509
				}
510
				public void setTaskName(String name) {
511
					// implements interface method
512
				}
513
				public void subTask(String name) {
514
					// implements interface method
515
				}
516
				public void worked(int work) {
517
					// implements interface method
518
				}
519
			};
520
			
521
			IRestrictedAccessConstructorRequestor constructorRequestor = new IRestrictedAccessConstructorRequestor() {
522
				public void acceptConstructor(
523
						int modifiers,
524
						char[] simpleTypeName,
525
						int parameterCount,
526
						char[] signature,
527
						char[][] parameterTypes,
528
						char[][] parameterNames,
529
						int typeModifiers,
530
						char[] packageName,
531
						int extraFlags,
532
						String path,
533
						AccessRestriction access) {
534
					if (excludePath != null && excludePath.equals(path))
535
						return;
536
					
537
					storage.acceptConstructor(
538
							modifiers,
539
							simpleTypeName,
540
							parameterCount,
541
							signature,
542
							parameterTypes,
543
							parameterNames, 
544
							typeModifiers,
545
							packageName,
546
							extraFlags,
547
							path,
548
							access);
549
				}
550
			};
551
			
552
			int matchRule = SearchPattern.R_PREFIX_MATCH;
553
			if (camelCaseMatch) matchRule |= SearchPattern.R_CAMELCASE_MATCH;
554
			if (monitor != null) {
555
				found : while (true) { //the loop will finish if the search request ends or is cancelled
556
					try {
557
						new BasicSearchEngine(this.workingCopies).searchAllConstructorDeclarations(
558
								qualification,
559
								simpleName,
560
								matchRule,
561
								getSearchScope(),
562
								constructorRequestor,
563
								CANCEL_IF_NOT_READY_TO_SEARCH,
564
								progressMonitor);
565
						break found;
566
					} catch (OperationCanceledException e) {
567
						if (monitor.isCanceled()) {
568
							throw e;
569
						} else {
570
							try {
571
								Thread.sleep(50); // indexes are not ready. sleep 50ms and retry the search request
572
							} catch (InterruptedException e1) {
573
								// Do nothing
574
							}
575
						}
576
					}
577
				}
578
			} else {
579
				try {
580
					new BasicSearchEngine(this.workingCopies).searchAllConstructorDeclarations(
581
							qualification,
582
							simpleName,
583
							matchRule,
584
							getSearchScope(),
585
							constructorRequestor,
586
							CANCEL_IF_NOT_READY_TO_SEARCH,
587
							progressMonitor);
588
				} catch (OperationCanceledException e) {
589
					// Do nothing
590
				}
591
			}
592
		} catch (JavaModelException e) {
593
			// Do nothing
594
		}
595
	}
450
596
451
	/**
597
	/**
452
	 * Returns all types whose name starts with the given (qualified) <code>prefix</code>.
598
	 * Returns all types whose name starts with the given (qualified) <code>prefix</code>.
(-)search/org/eclipse/jdt/internal/core/search/BasicSearchEngine.java (-1 / +366 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 430-435 Link Here
430
		}
430
		}
431
		return true;
431
		return true;
432
	}
432
	}
433
	
434
	boolean match(char[] patternName, char[] patternPackageName, int matchRule, char[] name, char[] packageName) {
435
		
436
		boolean isCaseSensitive = (matchRule & SearchPattern.R_CASE_SENSITIVE) != 0;
437
		
438
		if (patternPackageName != null && !CharOperation.equals(patternPackageName, packageName, true))
439
			return false;
440
		
441
		if (patternName != null) {
442
			boolean isCamelCase = (matchRule & (SearchPattern.R_CAMELCASE_MATCH | SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH)) != 0;
443
			int matchMode = matchRule & JavaSearchPattern.MATCH_MODE_MASK;
444
			if (!isCaseSensitive && !isCamelCase) {
445
				patternName = CharOperation.toLowerCase(patternName);
446
			}
447
			boolean matchFirstChar = !isCaseSensitive || patternName[0] == name[0];
448
			switch(matchMode) {
449
				case SearchPattern.R_EXACT_MATCH :
450
					return matchFirstChar && CharOperation.equals(patternName, name, isCaseSensitive);
451
				case SearchPattern.R_PREFIX_MATCH :
452
					return matchFirstChar && CharOperation.prefixEquals(patternName, name, isCaseSensitive);
453
				case SearchPattern.R_PATTERN_MATCH :
454
					return CharOperation.match(patternName, name, isCaseSensitive);
455
				case SearchPattern.R_REGEXP_MATCH :
456
					// TODO (frederic) implement regular expression match
457
					break;
458
				case SearchPattern.R_CAMELCASE_MATCH:
459
					if (matchFirstChar && CharOperation.camelCaseMatch(patternName, name, false)) {
460
						return true;
461
					}
462
					return !isCaseSensitive && matchFirstChar && CharOperation.prefixEquals(patternName, name, false);
463
				case SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH:
464
					return matchFirstChar && CharOperation.camelCaseMatch(patternName, name, true);
465
			}
466
		}
467
		return true;
468
469
	}
433
470
434
	boolean match(char patternTypeSuffix, char[] patternPkg, char[] patternTypeName, int matchRule, int typeKind, char[] pkg, char[] typeName) {
471
	boolean match(char patternTypeSuffix, char[] patternPkg, char[] patternTypeName, int matchRule, int typeKind, char[] pkg, char[] typeName) {
435
		switch(patternTypeSuffix) {
472
		switch(patternTypeSuffix) {
Lines 505-510 Link Here
505
		}
542
		}
506
		findMatches(pattern, participants, scope, requestor, monitor);
543
		findMatches(pattern, participants, scope, requestor, monitor);
507
	}
544
	}
545
	
546
	public void searchAllConstructorDeclarations(
547
		final char[] packageName,
548
		final char[] typeName,
549
		final int typeMatchRule,
550
		IJavaSearchScope scope,
551
		final IRestrictedAccessConstructorRequestor nameRequestor,
552
		int waitingPolicy,
553
		IProgressMonitor progressMonitor)  throws JavaModelException {
554
555
		// Validate match rule first
556
		final int validatedTypeMatchRule = SearchPattern.validateMatchRule(typeName == null ? null : new String (typeName), typeMatchRule);
557
558
		// Debug
559
		if (VERBOSE) {
560
			Util.verbose("BasicSearchEngine.searchAllTypeNames(char[], char[], int, int, IJavaSearchScope, IRestrictedAccessTypeRequestor, int, IProgressMonitor)"); //$NON-NLS-1$
561
			Util.verbose("	- package name: "+(packageName==null?"null":new String(packageName))); //$NON-NLS-1$ //$NON-NLS-2$
562
			Util.verbose("	- type name: "+(typeName==null?"null":new String(typeName))); //$NON-NLS-1$ //$NON-NLS-2$
563
			Util.verbose("	- type match rule: "+getMatchRuleString(typeMatchRule)); //$NON-NLS-1$
564
			if (validatedTypeMatchRule != typeMatchRule) {
565
				Util.verbose("	- validated type match rule: "+getMatchRuleString(validatedTypeMatchRule)); //$NON-NLS-1$
566
			}
567
			Util.verbose("	- scope: "+scope); //$NON-NLS-1$
568
		}
569
		if (validatedTypeMatchRule == -1) return; // invalid match rule => return no results
570
571
		// Create pattern
572
		IndexManager indexManager = JavaModelManager.getIndexManager();
573
		final ConstructorDeclarationPattern pattern = new ConstructorDeclarationPattern(
574
				packageName,
575
				typeName,
576
				validatedTypeMatchRule);
577
578
		// Get working copy path(s). Store in a single string in case of only one to optimize comparison in requestor
579
		final HashSet workingCopyPaths = new HashSet();
580
		String workingCopyPath = null;
581
		ICompilationUnit[] copies = getWorkingCopies();
582
		final int copiesLength = copies == null ? 0 : copies.length;
583
		if (copies != null) {
584
			if (copiesLength == 1) {
585
				workingCopyPath = copies[0].getPath().toString();
586
			} else {
587
				for (int i = 0; i < copiesLength; i++) {
588
					ICompilationUnit workingCopy = copies[i];
589
					workingCopyPaths.add(workingCopy.getPath().toString());
590
				}
591
			}
592
		}
593
		final String singleWkcpPath = workingCopyPath;
594
595
		// Index requestor
596
		IndexQueryRequestor searchRequestor = new IndexQueryRequestor(){
597
			public boolean acceptIndexMatch(String documentPath, SearchPattern indexRecord, SearchParticipant participant, AccessRuleSet access) {
598
				// Filter unexpected types
599
				ConstructorDeclarationPattern record = (ConstructorDeclarationPattern)indexRecord;
600
				
601
				if ((record.extraFlags & ExtraFlags.IsMemberType) != 0) {
602
					return true; // filter out member classes
603
				}
604
				if ((record.extraFlags & ExtraFlags.IsLocalType) != 0) {
605
					return true; // filter out local and anonymous classes
606
				}
607
				switch (copiesLength) {
608
					case 0:
609
						break;
610
					case 1:
611
						if (singleWkcpPath.equals(documentPath)) {
612
							return true; // filter out *the* working copy
613
						}
614
						break;
615
					default:
616
						if (workingCopyPaths.contains(documentPath)) {
617
							return true; // filter out working copies
618
						}
619
						break;
620
				}
621
622
				// Accept document path
623
				AccessRestriction accessRestriction = null;
624
				if (access != null) {
625
					// Compute document relative path
626
					int pkgLength = (record.declaringPackageName==null || record.declaringPackageName.length==0) ? 0 : record.declaringPackageName.length+1;
627
					int nameLength = record.declaringSimpleName==null ? 0 : record.declaringSimpleName.length;
628
					char[] path = new char[pkgLength+nameLength];
629
					int pos = 0;
630
					if (pkgLength > 0) {
631
						System.arraycopy(record.declaringPackageName, 0, path, pos, pkgLength-1);
632
						CharOperation.replace(path, '.', '/');
633
						path[pkgLength-1] = '/';
634
						pos += pkgLength;
635
					}
636
					if (nameLength > 0) {
637
						System.arraycopy(record.declaringSimpleName, 0, path, pos, nameLength);
638
						pos += nameLength;
639
					}
640
					// Update access restriction if path is not empty
641
					if (pos > 0) {
642
						accessRestriction = access.getViolatedRestriction(path);
643
					}
644
				}
645
				nameRequestor.acceptConstructor(
646
						record.modifiers,
647
						record.declaringSimpleName,
648
						record.parameterCount,
649
						record.signature,
650
						record.parameterTypes,
651
						record.parameterNames,
652
						record.declaringTypeModifiers,
653
						record.declaringPackageName,
654
						record.extraFlags,
655
						documentPath,
656
						accessRestriction);
657
				return true;
658
			}
659
		};
660
661
		try {
662
			if (progressMonitor != null) {
663
				progressMonitor.beginTask(Messages.engine_searching, 1000);
664
			}
665
			// add type names from indexes
666
			indexManager.performConcurrentJob(
667
				new PatternSearchJob(
668
					pattern,
669
					getDefaultSearchParticipant(), // Java search only
670
					scope,
671
					searchRequestor),
672
				waitingPolicy,
673
				progressMonitor == null ? null : new SubProgressMonitor(progressMonitor, 1000-copiesLength));
674
675
			// add type names from working copies
676
			if (copies != null) {
677
				for (int i = 0; i < copiesLength; i++) {
678
					final ICompilationUnit workingCopy = copies[i];
679
					if (!scope.encloses(workingCopy)) continue;
680
					final String path = workingCopy.getPath().toString();
681
					if (workingCopy.isConsistent()) {
682
						IPackageDeclaration[] packageDeclarations = workingCopy.getPackageDeclarations();
683
						char[] packageDeclaration = packageDeclarations.length == 0 ? CharOperation.NO_CHAR : packageDeclarations[0].getElementName().toCharArray();
684
						IType[] allTypes = workingCopy.getAllTypes();
685
						for (int j = 0, allTypesLength = allTypes.length; j < allTypesLength; j++) {
686
							IType type = allTypes[j];
687
							char[] simpleName = type.getElementName().toCharArray();
688
							if (match(typeName, packageName, validatedTypeMatchRule, simpleName, packageDeclaration) && !type.isMember()) {
689
								
690
								int extraFlags = ExtraFlags.getExtraFlags(type);
691
								
692
								boolean hasConstructor = false;
693
								
694
								IMethod[] methods = type.getMethods();
695
								for (int k = 0; k < methods.length; k++) {
696
									IMethod method = methods[k];
697
									if (method.isConstructor()) {
698
										hasConstructor = true;
699
										
700
										String[] stringParameterNames = method.getParameterNames();
701
										String[] stringParameterTypes = method.getParameterTypes();
702
										int length = stringParameterNames.length;
703
										char[][] parameterNames = new char[length][];
704
										char[][] parameterTypes = new char[length][];
705
										for (int l = 0; l < length; l++) {
706
											parameterNames[l] = stringParameterNames[l].toCharArray();
707
											parameterTypes[l] = Signature.toCharArray(Signature.getTypeErasure(stringParameterTypes[l]).toCharArray());
708
										}
709
										
710
										nameRequestor.acceptConstructor(
711
												method.getFlags(),
712
												simpleName,
713
												parameterNames.length,
714
												null,// signature is not used for source type
715
												parameterTypes, 
716
												parameterNames,
717
												type.getFlags(),
718
												packageDeclaration,
719
												extraFlags,
720
												path,
721
												null);
722
									}
723
								}
724
								
725
								if (!hasConstructor) {
726
									nameRequestor.acceptConstructor(
727
											Flags.AccPublic,
728
											simpleName,
729
											-1,
730
											null, // signature is not used for source type
731
											CharOperation.NO_CHAR_CHAR,
732
											CharOperation.NO_CHAR_CHAR,
733
											type.getFlags(),
734
											packageDeclaration,
735
											extraFlags,
736
											path,
737
											null);
738
								}
739
							}
740
						}
741
					} else {
742
						Parser basicParser = getParser();
743
						org.eclipse.jdt.internal.compiler.env.ICompilationUnit unit = (org.eclipse.jdt.internal.compiler.env.ICompilationUnit) workingCopy;
744
						CompilationResult compilationUnitResult = new CompilationResult(unit, 0, 0, this.compilerOptions.maxProblemsPerUnit);
745
						CompilationUnitDeclaration parsedUnit = basicParser.dietParse(unit, compilationUnitResult);
746
						if (parsedUnit != null) {
747
							final char[] packageDeclaration = parsedUnit.currentPackage == null ? CharOperation.NO_CHAR : CharOperation.concatWith(parsedUnit.currentPackage.getImportName(), '.');
748
							class AllConstructorDeclarationsVisitor extends ASTVisitor {
749
								private TypeDeclaration[] declaringTypes = new TypeDeclaration[0];
750
								private int declaringTypesPtr = -1;
751
								
752
								private void endVisit(TypeDeclaration typeDeclaration) {
753
									if (!hasConstructor(typeDeclaration) && typeDeclaration.enclosingType == null) {
754
									
755
										if (match(typeName, packageName, validatedTypeMatchRule, typeDeclaration.name, packageDeclaration)) {
756
											nameRequestor.acceptConstructor(
757
													Flags.AccPublic,
758
													typeName,
759
													-1,
760
													null, // signature is not used for source type
761
													CharOperation.NO_CHAR_CHAR,
762
													CharOperation.NO_CHAR_CHAR,
763
													typeDeclaration.modifiers,
764
													packageDeclaration,
765
													ExtraFlags.getExtraFlags(typeDeclaration),
766
													path,
767
													null);
768
										}
769
									}
770
									
771
									this.declaringTypes[this.declaringTypesPtr] = null;
772
									this.declaringTypesPtr--;
773
								}
774
								
775
								public void endVisit(TypeDeclaration typeDeclaration, CompilationUnitScope s) {
776
									endVisit(typeDeclaration);
777
								}
778
								
779
								public void endVisit(TypeDeclaration memberTypeDeclaration, ClassScope s) {
780
									endVisit(memberTypeDeclaration);
781
								}
782
								
783
								private boolean hasConstructor(TypeDeclaration typeDeclaration) {
784
									AbstractMethodDeclaration[] methods = typeDeclaration.methods;
785
									int length = methods == null ? 0 : methods.length;
786
									for (int j = 0; j < length; j++) {
787
										if (methods[j].isConstructor()) {
788
											return true;
789
										}
790
									}
791
									
792
									return false;
793
								}
794
								public boolean visit(ConstructorDeclaration constructorDeclaration, ClassScope classScope) {
795
									TypeDeclaration typeDeclaration = this.declaringTypes[this.declaringTypesPtr];
796
									if (match(typeName, packageName, validatedTypeMatchRule, typeDeclaration.name, packageDeclaration)) {
797
										Argument[] arguments = constructorDeclaration.arguments;
798
										int length = arguments == null ? 0 : arguments.length;
799
										char[][] parameterNames = new char[length][];
800
										char[][] parameterTypes = new char[length][];
801
										for (int l = 0; l < length; l++) {
802
											Argument argument = arguments[l];
803
											parameterNames[l] = argument.name;
804
											if (argument.type instanceof SingleTypeReference) {
805
												parameterTypes[l] = ((SingleTypeReference)argument.type).token;
806
											} else {
807
												parameterTypes[l] = CharOperation.concatWith(((QualifiedTypeReference)argument.type).tokens, '.');
808
											}
809
										}
810
										
811
										TypeDeclaration enclosing = typeDeclaration.enclosingType;
812
										char[][] enclosingTypeNames = CharOperation.NO_CHAR_CHAR;
813
										while (enclosing != null) {
814
											enclosingTypeNames = CharOperation.arrayConcat(new char[][] {enclosing.name}, enclosingTypeNames);
815
											if ((enclosing.bits & ASTNode.IsMemberType) != 0) {
816
												enclosing = enclosing.enclosingType;
817
											} else {
818
												enclosing = null;
819
											}
820
										}
821
										
822
										nameRequestor.acceptConstructor(
823
												constructorDeclaration.modifiers,
824
												typeName,
825
												parameterNames.length,
826
												null, // signature is not used for source type
827
												parameterTypes,
828
												parameterNames,
829
												typeDeclaration.modifiers,
830
												packageDeclaration,
831
												ExtraFlags.getExtraFlags(typeDeclaration),
832
												path,
833
												null);
834
									}
835
									return false; // no need to find constructors from local/anonymous type
836
								}
837
								public boolean visit(TypeDeclaration typeDeclaration, BlockScope blockScope) {
838
									return false; 
839
								}
840
								
841
								private boolean visit(TypeDeclaration typeDeclaration) {
842
									if(this.declaringTypes.length <= ++this.declaringTypesPtr) {
843
										int length = this.declaringTypesPtr;
844
										System.arraycopy(this.declaringTypes, 0, this.declaringTypes = new TypeDeclaration[length * 2 + 1], 0, length);
845
									}
846
									this.declaringTypes[this.declaringTypesPtr] = typeDeclaration;
847
									return true;
848
								}
849
								
850
								public boolean visit(TypeDeclaration typeDeclaration, CompilationUnitScope s) {
851
									return visit(typeDeclaration);
852
								}
853
								
854
								public boolean visit(TypeDeclaration memberTypeDeclaration, ClassScope s) {
855
									return visit(memberTypeDeclaration);
856
								}
857
							}
858
							parsedUnit.traverse(new AllConstructorDeclarationsVisitor(), parsedUnit.scope);
859
						}
860
					}
861
					if (progressMonitor != null) {
862
						if (progressMonitor.isCanceled()) throw new OperationCanceledException();
863
						progressMonitor.worked(1);
864
					}
865
				}
866
			}
867
		} finally {
868
			if (progressMonitor != null) {
869
				progressMonitor.done();
870
			}
871
		}
872
	}
508
873
509
	/**
874
	/**
510
	 * Searches for all secondary types in the given scope.
875
	 * Searches for all secondary types in the given scope.
(-)search/org/eclipse/jdt/internal/core/search/matching/ConstructorPattern.java (-20 / +261 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 19-24 Link Here
19
import org.eclipse.jdt.core.compiler.CharOperation;
19
import org.eclipse.jdt.core.compiler.CharOperation;
20
import org.eclipse.jdt.core.search.IJavaSearchConstants;
20
import org.eclipse.jdt.core.search.IJavaSearchConstants;
21
import org.eclipse.jdt.core.search.SearchPattern;
21
import org.eclipse.jdt.core.search.SearchPattern;
22
import org.eclipse.jdt.internal.compiler.ExtraFlags;
23
import org.eclipse.jdt.internal.compiler.ast.ASTNode;
22
import org.eclipse.jdt.internal.core.index.EntryResult;
24
import org.eclipse.jdt.internal.core.index.EntryResult;
23
import org.eclipse.jdt.internal.core.index.Index;
25
import org.eclipse.jdt.internal.core.index.Index;
24
import org.eclipse.jdt.internal.core.util.Util;
26
import org.eclipse.jdt.internal.core.util.Util;
Lines 52-57 Link Here
52
	IJavaSearchConstants.THIS_REFERENCE |
54
	IJavaSearchConstants.THIS_REFERENCE |
53
	IJavaSearchConstants.IMPLICIT_THIS_REFERENCE;
55
	IJavaSearchConstants.IMPLICIT_THIS_REFERENCE;
54
56
57
58
/**
59
 * Constructor entries are encoded as described
60
 * 
61
 * Binary constructor for class
62
 * TypeName '/' Arity '/' TypeModifers '/' PackageName '/' Signature '/' ParameterNamesopt '/' Modifiers
63
 * Source constructor for class
64
 * TypeName '/' Arity '/' TypeModifers '/' PackageName '/' ParameterTypes '/' ParameterNamesopt
65
 * Constructor with 0 arity for class
66
 * TypeName '/' 0 '/' TypeModifers '/' PackageName '/' Modifiers
67
 * Constructor for enum, interface (annotation) and class with default constructor
68
 * TypeName '/' # '/' TypeModifers '/' PackageName
69
 * Constructor for member type
70
 * TypeName '/' Arity '/' TypeModifers
71
 * 
72
 * TypeModifiers contains some encoded extra information
73
 * 		{@link ExtraFlags#IsMemberType}
74
 * 		{@link ExtraFlags#HasNonPrivateStaticMemberTypes}
75
 * 		{@link ExtraFlags#ParameterTypesStoredAsSignature}
76
 */
77
public static char[] createDeclarationIndexKey(
78
		char[] typeName,
79
		int argCount,
80
		char[] signature,
81
		char[][] parameterTypes,
82
		char[][] parameterNames,
83
		int modifiers,
84
		char[] packageName,
85
		int typeModifiers,
86
		int extraFlags) {
87
	
88
	char[] countChars;
89
	char[] parameterTypesChars = null;
90
	char[] parameterNamesChars = null;
91
	
92
	if (argCount < 0) {
93
		countChars = DEFAULT_CONSTRUCTOR;
94
	} else {
95
		countChars = argCount < 10
96
		? COUNTS[argCount]
97
		: ("/" + String.valueOf(argCount)).toCharArray(); //$NON-NLS-1$
98
		
99
		if (argCount > 0) {
100
			if (signature == null) {
101
				if (parameterTypes != null && parameterTypes.length == argCount) {
102
					char[][] parameterTypeErasures = new char[argCount][];
103
					for (int i = 0; i < parameterTypes.length; i++) {
104
						parameterTypeErasures[i] = getTypeErasure(parameterTypes[i]);
105
					}
106
					parameterTypesChars = CharOperation.concatWith(parameterTypeErasures, PARAMETER_SEPARATOR);
107
				}
108
			} else {
109
				extraFlags |= ExtraFlags.ParameterTypesStoredAsSignature;
110
			}
111
			
112
			if (parameterNames != null && parameterNames.length == argCount) {
113
				parameterNamesChars = CharOperation.concatWith(parameterNames, PARAMETER_SEPARATOR);
114
			}
115
		}
116
	}
117
	
118
	boolean isMemberType = (extraFlags & ExtraFlags.IsMemberType) != 0;
119
	boolean hasStoredParameterTypesAsSignature = (extraFlags & ExtraFlags.ParameterTypesStoredAsSignature) != 0;
120
	
121
	int typeNameLength = typeName == null ? 0 : typeName.length;
122
	int packageNameLength = packageName == null ? 0 : packageName.length;
123
	int countCharsLength = countChars.length;
124
	int parameterTypesLength = signature == null ? (parameterTypesChars == null ? 0 : parameterTypesChars.length): signature.length;
125
	int parameterNamesLength = parameterNamesChars == null ? 0 : parameterNamesChars.length;
126
	
127
	int resultLength = typeNameLength + countCharsLength + 3; // SEPARATOR=1 + TypeModifers=2
128
	if (!isMemberType) {
129
		resultLength += packageNameLength + 1; // SEPARATOR=1
130
		if (argCount == 0 ||  hasStoredParameterTypesAsSignature) {
131
			resultLength += 3; // SEPARATOR=1 + Modifiers=2
132
		}
133
		
134
		if (argCount > 0) {
135
			resultLength += parameterTypesLength + parameterNamesLength + 2; //SEPARATOR=1 + SEPARATOR=1
136
		}
137
	}
138
	
139
	char[] result = new char[resultLength];
140
	
141
	int pos = 0;
142
	if (typeNameLength > 0) {
143
		System.arraycopy(typeName, 0, result, pos, typeNameLength);
144
		pos += typeNameLength;
145
	}
146
	
147
	if (countCharsLength > 0) {
148
		System.arraycopy(countChars, 0, result, pos, countCharsLength);
149
		pos += countCharsLength;
150
	}
151
	
152
	int typeModifiersWithExtraFlags = typeModifiers | encodeExtraFlags(extraFlags);
153
	result[pos++] = SEPARATOR;
154
	result[pos++] = (char) typeModifiersWithExtraFlags;
155
	result[pos++] = (char) (typeModifiersWithExtraFlags>>16);
156
	
157
	if (!isMemberType) {
158
		result[pos++] = SEPARATOR;
159
		if (packageNameLength > 0) {
160
			System.arraycopy(packageName, 0, result, pos, packageNameLength);
161
			pos += packageNameLength;
162
		}
163
		
164
		if (argCount == 0) {
165
			result[pos++] = SEPARATOR;
166
			result[pos++] = (char) modifiers;
167
			result[pos++] = (char) (modifiers>>16);
168
		} else if (argCount > 0) {
169
			result[pos++] = SEPARATOR;
170
			if (parameterTypesLength > 0) {
171
				if (signature == null) {
172
					System.arraycopy(parameterTypesChars, 0, result, pos, parameterTypesLength);
173
				} else {
174
					System.arraycopy(CharOperation.replaceOnCopy(signature, SEPARATOR, '\\'), 0, result, pos, parameterTypesLength);
175
				}
176
				pos += parameterTypesLength;
177
			}
178
			
179
			result[pos++] = SEPARATOR;
180
			if (parameterNamesLength > 0) {
181
				System.arraycopy(parameterNamesChars, 0, result, pos, parameterNamesLength);
182
				pos += parameterNamesLength;
183
			}
184
			
185
			if (hasStoredParameterTypesAsSignature) {
186
				result[pos++] = SEPARATOR;
187
				result[pos++] = (char) modifiers;
188
				result[pos++] = (char) (modifiers>>16);
189
			}
190
		}
191
		
192
	}
193
	
194
	return result;
195
}
196
public static char[] createDefaultDeclarationIndexKey(
197
		char[] typeName,
198
		char[] packageName,
199
		int typeModifiers,
200
		int extraFlags) {
201
	return createDeclarationIndexKey(
202
			typeName,
203
			-1, // used to identify default constructor
204
			null,
205
			null,
206
			null,
207
			0, //
208
			packageName,
209
			typeModifiers,
210
			extraFlags);
211
}
212
55
/**
213
/**
56
 * Constructor entries are encoded as TypeName '/' Arity:
214
 * Constructor entries are encoded as TypeName '/' Arity:
57
 * e.g. 'X/0'
215
 * e.g. 'X/0'
Lines 62-68 Link Here
62
		: ("/" + String.valueOf(argCount)).toCharArray(); //$NON-NLS-1$
220
		: ("/" + String.valueOf(argCount)).toCharArray(); //$NON-NLS-1$
63
	return CharOperation.concat(typeName, countChars);
221
	return CharOperation.concat(typeName, countChars);
64
}
222
}
65
223
static int decodeExtraFlags(int modifiersWithExtraFlags) {
224
	int extraFlags = 0;
225
	
226
	if ((modifiersWithExtraFlags & ASTNode.Bit28) != 0) {
227
		extraFlags |= ExtraFlags.ParameterTypesStoredAsSignature;
228
	}
229
	
230
	if ((modifiersWithExtraFlags & ASTNode.Bit29) != 0) {
231
		extraFlags |= ExtraFlags.IsLocalType;
232
	}
233
	
234
	if ((modifiersWithExtraFlags & ASTNode.Bit30) != 0) {
235
		extraFlags |= ExtraFlags.IsMemberType;
236
	}
237
	
238
	if ((modifiersWithExtraFlags & ASTNode.Bit31) != 0) {
239
		extraFlags |= ExtraFlags.HasNonPrivateStaticMemberTypes;
240
	}
241
	
242
	return extraFlags;
243
}
244
static int decodeModifers(int modifiersWithExtraFlags) {
245
	return modifiersWithExtraFlags & ~(ASTNode.Bit31 | ASTNode.Bit30 | ASTNode.Bit29 | ASTNode.Bit28);
246
}
247
private static int encodeExtraFlags(int extraFlags) {
248
	int encodedExtraFlags = 0;
249
	
250
	if ((extraFlags & ExtraFlags.ParameterTypesStoredAsSignature) != 0) {
251
		encodedExtraFlags |= ASTNode.Bit28;
252
	}
253
	
254
	if ((extraFlags & ExtraFlags.IsLocalType) != 0) {
255
		encodedExtraFlags |= ASTNode.Bit29;
256
	}
257
	
258
	if ((extraFlags & ExtraFlags.IsMemberType) != 0) {
259
		encodedExtraFlags |= ASTNode.Bit30;
260
	}
261
	if ((extraFlags & ExtraFlags.HasNonPrivateStaticMemberTypes) != 0) {
262
		encodedExtraFlags |= ASTNode.Bit31;
263
	}
264
	
265
	return encodedExtraFlags;
266
}
267
private static char[] getTypeErasure(char[] typeName) {
268
	int index;
269
	if ((index = CharOperation.indexOf('<', typeName)) == -1) return typeName;
270
	
271
	int length = typeName.length;
272
	char[] typeErasurename = new char[length - 2];
273
	
274
	System.arraycopy(typeName, 0, typeErasurename, 0, index);
275
	
276
	int depth = 1;
277
	for (int i = index + 1; i < length; i++) {
278
		switch (typeName[i]) {
279
			case '<':
280
				depth++;
281
				break;
282
			case '>':
283
				depth--;
284
				break;
285
			default:
286
				if (depth == 0) {
287
					typeErasurename[index++] = typeName[i];
288
				}
289
				break;
290
		}
291
	}
292
	
293
	System.arraycopy(typeErasurename, 0, typeErasurename = new char[index], 0, index);
294
	return typeErasurename;
295
}
66
ConstructorPattern(int matchRule) {
296
ConstructorPattern(int matchRule) {
67
	super(CONSTRUCTOR_PATTERN, matchRule);
297
	super(CONSTRUCTOR_PATTERN, matchRule);
68
}
298
}
Lines 225-245 Link Here
225
	}
455
	}
226
	if (hasConstructorArguments())  this.mustResolve = true;
456
	if (hasConstructorArguments())  this.mustResolve = true;
227
}
457
}
458
228
public void decodeIndexKey(char[] key) {
459
public void decodeIndexKey(char[] key) {
229
	int last = key.length - 1;
460
	int last = key.length - 1;
230
	this.parameterCount = 0;
461
	int slash = CharOperation.indexOf(SEPARATOR, key, 0);
231
	this.declaringSimpleName = null;
462
	this.declaringSimpleName = CharOperation.subarray(key, 0, slash);
232
	int power = 1;
463
	
233
	for (int i=last; i>=0; i--) {
464
	int start = slash + 1;
234
		if (key[i] == SEPARATOR) {
465
	slash = CharOperation.indexOf(SEPARATOR, key, start);
235
			System.arraycopy(key, 0, this.declaringSimpleName = new char[i], 0, i);
466
	if (slash != -1) {
236
			break;
467
		last = slash - 1;
237
		}
468
	}
238
		if (i == last) {
469
	
239
			this.parameterCount = key[i] - '0';
470
	boolean isDefaultConstructor = key[last] == '#';
240
		} else {
471
	if (isDefaultConstructor) {
241
			power *= 10;
472
		this.parameterCount = -1;
242
			this.parameterCount += power * (key[i] - '0');
473
	} else {
474
		this.parameterCount = 0;
475
		int power = 1;
476
		for (int i = last; i >= start; i--) {
477
			if (i == last) {
478
				this.parameterCount = key[i] - '0';
479
			} else {
480
				power *= 10;
481
				this.parameterCount += power * (key[i] - '0');
482
			}
243
		}
483
		}
244
	}
484
	}
245
}
485
}
Lines 262-268 Link Here
262
public boolean matchesDecodedKey(SearchPattern decodedPattern) {
502
public boolean matchesDecodedKey(SearchPattern decodedPattern) {
263
	ConstructorPattern pattern = (ConstructorPattern) decodedPattern;
503
	ConstructorPattern pattern = (ConstructorPattern) decodedPattern;
264
504
265
	return (this.parameterCount == pattern.parameterCount || this.parameterCount == -1 || this.varargs)
505
	return pattern.parameterCount != -1
506
		&& (this.parameterCount == pattern.parameterCount || this.parameterCount == -1 || this.varargs)
266
		&& matchesName(this.declaringSimpleName, pattern.declaringSimpleName);
507
		&& matchesName(this.declaringSimpleName, pattern.declaringSimpleName);
267
}
508
}
268
protected boolean mustResolve() {
509
protected boolean mustResolve() {
Lines 280-291 Link Here
280
521
281
	switch(getMatchMode()) {
522
	switch(getMatchMode()) {
282
		case R_EXACT_MATCH :
523
		case R_EXACT_MATCH :
283
			if (this.declaringSimpleName != null && this.parameterCount >= 0 && !this.varargs)
524
			if (this.declaringSimpleName != null && this.parameterCount >= 0 && !this.varargs) {
284
				key = createIndexKey(this.declaringSimpleName, this.parameterCount);
525
				key = createIndexKey(this.declaringSimpleName, this.parameterCount);
285
			else { // do a prefix query with the declaringSimpleName
286
				matchRule &= ~R_EXACT_MATCH;
287
				matchRule |= R_PREFIX_MATCH;
288
			}
526
			}
527
			matchRule &= ~R_EXACT_MATCH;
528
			matchRule |= R_PREFIX_MATCH;
289
			break;
529
			break;
290
		case R_PREFIX_MATCH :
530
		case R_PREFIX_MATCH :
291
			// do a prefix query with the declaringSimpleName
531
			// do a prefix query with the declaringSimpleName
Lines 295-300 Link Here
295
				key = createIndexKey(this.declaringSimpleName == null ? ONE_STAR : this.declaringSimpleName, this.parameterCount);
535
				key = createIndexKey(this.declaringSimpleName == null ? ONE_STAR : this.declaringSimpleName, this.parameterCount);
296
			else if (this.declaringSimpleName != null && this.declaringSimpleName[this.declaringSimpleName.length - 1] != '*')
536
			else if (this.declaringSimpleName != null && this.declaringSimpleName[this.declaringSimpleName.length - 1] != '*')
297
				key = CharOperation.concat(this.declaringSimpleName, ONE_STAR, SEPARATOR);
537
				key = CharOperation.concat(this.declaringSimpleName, ONE_STAR, SEPARATOR);
538
			key = CharOperation.concat(key, ONE_STAR);
298
			// else do a pattern query with just the declaringSimpleName
539
			// else do a pattern query with just the declaringSimpleName
299
			break;
540
			break;
300
		case R_REGEXP_MATCH :
541
		case R_REGEXP_MATCH :
(-)search/org/eclipse/jdt/internal/core/search/matching/ConstructorDeclarationPattern.java (+190 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.jdt.internal.core.search.matching;
12
13
import java.io.IOException;
14
15
import org.eclipse.jdt.core.compiler.CharOperation;
16
import org.eclipse.jdt.core.search.SearchPattern;
17
import org.eclipse.jdt.internal.compiler.ExtraFlags;
18
import org.eclipse.jdt.internal.core.index.EntryResult;
19
import org.eclipse.jdt.internal.core.index.Index;
20
21
public class ConstructorDeclarationPattern extends ConstructorPattern {
22
	private static final char[][] EXT_DECL_CATEGORIES = {CONSTRUCTOR_DECL};
23
	
24
	public int extraFlags;
25
	
26
	public int declaringTypeModifiers;
27
	public char[] declaringPackageName;
28
	
29
	public int modifiers;
30
	public char[] signature;
31
	public char[][] parameterTypes;
32
	public char[][] parameterNames;
33
34
public ConstructorDeclarationPattern(char[] declaringPackageName, char[] declaringSimpleName, int matchRule) {
35
	this(matchRule);
36
	this.declaringSimpleName = (this.isCaseSensitive || this.isCamelCase) ? declaringSimpleName : CharOperation.toLowerCase(declaringSimpleName);
37
	this.declaringPackageName = declaringPackageName;
38
	this.findDeclarations = true;
39
	this.findReferences = false;
40
	this.parameterCount = -1;
41
	this.mustResolve = false;
42
}
43
44
ConstructorDeclarationPattern(int matchRule) {
45
	super(matchRule);
46
}
47
public void decodeIndexKey(char[] key) {
48
	int last = key.length - 1;
49
	int slash = CharOperation.indexOf(SEPARATOR, key, 0);
50
	this.declaringSimpleName = CharOperation.subarray(key, 0, slash);
51
	
52
	int start = slash + 1;
53
	slash = CharOperation.indexOf(SEPARATOR, key, start);
54
	last = slash - 1;
55
	
56
	boolean isDefaultConstructor = key[last] == '#';
57
	if (isDefaultConstructor) {
58
		this.parameterCount = -1;
59
	} else {
60
		this.parameterCount = 0;
61
		int power = 1;
62
		for (int i = last; i >= start; i--) {
63
			if (i == last) {
64
				this.parameterCount = key[i] - '0';
65
			} else {
66
				power *= 10;
67
				this.parameterCount += power * (key[i] - '0');
68
			}
69
		}
70
	}
71
	
72
	slash = slash + 3;
73
	last = slash - 1;
74
	
75
	int typeModifiersWithExtraFlags = key[last-1] + (key[last]<<16);
76
	this.declaringTypeModifiers = decodeModifers(typeModifiersWithExtraFlags);
77
	this.extraFlags = decodeExtraFlags(typeModifiersWithExtraFlags);
78
	
79
	boolean isMemberType = (this.extraFlags & ExtraFlags.IsMemberType) != 0;
80
	
81
	if (!isMemberType) {
82
		start = slash + 1;
83
		if (this.parameterCount == -1) {
84
			slash = key.length;
85
			last = slash - 1;
86
		} else {
87
			slash = CharOperation.indexOf(SEPARATOR, key, start);
88
		}
89
		last = slash - 1;
90
		
91
		this.declaringPackageName = CharOperation.subarray(key, start, slash);
92
		
93
		start = slash + 1;
94
		if (this.parameterCount == 0) {
95
			slash = slash + 3;
96
			last = slash - 1;
97
			
98
			this.modifiers = key[last-1] + (key[last]<<16);
99
		} else if (this.parameterCount > 0){
100
			slash = CharOperation.indexOf(SEPARATOR, key, start);
101
			last = slash - 1;
102
			
103
			boolean hasParameterStoredAsSignature = (this.extraFlags & ExtraFlags.ParameterTypesStoredAsSignature) != 0;
104
			if (hasParameterStoredAsSignature) {
105
				this.signature  = CharOperation.subarray(key, start, slash);
106
				CharOperation.replace(this.signature , '\\', SEPARATOR);
107
				
108
				start = slash + 1;
109
				slash = CharOperation.indexOf(SEPARATOR, key, start);
110
			} else {
111
				this.parameterTypes = CharOperation.splitOn(PARAMETER_SEPARATOR, key, start, slash);
112
				
113
				start = slash + 1;
114
				slash = key.length;
115
			}
116
			last = slash - 1;
117
			
118
			if (slash != start) {
119
				this.parameterNames = CharOperation.splitOn(PARAMETER_SEPARATOR, key, start, slash);
120
			}
121
			
122
			if (hasParameterStoredAsSignature) {
123
				slash = slash + 3;
124
				last = slash - 1;
125
				
126
				this.modifiers = key[last-1] + (key[last]<<16);
127
			}
128
		}
129
	}
130
	
131
	removeInternalFlags(); // remove internal flags
132
}
133
134
public SearchPattern getBlankPattern() {
135
	return new ConstructorDeclarationPattern(R_EXACT_MATCH | R_CASE_SENSITIVE);
136
}
137
public char[][] getIndexCategories() {
138
	return EXT_DECL_CATEGORIES;
139
}
140
public boolean matchesDecodedKey(SearchPattern decodedPattern) {
141
	ConstructorDeclarationPattern pattern = (ConstructorDeclarationPattern) decodedPattern;
142
	
143
	// only top level types
144
	if ((pattern.extraFlags & ExtraFlags.IsMemberType) != 0) return false;
145
	
146
	// check package - exact match only
147
	if (this.declaringPackageName != null && !CharOperation.equals(this.declaringPackageName, pattern.declaringPackageName, true))
148
		return false;
149
150
	return (this.parameterCount == pattern.parameterCount || this.parameterCount == -1 || this.varargs)
151
		&& matchesName(this.declaringSimpleName, pattern.declaringSimpleName);
152
}
153
public EntryResult[] queryIn(Index index) throws IOException {
154
	char[] key = this.declaringSimpleName; // can be null
155
	int matchRule = getMatchRule();
156
157
	switch(getMatchMode()) {
158
		case R_EXACT_MATCH :
159
			if (this.declaringSimpleName != null && this.parameterCount >= 0 && !this.varargs) {
160
				key = createIndexKey(this.declaringSimpleName, this.parameterCount);
161
			} 
162
			matchRule &= ~R_EXACT_MATCH;
163
			matchRule |= R_PREFIX_MATCH;
164
			break;
165
		case R_PREFIX_MATCH :
166
			// do a prefix query with the declaringSimpleName
167
			break;
168
		case R_PATTERN_MATCH :
169
			if (this.parameterCount >= 0 && !this.varargs)
170
				key = createIndexKey(this.declaringSimpleName == null ? ONE_STAR : this.declaringSimpleName, this.parameterCount);
171
			else if (this.declaringSimpleName != null && this.declaringSimpleName[this.declaringSimpleName.length - 1] != '*')
172
				key = CharOperation.concat(this.declaringSimpleName, ONE_STAR, SEPARATOR);
173
			key = CharOperation.concat(key, ONE_STAR);
174
			// else do a pattern query with just the declaringSimpleName
175
			break;
176
		case R_REGEXP_MATCH :
177
			// TODO (frederic) implement regular expression match
178
			break;
179
		case R_CAMELCASE_MATCH:
180
		case R_CAMELCASE_SAME_PART_COUNT_MATCH:
181
			// do a prefix query with the declaringSimpleName
182
			break;
183
	}
184
185
	return index.query(getIndexCategories(), key, matchRule); // match rule is irrelevant when the key is null
186
}
187
private void removeInternalFlags() {
188
	this.extraFlags = this.extraFlags & ~ExtraFlags.ParameterTypesStoredAsSignature; // ParameterTypesStoredAsSignature is an internal flags only used to decode key
189
}
190
}
(-)search/org/eclipse/jdt/internal/core/search/IRestrictedAccessConstructorRequestor.java (+34 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.jdt.internal.core.search;
12
13
import org.eclipse.jdt.internal.compiler.env.AccessRestriction;
14
15
/**
16
 * A <code>IRestrictedAccessConstructorRequestor</code> collects search results from a <code>searchAllConstructorDeclarations</code>
17
 * query to a <code>SearchBasicEngine</code> providing restricted access information of declaring type when a constructor is accepted.
18
 */
19
public interface IRestrictedAccessConstructorRequestor {
20
21
	public void acceptConstructor(
22
			int modifiers,
23
			char[] simpleTypeName,
24
			int parameterCount,
25
			char[] signature,
26
			char[][] parameterTypes,
27
			char[][] parameterNames,
28
			int typeModifiers,
29
			char[] packageName,
30
			int extraFlags,
31
			String path,
32
			AccessRestriction access);
33
34
}
(-)model/org/eclipse/jdt/internal/compiler/ExtraFlags.java (+104 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.jdt.internal.compiler;
12
13
import org.eclipse.jdt.core.IType;
14
import org.eclipse.jdt.core.JavaModelException;
15
import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
16
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
17
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader;
18
import org.eclipse.jdt.internal.compiler.env.IBinaryNestedType;
19
20
public final class ExtraFlags {
21
	public final static int HasNonPrivateStaticMemberTypes = 0x0001;
22
	public final static int IsMemberType = 0x0002;
23
	public final static int IsLocalType = 0x0004;
24
	
25
	//internal flags
26
	public final static int ParameterTypesStoredAsSignature = 0x0010;
27
	
28
	public static int getExtraFlags(ClassFileReader reader) {
29
		int extraFlags = 0;
30
		
31
		if (reader.isNestedType()) {
32
			extraFlags |= ExtraFlags.IsMemberType;
33
		}
34
		
35
		if (reader.isLocal()) {
36
			extraFlags |= ExtraFlags.IsLocalType;
37
		}
38
		
39
		IBinaryNestedType[] memberTypes = reader.getMemberTypes();
40
		int memberTypeCounter = memberTypes == null ? 0 : memberTypes.length;
41
		if (memberTypeCounter > 0) {
42
			done : for (int i = 0; i < memberTypeCounter; i++) {
43
				int modifiers = memberTypes[i].getModifiers();
44
				// if the member type is static and not private
45
				if ((modifiers & ClassFileConstants.AccStatic) != 0 && (modifiers & ClassFileConstants.AccPrivate) == 0) {
46
					extraFlags |= ExtraFlags.HasNonPrivateStaticMemberTypes;
47
					break done;
48
				}
49
			}
50
			
51
		}
52
		
53
		return extraFlags;
54
	}
55
	
56
	public static int getExtraFlags(IType type) throws JavaModelException {
57
		int extraFlags = 0;
58
		
59
		if (type.isMember()) {
60
			extraFlags |= ExtraFlags.IsMemberType;
61
		}
62
		
63
		if (type.isLocal()) {
64
			extraFlags |= ExtraFlags.IsLocalType;
65
		}
66
		
67
		IType[] memberTypes = type.getTypes();
68
		int memberTypeCounter = memberTypes == null ? 0 : memberTypes.length;
69
		if (memberTypeCounter > 0) {
70
			done : for (int i = 0; i < memberTypeCounter; i++) {
71
				int flags = memberTypes[i].getFlags();
72
				// if the member type is static and not private
73
				if ((flags & ClassFileConstants.AccStatic) != 0 && (flags & ClassFileConstants.AccPrivate) == 0 ) {
74
					extraFlags |= ExtraFlags.HasNonPrivateStaticMemberTypes;
75
					break done;
76
				}
77
			}
78
		}
79
		
80
		return extraFlags;
81
	}
82
	
83
	public static int getExtraFlags(TypeDeclaration typeDeclaration) {
84
		int extraFlags = 0;
85
		
86
		if (typeDeclaration.enclosingType != null) {
87
			extraFlags |= ExtraFlags.IsMemberType;
88
		}
89
		TypeDeclaration[] memberTypes = typeDeclaration.memberTypes;
90
		int memberTypeCounter = memberTypes == null ? 0 : memberTypes.length;
91
		if (memberTypeCounter > 0) {
92
			done : for (int i = 0; i < memberTypeCounter; i++) {
93
				int modifiers = memberTypes[i].modifiers;
94
				// if the member type is static and not private
95
				if ((modifiers & ClassFileConstants.AccStatic) != 0 && (modifiers & ClassFileConstants.AccPrivate) == 0) {
96
					extraFlags |= ExtraFlags.HasNonPrivateStaticMemberTypes;
97
					break done;
98
				}
99
			}
100
		}
101
		
102
		return extraFlags;
103
	}
104
}
(-)src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java (-2 / +152 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 160-165 Link Here
160
	);
160
	);
161
}
161
}
162
162
163
public void testBug6930_AllConstructorDeclarations01() throws Exception {
164
	this.workingCopies = new ICompilationUnit[2];
165
	this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/p6930/AllConstructorDeclarations01.java",
166
		"package p6930;\n" +
167
		"public class AllConstructorDeclarations01 {\n" +
168
		"  public AllConstructorDeclarations01() {}\n" +
169
		"  public AllConstructorDeclarations01(Object o) {}\n" +
170
		"  public AllConstructorDeclarations01(Object o, String s) {}\n" +
171
		"}\n"
172
	);
173
	
174
	this.workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/p6930/AllConstructorDeclarations01b.java",
175
		"package p6930;\n" +
176
		"public class AllConstructorDeclarations01b {\n" +
177
		"}\n"
178
	);
179
	
180
	ConstructorDeclarationsCollector requestor = new ConstructorDeclarationsCollector();
181
	searchAllConstructorDeclarations("AllConstructorDeclarations", SearchPattern.R_PREFIX_MATCH, requestor);
182
	assertSearchResults(
183
		"p6930.AllConstructorDeclarations01#AllConstructorDeclarations01()\n" + 
184
		"p6930.AllConstructorDeclarations01#AllConstructorDeclarations01(Object o)\n" + 
185
		"p6930.AllConstructorDeclarations01#AllConstructorDeclarations01(Object o,String s)\n" + 
186
		"p6930.AllConstructorDeclarations01b#AllConstructorDeclarations01b()*",
187
		requestor
188
	);
189
}
190
191
public void testBug6930_AllConstructorDeclarations02() throws Exception {
192
	try {
193
		IJavaProject p = createJavaProject("P", new String[] {}, new String[] {"/P/lib6930.jar"}, "");
194
		
195
		createJar(new String[] {
196
			"p6930/AllConstructorDeclarations02.java",
197
			"package p6930;\n" +
198
			"public class AllConstructorDeclarations02 {\n" +
199
			"  public AllConstructorDeclarations02() {}\n" +
200
			"  public AllConstructorDeclarations02(Object o) {}\n" +
201
			"  public AllConstructorDeclarations02(Object o, String s) {}\n" +
202
			"}",
203
			"p6930/AllConstructorDeclarations02b.java",
204
			"package p6930;\n" +
205
			"public class AllConstructorDeclarations02b {\n" +
206
			"}"
207
		}, p.getProject().getLocation().append("lib6930.jar").toOSString());
208
		refresh(p);
209
		
210
		ConstructorDeclarationsCollector requestor = new ConstructorDeclarationsCollector();
211
		searchAllConstructorDeclarations("AllConstructorDeclarations", SearchPattern.R_PREFIX_MATCH, requestor);
212
		assertSearchResults(
213
			"p6930.AllConstructorDeclarations02#AllConstructorDeclarations02()\n" + 
214
			"p6930.AllConstructorDeclarations02#AllConstructorDeclarations02(java.lang.Object o)\n" + 
215
			"p6930.AllConstructorDeclarations02#AllConstructorDeclarations02(java.lang.Object o,java.lang.String s)\n" + 
216
			"p6930.AllConstructorDeclarations02b#AllConstructorDeclarations02b()",
217
			requestor
218
		);
219
	} finally {
220
		deleteProject("P");
221
	}
222
}
223
224
public void testBug6930_AllConstructorDeclarations03() throws Exception {
225
	try {
226
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[] {}, "bin");
227
		
228
		createFolder("/P/src/p6930");
229
		
230
		createFile(
231
				"/P/src/p6930/AllConstructorDeclarations03.java",
232
				"package p6930;\n" +
233
				"public class AllConstructorDeclarations03 {\n" +
234
				"  public AllConstructorDeclarations03() {}\n" +
235
				"  public AllConstructorDeclarations03(Object o) {}\n" +
236
				"  public AllConstructorDeclarations03(Object o, String s) {}\n" +
237
				"}");
238
		
239
		createFile(
240
				"/P/src/p6930/AllConstructorDeclarations03b.java",
241
				"package p6930;\n" +
242
				"public class AllConstructorDeclarations03b {\n" +
243
				"}");
244
		refresh(p);
245
		
246
		ConstructorDeclarationsCollector requestor = new ConstructorDeclarationsCollector();
247
		searchAllConstructorDeclarations("AllConstructorDeclarations", SearchPattern.R_PREFIX_MATCH, requestor);
248
		assertSearchResults(
249
			"p6930.AllConstructorDeclarations03#AllConstructorDeclarations03()\n" + 
250
			"p6930.AllConstructorDeclarations03#AllConstructorDeclarations03(Object o)\n" + 
251
			"p6930.AllConstructorDeclarations03#AllConstructorDeclarations03(Object o,String s)\n" + 
252
			"p6930.AllConstructorDeclarations03b#AllConstructorDeclarations03b()*",
253
			requestor
254
		);
255
	} finally {
256
		deleteProject("P");
257
	}
258
}
259
260
public void testBug6930_AllConstructorDeclarations04() throws Exception {
261
	try {
262
		IJavaProject p = createJavaProject("P", new String[] {}, new String[] {"/P/lib6930.jar"}, "","1.5");
263
		
264
		createJar(
265
			new String[] {
266
				"p6930/AllConstructorDeclarations04.java",
267
				"package p6930;\n" +
268
				"public class AllConstructorDeclarations04 {\n" +
269
				"  public AllConstructorDeclarations04(java.util.Collection<Object> c) {}\n" +
270
				"}"
271
			},
272
			p.getProject().getLocation().append("lib6930.jar").toOSString(),
273
			new String[]{getExternalJCLPathString("1.5")},
274
			"1.5");
275
		refresh(p);
276
		
277
		ConstructorDeclarationsCollector requestor = new ConstructorDeclarationsCollector();
278
		searchAllConstructorDeclarations("AllConstructorDeclarations", SearchPattern.R_PREFIX_MATCH, requestor);
279
		assertSearchResults(
280
			"p6930.AllConstructorDeclarations04#AllConstructorDeclarations04(java.util.Collection<java.lang.Object> c)",
281
			requestor
282
		);
283
	} finally {
284
		deleteProject("P");
285
	}
286
}
287
288
public void testBug6930_AllConstructorDeclarations05() throws Exception {
289
	try {
290
		IJavaProject p = createJavaProject("P", new String[] {}, new String[] {"/P/lib6930.jar"}, "");
291
		
292
		createJar(new String[] {
293
			"p6930/AllConstructorDeclarations05.java",
294
			"package p6930;\n" +
295
			"public class AllConstructorDeclarations05 {\n" +
296
			"  public class AllConstructorDeclarations05b {\n" +
297
			"    public AllConstructorDeclarations05b(Object o) {}\n" +
298
			"  }\n" +
299
			"}"
300
		}, p.getProject().getLocation().append("lib6930.jar").toOSString());
301
		refresh(p);
302
		
303
		ConstructorDeclarationsCollector requestor = new ConstructorDeclarationsCollector();
304
		searchAllConstructorDeclarations("AllConstructorDeclarations", SearchPattern.R_PREFIX_MATCH, requestor);
305
		assertSearchResults(
306
			"p6930.AllConstructorDeclarations05#AllConstructorDeclarations05()",
307
			requestor
308
		);
309
	} finally {
310
		deleteProject("P");
311
	}
312
}
313
163
/**
314
/**
164
 * @bug 70827: [Search] wrong reference match to private method of supertype
315
 * @bug 70827: [Search] wrong reference match to private method of supertype
165
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=70827"
316
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=70827"
Lines 10273-10277 Link Here
10273
		deleteProject("P");
10424
		deleteProject("P");
10274
	}
10425
	}
10275
}
10426
}
10276
10277
}
10427
}
(-)src/org/eclipse/jdt/core/tests/model/CompletionTests2.java (-1 / +1771 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 25-30 Link Here
25
import org.eclipse.core.runtime.CoreException;
25
import org.eclipse.core.runtime.CoreException;
26
import org.eclipse.core.runtime.IPath;
26
import org.eclipse.core.runtime.IPath;
27
import org.eclipse.core.runtime.IProgressMonitor;
27
import org.eclipse.core.runtime.IProgressMonitor;
28
import org.eclipse.core.runtime.NullProgressMonitor;
28
import org.eclipse.core.runtime.Path;
29
import org.eclipse.core.runtime.Path;
29
import org.eclipse.jdt.core.IAccessRule;
30
import org.eclipse.jdt.core.IAccessRule;
30
import org.eclipse.jdt.core.IClasspathAttribute;
31
import org.eclipse.jdt.core.IClasspathAttribute;
Lines 417-422 Link Here
417
		this.deleteProject("P3");
418
		this.deleteProject("P3");
418
	}
419
	}
419
}
420
}
421
public void testBug6930_01() throws Exception {
422
	try {
423
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL_LIB"}, "bin");
424
		
425
		createFolder("/P/src/p6930");
426
		
427
		this.workingCopies = new ICompilationUnit[3];
428
		
429
		this.workingCopies[1] = getWorkingCopy("/P/src/p6930/AllConstructors01.java",
430
			"package p6930;\n" +
431
			"public class AllConstructors01 {\n" +
432
			"  public AllConstructors01() {}\n" +
433
			"  public AllConstructors01(Object o) {}\n" +
434
			"  public AllConstructors01(Object o, String s) {}\n" +
435
			"}\n"
436
		);
437
		
438
		this.workingCopies[2] = getWorkingCopy("/P/src/p6930/AllConstructors01b.java",
439
			"package p6930;\n" +
440
			"public class AllConstructors01b {\n" +
441
			"}\n"
442
		);
443
		
444
		refresh(p);
445
		
446
		waitUntilIndexesReady();
447
		
448
		this.workingCopies[0] = getWorkingCopy(
449
				"/P/src/test/Test.java",
450
				"package test;"+
451
				"public class Test {\n" +
452
				"  void foo() {\n" +
453
				"    new AllConstructors\n" +
454
				"  }\n" +
455
				"}");
456
457
		// do completion
458
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true);
459
		requestor.allowAllRequiredProposals();
460
		NullProgressMonitor monitor = new NullProgressMonitor();
461
462
	    String str = this.workingCopies[0].getSource();
463
	    String completeBehind = "AllConstructors";
464
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
465
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
466
	    
467
	    assertResults(
468
			"AllConstructors01[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors01;, ()V, AllConstructors01, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
469
			"   AllConstructors01[TYPE_REF]{p6930.AllConstructors01, p6930, Lp6930.AllConstructors01;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
470
			"AllConstructors01[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors01;, (Ljava.lang.Object;)V, AllConstructors01, (o), "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
471
			"   AllConstructors01[TYPE_REF]{p6930.AllConstructors01, p6930, Lp6930.AllConstructors01;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
472
			"AllConstructors01[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors01;, (Ljava.lang.Object;Ljava.lang.String;)V, AllConstructors01, (o, s), "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
473
			"   AllConstructors01[TYPE_REF]{p6930.AllConstructors01, p6930, Lp6930.AllConstructors01;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
474
			"AllConstructors01b[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors01b;, ()V, AllConstructors01b, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
475
			"   AllConstructors01b[TYPE_REF]{p6930.AllConstructors01b, p6930, Lp6930.AllConstructors01b;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}",
476
			requestor.getResults());
477
	} finally {
478
		deleteProject("P");
479
	}
480
}
481
public void testBug6930_02() throws Exception {
482
	try {
483
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL_LIB", "/P/lib6930.jar"}, "bin");
484
		
485
		createJar(new String[] {
486
			"p6930/AllConstructors02.java",
487
			"package p6930;\n" +
488
			"public class AllConstructors02 {\n" +
489
			"  public AllConstructors02() {}\n" +
490
			"  public AllConstructors02(Object o) {}\n" +
491
			"  public AllConstructors02(Object o, String s) {}\n" +
492
			"}",
493
			"p6930/AllConstructors02b.java",
494
			"package p6930;\n" +
495
			"public class AllConstructors02b {\n" +
496
			"}"
497
		}, p.getProject().getLocation().append("lib6930.jar").toOSString());
498
		
499
		refresh(p);
500
		
501
		waitUntilIndexesReady();
502
		
503
		this.workingCopies = new ICompilationUnit[1];
504
		this.workingCopies[0] = getWorkingCopy(
505
				"/P/src/test/Test.java",
506
				"package test;"+
507
				"public class Test {\n" +
508
				"  void foo() {\n" +
509
				"    new AllConstructors\n" +
510
				"  }\n" +
511
				"}");
512
513
		// do completion
514
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true);
515
		requestor.allowAllRequiredProposals();
516
		NullProgressMonitor monitor = new NullProgressMonitor();
517
518
	    String str = this.workingCopies[0].getSource();
519
	    String completeBehind = "AllConstructors";
520
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
521
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
522
	    
523
	    assertResults(
524
			"AllConstructors02[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors02;, ()V, AllConstructors02, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
525
			"   AllConstructors02[TYPE_REF]{p6930.AllConstructors02, p6930, Lp6930.AllConstructors02;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
526
			"AllConstructors02[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors02;, (Ljava.lang.Object;)V, AllConstructors02, (o), "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
527
			"   AllConstructors02[TYPE_REF]{p6930.AllConstructors02, p6930, Lp6930.AllConstructors02;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
528
			"AllConstructors02[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors02;, (Ljava.lang.Object;Ljava.lang.String;)V, AllConstructors02, (o, s), "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
529
			"   AllConstructors02[TYPE_REF]{p6930.AllConstructors02, p6930, Lp6930.AllConstructors02;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
530
			"AllConstructors02b[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors02b;, ()V, AllConstructors02b, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
531
			"   AllConstructors02b[TYPE_REF]{p6930.AllConstructors02b, p6930, Lp6930.AllConstructors02b;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}",
532
			requestor.getResults());
533
	} finally {
534
		deleteProject("P");
535
	}
536
}
537
public void testBug6930_03() throws Exception {
538
	try {
539
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL_LIB"}, "bin");
540
		
541
		createFolder("/P/src/p6930");
542
		
543
		createFile(
544
				"/P/src/p6930/AllConstructors03.java",
545
				"package p6930;\n" +
546
				"public class AllConstructors03 {\n" +
547
				"  public AllConstructors03() {}\n" +
548
				"  public AllConstructors03(Object o) {}\n" +
549
				"  public AllConstructors03(Object o, String s) {}\n" +
550
				"}");
551
		
552
		createFile(
553
				"/P/src/p6930/AllConstructors03b.java",
554
				"package p6930;\n" +
555
				"public class AllConstructors03b {\n" +
556
				"}");
557
		refresh(p);
558
		
559
		waitUntilIndexesReady();
560
		
561
		this.workingCopies = new ICompilationUnit[1];
562
		this.workingCopies[0] = getWorkingCopy(
563
				"/P/src/test/Test.java",
564
				"package test;"+
565
				"public class Test {\n" +
566
				"  void foo() {\n" +
567
				"    new AllConstructors\n" +
568
				"  }\n" +
569
				"}");
570
571
		// do completion
572
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true);
573
		requestor.allowAllRequiredProposals();
574
		NullProgressMonitor monitor = new NullProgressMonitor();
575
576
	    String str = this.workingCopies[0].getSource();
577
	    String completeBehind = "AllConstructors";
578
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
579
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
580
	    
581
	    assertResults(
582
			"AllConstructors03[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors03;, ()V, AllConstructors03, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
583
			"   AllConstructors03[TYPE_REF]{p6930.AllConstructors03, p6930, Lp6930.AllConstructors03;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
584
			"AllConstructors03[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors03;, (Ljava.lang.Object;)V, AllConstructors03, (o), "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
585
			"   AllConstructors03[TYPE_REF]{p6930.AllConstructors03, p6930, Lp6930.AllConstructors03;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
586
			"AllConstructors03[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors03;, (Ljava.lang.Object;Ljava.lang.String;)V, AllConstructors03, (o, s), "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
587
			"   AllConstructors03[TYPE_REF]{p6930.AllConstructors03, p6930, Lp6930.AllConstructors03;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
588
			"AllConstructors03b[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors03b;, ()V, AllConstructors03b, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
589
			"   AllConstructors03b[TYPE_REF]{p6930.AllConstructors03b, p6930, Lp6930.AllConstructors03b;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}",
590
			requestor.getResults());
591
	} finally {
592
		deleteProject("P");
593
	}
594
}
595
public void testBug6930_04() throws Exception {
596
	try {
597
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL_LIB"}, "bin");
598
		
599
		refresh(p);
600
		
601
		waitUntilIndexesReady();
602
		
603
		this.workingCopies = new ICompilationUnit[2];
604
		this.workingCopies[0] = getWorkingCopy(
605
				"/P/src/test/Test.java",
606
				"package test;"+
607
				"class AllConstructors04a {\n" +
608
				"  public class AllConstructors0b {\n" +
609
				"  }\n" +
610
				"}\n" +
611
				"public class Test {\n" +
612
				"  public class AllConstructors04c {\n" +
613
				"    public class AllConstructors04d {\n" +
614
				"    }\n" +
615
				"  }\n" +
616
				"  void foo() {\n" +
617
				"    class AllConstructors04e {\n" +
618
				"      class AllConstructors04f {\n" +
619
				"      }\n" +
620
				"    }\n" +
621
				"    new AllConstructors\n" +
622
				"  }\n" +
623
				"}");
624
		
625
		this.workingCopies[1] = getWorkingCopy(
626
				"/P/src/test/AllConstructors04g.java",
627
				"package test;"+
628
				"public class AllConstructors04g {\n" +
629
				"  public class AllConstructors0h {\n" +
630
				"  }\n" +
631
				"}");
632
633
		// do completion
634
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true);
635
		requestor.allowAllRequiredProposals();
636
		NullProgressMonitor monitor = new NullProgressMonitor();
637
638
	    String str = this.workingCopies[0].getSource();
639
	    String completeBehind = "AllConstructors";
640
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
641
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
642
	    
643
	    assertResults(
644
			"AllConstructors04a[CONSTRUCTOR_INVOCATION]{(), Ltest.AllConstructors04a;, ()V, AllConstructors04a, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
645
			"   AllConstructors04a[TYPE_REF]{AllConstructors04a, test, Ltest.AllConstructors04a;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
646
			"AllConstructors04c[CONSTRUCTOR_INVOCATION]{(), Ltest.Test$AllConstructors04c;, ()V, AllConstructors04c, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
647
			"   Test.AllConstructors04c[TYPE_REF]{AllConstructors04c, test, Ltest.Test$AllConstructors04c;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
648
			"AllConstructors04e[CONSTRUCTOR_INVOCATION]{(), LAllConstructors04e;, ()V, AllConstructors04e, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
649
			"   AllConstructors04e[TYPE_REF]{AllConstructors04e, null, LAllConstructors04e;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
650
			"AllConstructors04g[CONSTRUCTOR_INVOCATION]{(), Ltest.AllConstructors04g;, ()V, AllConstructors04g, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
651
			"   AllConstructors04g[TYPE_REF]{AllConstructors04g, test, Ltest.AllConstructors04g;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
652
			requestor.getResults());
653
	} finally {
654
		deleteProject("P");
655
	}
656
}
657
public void testBug6930_05() throws Exception {
658
	try {
659
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL_LIB"}, "bin");
660
		
661
		refresh(p);
662
		
663
		waitUntilIndexesReady();
664
		
665
		this.workingCopies = new ICompilationUnit[2];
666
		this.workingCopies[0] = getWorkingCopy(
667
				"/P/src/test/Test.java",
668
				"package test;"+
669
				"class AllConstructors05a {\n" +
670
				"  public static class AllConstructors0b {\n" +
671
				"  }\n" +
672
				"}\n" +
673
				"public class Test {\n" +
674
				"  public static class AllConstructors05c {\n" +
675
				"    public static class AllConstructors05d {\n" +
676
				"    }\n" +
677
				"  }\n" +
678
				"  void foo() {\n" +
679
				"    new AllConstructors\n" +
680
				"  }\n" +
681
				"}");
682
		
683
		this.workingCopies[1] = getWorkingCopy(
684
				"/P/src/test/AllConstructors05g.java",
685
				"package test;"+
686
				"public class AllConstructors05g {\n" +
687
				"  public static class AllConstructors0h {\n" +
688
				"  }\n" +
689
				"}");
690
691
		// do completion
692
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true);
693
		requestor.allowAllRequiredProposals();
694
		NullProgressMonitor monitor = new NullProgressMonitor();
695
696
	    String str = this.workingCopies[0].getSource();
697
	    String completeBehind = "AllConstructors";
698
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
699
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
700
	    
701
	    assertResults(
702
			"AllConstructors05a[TYPE_REF]{AllConstructors05a, test, Ltest.AllConstructors05a;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
703
			"AllConstructors05a[CONSTRUCTOR_INVOCATION]{(), Ltest.AllConstructors05a;, ()V, AllConstructors05a, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
704
			"   AllConstructors05a[TYPE_REF]{AllConstructors05a, test, Ltest.AllConstructors05a;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
705
			"AllConstructors05c[CONSTRUCTOR_INVOCATION]{(), Ltest.Test$AllConstructors05c;, ()V, AllConstructors05c, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
706
			"   Test.AllConstructors05c[TYPE_REF]{AllConstructors05c, test, Ltest.Test$AllConstructors05c;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
707
			"AllConstructors05g[TYPE_REF]{AllConstructors05g, test, Ltest.AllConstructors05g;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
708
			"AllConstructors05g[CONSTRUCTOR_INVOCATION]{(), Ltest.AllConstructors05g;, ()V, AllConstructors05g, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
709
			"   AllConstructors05g[TYPE_REF]{AllConstructors05g, test, Ltest.AllConstructors05g;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
710
			"Test.AllConstructors05c[TYPE_REF]{AllConstructors05c, test, Ltest.Test$AllConstructors05c;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
711
			requestor.getResults());
712
	} finally {
713
		deleteProject("P");
714
	}
715
}
716
public void testBug6930_06() throws Exception {
717
	try {
718
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL_LIB", "/P/lib6930.jar"}, "bin");
719
		
720
		createFolder("/P/src/p6930");
721
		
722
		createFile(
723
				"/P/src/p6930/AllConstructors06a.java",
724
				"package p6930;\n" +
725
				"public class AllConstructors06a {\n" +
726
				"}");
727
		
728
		createJar(new String[] {
729
			"p6930/AllConstructors06b.java",
730
			"package p6930;\n" +
731
			"public class AllConstructors06b {\n" +
732
			"}"
733
		}, p.getProject().getLocation().append("lib6930.jar").toOSString());
734
		
735
		refresh(p);
736
		
737
		waitUntilIndexesReady();
738
		
739
		this.workingCopies = new ICompilationUnit[2];
740
		this.workingCopies[0] = getWorkingCopy(
741
				"/P/src/test/Test.java",
742
				"package test;\n"+
743
				"import p6930.AllConstructors06a;\n"+
744
				"import p6930.AllConstructors06b;\n"+
745
				"import p6930.AllConstructors06c;\n"+
746
				"public class Test {\n" +
747
				"  void foo() {\n" +
748
				"    new AllConstructors\n" +
749
				"  }\n" +
750
				"}");
751
		
752
		this.workingCopies[1] = getWorkingCopy(
753
				"/P/src/p6930/AllConstructors06c.java",
754
				"package p6930;"+
755
				"public class AllConstructors06c {\n" +
756
				"}");
757
758
		// do completion
759
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true);
760
		requestor.allowAllRequiredProposals();
761
		NullProgressMonitor monitor = new NullProgressMonitor();
762
763
	    String str = this.workingCopies[0].getSource();
764
	    String completeBehind = "AllConstructors";
765
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
766
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
767
	    
768
	    assertResults(
769
			"AllConstructors06a[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors06a;, ()V, AllConstructors06a, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
770
			"   AllConstructors06a[TYPE_REF]{AllConstructors06a, p6930, Lp6930.AllConstructors06a;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
771
			"AllConstructors06b[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors06b;, ()V, AllConstructors06b, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
772
			"   AllConstructors06b[TYPE_REF]{AllConstructors06b, p6930, Lp6930.AllConstructors06b;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
773
			"AllConstructors06c[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors06c;, ()V, AllConstructors06c, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
774
			"   AllConstructors06c[TYPE_REF]{AllConstructors06c, p6930, Lp6930.AllConstructors06c;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
775
			requestor.getResults());
776
777
	} finally {
778
		deleteProject("P");
779
	}
780
}
781
public void testBug6930_07() throws Exception {
782
	try {
783
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL_LIB", "/P/lib6930.jar"}, "bin");
784
		
785
		createFolder("/P/src/p6930");
786
		
787
		createFile(
788
				"/P/src/p6930/AllConstructors07a.java",
789
				"package p6930;\n" +
790
				"public class AllConstructors07a {\n" +
791
				"  public class AllConstructors07b {\n" +
792
				"  }\n" +
793
				"  public static class AllConstructors07c {\n" +
794
				"  }\n" +
795
				"}");
796
		
797
		createFile(
798
				"/P/src/p6930/AllConstructors07d.java",
799
				"package p6930;\n" +
800
				"public class AllConstructors07d {\n" +
801
				"  public class AllConstructors07e {\n" +
802
				"  }\n" +
803
				"  public static class AllConstructors07f {\n" +
804
				"  }\n" +
805
				"}");
806
		
807
		refresh(p);
808
		
809
		waitUntilIndexesReady();
810
		
811
		this.workingCopies = new ICompilationUnit[1];
812
		this.workingCopies[0] = getWorkingCopy(
813
				"/P/src/test/Test.java",
814
				"package test;\n"+
815
				"import p6930.*;\n"+
816
				"public class Test {\n" +
817
				"  void foo() {\n" +
818
				"    new AllConstructors\n" +
819
				"  }\n" +
820
				"}");
821
822
		// do completion
823
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true);
824
		requestor.allowAllRequiredProposals();
825
		NullProgressMonitor monitor = new NullProgressMonitor();
826
827
	    String str = this.workingCopies[0].getSource();
828
	    String completeBehind = "AllConstructors";
829
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
830
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
831
	    
832
	    assertResults(
833
			"AllConstructors07a[TYPE_REF]{AllConstructors07a, p6930, Lp6930.AllConstructors07a;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
834
			"AllConstructors07a[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors07a;, ()V, AllConstructors07a, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
835
			"   AllConstructors07a[TYPE_REF]{AllConstructors07a, p6930, Lp6930.AllConstructors07a;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
836
			"AllConstructors07d[TYPE_REF]{AllConstructors07d, p6930, Lp6930.AllConstructors07d;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
837
			"AllConstructors07d[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors07d;, ()V, AllConstructors07d, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
838
			"   AllConstructors07d[TYPE_REF]{AllConstructors07d, p6930, Lp6930.AllConstructors07d;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
839
			requestor.getResults());
840
	} finally {
841
		deleteProject("P");
842
	}
843
}
844
public void testBug6930_08() throws Exception {
845
	try {
846
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL15_LIB", "/P/lib6930.jar"}, "bin", "1.5");
847
		
848
		createFolder("/P/src/p6930");
849
		
850
		createFile(
851
				"/P/src/p6930/AllConstructors08a.java",
852
				"package p6930;\n" +
853
				"public class AllConstructors08a {\n" +
854
				"  public class AllConstructors08b {\n" +
855
				"  }\n" +
856
				"  public static class AllConstructors08c {\n" +
857
				"  }\n" +
858
				"}");
859
		
860
		createFile(
861
				"/P/src/p6930/AllConstructors08d.java",
862
				"package p6930;\n" +
863
				"public class AllConstructors08d {\n" +
864
				"  public class AllConstructors08e {\n" +
865
				"  }\n" +
866
				"  public static class AllConstructors08f {\n" +
867
				"  }\n" +
868
				"}");
869
		
870
		refresh(p);
871
		
872
		waitUntilIndexesReady();
873
		
874
		this.workingCopies = new ICompilationUnit[1];
875
		this.workingCopies[0] = getWorkingCopy(
876
				"/P/src/test/Test.java",
877
				"package test;\n"+
878
				"import p6930.AllConstructors08a;\n"+
879
				"public class Test {\n" +
880
				"  void foo() {\n" +
881
				"    new AllConstructors\n" +
882
				"  }\n" +
883
				"}");
884
885
		// do completion
886
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true);
887
		requestor.allowAllRequiredProposals();
888
		NullProgressMonitor monitor = new NullProgressMonitor();
889
890
	    String str = this.workingCopies[0].getSource();
891
	    String completeBehind = "AllConstructors";
892
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
893
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
894
	    
895
	    assertResults(
896
			"AllConstructors08d[TYPE_REF]{p6930.AllConstructors08d, p6930, Lp6930.AllConstructors08d;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
897
			"AllConstructors08d[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors08d;, ()V, AllConstructors08d, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
898
			"   AllConstructors08d[TYPE_REF]{p6930.AllConstructors08d, p6930, Lp6930.AllConstructors08d;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
899
			"AllConstructors08a[TYPE_REF]{AllConstructors08a, p6930, Lp6930.AllConstructors08a;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
900
			"AllConstructors08a[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors08a;, ()V, AllConstructors08a, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
901
			"   AllConstructors08a[TYPE_REF]{AllConstructors08a, p6930, Lp6930.AllConstructors08a;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
902
			requestor.getResults());
903
	} finally {
904
		deleteProject("P");
905
	}
906
}
907
908
public void testBug6930_09() throws Exception {
909
	try {
910
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL15_LIB", "/P/lib6930.jar"}, "bin", "1.5");
911
		
912
		createFolder("/P/src/p6930");
913
		
914
		createFile(
915
				"/P/src/p6930/AllConstructors09a.java",
916
				"package p6930;\n" +
917
				"public class AllConstructors09a {\n" +
918
				"  public class AllConstructors09b {\n" +
919
				"  }\n" +
920
				"  public static class AllConstructors09c {\n" +
921
				"  }\n" +
922
				"}");
923
		
924
		createFile(
925
				"/P/src/p6930/AllConstructors09d.java",
926
				"package p6930;\n" +
927
				"public class AllConstructors09d {\n" +
928
				"  public class AllConstructors09e {\n" +
929
				"  }\n" +
930
				"  public static class AllConstructors09f {\n" +
931
				"    public static class AllConstructors09g {\n" +
932
				"    }\n" +
933
				"  }\n" +
934
				"}");
935
		
936
		refresh(p);
937
		
938
		waitUntilIndexesReady();
939
		
940
		this.workingCopies = new ICompilationUnit[1];
941
		this.workingCopies[0] = getWorkingCopy(
942
				"/P/src/test/Test.java",
943
				"package test;\n"+
944
				"import p6930.AllConstructors09a.*;\n"+
945
				"import static p6930.AllConstructors09d.*;\n"+
946
				"public class Test {\n" +
947
				"  void foo() {\n" +
948
				"    new AllConstructors\n" +
949
				"  }\n" +
950
				"}");
951
952
		// do completion
953
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true);
954
		requestor.allowAllRequiredProposals();
955
		NullProgressMonitor monitor = new NullProgressMonitor();
956
957
	    String str = this.workingCopies[0].getSource();
958
	    String completeBehind = "AllConstructors";
959
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
960
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
961
	    
962
	    assertResults(
963
			"AllConstructors09a[TYPE_REF]{p6930.AllConstructors09a, p6930, Lp6930.AllConstructors09a;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
964
			"AllConstructors09a[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors09a;, ()V, AllConstructors09a, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
965
			"   AllConstructors09a[TYPE_REF]{p6930.AllConstructors09a, p6930, Lp6930.AllConstructors09a;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
966
			"AllConstructors09d[TYPE_REF]{p6930.AllConstructors09d, p6930, Lp6930.AllConstructors09d;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
967
			"AllConstructors09d[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors09d;, ()V, AllConstructors09d, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
968
			"   AllConstructors09d[TYPE_REF]{p6930.AllConstructors09d, p6930, Lp6930.AllConstructors09d;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
969
			"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" +
970
			"AllConstructors09f[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors09d$AllConstructors09f;, ()V, AllConstructors09f, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
971
			"   AllConstructors09d.AllConstructors09f[TYPE_REF]{AllConstructors09f, p6930, Lp6930.AllConstructors09d$AllConstructors09f;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
972
			requestor.getResults());
973
	} finally {
974
		deleteProject("P");
975
	}
976
}
977
public void testBug6930_10() throws Exception {
978
	try {
979
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL15_LIB", "/P/lib6930.jar"}, "bin", "1.5");
980
		
981
		createFolder("/P/src/p6930");
982
		
983
		createFile(
984
				"/P/src/p6930/AllConstructors10a.java",
985
				"package p6930;\n" +
986
				"public class AllConstructors10a {\n" +
987
				"  public class AllConstructors10b {\n" +
988
				"    public static class AllConstructors10bs {\n" +
989
				"    }\n" +
990
				"  }\n" +
991
				"  public static class AllConstructors10c {\n" +
992
				"    public static class AllConstructors10cs {\n" +
993
				"    }\n" +
994
				"  }\n" +
995
				"}");
996
		
997
		createFile(
998
				"/P/src/p6930/AllConstructors10d.java",
999
				"package p6930;\n" +
1000
				"public class AllConstructors10d {\n" +
1001
				"  public class AllConstructors10e {\n" +
1002
				"    public static class AllConstructors10es {\n" +
1003
				"    }\n" +
1004
				"  }\n" +
1005
				"  public static class AllConstructors10f {\n" +
1006
				"    public static class AllConstructors10fs {\n" +
1007
				"    }\n" +
1008
				"  }\n" +
1009
				"}");
1010
		
1011
		refresh(p);
1012
		
1013
		waitUntilIndexesReady();
1014
		
1015
		this.workingCopies = new ICompilationUnit[1];
1016
		this.workingCopies[0] = getWorkingCopy(
1017
				"/P/src/test/Test.java",
1018
				"package test;\n"+
1019
				"import p6930.AllConstructors10a.AllConstructors10b;\n"+
1020
				"import p6930.AllConstructors10a.AllConstructors10c;\n"+
1021
				"import static p6930.AllConstructors10d.AllConstructors10e;\n"+
1022
				"import static p6930.AllConstructors10d.AllConstructors10f;\n"+
1023
				"public class Test {\n" +
1024
				"  void foo() {\n" +
1025
				"    new AllConstructors\n" +
1026
				"  }\n" +
1027
				"}");
1028
1029
		// do completion
1030
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true);
1031
		requestor.allowAllRequiredProposals();
1032
		NullProgressMonitor monitor = new NullProgressMonitor();
1033
1034
	    String str = this.workingCopies[0].getSource();
1035
	    String completeBehind = "AllConstructors";
1036
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1037
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
1038
	    
1039
	    assertResults(
1040
			"AllConstructors10a[TYPE_REF]{p6930.AllConstructors10a, p6930, Lp6930.AllConstructors10a;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1041
			"AllConstructors10a[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors10a;, ()V, AllConstructors10a, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1042
			"   AllConstructors10a[TYPE_REF]{p6930.AllConstructors10a, p6930, Lp6930.AllConstructors10a;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1043
			"AllConstructors10d[TYPE_REF]{p6930.AllConstructors10d, p6930, Lp6930.AllConstructors10d;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1044
			"AllConstructors10d[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors10d;, ()V, AllConstructors10d, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1045
			"   AllConstructors10d[TYPE_REF]{p6930.AllConstructors10d, p6930, Lp6930.AllConstructors10d;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1046
			"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" +
1047
			"AllConstructors10c[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors10a$AllConstructors10c;, ()V, AllConstructors10c, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
1048
			"   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" +
1049
			"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" +
1050
			"AllConstructors10f[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors10d$AllConstructors10f;, ()V, AllConstructors10f, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
1051
			"   AllConstructors10d.AllConstructors10f[TYPE_REF]{AllConstructors10f, p6930, Lp6930.AllConstructors10d$AllConstructors10f;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
1052
			requestor.getResults());
1053
	} finally {
1054
		deleteProject("P");
1055
	}
1056
}
1057
public void testBug6930_11() throws Exception {
1058
	try {
1059
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL_LIB", "/P/lib6930.jar"}, "bin");
1060
		
1061
		createFolder("/P/src/p6930");
1062
		
1063
		createFile(
1064
				"/P/src/p6930/AllConstructors11a.java",
1065
				"package p6930;\n" +
1066
				"public class AllConstructors11a {\n" +
1067
				"}");
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.AllConstructors11a a = new \n" +
1081
				"  }\n" +
1082
				"}");
1083
1084
		// do completion
1085
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true);
1086
		requestor.allowAllRequiredProposals();
1087
		NullProgressMonitor monitor = new NullProgressMonitor();
1088
1089
	    String str = this.workingCopies[0].getSource();
1090
	    String completeBehind = "new ";
1091
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1092
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
1093
	    
1094
	    assertResults(
1095
			"Test[CONSTRUCTOR_INVOCATION]{(), Ltest.Test;, ()V, Test, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
1096
			"   Test[TYPE_REF]{Test, test, Ltest.Test;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
1097
			"AllConstructors11a[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors11a;, ()V, AllConstructors11a, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED)+"}\n" +
1098
			"   AllConstructors11a[TYPE_REF]{p6930.AllConstructors11a, p6930, Lp6930.AllConstructors11a;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED)+"}",
1099
			requestor.getResults());
1100
	} finally {
1101
		deleteProject("P");
1102
	}
1103
}
1104
public void testBug6930_12() throws Exception {
1105
	try {
1106
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL_LIB", "/P/lib6930.jar"}, "bin");
1107
		
1108
		createFolder("/P/src/p6930");
1109
		
1110
		createFile(
1111
				"/P/src/p6930/AllConstructors12a.java",
1112
				"package p6930;\n" +
1113
				"public class AllConstructors12a {\n" +
1114
				"  public static class AllConstructors12b {\n" +
1115
				"  }\n" +
1116
				"}");
1117
		
1118
		refresh(p);
1119
		
1120
		waitUntilIndexesReady();
1121
		
1122
		this.workingCopies = new ICompilationUnit[1];
1123
		this.workingCopies[0] = getWorkingCopy(
1124
				"/P/src/test/Test.java",
1125
				"package test;\n"+
1126
				"public class Test {\n" +
1127
				"  void foo() {\n" +
1128
				"    p6930.AllConstructors12a a = new \n" +
1129
				"  }\n" +
1130
				"}");
1131
1132
		// do completion
1133
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true);
1134
		requestor.allowAllRequiredProposals();
1135
		NullProgressMonitor monitor = new NullProgressMonitor();
1136
1137
	    String str = this.workingCopies[0].getSource();
1138
	    String completeBehind = "new ";
1139
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1140
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
1141
	    
1142
	    assertResults(
1143
			"Test[CONSTRUCTOR_INVOCATION]{(), Ltest.Test;, ()V, Test, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
1144
			"   Test[TYPE_REF]{Test, test, Ltest.Test;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
1145
			"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" +
1146
			"AllConstructors12a[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors12a;, ()V, AllConstructors12a, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED)+"}\n" +
1147
			"   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)+"}",
1148
			requestor.getResults());
1149
	} finally {
1150
		deleteProject("P");
1151
	}
1152
}
1153
public void testBug6930_13() throws Exception {
1154
	try {
1155
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL_LIB", "/P/lib6930.jar"}, "bin");
1156
		
1157
		createFolder("/P/src/p6930");
1158
		
1159
		createFile(
1160
				"/P/src/p6930/AllConstructors13a.java",
1161
				"package p6930;\n" +
1162
				"public class AllConstructors13a {\n" +
1163
				"}");
1164
1165
		
1166
		refresh(p);
1167
		
1168
		waitUntilIndexesReady();
1169
		
1170
		this.workingCopies = new ICompilationUnit[1];
1171
		this.workingCopies[0] = getWorkingCopy(
1172
				"/P/src/test/Test.java",
1173
				"package test;\n"+
1174
				"public class Test {\n" +
1175
				"  void foo() {\n" +
1176
				"    p6930.AllConstructors13a a = new AllConstructors\n" +
1177
				"  }\n" +
1178
				"}");
1179
1180
		// do completion
1181
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true);
1182
		requestor.allowAllRequiredProposals();
1183
		NullProgressMonitor monitor = new NullProgressMonitor();
1184
1185
	    String str = this.workingCopies[0].getSource();
1186
	    String completeBehind = "new AllConstructors";
1187
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1188
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
1189
	    
1190
	    assertResults(
1191
			"AllConstructors13a[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors13a;, ()V, AllConstructors13a, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED)+"}\n" +
1192
			"   AllConstructors13a[TYPE_REF]{p6930.AllConstructors13a, p6930, Lp6930.AllConstructors13a;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED)+"}",
1193
			requestor.getResults());
1194
	} finally {
1195
		deleteProject("P");
1196
	}
1197
}
1198
public void testBug6930_14() throws Exception {
1199
	try {
1200
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL_LIB", "/P/lib6930.jar"}, "bin");
1201
		
1202
		createFolder("/P/src/p6930");
1203
		
1204
		createFile(
1205
				"/P/src/p6930/AllConstructors14a.java",
1206
				"package p6930;\n" +
1207
				"public class AllConstructors14a {\n" +
1208
				"  public static class AllConstructors14b {\n" +
1209
				"  }\n" +
1210
				"}");
1211
		
1212
		refresh(p);
1213
		
1214
		waitUntilIndexesReady();
1215
		
1216
		this.workingCopies = new ICompilationUnit[1];
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
				"    p6930.AllConstructors14a a = new AllConstructors\n" +
1223
				"  }\n" +
1224
				"}");
1225
1226
		// do completion
1227
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true);
1228
		requestor.allowAllRequiredProposals();
1229
		NullProgressMonitor monitor = new NullProgressMonitor();
1230
1231
	    String str = this.workingCopies[0].getSource();
1232
	    String completeBehind = "new AllConstructors";
1233
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1234
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
1235
	    
1236
	    assertResults(
1237
			"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" +
1238
			"AllConstructors14a[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors14a;, ()V, AllConstructors14a, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED)+"}\n" +
1239
			"   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)+"}",
1240
			requestor.getResults());
1241
	} finally {
1242
		deleteProject("P");
1243
	}
1244
}
1245
public void testBug6930_15() throws Exception {
1246
	try {
1247
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL15_LIB", "/P/lib6930.jar"}, "bin", "1.5");
1248
		
1249
		createFolder("/P/src/p6930");
1250
		
1251
		createFile(
1252
				"/P/src/p6930/AllConstructors15a.java",
1253
				"package p6930;\n" +
1254
				"public class AllConstructors15a<T> {\n" +
1255
				"}");
1256
		
1257
		createJar(
1258
				new String[] {
1259
					"p6930/AllConstructors15b.java",
1260
					"package p6930;\n" +
1261
					"public class AllConstructors15b<T> {\n" +
1262
					"}"
1263
				},
1264
				p.getProject().getLocation().append("lib6930.jar").toOSString(),
1265
				new String[]{getExternalJCLPathString("1.5")},
1266
				"1.5");
1267
		
1268
		refresh(p);
1269
		
1270
		waitUntilIndexesReady();
1271
		
1272
		this.workingCopies = new ICompilationUnit[2];
1273
		this.workingCopies[0] = getWorkingCopy(
1274
				"/P/src/test/Test.java",
1275
				"package test;\n"+
1276
				"public class Test {\n" +
1277
				"  void foo() {\n" +
1278
				"    new AllConstructors\n" +
1279
				"  }\n" +
1280
				"}");
1281
		
1282
		this.workingCopies[1] = getWorkingCopy(
1283
				"/P/src/p6930/AllConstructors15c.java",
1284
				"package p6930;"+
1285
				"public class AllConstructors15c<T> {\n" +
1286
				"}");
1287
1288
		// do completion
1289
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true);
1290
		requestor.allowAllRequiredProposals();
1291
		NullProgressMonitor monitor = new NullProgressMonitor();
1292
1293
	    String str = this.workingCopies[0].getSource();
1294
	    String completeBehind = "AllConstructors";
1295
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1296
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
1297
	    
1298
	    assertResults(
1299
			"AllConstructors15a[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors15a;, ()V, AllConstructors15a, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1300
			"   AllConstructors15a[TYPE_REF]{p6930.AllConstructors15a, p6930, Lp6930.AllConstructors15a;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1301
			"AllConstructors15b[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors15b;, ()V, AllConstructors15b, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1302
			"   AllConstructors15b[TYPE_REF]{p6930.AllConstructors15b, p6930, Lp6930.AllConstructors15b;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1303
			"AllConstructors15c[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors15c;, ()V, AllConstructors15c, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1304
			"   AllConstructors15c[TYPE_REF]{p6930.AllConstructors15c, p6930, Lp6930.AllConstructors15c;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}",
1305
			requestor.getResults());
1306
	} finally {
1307
		deleteProject("P");
1308
	}
1309
}
1310
public void testBug6930_16() throws Exception {
1311
	try {
1312
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL15_LIB", "/P/lib6930.jar"}, "bin", "1.5");
1313
		
1314
		createFolder("/P/src/p6930");
1315
		
1316
		createFile(
1317
				"/P/src/p6930/AllConstructors16a.java",
1318
				"package p6930;\n" +
1319
				"public class AllConstructors16a{\n" +
1320
				"  public <T> AllConstructors16a(){}\n" +
1321
				"}");
1322
		
1323
		createJar(
1324
				new String[] {
1325
					"p6930/AllConstructors16b.java",
1326
					"package p6930;\n" +
1327
					"public class AllConstructors16b {\n" +
1328
					"  public <T> AllConstructors16b(){}\n" +
1329
					"}"
1330
				},
1331
				p.getProject().getLocation().append("lib6930.jar").toOSString(),
1332
				new String[]{getExternalJCLPathString("1.5")},
1333
				"1.5");
1334
		
1335
		refresh(p);
1336
		
1337
		waitUntilIndexesReady();
1338
		
1339
		this.workingCopies = new ICompilationUnit[2];
1340
		this.workingCopies[0] = getWorkingCopy(
1341
				"/P/src/test/Test.java",
1342
				"package test;\n"+
1343
				"public class Test {\n" +
1344
				"  void foo() {\n" +
1345
				"    new AllConstructors\n" +
1346
				"  }\n" +
1347
				"}");
1348
		
1349
		this.workingCopies[1] = getWorkingCopy(
1350
				"/P/src/p6930/AllConstructors16c.java",
1351
				"package p6930;"+
1352
				"public class AllConstructors16c {\n" +
1353
				"  public <T> AllConstructors16c(){}\n" +
1354
				"}");
1355
1356
		// do completion
1357
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true);
1358
		requestor.allowAllRequiredProposals();
1359
		NullProgressMonitor monitor = new NullProgressMonitor();
1360
1361
	    String str = this.workingCopies[0].getSource();
1362
	    String completeBehind = "AllConstructors";
1363
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1364
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
1365
	    
1366
	    assertResults(
1367
			"AllConstructors16a[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors16a;, ()V, AllConstructors16a, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1368
			"   AllConstructors16a[TYPE_REF]{p6930.AllConstructors16a, p6930, Lp6930.AllConstructors16a;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1369
			"AllConstructors16b[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors16b;, ()V, AllConstructors16b, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1370
			"   AllConstructors16b[TYPE_REF]{p6930.AllConstructors16b, p6930, Lp6930.AllConstructors16b;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1371
			"AllConstructors16c[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors16c;, ()V, AllConstructors16c, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1372
			"   AllConstructors16c[TYPE_REF]{p6930.AllConstructors16c, p6930, Lp6930.AllConstructors16c;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}",
1373
			requestor.getResults());
1374
	} finally {
1375
		deleteProject("P");
1376
	}
1377
}
1378
public void testBug6930_17() throws Exception {
1379
	try {
1380
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL15_LIB", "/P/lib6930.jar"}, "bin", "1.5");
1381
		
1382
		createFolder("/P/src/p6930");
1383
		
1384
		createFile(
1385
				"/P/src/p6930/AllConstructors17a.java",
1386
				"package p6930;\n" +
1387
				"public class AllConstructors17a{\n" +
1388
				"  public AllConstructors17a(java.util.Collection<Object> o){}\n" +
1389
				"}");
1390
		
1391
		createJar(
1392
				new String[] {
1393
					"p6930/AllConstructors17b.java",
1394
					"package p6930;\n" +
1395
					"public class AllConstructors17b {\n" +
1396
					"  public AllConstructors17b(java.util.Collection<Object> o){}\n" +
1397
					"}"
1398
				},
1399
				p.getProject().getLocation().append("lib6930.jar").toOSString(),
1400
				new String[]{getExternalJCLPathString("1.5")},
1401
				"1.5");
1402
		
1403
		refresh(p);
1404
		
1405
		waitUntilIndexesReady();
1406
		
1407
		this.workingCopies = new ICompilationUnit[2];
1408
		this.workingCopies[0] = getWorkingCopy(
1409
				"/P/src/test/Test.java",
1410
				"package test;\n"+
1411
				"public class Test {\n" +
1412
				"  void foo() {\n" +
1413
				"    new AllConstructors\n" +
1414
				"  }\n" +
1415
				"}");
1416
		
1417
		this.workingCopies[1] = getWorkingCopy(
1418
				"/P/src/p6930/AllConstructors17c.java",
1419
				"package p6930;"+
1420
				"public class AllConstructors17c {\n" +
1421
				"  public AllConstructors17c(java.util.Collection<Object> o){}\n" +
1422
				"}");
1423
1424
		// do completion
1425
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true);
1426
		requestor.allowAllRequiredProposals();
1427
		NullProgressMonitor monitor = new NullProgressMonitor();
1428
1429
	    String str = this.workingCopies[0].getSource();
1430
	    String completeBehind = "AllConstructors";
1431
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1432
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
1433
	    
1434
	    assertResults(
1435
			"AllConstructors17a[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors17a;, (Ljava.util.Collection<Ljava.lang.Object;>;)V, AllConstructors17a, (o), "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1436
			"   AllConstructors17a[TYPE_REF]{p6930.AllConstructors17a, p6930, Lp6930.AllConstructors17a;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1437
			"AllConstructors17b[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors17b;, (Ljava.util.Collection<Ljava.lang.Object;>;)V, AllConstructors17b, (o), "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1438
			"   AllConstructors17b[TYPE_REF]{p6930.AllConstructors17b, p6930, Lp6930.AllConstructors17b;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1439
			"AllConstructors17c[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors17c;, (Ljava.util.Collection<Ljava.lang.Object;>;)V, AllConstructors17c, (o), "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1440
			"   AllConstructors17c[TYPE_REF]{p6930.AllConstructors17c, p6930, Lp6930.AllConstructors17c;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}",
1441
			requestor.getResults());
1442
	} finally {
1443
		deleteProject("P");
1444
	}
1445
}
1446
public void testBug6930_18() throws Exception {
1447
	try {
1448
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL_LIB", "/P/lib6930.jar"}, "bin");
1449
		
1450
		createFolder("/P/src/p6930");
1451
		
1452
		createFile(
1453
				"/P/src/p6930/AllConstructors18a.java",
1454
				"package p6930;\n" +
1455
				"public interface AllConstructors18a {\n" +
1456
				"}");
1457
		
1458
		createJar(new String[] {
1459
			"p6930/AllConstructors18b.java",
1460
			"package p6930;\n" +
1461
			"public interface AllConstructors18b {\n" +
1462
			"}"
1463
		}, p.getProject().getLocation().append("lib6930.jar").toOSString());
1464
		
1465
		refresh(p);
1466
		
1467
		waitUntilIndexesReady();
1468
		
1469
		this.workingCopies = new ICompilationUnit[2];
1470
		this.workingCopies[0] = getWorkingCopy(
1471
				"/P/src/test/Test.java",
1472
				"package test;\n"+
1473
				"public class Test {\n" +
1474
				"  void foo() {\n" +
1475
				"    new AllConstructors\n" +
1476
				"  }\n" +
1477
				"}");
1478
		
1479
		this.workingCopies[1] = getWorkingCopy(
1480
				"/P/src/p6930/AllConstructors18c.java",
1481
				"package p6930;"+
1482
				"public interface AllConstructors18c {\n" +
1483
				"}");
1484
1485
		// do completion
1486
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true);
1487
		requestor.allowAllRequiredProposals();
1488
		NullProgressMonitor monitor = new NullProgressMonitor();
1489
1490
	    String str = this.workingCopies[0].getSource();
1491
	    String completeBehind = "AllConstructors";
1492
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1493
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
1494
	    
1495
	    assertResults(
1496
			"AllConstructors18a[ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors18a;, ()V, AllConstructors18a, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1497
			"   AllConstructors18a[TYPE_REF]{p6930.AllConstructors18a, p6930, Lp6930.AllConstructors18a;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1498
			"AllConstructors18b[ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors18b;, ()V, AllConstructors18b, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1499
			"   AllConstructors18b[TYPE_REF]{p6930.AllConstructors18b, p6930, Lp6930.AllConstructors18b;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1500
			"AllConstructors18c[ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors18c;, ()V, AllConstructors18c, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1501
			"   AllConstructors18c[TYPE_REF]{p6930.AllConstructors18c, p6930, Lp6930.AllConstructors18c;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}",
1502
			requestor.getResults());
1503
	} finally {
1504
		deleteProject("P");
1505
	}
1506
}
1507
public void testBug6930_19() throws Exception {
1508
	try {
1509
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL_LIB", "/P/lib6930.jar"}, "bin");
1510
		
1511
		createFolder("/P/src/p6930");
1512
		
1513
		createFile(
1514
				"/P/src/p6930/AllConstructors19a.java",
1515
				"package p6930;\n" +
1516
				"public interface AllConstructors19a {\n" +
1517
				"}");
1518
		
1519
		createJar(new String[] {
1520
			"p6930/AllConstructors19b.java",
1521
			"package p6930;\n" +
1522
			"public interface AllConstructors19b {\n" +
1523
			"}"
1524
		}, p.getProject().getLocation().append("lib6930.jar").toOSString());
1525
		
1526
		refresh(p);
1527
		
1528
		waitUntilIndexesReady();
1529
		
1530
		this.workingCopies = new ICompilationUnit[2];
1531
		this.workingCopies[0] = getWorkingCopy(
1532
				"/P/src/test/Test.java",
1533
				"package test;\n"+
1534
				"import p6930.AllConstructors19a;\n"+
1535
				"import p6930.AllConstructors19b;\n"+
1536
				"import p6930.AllConstructors19c;\n"+
1537
				"public class Test {\n" +
1538
				"  void foo() {\n" +
1539
				"    new AllConstructors\n" +
1540
				"  }\n" +
1541
				"}");
1542
		
1543
		this.workingCopies[1] = getWorkingCopy(
1544
				"/P/src/p6930/AllConstructors19c.java",
1545
				"package p6930;"+
1546
				"public interface AllConstructors19c {\n" +
1547
				"}");
1548
1549
		// do completion
1550
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true);
1551
		requestor.allowAllRequiredProposals();
1552
		NullProgressMonitor monitor = new NullProgressMonitor();
1553
1554
	    String str = this.workingCopies[0].getSource();
1555
	    String completeBehind = "AllConstructors";
1556
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1557
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
1558
	    
1559
	    assertResults(
1560
			"AllConstructors19a[ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors19a;, ()V, AllConstructors19a, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
1561
			"   AllConstructors19a[TYPE_REF]{AllConstructors19a, p6930, Lp6930.AllConstructors19a;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
1562
			"AllConstructors19b[ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors19b;, ()V, AllConstructors19b, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
1563
			"   AllConstructors19b[TYPE_REF]{AllConstructors19b, p6930, Lp6930.AllConstructors19b;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
1564
			"AllConstructors19c[ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors19c;, ()V, AllConstructors19c, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
1565
			"   AllConstructors19c[TYPE_REF]{AllConstructors19c, p6930, Lp6930.AllConstructors19c;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
1566
			requestor.getResults());
1567
	} finally {
1568
		deleteProject("P");
1569
	}
1570
}
1571
public void testBug6930_20() throws Exception {
1572
	try {
1573
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL15_LIB", "/P/lib6930.jar"}, "bin", "1.5");
1574
		
1575
		createFolder("/P/src/p6930");
1576
		
1577
		createFile(
1578
				"/P/src/p6930/AllConstructors20a.java",
1579
				"package p6930;\n" +
1580
				"public enum AllConstructors20a {\n" +
1581
				"	ZZZ;\n" +
1582
				"}");
1583
		
1584
		createJar(new String[] {
1585
				"p6930/AllConstructors20b.java",
1586
				"package p6930;\n" +
1587
				"public enum AllConstructors20b {\n" +
1588
				"	ZZZ;\n" +
1589
				"}"
1590
			},
1591
			p.getProject().getLocation().append("lib6930.jar").toOSString(),
1592
			new String[]{getExternalJCLPathString("1.5")},
1593
			"1.5");
1594
		
1595
		refresh(p);
1596
		
1597
		waitUntilIndexesReady();
1598
		
1599
		this.workingCopies = new ICompilationUnit[2];
1600
		this.workingCopies[0] = getWorkingCopy(
1601
				"/P/src/test/Test.java",
1602
				"package test;\n"+
1603
				"public class Test {\n" +
1604
				"  void foo() {\n" +
1605
				"    new AllConstructors\n" +
1606
				"  }\n" +
1607
				"}");
1608
		
1609
		this.workingCopies[1] = getWorkingCopy(
1610
				"/P/src/p6930/AllConstructors20c.java",
1611
				"package p6930;"+
1612
				"public enum AllConstructors20c {\n" +
1613
				"	ZZZ;\n" +
1614
				"}");
1615
1616
		// do completion
1617
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true);
1618
		requestor.allowAllRequiredProposals();
1619
		NullProgressMonitor monitor = new NullProgressMonitor();
1620
1621
	    String str = this.workingCopies[0].getSource();
1622
	    String completeBehind = "AllConstructors";
1623
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1624
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
1625
	    
1626
	    assertResults(
1627
			"",
1628
			requestor.getResults());
1629
	} finally {
1630
		deleteProject("P");
1631
	}
1632
}
1633
public void testBug6930_21() throws Exception {
1634
	try {
1635
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL15_LIB", "/P/lib6930.jar"}, "bin", "1.5");
1636
		
1637
		createFolder("/P/src/p6930");
1638
		
1639
		createFile(
1640
				"/P/src/p6930/AllConstructors21a.java",
1641
				"package p6930;\n" +
1642
				"public enum AllConstructors21a {\n" +
1643
				"	ZZZ;\n" +
1644
				"}");
1645
		
1646
		createJar(
1647
				new String[] {
1648
					"p6930/AllConstructors21b.java",
1649
					"package p6930;\n" +
1650
					"public enum AllConstructors21b {\n" +
1651
					"	ZZZ;\n" +
1652
					"}"
1653
				},
1654
				p.getProject().getLocation().append("lib6930.jar").toOSString(),
1655
				new String[]{getExternalJCLPathString("1.5")},
1656
				"1.5");
1657
		
1658
		refresh(p);
1659
		
1660
		waitUntilIndexesReady();
1661
		
1662
		this.workingCopies = new ICompilationUnit[2];
1663
		this.workingCopies[0] = getWorkingCopy(
1664
				"/P/src/test/Test.java",
1665
				"package test;\n"+
1666
				"import p6930.AllConstructors21a;\n"+
1667
				"import p6930.AllConstructors21b;\n"+
1668
				"import p6930.AllConstructors21c;\n"+
1669
				"public class Test {\n" +
1670
				"  void foo() {\n" +
1671
				"    new AllConstructors\n" +
1672
				"  }\n" +
1673
				"}");
1674
		
1675
		this.workingCopies[1] = getWorkingCopy(
1676
				"/P/src/p6930/AllConstructors21c.java",
1677
				"package p6930;"+
1678
				"public enum AllConstructors21c {\n" +
1679
				"	ZZZ;\n" +
1680
				"}");
1681
1682
		// do completion
1683
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true);
1684
		requestor.allowAllRequiredProposals();
1685
		NullProgressMonitor monitor = new NullProgressMonitor();
1686
1687
	    String str = this.workingCopies[0].getSource();
1688
	    String completeBehind = "AllConstructors";
1689
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1690
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
1691
	    
1692
	    assertResults(
1693
			"",
1694
			requestor.getResults());
1695
	} finally {
1696
		deleteProject("P");
1697
	}
1698
}
1699
public void testBug6930_22() throws Exception {
1700
	Hashtable oldOptions = JavaCore.getOptions();
1701
	try {
1702
		Hashtable options = new Hashtable(oldOptions);
1703
		options.put(JavaCore.CODEASSIST_VISIBILITY_CHECK, JavaCore.ENABLED);
1704
		JavaCore.setOptions(options);
1705
		
1706
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL_LIB", "/P/lib6930.jar"}, "bin");
1707
		
1708
		createFolder("/P/src/p6930");
1709
		
1710
		createFile(
1711
				"/P/src/p6930/AllConstructors22a.java",
1712
				"package p6930;\n" +
1713
				"public class AllConstructors22a {\n" +
1714
				"	private AllConstructors22a(){}\n" +
1715
				"	public static class AllConstructorsInner{}\n" +
1716
				"}");
1717
		
1718
		createJar(new String[] {
1719
			"p6930/AllConstructors22b.java",
1720
			"package p6930;\n" +
1721
			"public class AllConstructors22b {\n" +
1722
			"	private AllConstructors22b(){}\n" +
1723
			"	public static class AllConstructorsInner{}\n" +
1724
			"}"
1725
		}, p.getProject().getLocation().append("lib6930.jar").toOSString());
1726
		
1727
		refresh(p);
1728
		
1729
		waitUntilIndexesReady();
1730
		
1731
		this.workingCopies = new ICompilationUnit[2];
1732
		this.workingCopies[0] = getWorkingCopy(
1733
				"/P/src/test/Test.java",
1734
				"package test;\n"+
1735
				"public class Test {\n" +
1736
				"  void foo() {\n" +
1737
				"    new AllConstructors\n" +
1738
				"  }\n" +
1739
				"}");
1740
		
1741
		this.workingCopies[1] = getWorkingCopy(
1742
				"/P/src/p6930/AllConstructors22c.java",
1743
				"package p6930;"+
1744
				"public class AllConstructors22c {\n" +
1745
				"	private AllConstructors22c(){}\n" +
1746
				"	public static class AllConstructorsInner{}\n" +
1747
				"}");
1748
1749
		// do completion
1750
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true);
1751
		requestor.allowAllRequiredProposals();
1752
		NullProgressMonitor monitor = new NullProgressMonitor();
1753
1754
	    String str = this.workingCopies[0].getSource();
1755
	    String completeBehind = "AllConstructors";
1756
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1757
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
1758
	    
1759
	    assertResults(
1760
			"AllConstructors22a[TYPE_REF]{p6930.AllConstructors22a, p6930, Lp6930.AllConstructors22a;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1761
			"AllConstructors22b[TYPE_REF]{p6930.AllConstructors22b, p6930, Lp6930.AllConstructors22b;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1762
			"AllConstructors22c[TYPE_REF]{p6930.AllConstructors22c, p6930, Lp6930.AllConstructors22c;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}",
1763
			requestor.getResults());
1764
	} finally {
1765
		deleteProject("P");
1766
		
1767
		JavaCore.setOptions(oldOptions);
1768
	}
1769
}
1770
public void testBug6930_23() throws Exception {
1771
	Hashtable oldOptions = JavaCore.getOptions();
1772
	try {
1773
		Hashtable options = new Hashtable(oldOptions);
1774
		options.put(JavaCore.CODEASSIST_VISIBILITY_CHECK, JavaCore.ENABLED);
1775
		JavaCore.setOptions(options);
1776
		
1777
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL_LIB", "/P/lib6930.jar"}, "bin");
1778
		
1779
		createFolder("/P/src/p6930");
1780
		
1781
		createFile(
1782
				"/P/src/p6930/AllConstructors23a.java",
1783
				"package p6930;\n" +
1784
				"public class AllConstructors23a {\n" +
1785
				"	private AllConstructors23a(){}\n" +
1786
				"	public static class AllConstructorsInner{}\n" +
1787
				"}");
1788
		
1789
		createJar(new String[] {
1790
			"p6930/AllConstructors23b.java",
1791
			"package p6930;\n" +
1792
			"public class AllConstructors23b {\n" +
1793
			"	private AllConstructors23b(){}\n" +
1794
			"	public static class AllConstructorsInner{}\n" +
1795
			"}"
1796
		}, p.getProject().getLocation().append("lib6930.jar").toOSString());
1797
		
1798
		refresh(p);
1799
		
1800
		waitUntilIndexesReady();
1801
		
1802
		this.workingCopies = new ICompilationUnit[2];
1803
		this.workingCopies[0] = getWorkingCopy(
1804
				"/P/src/test/Test.java",
1805
				"package test;\n"+
1806
				"import p6930.AllConstructors23a;\n"+
1807
				"import p6930.AllConstructors23b;\n"+
1808
				"import p6930.AllConstructors23c;\n"+
1809
				"public class Test {\n" +
1810
				"  void foo() {\n" +
1811
				"    new AllConstructors\n" +
1812
				"  }\n" +
1813
				"}");
1814
		
1815
		this.workingCopies[1] = getWorkingCopy(
1816
				"/P/src/p6930/AllConstructors23c.java",
1817
				"package p6930;"+
1818
				"public class AllConstructors23c {\n" +
1819
				"	private AllConstructors23c(){}\n" +
1820
				"	public static class AllConstructorsInner{}\n" +
1821
				"}");
1822
1823
		// do completion
1824
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true);
1825
		requestor.allowAllRequiredProposals();
1826
		NullProgressMonitor monitor = new NullProgressMonitor();
1827
1828
	    String str = this.workingCopies[0].getSource();
1829
	    String completeBehind = "AllConstructors";
1830
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1831
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
1832
	    
1833
	    assertResults(
1834
			"AllConstructors23a[TYPE_REF]{AllConstructors23a, p6930, Lp6930.AllConstructors23a;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
1835
			"AllConstructors23b[TYPE_REF]{AllConstructors23b, p6930, Lp6930.AllConstructors23b;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
1836
			"AllConstructors23c[TYPE_REF]{AllConstructors23c, p6930, Lp6930.AllConstructors23c;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
1837
			requestor.getResults());
1838
	} finally {
1839
		deleteProject("P");
1840
		
1841
		JavaCore.setOptions(oldOptions);
1842
	}
1843
}
1844
public void testBug6930_24() throws Exception {
1845
	Hashtable oldOptions = JavaCore.getOptions();
1846
	try {
1847
		Hashtable options = new Hashtable(oldOptions);
1848
		options.put(JavaCore.CODEASSIST_VISIBILITY_CHECK, JavaCore.ENABLED);
1849
		JavaCore.setOptions(options);
1850
		
1851
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL_LIB", "/P/lib6930.jar"}, "bin");
1852
		
1853
		createFolder("/P/src/p6930");
1854
		
1855
		createFile(
1856
				"/P/src/p6930/AllConstructors24a.java",
1857
				"package p6930;\n" +
1858
				"public class AllConstructors24a {\n" +
1859
				"	public AllConstructors24a(){}\n" +
1860
				"	private static class AllConstructorsInner{}\n" +
1861
				"}");
1862
		
1863
		createJar(new String[] {
1864
			"p6930/AllConstructors24b.java",
1865
			"package p6930;\n" +
1866
			"public class AllConstructors24b {\n" +
1867
			"	public AllConstructors24b(){}\n" +
1868
			"	private static class AllConstructorsInner{}\n" +
1869
			"}"
1870
		}, p.getProject().getLocation().append("lib6930.jar").toOSString());
1871
		
1872
		refresh(p);
1873
		
1874
		waitUntilIndexesReady();
1875
		
1876
		this.workingCopies = new ICompilationUnit[2];
1877
		this.workingCopies[0] = getWorkingCopy(
1878
				"/P/src/test/Test.java",
1879
				"package test;\n"+
1880
				"public class Test {\n" +
1881
				"  void foo() {\n" +
1882
				"    new AllConstructors\n" +
1883
				"  }\n" +
1884
				"}");
1885
		
1886
		this.workingCopies[1] = getWorkingCopy(
1887
				"/P/src/p6930/AllConstructors24c.java",
1888
				"package p6930;"+
1889
				"public class AllConstructors24c {\n" +
1890
				"	public AllConstructors24c(){}\n" +
1891
				"	private static class AllConstructorsInner{}\n" +
1892
				"}");
1893
1894
		// do completion
1895
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true);
1896
		requestor.allowAllRequiredProposals();
1897
		NullProgressMonitor monitor = new NullProgressMonitor();
1898
1899
	    String str = this.workingCopies[0].getSource();
1900
	    String completeBehind = "AllConstructors";
1901
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1902
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
1903
	    
1904
	    assertResults(
1905
			"AllConstructors24a[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors24a;, ()V, AllConstructors24a, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1906
			"   AllConstructors24a[TYPE_REF]{p6930.AllConstructors24a, p6930, Lp6930.AllConstructors24a;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1907
			"AllConstructors24b[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors24b;, ()V, AllConstructors24b, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1908
			"   AllConstructors24b[TYPE_REF]{p6930.AllConstructors24b, p6930, Lp6930.AllConstructors24b;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1909
			"AllConstructors24c[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors24c;, ()V, AllConstructors24c, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1910
			"   AllConstructors24c[TYPE_REF]{p6930.AllConstructors24c, p6930, Lp6930.AllConstructors24c;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}",
1911
			requestor.getResults());
1912
	} finally {
1913
		deleteProject("P");
1914
		
1915
		JavaCore.setOptions(oldOptions);
1916
	}
1917
}
1918
public void testBug6930_25() throws Exception {
1919
	Hashtable oldOptions = JavaCore.getOptions();
1920
	try {
1921
		Hashtable options = new Hashtable(oldOptions);
1922
		options.put(JavaCore.CODEASSIST_VISIBILITY_CHECK, JavaCore.ENABLED);
1923
		JavaCore.setOptions(options);
1924
		
1925
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL_LIB", "/P/lib6930.jar"}, "bin");
1926
		
1927
		createFolder("/P/src/p6930");
1928
		
1929
		createFile(
1930
				"/P/src/p6930/AllConstructors25a.java",
1931
				"package p6930;\n" +
1932
				"public class AllConstructors25a {\n" +
1933
				"	public AllConstructors25a(){}\n" +
1934
				"	private static class AllConstructorsInner{}\n" +
1935
				"}");
1936
		
1937
		createJar(new String[] {
1938
			"p6930/AllConstructors25b.java",
1939
			"package p6930;\n" +
1940
			"public class AllConstructors25b {\n" +
1941
			"	public AllConstructors25b(){}\n" +
1942
			"	private static class AllConstructorsInner{}\n" +
1943
			"}"
1944
		}, p.getProject().getLocation().append("lib6930.jar").toOSString());
1945
		
1946
		refresh(p);
1947
		
1948
		waitUntilIndexesReady();
1949
		
1950
		this.workingCopies = new ICompilationUnit[2];
1951
		this.workingCopies[0] = getWorkingCopy(
1952
				"/P/src/test/Test.java",
1953
				"package test;\n"+
1954
				"import p6930.AllConstructors25a;\n"+
1955
				"import p6930.AllConstructors25b;\n"+
1956
				"import p6930.AllConstructors25c;\n"+
1957
				"public class Test {\n" +
1958
				"  void foo() {\n" +
1959
				"    new AllConstructors\n" +
1960
				"  }\n" +
1961
				"}");
1962
		
1963
		this.workingCopies[1] = getWorkingCopy(
1964
				"/P/src/p6930/AllConstructors25c.java",
1965
				"package p6930;"+
1966
				"public class AllConstructors25c {\n" +
1967
				"	public AllConstructors25c(){}\n" +
1968
				"	private static class AllConstructorsInner{}\n" +
1969
				"}");
1970
1971
		// do completion
1972
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true);
1973
		requestor.allowAllRequiredProposals();
1974
		NullProgressMonitor monitor = new NullProgressMonitor();
1975
1976
	    String str = this.workingCopies[0].getSource();
1977
	    String completeBehind = "AllConstructors";
1978
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1979
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
1980
	    
1981
	    assertResults(
1982
			"AllConstructors25a[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors25a;, ()V, AllConstructors25a, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
1983
			"   AllConstructors25a[TYPE_REF]{AllConstructors25a, p6930, Lp6930.AllConstructors25a;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
1984
			"AllConstructors25b[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors25b;, ()V, AllConstructors25b, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
1985
			"   AllConstructors25b[TYPE_REF]{AllConstructors25b, p6930, Lp6930.AllConstructors25b;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
1986
			"AllConstructors25c[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors25c;, ()V, AllConstructors25c, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
1987
			"   AllConstructors25c[TYPE_REF]{AllConstructors25c, p6930, Lp6930.AllConstructors25c;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
1988
			requestor.getResults());
1989
	} finally {
1990
		deleteProject("P");
1991
		
1992
		JavaCore.setOptions(oldOptions);
1993
	}
1994
}
1995
public void testBug6930_26() throws Exception {
1996
	try {
1997
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL_LIB"}, "bin");
1998
		
1999
		refresh(p);
2000
		
2001
		waitUntilIndexesReady();
2002
		
2003
		this.workingCopies = new ICompilationUnit[2];
2004
		this.workingCopies[0] = getWorkingCopy(
2005
				"/P/src/test/Test.java",
2006
				"package test;\n"+
2007
				"public class Test {\n" +
2008
				"  void foo(p6930.AllConstructors26a var) {\n" +
2009
				"    var.new AllConstructors\n" +
2010
				"  }\n" +
2011
				"}");
2012
		
2013
		this.workingCopies[1] = getWorkingCopy(
2014
				"/P/src/p6930/AllConstructors26a.java",
2015
				"package p6930;"+
2016
				"public class AllConstructors26a {\n" +
2017
				"	public class AllConstructors26b {\n" +
2018
				"	  public AllConstructors26b(int i) {}\n" +
2019
				"	}\n" +
2020
				"}");
2021
2022
		// do completion
2023
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true);
2024
		requestor.allowAllRequiredProposals();
2025
		NullProgressMonitor monitor = new NullProgressMonitor();
2026
2027
	    String str = this.workingCopies[0].getSource();
2028
	    String completeBehind = "AllConstructors";
2029
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2030
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
2031
	    
2032
	    assertResults(
2033
			"AllConstructors26b[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors26a$AllConstructors26b;, (I)V, AllConstructors26b, (i), "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
2034
			"   AllConstructors26a.AllConstructors26b[TYPE_REF]{AllConstructors26b, p6930, Lp6930.AllConstructors26a$AllConstructors26b;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
2035
			requestor.getResults());
2036
	} finally {
2037
		deleteProject("P");
2038
	}
2039
}
2040
public void testBug6930_27() throws Exception {
2041
	try {
2042
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL_LIB"}, "bin");
2043
		
2044
		refresh(p);
2045
		
2046
		waitUntilIndexesReady();
2047
		
2048
		this.workingCopies = new ICompilationUnit[2];
2049
		this.workingCopies[0] = getWorkingCopy(
2050
				"/P/src/test/Test.java",
2051
				"package test;\n"+
2052
				"public class Test {\n" +
2053
				"  void foo() {\n" +
2054
				"    new p6930.AllConstructors27a.AllConstructors\n" +
2055
				"  }\n" +
2056
				"}");
2057
		
2058
		this.workingCopies[1] = getWorkingCopy(
2059
				"/P/src/p6930/AllConstructors27a.java",
2060
				"package p6930;"+
2061
				"public class AllConstructors27a {\n" +
2062
				"	public static class AllConstructors27b {\n" +
2063
				"	  public AllConstructors27b(int i) {}\n" +
2064
				"	}\n" +
2065
				"}");
2066
2067
		// do completion
2068
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true);
2069
		requestor.allowAllRequiredProposals();
2070
		NullProgressMonitor monitor = new NullProgressMonitor();
2071
2072
	    String str = this.workingCopies[0].getSource();
2073
	    String completeBehind = "AllConstructors";
2074
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2075
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
2076
	    
2077
	    assertResults(
2078
			"AllConstructors27b[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors27a$AllConstructors27b;, (I)V, AllConstructors27b, (i), "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
2079
			"   AllConstructors27a.AllConstructors27b[TYPE_REF]{AllConstructors27b, p6930, Lp6930.AllConstructors27a$AllConstructors27b;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}",
2080
			requestor.getResults());
2081
	} finally {
2082
		deleteProject("P");
2083
	}
2084
}
2085
public void testBug6930_28() throws Exception {
2086
	try {
2087
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL_LIB"}, "bin");
2088
		
2089
		refresh(p);
2090
		
2091
		waitUntilIndexesReady();
2092
		
2093
		this.workingCopies = new ICompilationUnit[3];
2094
		this.workingCopies[0] = getWorkingCopy(
2095
				"/P/src/p6930/Test.java",
2096
				"package p6930;\n"+
2097
				"class AllConstructors28a {\n" +
2098
				"	public AllConstructors28a(int i) {}\n" +
2099
				"}\n" +
2100
				"public class Test {\n" +
2101
				"  void foo() {\n" +
2102
				"    new p6930.AllConstructors\n" +
2103
				"  }\n" +
2104
				"}");
2105
		
2106
		this.workingCopies[1] = getWorkingCopy(
2107
				"/P/src/p6930/AllConstructors28b.java",
2108
				"package p6930;"+
2109
				"public class AllConstructors28b {\n" +
2110
				"	public AllConstructors28b(int i) {}\n" +
2111
				"}");
2112
		
2113
		this.workingCopies[2] = getWorkingCopy(
2114
				"/P/src/p6930b/AllConstructors28c.java",
2115
				"package p6930b;"+
2116
				"public class AllConstructors28c {\n" +
2117
				"	public AllConstructors28c(int i) {}\n" +
2118
				"}");
2119
2120
		// do completion
2121
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true);
2122
		requestor.allowAllRequiredProposals();
2123
		NullProgressMonitor monitor = new NullProgressMonitor();
2124
2125
	    String str = this.workingCopies[0].getSource();
2126
	    String completeBehind = "AllConstructors";
2127
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2128
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
2129
	    
2130
	    assertResults(
2131
			"AllConstructors28a[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors28a;, (I)V, AllConstructors28a, (i), "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
2132
			"   AllConstructors28a[TYPE_REF]{AllConstructors28a, p6930, Lp6930.AllConstructors28a;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
2133
			"AllConstructors28b[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors28b;, (I)V, AllConstructors28b, (i), "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
2134
			"   AllConstructors28b[TYPE_REF]{AllConstructors28b, p6930, Lp6930.AllConstructors28b;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}",
2135
			requestor.getResults());
2136
	} finally {
2137
		deleteProject("P");
2138
	}
2139
}
2140
public void testBug6930_29() throws Exception {
2141
	try {
2142
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL_LIB", "/P/lib6930.jar"}, "bin");
2143
		
2144
		createJar(new String[] {
2145
			"p6930/AllConstructors02.java",
2146
			"package p6930;\n" +
2147
			"public class AllConstructors02 {\n" +
2148
			"  public AllConstructors02() {}\n" +
2149
			"  public AllConstructors02(Object o) {}\n" +
2150
			"  public AllConstructors02(Object o, String s) {}\n" +
2151
			"}"
2152
		}, p.getProject().getLocation().append("lib6930.jar").toOSString());
2153
		
2154
		refresh(p);
2155
		
2156
		waitUntilIndexesReady();
2157
		
2158
		this.workingCopies = new ICompilationUnit[1];
2159
		this.workingCopies[0] = getWorkingCopy(
2160
				"/P/src/test/Test.java",
2161
				"package test;"+
2162
				"public class Test {\n" +
2163
				"  void foo() {\n" +
2164
				"    p6930.AllConstructors02 var = new AllConstructors\n" +
2165
				"  }\n" +
2166
				"}");
2167
2168
		// do completion
2169
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true);
2170
		requestor.allowAllRequiredProposals();
2171
		NullProgressMonitor monitor = new NullProgressMonitor();
2172
2173
	    String str = this.workingCopies[0].getSource();
2174
	    String completeBehind = "AllConstructors";
2175
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2176
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
2177
	    
2178
	    assertResults(
2179
			"AllConstructors02[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors02;, ()V, AllConstructors02, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED)+"}\n" +
2180
			"   AllConstructors02[TYPE_REF]{p6930.AllConstructors02, p6930, Lp6930.AllConstructors02;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED)+"}\n" +
2181
			"AllConstructors02[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors02;, (Ljava.lang.Object;)V, AllConstructors02, (o), "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED)+"}\n" +
2182
			"   AllConstructors02[TYPE_REF]{p6930.AllConstructors02, p6930, Lp6930.AllConstructors02;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED)+"}\n" +
2183
			"AllConstructors02[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors02;, (Ljava.lang.Object;Ljava.lang.String;)V, AllConstructors02, (o, s), "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED)+"}\n" +
2184
			"   AllConstructors02[TYPE_REF]{p6930.AllConstructors02, p6930, Lp6930.AllConstructors02;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED)+"}",
2185
			requestor.getResults());
2186
	} finally {
2187
		deleteProject("P");
2188
	}
2189
}
420
public void testBug79288() throws Exception {
2190
public void testBug79288() throws Exception {
421
	try {
2191
	try {
422
		// create variable
2192
		// create variable
(-)src/org/eclipse/jdt/core/tests/model/CompletionTestsRequestor2.java (-4 / +11 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2008 IBM Corporation and others.
2
 * Copyright (c) 2004, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
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 572-577 Link Here
572
			case CompletionProposal.JAVADOC_VALUE_REF :
577
			case CompletionProposal.JAVADOC_VALUE_REF :
573
			case CompletionProposal.FIELD_IMPORT :
578
			case CompletionProposal.FIELD_IMPORT :
574
			case CompletionProposal.METHOD_IMPORT :
579
			case CompletionProposal.METHOD_IMPORT :
580
			case CompletionProposal.CONSTRUCTOR_INVOCATION :
581
			case CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION :
575
				return new String(proposal.getName());
582
				return new String(proposal.getName());
576
			case CompletionProposal.PACKAGE_REF:
583
			case CompletionProposal.PACKAGE_REF:
577
				return new String(proposal.getDeclarationSignature());
584
				return new String(proposal.getDeclarationSignature());
(-)src/org/eclipse/jdt/core/tests/model/AbstractJavaSearchTests.java (-1 / +101 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
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 (-1 / +5 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 1128-1133 Link Here
1128
	protected void createJar(String[] javaPathsAndContents, String jarPath) throws IOException {
1128
	protected void createJar(String[] javaPathsAndContents, String jarPath) throws IOException {
1129
		org.eclipse.jdt.core.tests.util.Util.createJar(javaPathsAndContents, jarPath, "1.4");
1129
		org.eclipse.jdt.core.tests.util.Util.createJar(javaPathsAndContents, jarPath, "1.4");
1130
	}
1130
	}
1131
	
1132
	protected void createJar(String[] javaPathsAndContents, String jarPath, String[] classpath, String compliance) throws IOException {
1133
		org.eclipse.jdt.core.tests.util.Util.createJar(javaPathsAndContents, null,jarPath, classpath, compliance);
1134
	}
1131
1135
1132
	/*
1136
	/*
1133
	}
1137
	}

Return to bug 6930