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

Collapse All | Expand All

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