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
}
(-)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
	 */
(-)model/org/eclipse/jdt/internal/compiler/SourceElementNotifier.java (-8 / +16 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
2
 * Copyright (c) 2008, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 54-59 Link Here
54
	 * An ast visitor that visits local type declarations.
54
	 * An ast visitor that visits local type declarations.
55
	 */
55
	 */
56
	public class LocalDeclarationVisitor extends ASTVisitor {
56
	public class LocalDeclarationVisitor extends ASTVisitor {
57
		public ImportReference currentPackage;
57
		ArrayList declaringTypes;
58
		ArrayList declaringTypes;
58
		public void pushDeclaringType(TypeDeclaration declaringType) {
59
		public void pushDeclaringType(TypeDeclaration declaringType) {
59
			if (this.declaringTypes == null) {
60
			if (this.declaringTypes == null) {
Lines 71-81 Link Here
71
			return (TypeDeclaration) this.declaringTypes.get(size-1);
72
			return (TypeDeclaration) this.declaringTypes.get(size-1);
72
		}
73
		}
73
		public boolean visit(TypeDeclaration typeDeclaration, BlockScope scope) {
74
		public boolean visit(TypeDeclaration typeDeclaration, BlockScope scope) {
74
			notifySourceElementRequestor(typeDeclaration, true, peekDeclaringType());
75
			notifySourceElementRequestor(typeDeclaration, true, peekDeclaringType(), this.currentPackage);
75
			return false; // don't visit members as this was done during notifySourceElementRequestor(...)
76
			return false; // don't visit members as this was done during notifySourceElementRequestor(...)
76
		}
77
		}
77
		public boolean visit(TypeDeclaration typeDeclaration, ClassScope scope) {
78
		public boolean visit(TypeDeclaration typeDeclaration, ClassScope scope) {
78
			notifySourceElementRequestor(typeDeclaration, true, peekDeclaringType());
79
			notifySourceElementRequestor(typeDeclaration, true, peekDeclaringType(), this.currentPackage);
79
			return false; // don't visit members as this was done during notifySourceElementRequestor(...)
80
			return false; // don't visit members as this was done during notifySourceElementRequestor(...)
80
		}
81
		}
81
	}
82
	}
Lines 215-221 Link Here
215
/*
216
/*
216
 * Update the bodyStart of the corresponding parse node
217
 * Update the bodyStart of the corresponding parse node
217
 */
218
 */
218
protected void notifySourceElementRequestor(AbstractMethodDeclaration methodDeclaration) {
219
protected void notifySourceElementRequestor(AbstractMethodDeclaration methodDeclaration, TypeDeclaration declaringType, ImportReference currentPackage) {
219
220
220
	// range check
221
	// range check
221
	boolean isInRange =
222
	boolean isInRange =
Lines 288-293 Link Here
288
			methodInfo.typeParameters = getTypeParameterInfos(methodDeclaration.typeParameters());
289
			methodInfo.typeParameters = getTypeParameterInfos(methodDeclaration.typeParameters());
289
			methodInfo.categories = (char[][]) this.nodesToCategories.get(methodDeclaration);
290
			methodInfo.categories = (char[][]) this.nodesToCategories.get(methodDeclaration);
290
			methodInfo.annotations = methodDeclaration.annotations;
291
			methodInfo.annotations = methodDeclaration.annotations;
292
			methodInfo.declaringPackageName = currentPackage == null ? CharOperation.NO_CHAR : CharOperation.concatWith(currentPackage.tokens, '.');
293
			methodInfo.declaringTypeModifiers = declaringType.modifiers;
294
			methodInfo.extraFlags = ExtraFlags.getExtraFlags(declaringType);
291
			methodInfo.node = methodDeclaration;
295
			methodInfo.node = methodDeclaration;
292
			this.requestor.enterConstructor(methodInfo);
296
			this.requestor.enterConstructor(methodInfo);
293
		}
297
		}
Lines 394-399 Link Here
394
			this.requestor.enterCompilationUnit();
398
			this.requestor.enterCompilationUnit();
395
		}
399
		}
396
		ImportReference currentPackage = parsedUnit.currentPackage;
400
		ImportReference currentPackage = parsedUnit.currentPackage;
401
		if (this.localDeclarationVisitor !=  null) {
402
			this.localDeclarationVisitor.currentPackage = currentPackage;
403
		}
397
		ImportReference[] imports = parsedUnit.imports;
404
		ImportReference[] imports = parsedUnit.imports;
398
		TypeDeclaration[] types = parsedUnit.types;
405
		TypeDeclaration[] types = parsedUnit.types;
399
		length =
406
		length =
Lines 429-435 Link Here
429
						notifySourceElementRequestor(importRef, false);
436
						notifySourceElementRequestor(importRef, false);
430
					}
437
					}
431
				} else { // instanceof TypeDeclaration
438
				} else { // instanceof TypeDeclaration
432
					notifySourceElementRequestor((TypeDeclaration)node, true, null);
439
					notifySourceElementRequestor((TypeDeclaration)node, true, null, currentPackage);
433
				}
440
				}
434
			}
441
			}
435
		}
442
		}
Lines 544-550 Link Here
544
			importReference.modifiers);
551
			importReference.modifiers);
545
	}
552
	}
546
}
553
}
547
protected void notifySourceElementRequestor(TypeDeclaration typeDeclaration, boolean notifyTypePresence, TypeDeclaration declaringType) {
554
protected void notifySourceElementRequestor(TypeDeclaration typeDeclaration, boolean notifyTypePresence, TypeDeclaration declaringType, ImportReference currentPackage) {
548
555
549
	if (CharOperation.equals(TypeConstants.PACKAGE_INFO_NAME, typeDeclaration.name)) return;
556
	if (CharOperation.equals(TypeConstants.PACKAGE_INFO_NAME, typeDeclaration.name)) return;
550
557
Lines 600-605 Link Here
600
			typeInfo.secondary = typeDeclaration.isSecondary();
607
			typeInfo.secondary = typeDeclaration.isSecondary();
601
			typeInfo.anonymousMember = typeDeclaration.allocation != null && typeDeclaration.allocation.enclosingInstance != null;
608
			typeInfo.anonymousMember = typeDeclaration.allocation != null && typeDeclaration.allocation.enclosingInstance != null;
602
			typeInfo.annotations = typeDeclaration.annotations;
609
			typeInfo.annotations = typeDeclaration.annotations;
610
			typeInfo.extraFlags = ExtraFlags.getExtraFlags(typeDeclaration);
603
			typeInfo.node = typeDeclaration;
611
			typeInfo.node = typeDeclaration;
604
			this.requestor.enterType(typeInfo);
612
			this.requestor.enterType(typeInfo);
605
			switch (kind) {
613
			switch (kind) {
Lines 663-673 Link Here
663
				break;
671
				break;
664
			case 1 :
672
			case 1 :
665
				methodIndex++;
673
				methodIndex++;
666
				notifySourceElementRequestor(nextMethodDeclaration);
674
				notifySourceElementRequestor(nextMethodDeclaration, typeDeclaration, currentPackage);
667
				break;
675
				break;
668
			case 2 :
676
			case 2 :
669
				memberTypeIndex++;
677
				memberTypeIndex++;
670
				notifySourceElementRequestor(nextMemberDeclaration, true, null);
678
				notifySourceElementRequestor(nextMemberDeclaration, true, null, currentPackage);
671
		}
679
		}
672
	}
680
	}
673
	if (notifyTypePresence){
681
	if (notifyTypePresence){
(-)model/org/eclipse/jdt/internal/compiler/ISourceElementRequestor.java (-1 / +5 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 59-64 Link Here
59
		public boolean secondary;
59
		public boolean secondary;
60
		public boolean anonymousMember;
60
		public boolean anonymousMember;
61
		public Annotation[] annotations;
61
		public Annotation[] annotations;
62
		public int extraFlags;
62
		public TypeDeclaration node;
63
		public TypeDeclaration node;
63
		public HashMap childrenCategories = new HashMap();
64
		public HashMap childrenCategories = new HashMap();
64
	}
65
	}
Lines 87-92 Link Here
87
		public TypeParameterInfo[] typeParameters;
88
		public TypeParameterInfo[] typeParameters;
88
		public char[][] categories;
89
		public char[][] categories;
89
		public Annotation[] annotations;
90
		public Annotation[] annotations;
91
		public char[] declaringPackageName;
92
		public int declaringTypeModifiers;
93
		public int extraFlags;
90
		public AbstractMethodDeclaration node;
94
		public AbstractMethodDeclaration node;
91
	}
95
	}
92
96
(-)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 (-268 / +1719 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
	}
410
	
411
	private static boolean hasMemberTypesInEnclosingScope(SourceTypeBinding typeBinding, Scope scope) {
412
		ReferenceBinding[] memberTypes = typeBinding.memberTypes();
413
		int length = memberTypes == null ? 0 : memberTypes.length;
414
		
415
		if (length > 0) {
416
			MethodScope methodScope = scope.methodScope();
417
			if (methodScope != null && !methodScope.isStatic) {
418
				ClassScope classScope = typeBinding.scope;
419
				Scope currentScope = scope;
420
				while (currentScope != null) {
421
					if (currentScope == classScope) {
422
						return true;
423
					}
424
					currentScope = currentScope.parent;
425
				}
426
			}
427
		}
428
		return false;
429
	}
430
	
305
	public HashtableOfObject typeCache;
431
	public HashtableOfObject typeCache;
432
	public int openedBinaryTypes; // used during InternalCompletionProposal#findConstructorParameterNames()
306
	
433
	
307
	public static boolean DEBUG = false;
434
	public static boolean DEBUG = false;
308
	public static boolean PERF = false;
435
	public static boolean PERF = false;
309
	
436
	
310
	private final static int CHECK_CANCEL_FREQUENCY_IN_FIND_TYPES = 50;
437
	private static final char[] KNOWN_TYPE_WITH_UNKNOWN_CONSTRUCTORS = new char[]{};
438
	private static final char[] KNOWN_TYPE_WITH_KNOWN_CONSTRUCTORS = new char[]{};
439
	
440
	private static final char[] ARG = "arg".toCharArray();  //$NON-NLS-1$
441
	private static final char[] ARG0 = "arg0".toCharArray();  //$NON-NLS-1$
442
	private static final char[] ARG1 = "arg1".toCharArray();  //$NON-NLS-1$
443
	private static final char[] ARG2 = "arg2".toCharArray();  //$NON-NLS-1$
444
	private static final char[] ARG3 = "arg3".toCharArray();  //$NON-NLS-1$
445
	private static final char[][] ARGS1 = new char[][]{ARG0};
446
	private static final char[][] ARGS2 = new char[][]{ARG0, ARG1};
447
	private static final char[][] ARGS3 = new char[][]{ARG0, ARG1, ARG2};
448
	private static final char[][] ARGS4 = new char[][]{ARG0, ARG1, ARG2, ARG3};
449
	
450
	private final static int CHECK_CANCEL_FREQUENCY = 50;
311
	
451
	
312
	// temporary constants to quickly disabled polish features if necessary
452
	// temporary constants to quickly disabled polish features if necessary
313
	public final static boolean NO_TYPE_COMPLETION_ON_EMPTY_TOKEN = false;
453
	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$
463
	private final static char[] VALUE = "value".toCharArray();  //$NON-NLS-1$
324
	private final static char[] EXTENDS = "extends".toCharArray();  //$NON-NLS-1$
464
	private final static char[] EXTENDS = "extends".toCharArray();  //$NON-NLS-1$
325
	private final static char[] SUPER = "super".toCharArray();  //$NON-NLS-1$
465
	private final static char[] SUPER = "super".toCharArray();  //$NON-NLS-1$
466
	private final static char[] DEFAULT_CONSTRUCTOR_SIGNATURE = "()V".toCharArray();  //$NON-NLS-1$
326
	
467
	
327
	private final static char[] DOT = ".".toCharArray();  //$NON-NLS-1$
468
	private final static char[] DOT = ".".toCharArray();  //$NON-NLS-1$
328
469
Lines 374-379 Link Here
374
	CompletionRequestor requestor;
515
	CompletionRequestor requestor;
375
	CompletionProblemFactory problemFactory;
516
	CompletionProblemFactory problemFactory;
376
	ProblemReporter problemReporter;
517
	ProblemReporter problemReporter;
518
	private JavaSearchNameEnvironment noCacheNameEnvironment;
377
	char[] source;
519
	char[] source;
378
	char[] completionToken;
520
	char[] completionToken;
379
	char[] qualifiedCompletionToken;
521
	char[] qualifiedCompletionToken;
Lines 459-464 Link Here
459
601
460
	private int foundTypesCount;
602
	private int foundTypesCount;
461
	private ObjectVector acceptedTypes;
603
	private ObjectVector acceptedTypes;
604
	
605
	private int foundConstructorsCount;
606
	private ObjectVector acceptedConstructors;
462
607
463
	/**
608
	/**
464
	 * The CompletionEngine is responsible for computing source completions.
609
	 * The CompletionEngine is responsible for computing source completions.
Lines 489-494 Link Here
489
		this.requestor = requestor;
634
		this.requestor = requestor;
490
		this.nameEnvironment = nameEnvironment;
635
		this.nameEnvironment = nameEnvironment;
491
		this.typeCache = new HashtableOfObject(5);
636
		this.typeCache = new HashtableOfObject(5);
637
		this.openedBinaryTypes = 0;
492
638
493
		this.problemFactory = new CompletionProblemFactory(Locale.getDefault());
639
		this.problemFactory = new CompletionProblemFactory(Locale.getDefault());
494
		this.problemReporter = new ProblemReporter(
640
		this.problemReporter = new ProblemReporter(
Lines 511-516 Link Here
511
		this.owner = owner;
657
		this.owner = owner;
512
		this.monitor = monitor;
658
		this.monitor = monitor;
513
	}
659
	}
660
	
661
	public void acceptConstructor(
662
			int modifiers,
663
			char[] simpleTypeName,
664
			int parameterCount,
665
			char[] signature,
666
			char[][] parameterTypes,
667
			char[][] parameterNames,
668
			int typeModifiers,
669
			char[] packageName,
670
			int extraFlags,
671
			String path,
672
			AccessRestriction accessRestriction) {
673
		
674
		// does not check cancellation for every types to avoid performance loss
675
		if ((this.foundConstructorsCount % (CHECK_CANCEL_FREQUENCY)) == 0) checkCancel();
676
		this.foundConstructorsCount++;
677
		
678
		if ((typeModifiers & ClassFileConstants.AccEnum) != 0) return;
679
		
680
		if (this.options.checkDeprecation && (typeModifiers & ClassFileConstants.AccDeprecated) != 0) return;
681
682
		if (this.options.checkVisibility) {
683
			if((typeModifiers & ClassFileConstants.AccPublic) == 0) {
684
				if((typeModifiers & ClassFileConstants.AccPrivate) != 0) return;
685
686
				if (this.currentPackageName == null) {
687
					initializePackageCache();
688
				}
689
				
690
				if(!CharOperation.equals(packageName, this.currentPackageName)) return;
691
			}
692
		}
693
694
		int accessibility = IAccessRule.K_ACCESSIBLE;
695
		if(accessRestriction != null) {
696
			switch (accessRestriction.getProblemId()) {
697
				case IProblem.ForbiddenReference:
698
					if (this.options.checkForbiddenReference) {
699
						return;
700
					}
701
					accessibility = IAccessRule.K_NON_ACCESSIBLE;
702
					break;
703
				case IProblem.DiscouragedReference:
704
					if (this.options.checkDiscouragedReference) {
705
						return;
706
					}
707
					accessibility = IAccessRule.K_DISCOURAGED;
708
					break;
709
			}
710
		}
711
		
712
		if(this.acceptedConstructors == null) {
713
			this.acceptedConstructors = new ObjectVector();
714
		}
715
		this.acceptedConstructors.add(
716
				new AcceptedConstructor(
717
						modifiers,
718
						simpleTypeName,
719
						parameterCount,
720
						signature,
721
						parameterTypes,
722
						parameterNames,
723
						typeModifiers,
724
						packageName,
725
						extraFlags,
726
						accessibility));
727
	}
728
	
729
	private void acceptConstructors(Scope scope) {
730
		final boolean DEFER_QUALIFIED_PROPOSALS = false;
731
		
732
		this.checkCancel();
733
		
734
		if(this.acceptedConstructors == null) return;
735
736
		int length = this.acceptedConstructors.size();
737
738
		if(length == 0) return;
739
		
740
		HashtableOfObject onDemandFound = new HashtableOfObject();
741
		
742
		ArrayList deferredProposals = new ArrayList();
743
		
744
		try {
745
			next : for (int i = 0; i < length; i++) {
746
				
747
				// does not check cancellation for every types to avoid performance loss
748
				if ((i % CHECK_CANCEL_FREQUENCY) == 0) checkCancel();
749
				
750
				AcceptedConstructor acceptedConstructor = (AcceptedConstructor)this.acceptedConstructors.elementAt(i);
751
				final int typeModifiers = acceptedConstructor.typeModifiers;
752
				final char[] packageName = acceptedConstructor.packageName;
753
				final char[] simpleTypeName = acceptedConstructor.simpleTypeName;
754
				final int modifiers = acceptedConstructor.modifiers;
755
				final int parameterCount = acceptedConstructor.parameterCount;
756
				final char[] signature = acceptedConstructor.signature;
757
				final char[][] parameterTypes = acceptedConstructor.parameterTypes;
758
				final char[][] parameterNames = acceptedConstructor.parameterNames;
759
				final int extraFlags = acceptedConstructor.extraFlags;
760
				final int accessibility = acceptedConstructor.accessibility;
761
				
762
				boolean proposeType = (extraFlags & ExtraFlags.HasNonPrivateStaticMemberTypes) != 0;
763
				
764
				char[] fullyQualifiedName = CharOperation.concat(packageName, simpleTypeName, '.');
765
						
766
				Object knownTypeKind = this.knownTypes.get(fullyQualifiedName);
767
				if (knownTypeKind != null) {
768
					if (knownTypeKind == KNOWN_TYPE_WITH_KNOWN_CONSTRUCTORS) {
769
						// the type and its constructors are already accepted
770
						continue next;
771
					}
772
					// this type is already accepted
773
					proposeType = false;
774
				} else {
775
					this.knownTypes.put(fullyQualifiedName, KNOWN_TYPE_WITH_UNKNOWN_CONSTRUCTORS);
776
				}
777
				
778
				boolean proposeConstructor = true;
779
					
780
				if (this.options.checkVisibility) {
781
					if((modifiers & ClassFileConstants.AccPublic) == 0) {
782
						if((modifiers & ClassFileConstants.AccPrivate) != 0) {
783
							if (!proposeType) continue next;
784
							proposeConstructor = false;
785
						} else {
786
							if (this.currentPackageName == null) {
787
								initializePackageCache();
788
							}
789
							
790
							if(!CharOperation.equals(packageName, this.currentPackageName)) {
791
								if (!proposeType) continue next;
792
								proposeConstructor = false;
793
							}
794
						}
795
					}
796
				}
797
				
798
				acceptedConstructor.fullyQualifiedName = fullyQualifiedName;
799
				acceptedConstructor.proposeType = proposeType;
800
				acceptedConstructor.proposeConstructor = proposeConstructor;
801
				
802
				
803
				if(!this.importCachesInitialized) {
804
					initializeImportCaches();
805
				}
806
				
807
				for (int j = 0; j < this.importCacheCount; j++) {
808
					char[][] importName = this.importsCache[j];
809
					if(CharOperation.equals(simpleTypeName, importName[0])) {
810
						if (proposeType) {
811
							proposeType(
812
									packageName,
813
									simpleTypeName,
814
									typeModifiers,
815
									accessibility,
816
									simpleTypeName,
817
									fullyQualifiedName,
818
									!CharOperation.equals(fullyQualifiedName, importName[1]),
819
									scope);
820
						}
821
						
822
						if (proposeConstructor && !Flags.isEnum(typeModifiers)) {
823
							boolean isQualified = !CharOperation.equals(fullyQualifiedName, importName[1]);
824
							if (!isQualified) {
825
								proposeConstructor(
826
										simpleTypeName,
827
										parameterCount,
828
										signature,
829
										parameterTypes,
830
										parameterNames,
831
										modifiers,
832
										packageName,
833
										typeModifiers,
834
										accessibility,
835
										simpleTypeName,
836
										fullyQualifiedName,
837
										isQualified,
838
										scope,
839
										extraFlags);
840
							} else {
841
								acceptedConstructor.mustBeQualified = true;
842
								if (DEFER_QUALIFIED_PROPOSALS) {
843
									deferredProposals.add(acceptedConstructor);
844
								} else {
845
									proposeConstructor(acceptedConstructor, scope);
846
								}
847
							}
848
						}
849
						continue next;
850
					}
851
				}
852
853
854
				if (CharOperation.equals(this.currentPackageName, packageName)) {
855
					if (proposeType) {
856
						proposeType(
857
								packageName,
858
								simpleTypeName,
859
								typeModifiers,
860
								accessibility,
861
								simpleTypeName,
862
								fullyQualifiedName,
863
								false,
864
								scope);
865
					}
866
					
867
					if (proposeConstructor && !Flags.isEnum(typeModifiers)) {
868
						proposeConstructor(
869
								simpleTypeName,
870
								parameterCount,
871
								signature,
872
								parameterTypes,
873
								parameterNames,
874
								modifiers,
875
								packageName,
876
								typeModifiers,
877
								accessibility,
878
								simpleTypeName,
879
								fullyQualifiedName,
880
								false,
881
								scope,
882
								extraFlags);
883
					}
884
					continue next;
885
				} else {
886
					char[] fullyQualifiedEnclosingTypeOrPackageName = null;
887
888
					AcceptedConstructor foundConstructor = null;
889
					if((foundConstructor = (AcceptedConstructor)onDemandFound.get(simpleTypeName)) == null) {
890
						for (int j = 0; j < this.onDemandImportCacheCount; j++) {
891
							ImportBinding importBinding = this.onDemandImportsCache[j];
892
893
							char[][] importName = importBinding.compoundName;
894
							char[] importFlatName = CharOperation.concatWith(importName, '.');
895
896
							if(fullyQualifiedEnclosingTypeOrPackageName == null) {
897
								fullyQualifiedEnclosingTypeOrPackageName = packageName;
898
							}
899
							if(CharOperation.equals(fullyQualifiedEnclosingTypeOrPackageName, importFlatName)) {
900
								if(importBinding.isStatic()) {
901
									if((typeModifiers & ClassFileConstants.AccStatic) != 0) {
902
										onDemandFound.put(
903
												simpleTypeName,
904
												acceptedConstructor);
905
										continue next;
906
									}
907
								} else {
908
									onDemandFound.put(
909
											simpleTypeName,
910
											acceptedConstructor);
911
									continue next;
912
								}
913
							}
914
						}
915
					} else if(!foundConstructor.mustBeQualified){
916
						done : for (int j = 0; j < this.onDemandImportCacheCount; j++) {
917
							ImportBinding importBinding = this.onDemandImportsCache[j];
918
919
							char[][] importName = importBinding.compoundName;
920
							char[] importFlatName = CharOperation.concatWith(importName, '.');
921
922
							if(fullyQualifiedEnclosingTypeOrPackageName == null) {
923
								fullyQualifiedEnclosingTypeOrPackageName = packageName;
924
							}
925
							if(CharOperation.equals(fullyQualifiedEnclosingTypeOrPackageName, importFlatName)) {
926
								if(importBinding.isStatic()) {
927
									if((typeModifiers & ClassFileConstants.AccStatic) != 0) {
928
										foundConstructor.mustBeQualified = true;
929
										break done;
930
									}
931
								} else {
932
									foundConstructor.mustBeQualified = true;
933
									break done;
934
								}
935
							}
936
						}
937
					}
938
					if (proposeType) {
939
						proposeType(
940
								packageName,
941
								simpleTypeName,
942
								typeModifiers,
943
								accessibility,
944
								simpleTypeName,
945
								fullyQualifiedName,
946
								true,
947
								scope);
948
					}
949
					
950
					if (proposeConstructor && !Flags.isEnum(typeModifiers)) {
951
						acceptedConstructor.mustBeQualified = true;
952
						if (DEFER_QUALIFIED_PROPOSALS) {
953
							deferredProposals.add(acceptedConstructor);
954
						} else {
955
							proposeConstructor(acceptedConstructor, scope);
956
						}
957
					}
958
				}
959
			}
960
		
961
			char[][] keys = onDemandFound.keyTable;
962
			Object[] values = onDemandFound.valueTable;
963
			int max = keys.length;
964
			for (int i = 0; i < max; i++) {
965
				
966
				// does not check cancellation for every types to avoid performance loss
967
				if ((i % CHECK_CANCEL_FREQUENCY) == 0) checkCancel();
968
				
969
				if(keys[i] != null) {
970
					AcceptedConstructor value = (AcceptedConstructor) values[i];
971
					if(value != null) {
972
						if (value.proposeType) {
973
							proposeType(
974
									value.packageName,
975
									value.simpleTypeName,
976
									value.typeModifiers,
977
									value.accessibility,
978
									value.simpleTypeName,
979
									value.fullyQualifiedName,
980
									value.mustBeQualified,
981
									scope);
982
						}
983
						
984
						if (value.proposeConstructor && !Flags.isEnum(value.modifiers)) {
985
							if (!value.mustBeQualified) {
986
								proposeConstructor(
987
										value.simpleTypeName,
988
										value.parameterCount,
989
										value.signature,
990
										value.parameterTypes,
991
										value.parameterNames,
992
										value.modifiers,
993
										value.packageName,
994
										value.typeModifiers,
995
										value.accessibility,
996
										value.simpleTypeName,
997
										value.fullyQualifiedName,
998
										value.mustBeQualified,
999
										scope,
1000
										value.extraFlags);
1001
							} else {
1002
								if (DEFER_QUALIFIED_PROPOSALS) {
1003
									deferredProposals.add(value);
1004
								} else {
1005
									proposeConstructor(value, scope);
1006
								}
1007
							}
1008
						}
1009
					}
1010
				}
1011
			}
1012
			
1013
			if (DEFER_QUALIFIED_PROPOSALS) {
1014
				int size = deferredProposals.size();
1015
				for (int i = 0; i < size; i++) {
1016
					
1017
					// does not check cancellation for every types to avoid performance loss
1018
					if ((i % CHECK_CANCEL_FREQUENCY) == 0) checkCancel();
1019
				
1020
					AcceptedConstructor deferredProposal = (AcceptedConstructor)deferredProposals.get(i);
1021
					
1022
					if (deferredProposal.proposeConstructor) {
1023
						proposeConstructor(
1024
								deferredProposal.simpleTypeName,
1025
								deferredProposal.parameterCount,
1026
								deferredProposal.signature,
1027
								deferredProposal.parameterTypes,
1028
								deferredProposal.parameterNames,
1029
								deferredProposal.modifiers,
1030
								deferredProposal.packageName,
1031
								deferredProposal.typeModifiers,
1032
								deferredProposal.accessibility,
1033
								deferredProposal.simpleTypeName,
1034
								deferredProposal.fullyQualifiedName,
1035
								deferredProposal.mustBeQualified,
1036
								scope,
1037
								deferredProposal.extraFlags);
1038
					}
1039
				}
1040
			}
1041
		} finally {
1042
			this.acceptedTypes = null; // reset
1043
		}
1044
	}
514
1045
515
	/**
1046
	/**
516
	 * One result of the search consists of a new package.
1047
	 * One result of the search consists of a new package.
Lines 577-583 Link Here
577
		AccessRestriction accessRestriction) {
1108
		AccessRestriction accessRestriction) {
578
		
1109
		
579
		// does not check cancellation for every types to avoid performance loss
1110
		// does not check cancellation for every types to avoid performance loss
580
		if ((this.foundTypesCount % CHECK_CANCEL_FREQUENCY_IN_FIND_TYPES) == 0) checkCancel();
1111
		if ((this.foundTypesCount % CHECK_CANCEL_FREQUENCY) == 0) checkCancel();
581
		this.foundTypesCount++;
1112
		this.foundTypesCount++;
582
		
1113
		
583
		if (this.options.checkDeprecation && (modifiers & ClassFileConstants.AccDeprecated) != 0) return;
1114
		if (this.options.checkDeprecation && (modifiers & ClassFileConstants.AccDeprecated) != 0) return;
Lines 630-636 Link Here
630
			next : for (int i = 0; i < length; i++) {
1161
			next : for (int i = 0; i < length; i++) {
631
				
1162
				
632
				// does not check cancellation for every types to avoid performance loss
1163
				// does not check cancellation for every types to avoid performance loss
633
				if ((i % CHECK_CANCEL_FREQUENCY_IN_FIND_TYPES) == 0) checkCancel();
1164
				if ((i % CHECK_CANCEL_FREQUENCY) == 0) checkCancel();
634
				
1165
				
635
				AcceptedType acceptedType = (AcceptedType)this.acceptedTypes.elementAt(i);
1166
				AcceptedType acceptedType = (AcceptedType)this.acceptedTypes.elementAt(i);
636
				char[] packageName = acceptedType.packageName;
1167
				char[] packageName = acceptedType.packageName;
Lines 652-658 Link Here
652
	
1183
	
653
				if (this.knownTypes.containsKey(fullyQualifiedName)) continue next;
1184
				if (this.knownTypes.containsKey(fullyQualifiedName)) continue next;
654
	
1185
	
655
				this.knownTypes.put(fullyQualifiedName, this);
1186
				this.knownTypes.put(fullyQualifiedName, KNOWN_TYPE_WITH_UNKNOWN_CONSTRUCTORS);
656
	
1187
	
657
				if (this.resolvingImports) {
1188
				if (this.resolvingImports) {
658
					if(this.compilerOptions.complianceLevel >= ClassFileConstants.JDK1_4 && packageName.length == 0) {
1189
					if(this.compilerOptions.complianceLevel >= ClassFileConstants.JDK1_4 && packageName.length == 0) {
Lines 808-813 Link Here
808
			Object[] values = onDemandFound.valueTable;
1339
			Object[] values = onDemandFound.valueTable;
809
			int max = keys.length;
1340
			int max = keys.length;
810
			for (int i = 0; i < max; i++) {
1341
			for (int i = 0; i < max; i++) {
1342
				if ((i % CHECK_CANCEL_FREQUENCY) == 0) checkCancel();
811
				if(keys[i] != null) {
1343
				if(keys[i] != null) {
812
					AcceptedType value = (AcceptedType) values[i];
1344
					AcceptedType value = (AcceptedType) values[i];
813
					if(value != null) {
1345
					if(value != null) {
Lines 2448-2453 Link Here
2448
		this.assistNodeIsClass = ref.isClass();
2980
		this.assistNodeIsClass = ref.isClass();
2449
		this.assistNodeIsException = ref.isException();
2981
		this.assistNodeIsException = ref.isException();
2450
		this.assistNodeIsInterface = ref.isInterface();
2982
		this.assistNodeIsInterface = ref.isInterface();
2983
		this.assistNodeIsConstructor = ref.isConstructorType;
2451
		this.assistNodeIsSuperType = ref.isSuperType();
2984
		this.assistNodeIsSuperType = ref.isSuperType();
2452
2985
2453
		this.completionToken = ref.completionIdentifier;
2986
		this.completionToken = ref.completionIdentifier;
Lines 3201-3207 Link Here
3201
						TypeBinding caughtException = catchArguments[i].type.resolvedType;
3734
						TypeBinding caughtException = catchArguments[i].type.resolvedType;
3202
						if (caughtException != null) {
3735
						if (caughtException != null) {
3203
							addForbiddenBindings(caughtException);
3736
							addForbiddenBindings(caughtException);
3204
							this.knownTypes.put(CharOperation.concat(caughtException.qualifiedPackageName(), caughtException.qualifiedSourceName(), '.'), this);
3737
							this.knownTypes.put(CharOperation.concat(caughtException.qualifiedPackageName(), caughtException.qualifiedSourceName(), '.'), KNOWN_TYPE_WITH_KNOWN_CONSTRUCTORS);
3205
						}
3738
						}
3206
					}
3739
					}
3207
					this.forbbidenBindingsFilter = SUBTYPE;
3740
					this.forbbidenBindingsFilter = SUBTYPE;
Lines 3943-3987 Link Here
3943
		}
4476
		}
3944
	}
4477
	}
3945
	private void findAnonymousType(
4478
	private void findAnonymousType(
4479
			ReferenceBinding currentType,
4480
			TypeBinding[] argTypes,
4481
			Scope scope,
4482
			InvocationSite invocationSite) {
4483
		
4484
		int relevance = computeBaseRelevance();
4485
		relevance += computeRelevanceForResolution();
4486
		relevance += computeRelevanceForInterestingProposal();
4487
		relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE);
4488
		
4489
		findAnonymousType(currentType, argTypes, scope, invocationSite, true, false, relevance);
4490
	}
4491
	private void findAnonymousType(
3946
		ReferenceBinding currentType,
4492
		ReferenceBinding currentType,
3947
		TypeBinding[] argTypes,
4493
		TypeBinding[] argTypes,
3948
		Scope scope,
4494
		Scope scope,
3949
		InvocationSite invocationSite) {
4495
		InvocationSite invocationSite,
4496
		boolean exactMatch,
4497
		boolean isQualified,
4498
		int relevance) {
3950
4499
3951
		if (currentType.isInterface()) {
4500
		if (currentType.isInterface()) {
3952
			char[] completion = CharOperation.NO_CHAR;
4501
			char[] completion = CharOperation.NO_CHAR;
3953
			int relevance = computeBaseRelevance();
4502
			char[] typeCompletion = null;
3954
			relevance += computeRelevanceForResolution();
4503
			if (!exactMatch) {
3955
			relevance += computeRelevanceForInterestingProposal();
4504
				typeCompletion = 
3956
			relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE);
4505
					isQualified ?
4506
							CharOperation.concat(currentType.qualifiedPackageName(), currentType.qualifiedSourceName(), '.') :
4507
								currentType.sourceName();
4508
				if (this.source != null
4509
							&& this.source.length > this.endPosition
4510
							&& this.source[this.endPosition] == '(') {
4511
					completion = CharOperation.NO_CHAR;
4512
				} else {
4513
					completion = new char[] { '(', ')' };
4514
				}
4515
			}
3957
4516
3958
			this.noProposal = false;
4517
			this.noProposal = false;
3959
			if(!this.requestor.isIgnored(CompletionProposal.ANONYMOUS_CLASS_DECLARATION)) {
4518
			if (!exactMatch) {
3960
				InternalCompletionProposal proposal = createProposal(CompletionProposal.ANONYMOUS_CLASS_DECLARATION, this.actualCompletionPosition);
4519
				if(!isIgnored(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION, CompletionProposal.TYPE_REF)) {
3961
				proposal.setDeclarationSignature(getSignature(currentType));
4520
					char[] packageName = currentType.isLocalType() ? null : currentType.qualifiedPackageName();
3962
				proposal.setDeclarationKey(currentType.computeUniqueKey());
4521
					char[] typeName = currentType.qualifiedSourceName();
3963
				proposal.setSignature(
4522
					
3964
						createMethodSignature(
4523
					InternalCompletionProposal proposal = createProposal(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION, this.actualCompletionPosition);
3965
								CharOperation.NO_CHAR_CHAR,
4524
					proposal.setDeclarationSignature(getSignature(currentType));
3966
								CharOperation.NO_CHAR_CHAR,
4525
					proposal.setDeclarationKey(currentType.computeUniqueKey());
3967
								CharOperation.NO_CHAR,
4526
					proposal.setSignature(
3968
								CharOperation.NO_CHAR));
4527
							createMethodSignature(
3969
				//proposal.setOriginalSignature(null);
4528
									CharOperation.NO_CHAR_CHAR,
3970
				//proposal.setUniqueKey(null);
4529
									CharOperation.NO_CHAR_CHAR,
3971
				proposal.setDeclarationPackageName(currentType.qualifiedPackageName());
4530
									CharOperation.NO_CHAR,
3972
				proposal.setDeclarationTypeName(currentType.qualifiedSourceName());
4531
									CharOperation.NO_CHAR));
3973
				//proposal.setParameterPackageNames(null);
4532
					//proposal.setOriginalSignature(null);
3974
				//proposal.setParameterTypeNames(null);
4533
					//proposal.setUniqueKey(null);
3975
				//proposal.setPackageName(null);
4534
					proposal.setDeclarationPackageName(packageName);
3976
				//proposal.setTypeName(null);
4535
					proposal.setDeclarationTypeName(typeName);
3977
				proposal.setCompletion(completion);
4536
					//proposal.setParameterPackageNames(null);
3978
				proposal.setFlags(Flags.AccPublic);
4537
					//proposal.setParameterTypeNames(null);
3979
				proposal.setReplaceRange(this.endPosition - this.offset, this.endPosition - this.offset);
4538
					//proposal.setPackageName(null);
3980
				proposal.setTokenRange(this.tokenEnd - this.offset, this.tokenEnd - this.offset);
4539
					//proposal.setTypeName(null);
3981
				proposal.setRelevance(relevance);
4540
					proposal.setName(currentType.sourceName());
3982
				this.requestor.accept(proposal);
4541
					
3983
				if(DEBUG) {
4542
					InternalCompletionProposal typeProposal = createProposal(CompletionProposal.TYPE_REF, this.actualCompletionPosition);
3984
					this.printDebug(proposal);
4543
					typeProposal.nameLookup = this.nameEnvironment.nameLookup;
4544
					typeProposal.completionEngine = this;
4545
					typeProposal.setDeclarationSignature(packageName);
4546
					typeProposal.setSignature(getRequiredTypeSignature(currentType));
4547
					typeProposal.setPackageName(packageName);
4548
					typeProposal.setTypeName(typeName);
4549
					typeProposal.setCompletion(typeCompletion);
4550
					typeProposal.setFlags(currentType.modifiers);
4551
					typeProposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset);
4552
					typeProposal.setTokenRange(this.startPosition - this.offset, this.endPosition - this.offset);
4553
					typeProposal.setRelevance(relevance);
4554
					proposal.setRequiredProposals( new CompletionProposal[]{typeProposal});
4555
								
4556
					proposal.setCompletion(completion);
4557
					proposal.setFlags(Flags.AccPublic);
4558
					proposal.setReplaceRange(this.endPosition - this.offset, this.endPosition - this.offset);
4559
					proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset);
4560
					proposal.setRelevance(relevance);
4561
					this.requestor.accept(proposal);
4562
					if(DEBUG) {
4563
						this.printDebug(proposal);
4564
					}
4565
				}
4566
			}  else {
4567
				if(!this.requestor.isIgnored(CompletionProposal.ANONYMOUS_CLASS_DECLARATION)) {
4568
					InternalCompletionProposal proposal = createProposal(CompletionProposal.ANONYMOUS_CLASS_DECLARATION, this.actualCompletionPosition);
4569
					proposal.setDeclarationSignature(getSignature(currentType));
4570
					proposal.setDeclarationKey(currentType.computeUniqueKey());
4571
					proposal.setSignature(
4572
							createMethodSignature(
4573
									CharOperation.NO_CHAR_CHAR,
4574
									CharOperation.NO_CHAR_CHAR,
4575
									CharOperation.NO_CHAR,
4576
									CharOperation.NO_CHAR));
4577
					//proposal.setOriginalSignature(null);
4578
					//proposal.setUniqueKey(null);
4579
					proposal.setDeclarationPackageName(currentType.qualifiedPackageName());
4580
					proposal.setDeclarationTypeName(currentType.qualifiedSourceName());
4581
					//proposal.setParameterPackageNames(null);
4582
					//proposal.setParameterTypeNames(null);
4583
					//proposal.setPackageName(null);
4584
					//proposal.setTypeName(null);
4585
					proposal.setCompletion(completion);
4586
					proposal.setFlags(Flags.AccPublic);
4587
					proposal.setReplaceRange(this.endPosition - this.offset, this.endPosition - this.offset);
4588
					proposal.setTokenRange(this.tokenEnd - this.offset, this.tokenEnd - this.offset);
4589
					proposal.setRelevance(relevance);
4590
					this.requestor.accept(proposal);
4591
					if(DEBUG) {
4592
						this.printDebug(proposal);
4593
					}
3985
				}
4594
				}
3986
			}
4595
			}
3987
		} else {
4596
		} else {
Lines 3990-3996 Link Here
3990
				argTypes,
4599
				argTypes,
3991
				scope,
4600
				scope,
3992
				invocationSite,
4601
				invocationSite,
3993
				true);
4602
				true,
4603
				exactMatch,
4604
				isQualified,
4605
				relevance);
3994
		}
4606
		}
3995
	}
4607
	}
3996
	private void findClassField(
4608
	private void findClassField(
Lines 4075-4080 Link Here
4075
		Scope scope,
4687
		Scope scope,
4076
		InvocationSite invocationSite,
4688
		InvocationSite invocationSite,
4077
		boolean forAnonymousType) {
4689
		boolean forAnonymousType) {
4690
		
4691
		int relevance = computeBaseRelevance();
4692
						relevance += computeRelevanceForResolution();
4693
						relevance += computeRelevanceForInterestingProposal();
4694
						relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE);
4695
		
4696
		findConstructors(currentType, argTypes, scope, invocationSite, forAnonymousType, true, false, relevance);
4697
	}
4698
		
4699
	private void findConstructors(
4700
		ReferenceBinding currentType,
4701
		TypeBinding[] argTypes,
4702
		Scope scope,
4703
		InvocationSite invocationSite,
4704
		boolean forAnonymousType,
4705
		boolean exactMatch,
4706
		boolean isQualified,
4707
		int relevance) {
4078
4708
4079
		// No visibility checks can be performed without the scope & invocationSite
4709
		// No visibility checks can be performed without the scope & invocationSite
4080
		MethodBinding[] methods = currentType.availableMethods();
4710
		MethodBinding[] methods = currentType.availableMethods();
Lines 4117-4162 Link Here
4117
					char[][] parameterNames = findMethodParameterNames(constructor,parameterTypeNames);
4747
					char[][] parameterNames = findMethodParameterNames(constructor,parameterTypeNames);
4118
4748
4119
					char[] completion = CharOperation.NO_CHAR;
4749
					char[] completion = CharOperation.NO_CHAR;
4750
					
4120
					if(forAnonymousType){
4751
					if(forAnonymousType){
4121
						int relevance = computeBaseRelevance();
4752
						char[] typeCompletion = null;
4122
						relevance += computeRelevanceForResolution();
4753
						if (!exactMatch) {
4123
						relevance += computeRelevanceForInterestingProposal();
4754
							typeCompletion = 
4124
						relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE);
4755
								isQualified ?
4125
4756
										CharOperation.concat(currentType.qualifiedPackageName(), currentType.qualifiedSourceName(), '.') :
4757
											currentType.sourceName();
4758
							if (this.source != null
4759
										&& this.source.length > this.endPosition
4760
										&& this.source[this.endPosition] == '(') {
4761
								completion = CharOperation.NO_CHAR;
4762
							} else {
4763
								completion = new char[] { '(', ')' };
4764
							}
4765
						}
4766
						
4126
						this.noProposal = false;
4767
						this.noProposal = false;
4127
						if(!this.requestor.isIgnored(CompletionProposal.ANONYMOUS_CLASS_DECLARATION)) {
4768
						if (!exactMatch) {
4128
							InternalCompletionProposal proposal = createProposal(CompletionProposal.ANONYMOUS_CLASS_DECLARATION, this.actualCompletionPosition);
4769
							if(!isIgnored(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION, CompletionProposal.TYPE_REF)) {
4129
							proposal.setDeclarationSignature(getSignature(currentType));
4770
								char[] packageName = currentType.isLocalType() ? null : currentType.qualifiedPackageName();
4130
							proposal.setDeclarationKey(currentType.computeUniqueKey());
4771
								char[] typeName = currentType.qualifiedSourceName();
4131
							proposal.setSignature(getSignature(constructor));
4772
								
4132
							MethodBinding original = constructor.original();
4773
								InternalCompletionProposal proposal = createProposal(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION, this.actualCompletionPosition);
4133
							if(original != constructor) {
4774
								proposal.setDeclarationSignature(getSignature(currentType));
4134
								proposal.setOriginalSignature(getSignature(original));
4775
								proposal.setDeclarationKey(currentType.computeUniqueKey());
4776
								proposal.setSignature(getSignature(constructor));
4777
								MethodBinding original = constructor.original();
4778
								if(original != constructor) {
4779
									proposal.setOriginalSignature(getSignature(original));
4780
								}
4781
								proposal.setKey(constructor.computeUniqueKey());
4782
								proposal.setDeclarationPackageName(packageName);
4783
								proposal.setDeclarationTypeName(typeName);
4784
								proposal.setParameterPackageNames(parameterPackageNames);
4785
								proposal.setParameterTypeNames(parameterTypeNames);
4786
								//proposal.setPackageName(null);
4787
								//proposal.setTypeName(null);
4788
								proposal.setName(currentType.sourceName());
4789
								
4790
								InternalCompletionProposal typeProposal = createProposal(CompletionProposal.TYPE_REF, this.actualCompletionPosition);
4791
								typeProposal.nameLookup = this.nameEnvironment.nameLookup;
4792
								typeProposal.completionEngine = this;
4793
								typeProposal.setDeclarationSignature(packageName);
4794
								typeProposal.setSignature(getRequiredTypeSignature(currentType));
4795
								typeProposal.setPackageName(packageName);
4796
								typeProposal.setTypeName(typeName);
4797
								typeProposal.setCompletion(typeCompletion);
4798
								typeProposal.setFlags(currentType.modifiers);
4799
								typeProposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset);
4800
								typeProposal.setTokenRange(this.startPosition - this.offset, this.endPosition - this.offset);
4801
								typeProposal.setRelevance(relevance);
4802
								proposal.setRequiredProposals( new CompletionProposal[]{typeProposal});
4803
								
4804
								proposal.setCompletion(completion);
4805
								proposal.setFlags(constructor.modifiers);
4806
								proposal.setReplaceRange(this.endPosition - this.offset, this.endPosition - this.offset);
4807
								proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset);
4808
								proposal.setRelevance(relevance);
4809
								if(parameterNames != null) proposal.setParameterNames(parameterNames);
4810
								this.requestor.accept(proposal);
4811
								if(DEBUG) {
4812
									this.printDebug(proposal);
4813
								}
4135
							}
4814
							}
4136
							proposal.setKey(constructor.computeUniqueKey());
4815
						} else {
4137
							proposal.setDeclarationPackageName(currentType.qualifiedPackageName());
4816
							if(!this.requestor.isIgnored(CompletionProposal.ANONYMOUS_CLASS_DECLARATION)) {
4138
							proposal.setDeclarationTypeName(currentType.qualifiedSourceName());
4817
								InternalCompletionProposal proposal = createProposal(CompletionProposal.ANONYMOUS_CLASS_DECLARATION, this.actualCompletionPosition);
4139
							proposal.setParameterPackageNames(parameterPackageNames);
4818
								proposal.setDeclarationSignature(getSignature(currentType));
4140
							proposal.setParameterTypeNames(parameterTypeNames);
4819
								proposal.setDeclarationKey(currentType.computeUniqueKey());
4141
							//proposal.setPackageName(null);
4820
								proposal.setSignature(getSignature(constructor));
4142
							//proposal.setTypeName(null);
4821
								MethodBinding original = constructor.original();
4143
							proposal.setCompletion(completion);
4822
								if(original != constructor) {
4144
							proposal.setFlags(constructor.modifiers);
4823
									proposal.setOriginalSignature(getSignature(original));
4145
							proposal.setReplaceRange(this.endPosition - this.offset, this.endPosition - this.offset);
4824
								}
4146
							proposal.setTokenRange(this.tokenEnd - this.offset, this.tokenEnd - this.offset);
4825
								proposal.setKey(constructor.computeUniqueKey());
4147
							proposal.setRelevance(relevance);
4826
								proposal.setDeclarationPackageName(currentType.qualifiedPackageName());
4148
							if(parameterNames != null) proposal.setParameterNames(parameterNames);
4827
								proposal.setDeclarationTypeName(currentType.qualifiedSourceName());
4149
							this.requestor.accept(proposal);
4828
								proposal.setParameterPackageNames(parameterPackageNames);
4150
							if(DEBUG) {
4829
								proposal.setParameterTypeNames(parameterTypeNames);
4151
								this.printDebug(proposal);
4830
								//proposal.setPackageName(null);
4831
								//proposal.setTypeName(null);
4832
								proposal.setCompletion(completion);
4833
								proposal.setFlags(constructor.modifiers);
4834
								proposal.setReplaceRange(this.endPosition - this.offset, this.endPosition - this.offset);
4835
								proposal.setTokenRange(this.tokenEnd - this.offset, this.tokenEnd - this.offset);
4836
								proposal.setRelevance(relevance);
4837
								if(parameterNames != null) proposal.setParameterNames(parameterNames);
4838
								this.requestor.accept(proposal);
4839
								if(DEBUG) {
4840
									this.printDebug(proposal);
4841
								}
4152
							}
4842
							}
4153
						}
4843
						}
4154
					} else {
4844
					} else {
4155
						int relevance = computeBaseRelevance();
4845
						char[] typeCompletion = null;
4156
						relevance += computeRelevanceForResolution();
4157
						relevance += computeRelevanceForInterestingProposal();
4158
						relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE);
4159
4160
						// Special case for completion in javadoc
4846
						// Special case for completion in javadoc
4161
						if (this.assistNodeInJavadoc > 0) {
4847
						if (this.assistNodeInJavadoc > 0) {
4162
							Expression receiver = null;
4848
							Expression receiver = null;
Lines 4208-4278 Link Here
4208
								javadocCompletion.append(')');
4894
								javadocCompletion.append(')');
4209
								completion = javadocCompletion.toString().toCharArray();
4895
								completion = javadocCompletion.toString().toCharArray();
4210
							}
4896
							}
4897
						} else {
4898
							if (!exactMatch) {
4899
								typeCompletion = 
4900
									isQualified ?
4901
											CharOperation.concat(currentType.qualifiedPackageName(), currentType.qualifiedSourceName(), '.') :
4902
												currentType.sourceName();
4903
								
4904
								if (this.source != null
4905
											&& this.source.length > this.endPosition
4906
											&& this.source[this.endPosition] == '(') {
4907
									completion = CharOperation.NO_CHAR;
4908
								} else {
4909
									completion = new char[] { '(', ')' };
4910
								}
4911
							}
4211
						}
4912
						}
4212
4913
4213
						// Create standard proposal
4914
						// Create standard proposal
4214
						this.noProposal = false;
4915
						this.noProposal = false;
4215
						if(!this.requestor.isIgnored(CompletionProposal.METHOD_REF) && (this.assistNodeInJavadoc & CompletionOnJavadoc.ONLY_INLINE_TAG) == 0) {
4916
						if (!exactMatch) {
4216
							InternalCompletionProposal proposal =  createProposal(CompletionProposal.METHOD_REF, this.actualCompletionPosition);
4917
							if(!isIgnored(CompletionProposal.CONSTRUCTOR_INVOCATION, CompletionProposal.TYPE_REF)) {
4217
							proposal.setDeclarationSignature(getSignature(currentType));
4918
								char[] packageName = currentType.isLocalType() ? null : currentType.qualifiedPackageName();
4218
							proposal.setSignature(getSignature(constructor));
4919
								char[] typeName = currentType.qualifiedSourceName();
4219
							MethodBinding original = constructor.original();
4920
								
4220
							if(original != constructor) {
4921
								InternalCompletionProposal proposal =  createProposal(CompletionProposal.CONSTRUCTOR_INVOCATION, this.actualCompletionPosition);
4221
								proposal.setOriginalSignature(getSignature(original));
4922
								proposal.setDeclarationSignature(getSignature(currentType));
4923
								proposal.setSignature(getSignature(constructor));
4924
								MethodBinding original = constructor.original();
4925
								if(original != constructor) {
4926
									proposal.setOriginalSignature(getSignature(original));
4927
								}
4928
								proposal.setDeclarationPackageName(packageName);
4929
								proposal.setDeclarationTypeName(typeName);
4930
								proposal.setParameterPackageNames(parameterPackageNames);
4931
								proposal.setParameterTypeNames(parameterTypeNames);
4932
								//proposal.setPackageName(null);
4933
								//proposal.setTypeName(null);
4934
								proposal.setName(currentType.sourceName());
4935
					
4936
								InternalCompletionProposal typeProposal = createProposal(CompletionProposal.TYPE_REF, this.actualCompletionPosition);
4937
								typeProposal.nameLookup = this.nameEnvironment.nameLookup;
4938
								typeProposal.completionEngine = this;
4939
								typeProposal.setDeclarationSignature(packageName);
4940
								typeProposal.setSignature(getRequiredTypeSignature(currentType));
4941
								typeProposal.setPackageName(packageName);
4942
								typeProposal.setTypeName(typeName);
4943
								typeProposal.setCompletion(typeCompletion);
4944
								typeProposal.setFlags(currentType.modifiers);
4945
								typeProposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset);
4946
								typeProposal.setTokenRange(this.startPosition - this.offset, this.endPosition - this.offset);
4947
								typeProposal.setRelevance(relevance);
4948
								proposal.setRequiredProposals( new CompletionProposal[]{typeProposal});
4949
								
4950
								proposal.setIsContructor(true);
4951
								proposal.setCompletion(completion);
4952
								proposal.setFlags(constructor.modifiers);
4953
								proposal.setReplaceRange(this.endPosition - this.offset, this.endPosition - this.offset);
4954
								proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset);
4955
								proposal.setRelevance(relevance);
4956
								if(parameterNames != null) proposal.setParameterNames(parameterNames);
4957
								this.requestor.accept(proposal);
4958
								if(DEBUG) {
4959
									this.printDebug(proposal);
4960
								}
4222
							}
4961
							}
4223
							proposal.setDeclarationPackageName(currentType.qualifiedPackageName());
4962
						} else {
4224
							proposal.setDeclarationTypeName(currentType.qualifiedSourceName());
4963
							if(!this.requestor.isIgnored(CompletionProposal.METHOD_REF) && (this.assistNodeInJavadoc & CompletionOnJavadoc.ONLY_INLINE_TAG) == 0) {
4225
							proposal.setParameterPackageNames(parameterPackageNames);
4964
								InternalCompletionProposal proposal =  createProposal(CompletionProposal.METHOD_REF, this.actualCompletionPosition);
4226
							proposal.setParameterTypeNames(parameterTypeNames);
4965
								proposal.setDeclarationSignature(getSignature(currentType));
4227
							//proposal.setPackageName(null);
4966
								proposal.setSignature(getSignature(constructor));
4228
							//proposal.setTypeName(null);
4967
								MethodBinding original = constructor.original();
4229
							proposal.setName(currentType.sourceName());
4968
								if(original != constructor) {
4230
							proposal.setIsContructor(true);
4969
									proposal.setOriginalSignature(getSignature(original));
4231
							proposal.setCompletion(completion);
4970
								}
4232
							proposal.setFlags(constructor.modifiers);
4971
								proposal.setDeclarationPackageName(currentType.qualifiedPackageName());
4233
							int start = (this.assistNodeInJavadoc > 0) ? this.startPosition : this.endPosition;
4972
								proposal.setDeclarationTypeName(currentType.qualifiedSourceName());
4234
							proposal.setReplaceRange(start - this.offset, this.endPosition - this.offset);
4973
								proposal.setParameterPackageNames(parameterPackageNames);
4235
							proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset);
4974
								proposal.setParameterTypeNames(parameterTypeNames);
4236
							proposal.setRelevance(relevance);
4975
								//proposal.setPackageName(null);
4237
							if(parameterNames != null) proposal.setParameterNames(parameterNames);
4976
								//proposal.setTypeName(null);
4238
							this.requestor.accept(proposal);
4977
								proposal.setName(currentType.sourceName());
4239
							if(DEBUG) {
4978
								proposal.setIsContructor(true);
4240
								this.printDebug(proposal);
4979
								proposal.setCompletion(completion);
4980
								proposal.setFlags(constructor.modifiers);
4981
								int start = (this.assistNodeInJavadoc > 0) ? this.startPosition : this.endPosition;
4982
								proposal.setReplaceRange(start - this.offset, this.endPosition - this.offset);
4983
								proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset);
4984
								proposal.setRelevance(relevance);
4985
								if(parameterNames != null) proposal.setParameterNames(parameterNames);
4986
								this.requestor.accept(proposal);
4987
								if(DEBUG) {
4988
									this.printDebug(proposal);
4989
								}
4241
							}
4990
							}
4242
						}
4991
							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)) {
4992
								char[] javadocCompletion = inlineTagCompletion(completion, JavadocTagConstants.TAG_LINK);
4244
							char[] javadocCompletion = inlineTagCompletion(completion, JavadocTagConstants.TAG_LINK);
4993
								InternalCompletionProposal proposal =  createProposal(CompletionProposal.JAVADOC_METHOD_REF, this.actualCompletionPosition);
4245
							InternalCompletionProposal proposal =  createProposal(CompletionProposal.JAVADOC_METHOD_REF, this.actualCompletionPosition);
4994
								proposal.setDeclarationSignature(getSignature(currentType));
4246
							proposal.setDeclarationSignature(getSignature(currentType));
4995
								proposal.setSignature(getSignature(constructor));
4247
							proposal.setSignature(getSignature(constructor));
4996
								MethodBinding original = constructor.original();
4248
							MethodBinding original = constructor.original();
4997
								if(original != constructor) {
4249
							if(original != constructor) {
4998
									proposal.setOriginalSignature(getSignature(original));
4250
								proposal.setOriginalSignature(getSignature(original));
4999
								}
5000
								proposal.setDeclarationPackageName(currentType.qualifiedPackageName());
5001
								proposal.setDeclarationTypeName(currentType.qualifiedSourceName());
5002
								proposal.setParameterPackageNames(parameterPackageNames);
5003
								proposal.setParameterTypeNames(parameterTypeNames);
5004
								//proposal.setPackageName(null);
5005
								//proposal.setTypeName(null);
5006
								proposal.setName(currentType.sourceName());
5007
								proposal.setIsContructor(true);
5008
								proposal.setCompletion(javadocCompletion);
5009
								proposal.setFlags(constructor.modifiers);
5010
								int start = (this.assistNodeInJavadoc & CompletionOnJavadoc.REPLACE_TAG) != 0 ? this.javadocTagPosition : this.startPosition;
5011
								proposal.setReplaceRange(start - this.offset, this.endPosition - this.offset);
5012
								proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset);
5013
								proposal.setRelevance(relevance+R_INLINE_TAG);
5014
								if(parameterNames != null) proposal.setParameterNames(parameterNames);
5015
								this.requestor.accept(proposal);
5016
								if(DEBUG) {
5017
									this.printDebug(proposal);
5018
								}
4251
							}
5019
							}
4252
							proposal.setDeclarationPackageName(currentType.qualifiedPackageName());
5020
						}
4253
							proposal.setDeclarationTypeName(currentType.qualifiedSourceName());
5021
					}
4254
							proposal.setParameterPackageNames(parameterPackageNames);
5022
				}
4255
							proposal.setParameterTypeNames(parameterTypeNames);
5023
			}
4256
							//proposal.setPackageName(null);
5024
		}
4257
							//proposal.setTypeName(null);
5025
	}
4258
							proposal.setName(currentType.sourceName());
5026
	
4259
							proposal.setIsContructor(true);
5027
	private char[] getResolvedSignature(char[][] parameterTypes, char[] fullyQualifiedTypeName, int parameterCount, Scope scope) {
4260
							proposal.setCompletion(javadocCompletion);
5028
		char[][] cn = CharOperation.splitOn('.', fullyQualifiedTypeName);
4261
							proposal.setFlags(constructor.modifiers);
5029
4262
							int start = (this.assistNodeInJavadoc & CompletionOnJavadoc.REPLACE_TAG) != 0 ? this.javadocTagPosition : this.startPosition;
5030
		TypeReference ref;
4263
							proposal.setReplaceRange(start - this.offset, this.endPosition - this.offset);
5031
		if (cn.length == 1) {
4264
							proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset);
5032
			ref = new SingleTypeReference(cn[0], 0);
4265
							proposal.setRelevance(relevance+R_INLINE_TAG);
5033
		} else {
4266
							if(parameterNames != null) proposal.setParameterNames(parameterNames);
5034
			ref = new QualifiedTypeReference(cn,new long[cn.length]);
4267
							this.requestor.accept(proposal);
5035
		}
4268
							if(DEBUG) {
5036
		
4269
								this.printDebug(proposal);
5037
		TypeBinding guessedType = null;
5038
		INameEnvironment oldNameEnvironment = this.lookupEnvironment.nameEnvironment;
5039
		this.lookupEnvironment.nameEnvironment = getNoCacheNameEnvironment();
5040
		try {
5041
			switch (scope.kind) {
5042
				case Scope.METHOD_SCOPE :
5043
				case Scope.BLOCK_SCOPE :
5044
					guessedType = ref.resolveType((BlockScope)scope);
5045
					break;
5046
				case Scope.CLASS_SCOPE :
5047
					guessedType = ref.resolveType((ClassScope)scope);
5048
					break;
5049
			}
5050
		} finally {
5051
			this.lookupEnvironment.nameEnvironment = oldNameEnvironment;
5052
		}
5053
5054
		if (guessedType != null && guessedType.isValidBinding()) {
5055
			if (guessedType instanceof ReferenceBinding) {
5056
				ReferenceBinding refBinding = (ReferenceBinding) guessedType;
5057
				
5058
				MethodBinding bestConstructor = null;
5059
				int[] bestMatchingLengths = null;
5060
				
5061
				MethodBinding[] methods = refBinding.methods();
5062
				next : for (int i = 0; i < methods.length; i++) {
5063
					MethodBinding method = methods[i];
5064
					
5065
					if (!method.isConstructor()) break next;
5066
					
5067
					TypeBinding[] parameters = method.parameters;
5068
					//TODO take careful of member types
5069
					int parametersLength = parameters == null ? 0 : parameters.length;
5070
					if (parameterCount != parametersLength) continue next;
5071
					
5072
					int[] matchingLengths = new int[parameterCount];
5073
					for (int j = 0; j < parametersLength; j++) {
5074
						TypeBinding parameter = parameters[j];
5075
						
5076
						char[] parameterTypeName;
5077
						if (parameter instanceof ReferenceBinding) {
5078
							parameterTypeName = CharOperation.concatWith(((ReferenceBinding)parameter).compoundName, '.');
5079
						} else {
5080
							parameterTypeName = parameter.sourceName();
5081
						}
5082
						
5083
						if (!CharOperation.endsWith(parameterTypeName, parameterTypes[j])) {
5084
							continue next;
5085
						}
5086
						
5087
						int matchingLength = parameterTypes[j].length;
5088
						
5089
						if (bestMatchingLengths != null) {
5090
							if (bestMatchingLengths[j] > matchingLength) {
5091
								continue next;
4270
							}
5092
							}
4271
						}
5093
						}
5094
						
5095
						matchingLengths[j] = matchingLength;
4272
					}
5096
					}
5097
					
5098
					
5099
					bestConstructor = method;
5100
					bestMatchingLengths = matchingLengths;
4273
				}
5101
				}
5102
				
5103
				if (bestConstructor == null) return null;
5104
				return getSignature(bestConstructor);
4274
			}
5105
			}
4275
		}
5106
		}
5107
		
5108
		return null;
5109
	}
5110
5111
	private void findConstructorsOrAnonymousTypes(
5112
			ReferenceBinding currentType,
5113
			Scope scope,
5114
			InvocationSite invocationSite,
5115
			boolean isQualified,
5116
			int relevance) {
5117
		
5118
		if (!isIgnored(CompletionProposal.CONSTRUCTOR_INVOCATION, CompletionProposal.TYPE_REF)
5119
				&& currentType.isClass()
5120
				&& !currentType.isAbstract()) {
5121
				findConstructors(
5122
					currentType,
5123
					null,
5124
					scope,
5125
					invocationSite,
5126
					false,
5127
					false,
5128
					isQualified,
5129
					relevance);
5130
		}
5131
		
5132
		// This code is disabled because there is too much proposals when constructors and anonymous are proposed
5133
		if (!isIgnored(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION, CompletionProposal.TYPE_REF)
5134
				&& !currentType.isFinal()
5135
				&& (currentType.isInterface() || (currentType.isClass() && currentType.isAbstract()))){
5136
			findAnonymousType(
5137
				currentType,
5138
				null,
5139
				scope,
5140
				invocationSite,
5141
				false,
5142
				isQualified,
5143
				relevance);
5144
		}
4276
	}
5145
	}
4277
	private char[][] findEnclosingTypeNames(Scope scope){
5146
	private char[][] findEnclosingTypeNames(Scope scope){
4278
		char[][] excludedNames = new char[10][];
5147
		char[][] excludedNames = new char[10][];
Lines 8230-8246 Link Here
8230
				relevance += computeRelevanceForMissingElements(missingElementsHaveProblems);
9099
				relevance += computeRelevanceForMissingElements(missingElementsHaveProblems);
8231
			}
9100
			}
8232
9101
9102
			boolean allowingLongComputationProposals = isAllowingLongComputationProposals();
9103
			
8233
			this.noProposal = false;
9104
			this.noProposal = false;
8234
			createTypeProposal(
9105
			if (!this.assistNodeIsConstructor ||
8235
					memberType,
9106
					!allowingLongComputationProposals ||
8236
					memberType.qualifiedSourceName(),
9107
					hasStaticMemberTypes(memberType, invocationType, this.unitScope) ||
8237
					IAccessRule.K_ACCESSIBLE,
9108
					(memberType instanceof SourceTypeBinding && hasMemberTypesInEnclosingScope((SourceTypeBinding)memberType, scope))) {
8238
					completionName,
9109
				createTypeProposal(
8239
					relevance,
9110
						memberType,
8240
					missingElements,
9111
						memberType.qualifiedSourceName(),
8241
					missingElementsStarts,
9112
						IAccessRule.K_ACCESSIBLE,
8242
					missingElementsEnds,
9113
						completionName,
8243
					missingElementsHaveProblems);
9114
						relevance,
9115
						missingElements,
9116
						missingElementsStarts,
9117
						missingElementsEnds,
9118
						missingElementsHaveProblems);
9119
			}
9120
			
9121
			if (this.assistNodeIsConstructor && allowingLongComputationProposals) {
9122
				findConstructorsOrAnonymousTypes(
9123
						memberType,
9124
						scope,
9125
						FakeInvocationSite,
9126
						isQualified,
9127
						relevance);
9128
			}
8244
		}
9129
		}
8245
	}
9130
	}
8246
	private void findMemberTypesFromMissingType(
9131
	private void findMemberTypesFromMissingType(
Lines 8659-8676 Link Here
8659
								relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE); // no access restriction for nested type
9544
								relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE); // no access restriction for nested type
8660
								relevance += computeRelevanceForAnnotationTarget(localType);
9545
								relevance += computeRelevanceForAnnotationTarget(localType);
8661
9546
8662
								this.noProposal = false;
9547
								boolean allowingLongComputationProposals = isAllowingLongComputationProposals();
8663
								if(!this.requestor.isIgnored(CompletionProposal.TYPE_REF)) {
9548
								if (!this.assistNodeIsConstructor || !allowingLongComputationProposals) {
8664
									createTypeProposal(
9549
									this.noProposal = false;
9550
									if(!this.requestor.isIgnored(CompletionProposal.TYPE_REF)) {
9551
										createTypeProposal(
9552
												localType,
9553
												localType.sourceName,
9554
												IAccessRule.K_ACCESSIBLE,
9555
												localType.sourceName,
9556
												relevance,
9557
												null,
9558
												null,
9559
												null,
9560
												false);
9561
									}
9562
								}
9563
								
9564
								if (this.assistNodeIsConstructor && allowingLongComputationProposals) {
9565
									findConstructorsOrAnonymousTypes(
8665
											localType,
9566
											localType,
8666
											localType.sourceName,
9567
											blockScope,
8667
											IAccessRule.K_ACCESSIBLE,
9568
											FakeInvocationSite,
8668
											localType.sourceName,
9569
											false,
8669
											relevance,
9570
											relevance);
8670
											null,
8671
											null,
8672
											null,
8673
											false);
8674
								}
9571
								}
8675
							}
9572
							}
8676
						}
9573
						}
Lines 8918-8931 Link Here
8918
9815
8919
		if (token == null)
9816
		if (token == null)
8920
			return;
9817
			return;
8921
9818
		
9819
		boolean allowingLongComputationProposals = isAllowingLongComputationProposals();
9820
		
8922
		boolean proposeType =
9821
		boolean proposeType =
8923
			!this.requestor.isIgnored(CompletionProposal.TYPE_REF) ||
9822
			!this.requestor.isIgnored(CompletionProposal.TYPE_REF) ||
8924
			((this.assistNodeInJavadoc & CompletionOnJavadoc.TEXT) != 0 && !this.requestor.isIgnored(CompletionProposal.JAVADOC_TYPE_REF));
9823
			((this.assistNodeInJavadoc & CompletionOnJavadoc.TEXT) != 0 && !this.requestor.isIgnored(CompletionProposal.JAVADOC_TYPE_REF));
8925
9824
8926
		boolean proposeAllMemberTypes = !this.assistNodeIsConstructor;
9825
		boolean proposeAllMemberTypes = !this.assistNodeIsConstructor;
9826
		
9827
		boolean proposeConstructor =
9828
			allowingLongComputationProposals &&
9829
			this.assistNodeIsConstructor &&
9830
			(!isIgnored(CompletionProposal.CONSTRUCTOR_INVOCATION, CompletionProposal.TYPE_REF) ||
9831
					!isIgnored(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION, CompletionProposal.TYPE_REF));
9832
		
8927
9833
8928
		if (proposeType && scope.enclosingSourceType() != null) {
9834
		if ((proposeType || proposeConstructor) && scope.enclosingSourceType() != null) {
8929
			
9835
			
8930
			checkCancel();
9836
			checkCancel();
8931
			
9837
			
Lines 8944-8950 Link Here
8944
9850
8945
		boolean isEmptyPrefix = token.length == 0;
9851
		boolean isEmptyPrefix = token.length == 0;
8946
9852
8947
		if (proposeType && this.unitScope != null) {
9853
		if ((proposeType || proposeConstructor) && this.unitScope != null) {
8948
			
9854
			
8949
			ReferenceBinding outerInvocationType = scope.enclosingSourceType();
9855
			ReferenceBinding outerInvocationType = scope.enclosingSourceType();
8950
			if(outerInvocationType != null) {
9856
			if(outerInvocationType != null) {
Lines 8985-8991 Link Here
8985
				if (typeLength > sourceType.sourceName.length) continue next;
9891
				if (typeLength > sourceType.sourceName.length) continue next;
8986
9892
8987
				if (!CharOperation.prefixEquals(token, sourceType.sourceName, false)
9893
				if (!CharOperation.prefixEquals(token, sourceType.sourceName, false)
8988
						&& !(this.options.camelCaseMatch && CharOperation.camelCaseMatch(token, sourceType.sourceName))) continue;
9894
						&& !(this.options.camelCaseMatch && CharOperation.camelCaseMatch(token, sourceType.sourceName))) continue next;
8989
9895
8990
				if (this.assistNodeIsAnnotation && !hasPossibleAnnotationTarget(sourceType, scope)) {
9896
				if (this.assistNodeIsAnnotation && !hasPossibleAnnotationTarget(sourceType, scope)) {
8991
					continue next;
9897
					continue next;
Lines 8996-9003 Link Here
8996
9902
8997
					if (sourceType == otherType) continue next;
9903
					if (sourceType == otherType) continue next;
8998
				}
9904
				}
8999
9905
				
9000
				this.knownTypes.put(CharOperation.concat(sourceType.qualifiedPackageName(), sourceType.sourceName(), '.'), this);
9906
				typesFound.add(sourceType);
9001
9907
9002
				if(this.assistNodeIsClass) {
9908
				if(this.assistNodeIsClass) {
9003
					if(!sourceType.isClass()) continue next;
9909
					if(!sourceType.isClass()) continue next;
Lines 9028-9035 Link Here
9028
					relevance += computeRelevanceForClass();
9934
					relevance += computeRelevanceForClass();
9029
					relevance += computeRelevanceForException(sourceType.sourceName);
9935
					relevance += computeRelevanceForException(sourceType.sourceName);
9030
				}
9936
				}
9937
				
9938
				
9031
				this.noProposal = false;
9939
				this.noProposal = false;
9032
				if(proposeType) {
9940
				if(proposeType &&
9941
						(!this.assistNodeIsConstructor ||
9942
								!allowingLongComputationProposals ||
9943
								hasStaticMemberTypes(sourceType, null, this.unitScope) ||
9944
								hasMemberTypesInEnclosingScope(sourceType, scope))) {
9033
					char[] typeName = sourceType.sourceName();
9945
					char[] typeName = sourceType.sourceName();
9034
					createTypeProposal(
9946
					createTypeProposal(
9035
							sourceType,
9947
							sourceType,
Lines 9042-9168 Link Here
9042
							null,
9954
							null,
9043
							false);
9955
							false);
9044
				}
9956
				}
9957
				
9958
				if (proposeConstructor) {
9959
					findConstructorsOrAnonymousTypes(
9960
							sourceType,
9961
							scope,
9962
							FakeInvocationSite,
9963
							false,
9964
							relevance);
9965
				}
9045
			}
9966
			}
9046
		}
9967
		}
9047
9968
9048
		if(proposeType) {
9969
		if (proposeConstructor && !isEmptyPrefix) {
9970
			
9971
			checkCancel();
9972
			
9973
			findTypesFromImports(token, scope, proposeType, typesFound);
9974
		} else if(proposeType) {
9049
			
9975
			
9050
			checkCancel();
9976
			checkCancel();
9051
			
9977
			
9052
			findTypesFromStaticImports(token, scope, proposeAllMemberTypes, typesFound);
9978
			findTypesFromStaticImports(token, scope, proposeAllMemberTypes, typesFound);
9053
		}
9979
		}
9980
		
9981
		if (proposeConstructor) {
9982
			
9983
			checkCancel();
9984
			
9985
			findTypesFromExpectedTypes(token, scope, typesFound, proposeType, proposeConstructor);
9986
		}
9054
9987
9055
		if (isEmptyPrefix && !this.assistNodeIsAnnotation) {
9988
		if (isEmptyPrefix && !this.assistNodeIsAnnotation) {
9056
			if(proposeType && this.expectedTypesPtr > -1) {
9989
			if (!proposeConstructor) {
9057
				next : for (int i = 0; i <= this.expectedTypesPtr; i++) {
9990
				findTypesFromExpectedTypes(token, scope, typesFound, proposeType, proposeConstructor);
9058
					
9059
					checkCancel();
9060
					
9061
					if(this.expectedTypes[i] instanceof ReferenceBinding) {
9062
						ReferenceBinding refBinding = (ReferenceBinding)this.expectedTypes[i];
9063
9064
						if(refBinding.isTypeVariable() && this.assistNodeIsConstructor) {
9065
							// don't propose type variable if the completion is a constructor ('new |')
9066
							continue next;
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
						}
9164
					}
9165
				}
9166
			}
9991
			}
9167
		} else {
9992
		} else {
9168
			if(!isEmptyPrefix && !this.requestor.isIgnored(CompletionProposal.KEYWORD)) {
9993
			if(!isEmptyPrefix && !this.requestor.isIgnored(CompletionProposal.KEYWORD)) {
Lines 9176-9182 Link Here
9176
					}
10001
					}
9177
				}
10002
				}
9178
			}
10003
			}
9179
			if(proposeType) {
10004
			
10005
			if (proposeConstructor) {
10006
				int l = typesFound.size();
10007
				for (int i = 0; i < l; i++) {
10008
					ReferenceBinding typeFound = (ReferenceBinding) typesFound.elementAt(i);
10009
					char[] fullyQualifiedTypeName =
10010
						CharOperation.concat(
10011
								typeFound.qualifiedPackageName(),
10012
								typeFound.qualifiedSourceName(),
10013
								'.');
10014
					this.knownTypes.put(fullyQualifiedTypeName, KNOWN_TYPE_WITH_KNOWN_CONSTRUCTORS);
10015
				}
10016
				
10017
				checkCancel();
10018
				
10019
				this.foundConstructorsCount = 0;
10020
				this.nameEnvironment.findConstructorDeclarations(
10021
						token,
10022
						this.options.camelCaseMatch,
10023
						this,
10024
						this.monitor);
10025
				acceptConstructors(scope);
10026
			} else if (proposeType) {
9180
				int l = typesFound.size();
10027
				int l = typesFound.size();
9181
				for (int i = 0; i < l; i++) {
10028
				for (int i = 0; i < l; i++) {
9182
					ReferenceBinding typeFound = (ReferenceBinding) typesFound.elementAt(i);
10029
					ReferenceBinding typeFound = (ReferenceBinding) typesFound.elementAt(i);
Lines 9185-9191 Link Here
9185
								typeFound.qualifiedPackageName(),
10032
								typeFound.qualifiedPackageName(),
9186
								typeFound.qualifiedSourceName(),
10033
								typeFound.qualifiedSourceName(),
9187
								'.');
10034
								'.');
9188
					this.knownTypes.put(fullyQualifiedTypeName, this);
10035
					this.knownTypes.put(fullyQualifiedTypeName, KNOWN_TYPE_WITH_KNOWN_CONSTRUCTORS);
9189
				}
10036
				}
9190
				int searchFor = IJavaSearchConstants.TYPE;
10037
				int searchFor = IJavaSearchConstants.TYPE;
9191
				if(this.assistNodeIsClass) {
10038
				if(this.assistNodeIsClass) {
Lines 9223-9232 Link Here
9223
		char[] token,
10070
		char[] token,
9224
		PackageBinding packageBinding,
10071
		PackageBinding packageBinding,
9225
		Scope scope) {
10072
		Scope scope) {
10073
		
10074
		boolean allowingLongComputationProposals = isAllowingLongComputationProposals();
9226
10075
9227
		boolean proposeType =
10076
		boolean proposeType =
9228
			!this.requestor.isIgnored(CompletionProposal.TYPE_REF) ||
10077
			!this.requestor.isIgnored(CompletionProposal.TYPE_REF) ||
9229
			((this.assistNodeInJavadoc & CompletionOnJavadoc.TEXT) != 0 && !this.requestor.isIgnored(CompletionProposal.JAVADOC_TYPE_REF));
10078
			((this.assistNodeInJavadoc & CompletionOnJavadoc.TEXT) != 0 && !this.requestor.isIgnored(CompletionProposal.JAVADOC_TYPE_REF));
10079
		
10080
		boolean proposeConstructor =
10081
			allowingLongComputationProposals &&
10082
			this.assistNodeIsConstructor &&
10083
			(!isIgnored(CompletionProposal.CONSTRUCTOR_INVOCATION, CompletionProposal.TYPE_REF) ||
10084
					!isIgnored(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION, CompletionProposal.TYPE_REF));
9230
10085
9231
		char[] qualifiedName =
10086
		char[] qualifiedName =
9232
			CharOperation.concatWith(packageBinding.compoundName, token, '.');
10087
			CharOperation.concatWith(packageBinding.compoundName, token, '.');
Lines 9244-9250 Link Here
9244
10099
9245
		this.qualifiedCompletionToken = qualifiedName;
10100
		this.qualifiedCompletionToken = qualifiedName;
9246
10101
9247
		if (proposeType && this.unitScope != null) {
10102
		if ((proposeType || proposeConstructor) && this.unitScope != null) {
9248
			int typeLength = qualifiedName.length;
10103
			int typeLength = qualifiedName.length;
9249
			SourceTypeBinding[] types = this.unitScope.topLevelTypes;
10104
			SourceTypeBinding[] types = this.unitScope.topLevelTypes;
9250
10105
Lines 9290-9296 Link Here
9290
					}
10145
					}
9291
				}
10146
				}
9292
10147
9293
				this.knownTypes.put(CharOperation.concat(sourceType.qualifiedPackageName(), sourceType.sourceName(), '.'), this);
10148
				this.knownTypes.put(CharOperation.concat(sourceType.qualifiedPackageName(), sourceType.sourceName(), '.'), KNOWN_TYPE_WITH_KNOWN_CONSTRUCTORS);
9294
10149
9295
				int relevance = computeBaseRelevance();
10150
				int relevance = computeBaseRelevance();
9296
				relevance += computeRelevanceForResolution();
10151
				relevance += computeRelevanceForResolution();
Lines 9308-9315 Link Here
9308
					relevance += computeRelevanceForClass();
10163
					relevance += computeRelevanceForClass();
9309
					relevance += computeRelevanceForException(sourceType.sourceName);
10164
					relevance += computeRelevanceForException(sourceType.sourceName);
9310
				}
10165
				}
10166
				
9311
				this.noProposal = false;
10167
				this.noProposal = false;
9312
				if(proposeType) {
10168
				if(proposeType &&
10169
						(!this.assistNodeIsConstructor ||
10170
								!allowingLongComputationProposals ||
10171
								hasStaticMemberTypes(sourceType, null, this.unitScope) ||
10172
								hasMemberTypesInEnclosingScope(sourceType, scope))) {
9313
					char[] typeName = sourceType.sourceName();
10173
					char[] typeName = sourceType.sourceName();
9314
					createTypeProposal(
10174
					createTypeProposal(
9315
							sourceType,
10175
							sourceType,
Lines 9322-9331 Link Here
9322
							null,
10182
							null,
9323
							false);
10183
							false);
9324
				}
10184
				}
10185
				
10186
				if (proposeConstructor) {
10187
					findConstructorsOrAnonymousTypes(
10188
							sourceType,
10189
							scope,
10190
							FakeInvocationSite,
10191
							false,
10192
							relevance);
10193
				}
9325
			}
10194
			}
9326
		}
10195
		}
9327
10196
9328
		if(proposeType) {
10197
		if (proposeConstructor) {
10198
10199
			
10200
			checkCancel();
10201
			
10202
			this.foundConstructorsCount = 0;
10203
			this.nameEnvironment.findConstructorDeclarations(
10204
					qualifiedName,
10205
					this.options.camelCaseMatch,
10206
					this,
10207
					this.monitor);
10208
			acceptConstructors(scope);
10209
		} if(proposeType) {
9329
			int searchFor = IJavaSearchConstants.TYPE;
10210
			int searchFor = IJavaSearchConstants.TYPE;
9330
			if(this.assistNodeIsClass) {
10211
			if(this.assistNodeIsClass) {
9331
				searchFor = IJavaSearchConstants.CLASS;
10212
				searchFor = IJavaSearchConstants.CLASS;
Lines 9349-9359 Link Here
9349
					this.monitor);
10230
					this.monitor);
9350
			acceptTypes(scope);
10231
			acceptTypes(scope);
9351
		}
10232
		}
10233
		
9352
		if(!this.requestor.isIgnored(CompletionProposal.PACKAGE_REF)) {
10234
		if(!this.requestor.isIgnored(CompletionProposal.PACKAGE_REF)) {
9353
			this.nameEnvironment.findPackages(qualifiedName, this);
10235
			this.nameEnvironment.findPackages(qualifiedName, this);
9354
		}
10236
		}
9355
	}
10237
	}
10238
	
10239
	private void findTypesFromExpectedTypes(char[] token, Scope scope, ObjectVector typesFound, boolean proposeType, boolean proposeConstructor) {
10240
		if(this.expectedTypesPtr > -1) {
10241
			boolean allowingLongComputationProposals = isAllowingLongComputationProposals();
10242
			
10243
			int typeLength = token == null ? 0 : token.length;
10244
			
10245
			next : for (int i = 0; i <= this.expectedTypesPtr; i++) {
10246
				
10247
				checkCancel();
10248
				
10249
				if(this.expectedTypes[i] instanceof ReferenceBinding) {
10250
					ReferenceBinding refBinding = (ReferenceBinding)this.expectedTypes[i];
10251
					
10252
					if (typeLength > 0) {
10253
						if (typeLength > refBinding.sourceName.length) continue next;
10254
	
10255
						if (!CharOperation.prefixEquals(token, refBinding.sourceName, false)
10256
								&& !(this.options.camelCaseMatch && CharOperation.camelCaseMatch(token, refBinding.sourceName))) continue next;
10257
					}
10258
10259
10260
					if(refBinding.isTypeVariable() && this.assistNodeIsConstructor) {
10261
						// don't propose type variable if the completion is a constructor ('new |')
10262
						continue next;
10263
					}
10264
					if (this.options.checkDeprecation &&
10265
							refBinding.isViewedAsDeprecated() &&
10266
							!scope.isDefinedInSameUnit(refBinding))
10267
						continue next;
10268
10269
					int accessibility = IAccessRule.K_ACCESSIBLE;
10270
					if(refBinding.hasRestrictedAccess()) {
10271
						AccessRestriction accessRestriction = this.lookupEnvironment.getAccessRestriction(refBinding);
10272
						if(accessRestriction != null) {
10273
							switch (accessRestriction.getProblemId()) {
10274
								case IProblem.ForbiddenReference:
10275
									if (this.options.checkForbiddenReference) {
10276
										continue next;
10277
									}
10278
									accessibility = IAccessRule.K_NON_ACCESSIBLE;
10279
									break;
10280
								case IProblem.DiscouragedReference:
10281
									if (this.options.checkDiscouragedReference) {
10282
										continue next;
10283
									}
10284
									accessibility = IAccessRule.K_DISCOURAGED;
10285
									break;
10286
							}
10287
						}
10288
					}
10289
10290
					for (int j = 0; j < typesFound.size(); j++) {
10291
						ReferenceBinding typeFound = (ReferenceBinding)typesFound.elementAt(j);
10292
						if (typeFound == refBinding) {
10293
							continue next;
10294
						}
10295
					}
10296
					
10297
					typesFound.add(refBinding);
10298
10299
					boolean inSameUnit = this.unitScope.isDefinedInSameUnit(refBinding);
10300
10301
					// top level types of the current unit are already proposed.
10302
					if(!inSameUnit || (inSameUnit && refBinding.isMemberType())) {
10303
						char[] packageName = refBinding.qualifiedPackageName();
10304
						char[] typeName = refBinding.sourceName();
10305
						char[] completionName = typeName;
10306
10307
						boolean isQualified = false;
10308
						if (!this.insideQualifiedReference && !refBinding.isMemberType()) {
10309
							if (mustQualifyType(packageName, typeName, null, refBinding.modifiers)) {
10310
								if (packageName == null || packageName.length == 0)
10311
									if (this.unitScope != null && this.unitScope.fPackage.compoundName != CharOperation.NO_CHAR_CHAR)
10312
										continue next; // ignore types from the default package from outside it
10313
								completionName = CharOperation.concat(packageName, typeName, '.');
10314
								isQualified = true;
10315
							}
10316
						}
10317
10318
						if(this.assistNodeIsClass) {
10319
							if(!refBinding.isClass()) continue next;
10320
						} else if(this.assistNodeIsInterface) {
10321
							if(!refBinding.isInterface() && !refBinding.isAnnotationType()) continue next;
10322
						} else if (this.assistNodeIsAnnotation) {
10323
							if(!refBinding.isAnnotationType()) continue next;
10324
						}
10325
10326
						int relevance = computeBaseRelevance();
10327
						relevance += computeRelevanceForResolution();
10328
						relevance += computeRelevanceForInterestingProposal();
10329
						relevance += computeRelevanceForCaseMatching(token, typeName);
10330
						relevance += computeRelevanceForExpectingType(refBinding);
10331
						relevance += computeRelevanceForQualification(isQualified);
10332
						relevance += computeRelevanceForRestrictions(accessibility);
10333
10334
						if(refBinding.isClass()) {
10335
							relevance += computeRelevanceForClass();
10336
							relevance += computeRelevanceForException(typeName);
10337
						} else if(refBinding.isEnum()) {
10338
							relevance += computeRelevanceForEnum();
10339
						} else if(refBinding.isInterface()) {
10340
							relevance += computeRelevanceForInterface();
10341
						}
10342
						
10343
						if (proposeType && (!this.assistNodeIsConstructor || !allowingLongComputationProposals || hasStaticMemberTypes(refBinding, scope.enclosingSourceType() ,this.unitScope))) {
10344
							this.noProposal = false;
10345
							if(!this.requestor.isIgnored(CompletionProposal.TYPE_REF)) {
10346
								InternalCompletionProposal proposal =  createProposal(CompletionProposal.TYPE_REF, this.actualCompletionPosition);
10347
								proposal.setDeclarationSignature(packageName);
10348
								proposal.setSignature(getSignature(refBinding));
10349
								proposal.setPackageName(packageName);
10350
								proposal.setTypeName(typeName);
10351
								proposal.setCompletion(completionName);
10352
								proposal.setFlags(refBinding.modifiers);
10353
								proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset);
10354
								proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset);
10355
								proposal.setRelevance(relevance);
10356
								proposal.setAccessibility(accessibility);
10357
								this.requestor.accept(proposal);
10358
								if(DEBUG) {
10359
									this.printDebug(proposal);
10360
								}
10361
							}
10362
						}
10363
						
10364
						if (proposeConstructor) {
10365
							findConstructorsOrAnonymousTypes(
10366
									refBinding,
10367
									scope,
10368
									FakeInvocationSite,
10369
									isQualified,
10370
									relevance);
10371
						}
10372
					}
10373
				}
10374
			}
10375
		}
10376
	}
9356
10377
10378
	private void findTypesFromImports(char[] token, Scope scope, boolean proposeType, ObjectVector typesFound) {
10379
		ImportBinding[] importBindings = scope.compilationUnitScope().imports;
10380
		next : for (int i = 0; i < importBindings.length; i++) {
10381
			ImportBinding importBinding = importBindings[i];
10382
			if(importBinding.isValidBinding()) {
10383
				Binding binding = importBinding.resolvedImport;
10384
				if(binding != null && binding.isValidBinding()) {
10385
					if(importBinding.onDemand) {
10386
						if (importBinding.isStatic()) {
10387
							if((binding.kind() & Binding.TYPE) != 0) {
10388
								this.findMemberTypes(
10389
										token,
10390
										(ReferenceBinding) binding,
10391
										scope,
10392
										scope.enclosingSourceType(),
10393
										true,
10394
										false,
10395
										true,
10396
										true,
10397
										false,
10398
										null,
10399
										typesFound,
10400
										null,
10401
										null,
10402
										null,
10403
										false);
10404
							}
10405
						}
10406
					} else {
10407
						if ((binding.kind() & Binding.TYPE) != 0) {
10408
							ReferenceBinding typeBinding = (ReferenceBinding) binding;
10409
							int typeLength = token.length;
10410
10411
							if (!typeBinding.isStatic()) continue next;
10412
10413
							if (typeLength > typeBinding.sourceName.length)	continue next;
10414
10415
							if (!CharOperation.prefixEquals(token, typeBinding.sourceName, false)
10416
									&& !(this.options.camelCaseMatch && CharOperation.camelCaseMatch(token, typeBinding.sourceName))) continue next;
10417
							
10418
							int accessibility = IAccessRule.K_ACCESSIBLE;
10419
							if(typeBinding.hasRestrictedAccess()) {
10420
								AccessRestriction accessRestriction = this.lookupEnvironment.getAccessRestriction(typeBinding);
10421
								if(accessRestriction != null) {
10422
									switch (accessRestriction.getProblemId()) {
10423
										case IProblem.ForbiddenReference:
10424
											if (this.options.checkForbiddenReference) {
10425
												continue next;
10426
											}
10427
											accessibility = IAccessRule.K_NON_ACCESSIBLE;
10428
											break;
10429
										case IProblem.DiscouragedReference:
10430
											if (this.options.checkDiscouragedReference) {
10431
												continue next;
10432
											}
10433
											accessibility = IAccessRule.K_DISCOURAGED;
10434
											break;
10435
									}
10436
								}
10437
							}
10438
							
10439
							if (typesFound.contains(typeBinding)) continue next;
10440
							
10441
							typesFound.add(typeBinding);
10442
							
10443
							if(this.assistNodeIsClass) {
10444
								if(!typeBinding.isClass()) continue;
10445
							} else if(this.assistNodeIsInterface) {
10446
								if(!typeBinding.isInterface() && !typeBinding.isAnnotationType()) continue;
10447
							} else if (this.assistNodeIsAnnotation) {
10448
								if(!typeBinding.isAnnotationType()) continue;
10449
							}
10450
							
10451
							int relevance = computeBaseRelevance();
10452
							relevance += computeRelevanceForResolution();
10453
							relevance += computeRelevanceForInterestingProposal();
10454
							relevance += computeRelevanceForCaseMatching(token, typeBinding.sourceName);
10455
							relevance += computeRelevanceForExpectingType(typeBinding);
10456
							relevance += computeRelevanceForQualification(false);
10457
							relevance += computeRelevanceForRestrictions(accessibility);
10458
			
10459
							if (typeBinding.isAnnotationType()) {
10460
								relevance += computeRelevanceForAnnotation();
10461
								relevance += computeRelevanceForAnnotationTarget(typeBinding);
10462
							} else if (typeBinding.isInterface()) {
10463
								relevance += computeRelevanceForInterface();
10464
							} else if(typeBinding.isClass()){
10465
								relevance += computeRelevanceForClass();
10466
								relevance += computeRelevanceForException(typeBinding.sourceName);
10467
							}
10468
							
10469
							if (proposeType && hasStaticMemberTypes(typeBinding, scope.enclosingSourceType(), this.unitScope)) {
10470
								this.noProposal = false;
10471
								if(!this.requestor.isIgnored(CompletionProposal.TYPE_REF)) {
10472
									InternalCompletionProposal proposal =  createProposal(CompletionProposal.TYPE_REF, this.actualCompletionPosition);
10473
									proposal.setDeclarationSignature(typeBinding.qualifiedPackageName());
10474
									proposal.setSignature(getSignature(typeBinding));
10475
									proposal.setPackageName(typeBinding.qualifiedPackageName());
10476
									proposal.setTypeName(typeBinding.qualifiedSourceName());
10477
									proposal.setCompletion(typeBinding.sourceName());
10478
									proposal.setFlags(typeBinding.modifiers);
10479
									proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset);
10480
									proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset);
10481
									proposal.setRelevance(relevance);
10482
									this.requestor.accept(proposal);
10483
									if(DEBUG) {
10484
										this.printDebug(proposal);
10485
									}
10486
								}
10487
							}
10488
							
10489
							findConstructorsOrAnonymousTypes(
10490
									typeBinding,
10491
									scope,
10492
									FakeInvocationSite,
10493
									false,
10494
									relevance);
10495
						}
10496
					}
10497
				}
10498
			}
10499
		}
10500
	}
10501
	
9357
	private void findTypesFromStaticImports(char[] token, Scope scope, boolean proposeAllMemberTypes, ObjectVector typesFound) {
10502
	private void findTypesFromStaticImports(char[] token, Scope scope, boolean proposeAllMemberTypes, ObjectVector typesFound) {
9358
		ImportBinding[] importBindings = scope.compilationUnitScope().imports;
10503
		ImportBinding[] importBindings = scope.compilationUnitScope().imports;
9359
		for (int i = 0; i < importBindings.length; i++) {
10504
		for (int i = 0; i < importBindings.length; i++) {
Lines 10206-10211 Link Here
10206
11351
10207
		return this.favoriteReferenceBindings = resolvedImports;
11352
		return this.favoriteReferenceBindings = resolvedImports;
10208
	}
11353
	}
11354
	
11355
	private INameEnvironment getNoCacheNameEnvironment() {
11356
		if (this.noCacheNameEnvironment == null) {
11357
			JavaModelManager.getJavaModelManager().cacheZipFiles();
11358
			this.noCacheNameEnvironment = new JavaSearchNameEnvironment(this.javaProject, this.owner == null ? null : JavaModelManager.getJavaModelManager().getWorkingCopies(this.owner, true/*add primary WCs*/));
11359
		}
11360
		return this.noCacheNameEnvironment;
11361
	}
10209
11362
10210
	public AssistParser getParser() {
11363
	public AssistParser getParser() {
10211
11364
Lines 10256-10261 Link Here
10256
		inlineCompletion[inlineLength-1] = '}';
11409
		inlineCompletion[inlineLength-1] = '}';
10257
		return inlineCompletion;
11410
		return inlineCompletion;
10258
	}
11411
	}
11412
	private boolean isAllowingLongComputationProposals() {
11413
		return this.monitor != null;
11414
	}
10259
	private boolean isForbidden(Binding binding) {
11415
	private boolean isForbidden(Binding binding) {
10260
		for (int i = 0; i <= this.forbbidenBindingsPtr; i++) {
11416
		for (int i = 0; i <= this.forbbidenBindingsPtr; i++) {
10261
			if(this.forbbidenBindings[i] == binding) {
11417
			if(this.forbbidenBindings[i] == binding) {
Lines 10469-10474 Link Here
10469
			case CompletionProposal.TYPE_IMPORT :
11625
			case CompletionProposal.TYPE_IMPORT :
10470
				buffer.append("TYPE_IMPORT"); //$NON-NLS-1$
11626
				buffer.append("TYPE_IMPORT"); //$NON-NLS-1$
10471
				break;
11627
				break;
11628
			case CompletionProposal.CONSTRUCTOR_INVOCATION :
11629
				buffer.append("CONSTRUCTOR_INVOCATION"); //$NON-NLS-1$
11630
				break;
11631
			case CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION :
11632
				buffer.append("ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION"); //$NON-NLS-1$
11633
				break;
10472
			default :
11634
			default :
10473
				buffer.append("PROPOSAL"); //$NON-NLS-1$
11635
				buffer.append("PROPOSAL"); //$NON-NLS-1$
10474
				break;
11636
				break;
Lines 10540-10545 Link Here
10540
			buffer.append('\t');
11702
			buffer.append('\t');
10541
		}
11703
		}
10542
	}
11704
	}
11705
	
11706
	private void proposeConstructor(AcceptedConstructor deferredProposal, Scope scope) {
11707
		if (deferredProposal.proposeConstructor) {
11708
			proposeConstructor(
11709
					deferredProposal.simpleTypeName,
11710
					deferredProposal.parameterCount,
11711
					deferredProposal.signature,
11712
					deferredProposal.parameterTypes,
11713
					deferredProposal.parameterNames,
11714
					deferredProposal.modifiers,
11715
					deferredProposal.packageName,
11716
					deferredProposal.typeModifiers,
11717
					deferredProposal.accessibility,
11718
					deferredProposal.simpleTypeName,
11719
					deferredProposal.fullyQualifiedName,
11720
					deferredProposal.mustBeQualified,
11721
					scope,
11722
					deferredProposal.extraFlags);
11723
		}
11724
	}
11725
	
11726
	private void proposeConstructor(
11727
			char[] simpleTypeName,
11728
			int parameterCount,
11729
			char[] signature,
11730
			char[][] parameterTypes,
11731
			char[][] parameterNames,
11732
			int modifiers,
11733
			char[] packageName,
11734
			int typeModifiers,
11735
			int accessibility,
11736
			char[] typeName,
11737
			char[] fullyQualifiedName,
11738
			boolean isQualified,
11739
			Scope scope,
11740
			int extraFlags) {
11741
		char[] typeCompletion = fullyQualifiedName;
11742
		if(isQualified) {
11743
			if (packageName == null || packageName.length == 0)
11744
				if (this.unitScope != null && this.unitScope.fPackage.compoundName != CharOperation.NO_CHAR_CHAR)
11745
					return; // ignore types from the default package from outside it
11746
		} else {
11747
			typeCompletion = simpleTypeName;
11748
		}
11749
11750
		int relevance = computeBaseRelevance();
11751
		relevance += computeRelevanceForResolution();
11752
		relevance += computeRelevanceForInterestingProposal();
11753
		relevance += computeRelevanceForRestrictions(accessibility);
11754
		relevance += computeRelevanceForCaseMatching(this.completionToken, simpleTypeName);
11755
		relevance += computeRelevanceForExpectingType(packageName, simpleTypeName);
11756
		relevance += computeRelevanceForQualification(isQualified);
11757
11758
		boolean isInterface = false;
11759
		int kind = typeModifiers & (ClassFileConstants.AccInterface | ClassFileConstants.AccEnum | ClassFileConstants.AccAnnotation);
11760
		switch (kind) {
11761
			case ClassFileConstants.AccAnnotation:
11762
			case ClassFileConstants.AccAnnotation | ClassFileConstants.AccInterface:
11763
				relevance += computeRelevanceForAnnotation();
11764
				relevance += computeRelevanceForInterface();
11765
				isInterface = true;
11766
				break;
11767
			case ClassFileConstants.AccEnum:
11768
				relevance += computeRelevanceForEnum();
11769
				break;
11770
			case ClassFileConstants.AccInterface:
11771
				relevance += computeRelevanceForInterface();
11772
				isInterface = true;
11773
				break;
11774
			default:
11775
				relevance += computeRelevanceForClass();
11776
				relevance += computeRelevanceForException(simpleTypeName);
11777
				break;
11778
		}
11779
		
11780
		char[] completion;
11781
		if (this.source != null
11782
					&& this.source.length > this.endPosition
11783
					&& this.source[this.endPosition] == '(') {
11784
			completion = CharOperation.NO_CHAR;
11785
		} else {
11786
			completion = new char[] { '(', ')' };
11787
		}
11788
		
11789
		InternalCompletionProposal typeProposal = createProposal(CompletionProposal.TYPE_REF, this.actualCompletionPosition);
11790
		typeProposal.nameLookup = this.nameEnvironment.nameLookup;
11791
		typeProposal.completionEngine = this;
11792
		typeProposal.setDeclarationSignature(packageName);
11793
		typeProposal.setSignature(createNonGenericTypeSignature(packageName, typeName));
11794
		typeProposal.setPackageName(packageName);
11795
		typeProposal.setTypeName(typeName);
11796
		typeProposal.setCompletion(typeCompletion);
11797
		typeProposal.setFlags(typeModifiers);
11798
		typeProposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset);
11799
		typeProposal.setTokenRange(this.startPosition - this.offset, this.endPosition - this.offset);
11800
		typeProposal.setRelevance(relevance);
11801
		
11802
		switch (parameterCount) {
11803
			case -1: // default constructor
11804
				int flags = Flags.AccPublic;
11805
				if (Flags.isDeprecated(typeModifiers)) {
11806
					flags |= Flags.AccDeprecated;
11807
				}
11808
				
11809
				if (isInterface || (typeModifiers & ClassFileConstants.AccAbstract) != 0) {
11810
					this.noProposal = false;
11811
					if(!isIgnored(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION, CompletionProposal.TYPE_REF)) {
11812
						InternalCompletionProposal proposal = createProposal(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION, this.actualCompletionPosition);
11813
						proposal.setDeclarationSignature(createNonGenericTypeSignature(packageName, typeName));
11814
						proposal.setDeclarationKey(createBindingKey(packageName, typeName));
11815
						proposal.setSignature(DEFAULT_CONSTRUCTOR_SIGNATURE);
11816
						proposal.setDeclarationPackageName(packageName);
11817
						proposal.setDeclarationTypeName(typeName);
11818
						proposal.setParameterPackageNames(CharOperation.NO_CHAR_CHAR);
11819
						proposal.setParameterTypeNames(CharOperation.NO_CHAR_CHAR);
11820
						proposal.setParameterNames(CharOperation.NO_CHAR_CHAR);
11821
						proposal.setName(simpleTypeName);
11822
						proposal.setRequiredProposals(new CompletionProposal[]{typeProposal});
11823
						proposal.setIsContructor(true);
11824
						proposal.setCompletion(completion);
11825
						proposal.setFlags(flags);
11826
						proposal.setReplaceRange(this.endPosition - this.offset, this.endPosition - this.offset);
11827
						proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset);
11828
						proposal.setRelevance(relevance);
11829
						this.requestor.accept(proposal);
11830
						if(DEBUG) {
11831
							this.printDebug(proposal);
11832
						}
11833
					}
11834
				} else {
11835
					this.noProposal = false;
11836
					if(!isIgnored(CompletionProposal.CONSTRUCTOR_INVOCATION, CompletionProposal.TYPE_REF)) {
11837
						InternalCompletionProposal proposal =  createProposal(CompletionProposal.CONSTRUCTOR_INVOCATION, this.actualCompletionPosition);
11838
						proposal.setDeclarationSignature(createNonGenericTypeSignature(packageName, typeName));
11839
						proposal.setSignature(DEFAULT_CONSTRUCTOR_SIGNATURE);
11840
						proposal.setDeclarationPackageName(packageName);
11841
						proposal.setDeclarationTypeName(typeName);
11842
						proposal.setParameterPackageNames(CharOperation.NO_CHAR_CHAR);
11843
						proposal.setParameterTypeNames(CharOperation.NO_CHAR_CHAR);
11844
						proposal.setParameterNames(CharOperation.NO_CHAR_CHAR);
11845
						proposal.setName(simpleTypeName);
11846
						proposal.setRequiredProposals(new CompletionProposal[]{typeProposal});
11847
						proposal.setIsContructor(true);
11848
						proposal.setCompletion(completion);
11849
						proposal.setFlags(flags);
11850
						proposal.setReplaceRange(this.endPosition - this.offset, this.endPosition - this.offset);
11851
						proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset);
11852
						proposal.setRelevance(relevance);
11853
						this.requestor.accept(proposal);
11854
						if(DEBUG) {
11855
							this.printDebug(proposal);
11856
						}
11857
					}
11858
				}
11859
				break;
11860
			case 0: // constructor with no parameter
11861
				
11862
				if ((typeModifiers & ClassFileConstants.AccAbstract) != 0) {
11863
					this.noProposal = false;
11864
					if(!isIgnored(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION, CompletionProposal.TYPE_REF)) {
11865
						InternalCompletionProposal proposal = createProposal(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION, this.actualCompletionPosition);
11866
						proposal.setDeclarationSignature(createNonGenericTypeSignature(packageName, typeName));
11867
						proposal.setDeclarationKey(createBindingKey(packageName, typeName));
11868
						proposal.setSignature(DEFAULT_CONSTRUCTOR_SIGNATURE);
11869
						proposal.setDeclarationPackageName(packageName);
11870
						proposal.setDeclarationTypeName(typeName);
11871
						proposal.setParameterPackageNames(CharOperation.NO_CHAR_CHAR);
11872
						proposal.setParameterTypeNames(CharOperation.NO_CHAR_CHAR);
11873
						proposal.setParameterNames(CharOperation.NO_CHAR_CHAR);
11874
						proposal.setName(simpleTypeName);
11875
						proposal.setRequiredProposals(new CompletionProposal[]{typeProposal});
11876
						proposal.setIsContructor(true);
11877
						proposal.setCompletion(completion);
11878
						proposal.setFlags(modifiers);
11879
						proposal.setReplaceRange(this.endPosition - this.offset, this.endPosition - this.offset);
11880
						proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset);
11881
						proposal.setRelevance(relevance);
11882
						this.requestor.accept(proposal);
11883
						if(DEBUG) {
11884
							this.printDebug(proposal);
11885
						}
11886
					}
11887
				} else {
11888
					this.noProposal = false;
11889
					if(!isIgnored(CompletionProposal.CONSTRUCTOR_INVOCATION, CompletionProposal.TYPE_REF)) {
11890
						InternalCompletionProposal proposal =  createProposal(CompletionProposal.CONSTRUCTOR_INVOCATION, this.actualCompletionPosition);
11891
						proposal.setDeclarationSignature(createNonGenericTypeSignature(packageName, typeName));
11892
						proposal.setSignature(DEFAULT_CONSTRUCTOR_SIGNATURE);
11893
						proposal.setDeclarationPackageName(packageName);
11894
						proposal.setDeclarationTypeName(typeName);
11895
						proposal.setParameterPackageNames(CharOperation.NO_CHAR_CHAR);
11896
						proposal.setParameterTypeNames(CharOperation.NO_CHAR_CHAR);
11897
						proposal.setParameterNames(CharOperation.NO_CHAR_CHAR);
11898
						proposal.setName(simpleTypeName);
11899
						proposal.setRequiredProposals(new CompletionProposal[]{typeProposal});
11900
						proposal.setIsContructor(true);
11901
						proposal.setCompletion(completion);
11902
						proposal.setFlags(modifiers);
11903
						proposal.setReplaceRange(this.endPosition - this.offset, this.endPosition - this.offset);
11904
						proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset);
11905
						proposal.setRelevance(relevance);
11906
						this.requestor.accept(proposal);
11907
						if(DEBUG) {
11908
							this.printDebug(proposal);
11909
						}
11910
					}
11911
				}
11912
				break;
11913
			default: // constructor with parameter
11914
				if (signature == null) {
11915
					// resolve type to found parameter types
11916
					signature = getResolvedSignature(parameterTypes, fullyQualifiedName, parameterCount, scope);
11917
					if (signature == null) return;
11918
				} else {
11919
					signature = CharOperation.replaceOnCopy(signature, '/', '.');
11920
				}
11921
				
11922
				int parameterNamesLength = parameterNames == null ? 0 : parameterNames.length;
11923
				if (parameterCount != parameterNamesLength) {
11924
					parameterNames = null;
11925
				}
11926
				
11927
				if ((typeModifiers & ClassFileConstants.AccAbstract) != 0) {
11928
					this.noProposal = false;
11929
					if(!isIgnored(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION, CompletionProposal.TYPE_REF)) {
11930
						InternalCompletionProposal proposal = createProposal(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION, this.actualCompletionPosition);
11931
						proposal.setDeclarationSignature(createNonGenericTypeSignature(packageName, typeName));
11932
						proposal.setDeclarationKey(createBindingKey(packageName, typeName));
11933
						proposal.setSignature(signature);
11934
						proposal.setDeclarationPackageName(packageName);
11935
						proposal.setDeclarationTypeName(typeName);
11936
						proposal.setParameterPackageNames(CharOperation.NO_CHAR_CHAR);
11937
						proposal.setParameterTypeNames(CharOperation.NO_CHAR_CHAR);
11938
						if (parameterNames != null) {
11939
							proposal.setParameterNames(parameterNames);
11940
						} else {
11941
							proposal.setHasNoParameterNamesFromIndex(true);
11942
						}
11943
						proposal.setName(simpleTypeName);
11944
						proposal.setRequiredProposals(new CompletionProposal[]{typeProposal});
11945
						proposal.setIsContructor(true);
11946
						proposal.setCompletion(completion);
11947
						proposal.setFlags(modifiers);
11948
						proposal.setReplaceRange(this.endPosition - this.offset, this.endPosition - this.offset);
11949
						proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset);
11950
						proposal.setRelevance(relevance);
11951
						this.requestor.accept(proposal);
11952
						if(DEBUG) {
11953
							this.printDebug(proposal);
11954
						}
11955
					}
11956
				} else {
11957
					this.noProposal = false;
11958
					if(!isIgnored(CompletionProposal.CONSTRUCTOR_INVOCATION, CompletionProposal.TYPE_REF)) {
11959
						InternalCompletionProposal proposal =  createProposal(CompletionProposal.CONSTRUCTOR_INVOCATION, this.actualCompletionPosition);
11960
						proposal.setDeclarationSignature(createNonGenericTypeSignature(packageName, typeName));
11961
						proposal.setSignature(signature);
11962
						proposal.setDeclarationPackageName(packageName);
11963
						proposal.setDeclarationTypeName(typeName);
11964
						proposal.setParameterPackageNames(CharOperation.NO_CHAR_CHAR);
11965
						proposal.setParameterTypeNames(CharOperation.NO_CHAR_CHAR);
11966
						if (parameterNames != null) {
11967
							proposal.setParameterNames(parameterNames);
11968
						} else {
11969
							proposal.setHasNoParameterNamesFromIndex(true);
11970
						}
11971
						proposal.setName(simpleTypeName);
11972
						proposal.setRequiredProposals(new CompletionProposal[]{typeProposal});
11973
						proposal.setIsContructor(true);
11974
						proposal.setCompletion(completion);
11975
						proposal.setFlags(modifiers);
11976
						proposal.setReplaceRange(this.endPosition - this.offset, this.endPosition - this.offset);
11977
						proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset);
11978
						proposal.setRelevance(relevance);
11979
						
11980
						this.requestor.accept(proposal);
11981
						if(DEBUG) {
11982
							this.printDebug(proposal);
11983
						}
11984
					}
11985
				}
11986
				break;
11987
		}
11988
	}
10543
11989
10544
	private void proposeNewMethod(char[] token, ReferenceBinding reference) {
11990
	private void proposeNewMethod(char[] token, ReferenceBinding reference) {
10545
		if(!this.requestor.isIgnored(CompletionProposal.POTENTIAL_METHOD_DECLARATION)) {
11991
		if(!this.requestor.isIgnored(CompletionProposal.POTENTIAL_METHOD_DECLARATION)) {
Lines 10662-10667 Link Here
10662
		super.reset(false);
12108
		super.reset(false);
10663
		this.knownPkgs = new HashtableOfObject(10);
12109
		this.knownPkgs = new HashtableOfObject(10);
10664
		this.knownTypes = new HashtableOfObject(10);
12110
		this.knownTypes = new HashtableOfObject(10);
12111
		if (this.noCacheNameEnvironment != null) {
12112
			this.noCacheNameEnvironment.cleanup();
12113
			this.noCacheNameEnvironment = null;
12114
			JavaModelManager.getJavaModelManager().flushZipFiles();
12115
		}
10665
	}
12116
	}
10666
12117
10667
	private void setSourceAndTokenRange(int start, int end) {
12118
	private void setSourceAndTokenRange(int start, int end) {
(-)codeassist/org/eclipse/jdt/internal/codeassist/InternalCompletionProposal.java (-37 / +148 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2006 IBM Corporation and others.
2
 * Copyright (c) 2004, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 18-30 Link Here
18
import org.eclipse.jdt.core.IAccessRule;
18
import org.eclipse.jdt.core.IAccessRule;
19
import org.eclipse.jdt.core.ICodeAssist;
19
import org.eclipse.jdt.core.ICodeAssist;
20
import org.eclipse.jdt.core.ICompilationUnit;
20
import org.eclipse.jdt.core.ICompilationUnit;
21
import org.eclipse.jdt.core.IJavaElement;
21
import org.eclipse.jdt.core.IMethod;
22
import org.eclipse.jdt.core.IMethod;
23
import org.eclipse.jdt.core.IPackageFragmentRoot;
22
import org.eclipse.jdt.core.IType;
24
import org.eclipse.jdt.core.IType;
23
import org.eclipse.jdt.core.JavaModelException;
25
import org.eclipse.jdt.core.JavaModelException;
24
import org.eclipse.jdt.core.Signature;
26
import org.eclipse.jdt.core.Signature;
25
import org.eclipse.jdt.core.compiler.CharOperation;
27
import org.eclipse.jdt.core.compiler.CharOperation;
28
import org.eclipse.jdt.internal.compiler.env.IBinaryMethod;
29
import org.eclipse.jdt.internal.compiler.env.IBinaryType;
26
import org.eclipse.jdt.internal.core.BinaryType;
30
import org.eclipse.jdt.internal.core.BinaryType;
31
import org.eclipse.jdt.internal.core.JavaElement;
27
import org.eclipse.jdt.internal.core.NameLookup;
32
import org.eclipse.jdt.internal.core.NameLookup;
33
import org.eclipse.jdt.internal.core.SourceMapper;
28
34
29
/**
35
/**
30
 * Internal completion proposal
36
 * Internal completion proposal
Lines 32-47 Link Here
32
 */
38
 */
33
public class InternalCompletionProposal extends CompletionProposal {
39
public class InternalCompletionProposal extends CompletionProposal {
34
	private static Object NO_ATTACHED_SOURCE = new Object();
40
	private static Object NO_ATTACHED_SOURCE = new Object();
41
	private static final int OPENED_BYNARY_TYPES_THRESHOLD = 100; // threshold of opened binary to avoid to harm java model cache
35
42
36
	static final char[] ARG = "arg".toCharArray();  //$NON-NLS-1$
37
	static final char[] ARG0 = "arg0".toCharArray();  //$NON-NLS-1$
38
	static final char[] ARG1 = "arg1".toCharArray();  //$NON-NLS-1$
39
	static final char[] ARG2 = "arg2".toCharArray();  //$NON-NLS-1$
40
	static final char[] ARG3 = "arg3".toCharArray();  //$NON-NLS-1$
41
	static final char[][] ARGS1 = new char[][]{ARG0};
42
	static final char[][] ARGS2 = new char[][]{ARG0, ARG1};
43
	static final char[][] ARGS3 = new char[][]{ARG0, ARG1, ARG2};
44
	static final char[][] ARGS4 = new char[][]{ARG0, ARG1, ARG2, ARG3};
45
43
46
	protected CompletionEngine completionEngine;
44
	protected CompletionEngine completionEngine;
47
	protected NameLookup nameLookup;
45
	protected NameLookup nameLookup;
Lines 55-60 Link Here
55
53
56
	protected char[] originalSignature;
54
	protected char[] originalSignature;
57
55
56
	private boolean hasNoParameterNamesFromIndex = false;
58
	private boolean updateCompletion = false;
57
	private boolean updateCompletion = false;
59
58
60
	protected int accessibility = IAccessRule.K_ACCESSIBLE;
59
	protected int accessibility = IAccessRule.K_ACCESSIBLE;
Lines 179-212 Link Here
179
	 * Indicates whether parameter names have been computed.
178
	 * Indicates whether parameter names have been computed.
180
	 */
179
	 */
181
	private boolean parameterNamesComputed = false;
180
	private boolean parameterNamesComputed = false;
181
	
182
	protected char[][] findConstructorParameterNames(char[] declaringTypePackageName, char[] declaringTypeName, char[] selector, char[][] paramTypeNames){
183
		if(paramTypeNames == null || declaringTypeName == null) return null;
182
184
183
	protected char[][] createDefaultParameterNames(int length) {
185
		char[][] parameters = null;
184
		char[][] parameters;
186
		int length = paramTypeNames.length;
185
		switch (length) {
187
186
			case 0 :
188
		char[] tName = CharOperation.concat(declaringTypePackageName,declaringTypeName,'.');
187
				parameters = new char[length][];
189
		Object cachedType = this.completionEngine.typeCache.get(tName);
188
				break;
190
189
			case 1 :
191
		IType type = null;
190
				parameters = ARGS1;
192
		if(cachedType != null) {
191
				break;
193
			if(cachedType != NO_ATTACHED_SOURCE && cachedType instanceof BinaryType) {
192
			case 2 :
194
				type = (BinaryType)cachedType;
193
				parameters = ARGS2;
195
			}
194
				break;
196
		} else {
195
			case 3 :
197
			// TODO (david) shouldn't it be NameLookup.ACCEPT_ALL ?
196
				parameters = ARGS3;
198
			NameLookup.Answer answer = this.nameLookup.findType(new String(tName),
197
				break;
199
				false,
198
			case 4 :
200
				NameLookup.ACCEPT_CLASSES & NameLookup.ACCEPT_INTERFACES,
199
				parameters = ARGS4;
201
				true/* consider secondary types */,
200
				break;
202
				false/* do NOT wait for indexes */,
201
			default :
203
				false/*don't check restrictions*/,
202
				parameters = new char[length][];
204
				null);
203
				for (int i = 0; i < length; i++) {
205
			type = answer == null ? null : answer.type;
204
					parameters[i] = CharOperation.concat(ARG, String.valueOf(i).toCharArray());
206
			if(type instanceof BinaryType){
207
				this.completionEngine.typeCache.put(tName, type);
208
			} else {
209
				type = null;
210
			}
211
		}
212
213
		if(type != null) {
214
			String[] args = new String[length];
215
			for(int i = 0;	i< length ; i++){
216
				args[i] = new String(paramTypeNames[i]);
217
			}
218
			IMethod method = type.getMethod(new String(selector),args);
219
			
220
			if (this.hasNoParameterNamesFromIndex) {
221
				IPackageFragmentRoot packageFragmentRoot = (IPackageFragmentRoot)type.getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT);
222
				if (packageFragmentRoot.isArchive() ||
223
						this.completionEngine.openedBinaryTypes < OPENED_BYNARY_TYPES_THRESHOLD) {
224
					SourceMapper mapper = ((JavaElement)method).getSourceMapper();
225
					if (mapper != null) {
226
						try {
227
							char[][] paramNames = mapper.getMethodParameterNames(method);
228
					
229
							// map source and try to find parameter names
230
							if(paramNames == null) {
231
								if (!packageFragmentRoot.isArchive()) this.completionEngine.openedBinaryTypes++;
232
								IBinaryType info = (IBinaryType) ((BinaryType) type).getElementInfo();
233
								char[] source = mapper.findSource(type, info);
234
								if (source != null){
235
									mapper.mapSource(type, source, info);
236
								}
237
								paramNames = mapper.getMethodParameterNames(method);
238
							}
239
							
240
							if(paramNames != null) {
241
								parameters = paramNames;
242
							}
243
						} catch(JavaModelException e){
244
							//parameters == null;
245
						}
246
					}
205
				}
247
				}
206
				break;
248
			} else {
249
				try{
250
					IBinaryMethod info = (IBinaryMethod) ((JavaElement)method).getElementInfo();
251
					char[][] argumentNames = info.getArgumentNames();
252
					if (argumentNames != null && argumentNames.length == length) {
253
						parameters = argumentNames;
254
					}
255
				} catch(JavaModelException e){
256
					//parameters == null;
257
				}
258
				
259
				try{
260
					parameters = new char[length][];
261
					String[] params = method.getParameterNames();
262
					for(int i = 0;	i< length ; i++){
263
						parameters[i] = params[i].toCharArray();
264
					}
265
				} catch(JavaModelException e){
266
					parameters = null;
267
				}
268
			}
269
		}
270
271
		// default parameters name
272
		if(parameters == null) {
273
			parameters = CompletionEngine.createDefaultParameterNames(length);
207
		}
274
		}
275
208
		return parameters;
276
		return parameters;
209
	}
277
	}
278
	
210
	protected char[][] findMethodParameterNames(char[] declaringTypePackageName, char[] declaringTypeName, char[] selector, char[][] paramTypeNames){
279
	protected char[][] findMethodParameterNames(char[] declaringTypePackageName, char[] declaringTypeName, char[] selector, char[][] paramTypeNames){
211
		if(paramTypeNames == null || declaringTypeName == null) return null;
280
		if(paramTypeNames == null || declaringTypeName == null) return null;
212
281
Lines 257-263 Link Here
257
326
258
		// default parameters name
327
		// default parameters name
259
		if(parameters == null) {
328
		if(parameters == null) {
260
			parameters = createDefaultParameterNames(length);
329
			parameters = CompletionEngine.createDefaultParameterNames(length);
261
		}
330
		}
262
331
263
		return parameters;
332
		return parameters;
Lines 1206-1211 Link Here
1206
	public void setFlags(int flags) {
1275
	public void setFlags(int flags) {
1207
		this.flags = flags;
1276
		this.flags = flags;
1208
	}
1277
	}
1278
	
1279
	public void setHasNoParameterNamesFromIndex(boolean hasNoParameterNamesFromIndex) {
1280
		this.hasNoParameterNamesFromIndex = hasNoParameterNamesFromIndex;
1281
	}
1209
1282
1210
	/**
1283
	/**
1211
	 * Returns the required completion proposals.
1284
	 * Returns the required completion proposals.
Lines 1312-1318 Link Here
1312
					} catch(IllegalArgumentException e) {
1385
					} catch(IllegalArgumentException e) {
1313
						// protection for invalid signature
1386
						// protection for invalid signature
1314
						if(this.parameterTypeNames != null) {
1387
						if(this.parameterTypeNames != null) {
1315
							this.parameterNames =  createDefaultParameterNames(this.parameterTypeNames.length);
1388
							this.parameterNames =  CompletionEngine.createDefaultParameterNames(this.parameterTypeNames.length);
1389
						} else {
1390
							this.parameterNames = null;
1391
						}
1392
					}
1393
					break;
1394
				case ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION:
1395
					try {
1396
						this.parameterNames = findConstructorParameterNames(
1397
								this.declarationPackageName,
1398
								this.declarationTypeName,
1399
								CharOperation.lastSegment(this.declarationTypeName, '.'),
1400
								Signature.getParameterTypes(this.originalSignature == null ? this.signature : this.originalSignature));
1401
					} catch(IllegalArgumentException e) {
1402
						// protection for invalid signature
1403
						if(this.parameterTypeNames != null) {
1404
							this.parameterNames =  CompletionEngine.createDefaultParameterNames(this.parameterTypeNames.length);
1316
						} else {
1405
						} else {
1317
							this.parameterNames = null;
1406
							this.parameterNames = null;
1318
						}
1407
						}
Lines 1329-1335 Link Here
1329
					} catch(IllegalArgumentException e) {
1418
					} catch(IllegalArgumentException e) {
1330
						// protection for invalid signature
1419
						// protection for invalid signature
1331
						if(this.parameterTypeNames != null) {
1420
						if(this.parameterTypeNames != null) {
1332
							this.parameterNames =  createDefaultParameterNames(this.parameterTypeNames.length);
1421
							this.parameterNames =  CompletionEngine.createDefaultParameterNames(this.parameterTypeNames.length);
1422
						} else {
1423
							this.parameterNames = null;
1424
						}
1425
					}
1426
					break;
1427
				case CONSTRUCTOR_INVOCATION:
1428
					try {
1429
						this.parameterNames = findConstructorParameterNames(
1430
								this.declarationPackageName,
1431
								this.declarationTypeName,
1432
								this.name,
1433
								Signature.getParameterTypes(this.originalSignature == null ? this.signature : this.originalSignature));
1434
					} catch(IllegalArgumentException e) {
1435
						// protection for invalid signature
1436
						if(this.parameterTypeNames != null) {
1437
							this.parameterNames =  CompletionEngine.createDefaultParameterNames(this.parameterTypeNames.length);
1333
						} else {
1438
						} else {
1334
							this.parameterNames = null;
1439
							this.parameterNames = null;
1335
						}
1440
						}
Lines 1345-1351 Link Here
1345
					} catch(IllegalArgumentException e) {
1450
					} catch(IllegalArgumentException e) {
1346
						// protection for invalid signature
1451
						// protection for invalid signature
1347
						if(this.parameterTypeNames != null) {
1452
						if(this.parameterTypeNames != null) {
1348
							this.parameterNames =  createDefaultParameterNames(this.parameterTypeNames.length);
1453
							this.parameterNames =  CompletionEngine.createDefaultParameterNames(this.parameterTypeNames.length);
1349
						} else {
1454
						} else {
1350
							this.parameterNames = null;
1455
							this.parameterNames = null;
1351
						}
1456
						}
Lines 1623-1628 Link Here
1623
			case CompletionProposal.FIELD_REF_WITH_CASTED_RECEIVER :
1728
			case CompletionProposal.FIELD_REF_WITH_CASTED_RECEIVER :
1624
				buffer.append("FIELD_REF_WITH_CASTED_RECEIVER"); //$NON-NLS-1$
1729
				buffer.append("FIELD_REF_WITH_CASTED_RECEIVER"); //$NON-NLS-1$
1625
				break;
1730
				break;
1731
			case CompletionProposal.CONSTRUCTOR_INVOCATION :
1732
				buffer.append("CONSTRUCTOR_INVOCATION"); //$NON-NLS-1$
1733
				break;
1734
			case CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION :
1735
				buffer.append("ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION"); //$NON-NLS-1$
1736
				break;
1626
			default :
1737
			default :
1627
				buffer.append("PROPOSAL"); //$NON-NLS-1$
1738
				buffer.append("PROPOSAL"); //$NON-NLS-1$
1628
				break;
1739
				break;
(-)codeassist/org/eclipse/jdt/internal/codeassist/ISearchRequestor.java (-1 / +13 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2006 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 20-25 Link Here
20
 * to the raw name environment results before answering them to the UI.
20
 * to the raw name environment results before answering them to the UI.
21
 */
21
 */
22
public interface ISearchRequestor {
22
public interface ISearchRequestor {
23
	public void acceptConstructor(
24
						int modifiers,
25
						char[] simpleTypeName,
26
						int parameterCount,
27
						char[] signature,
28
						char[][] parameterTypes,
29
						char[][] parameterNames,
30
						int typeModifiers,
31
						char[] packageName,
32
						int extraFlags,
33
						String path,
34
						AccessRestriction access);
23
	/**
35
	/**
24
	 * One result of the search consists of a new type.
36
	 * One result of the search consists of a new type.
25
	 *
37
	 *
(-)codeassist/org/eclipse/jdt/internal/codeassist/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/eval/IEvaluationContext.java (+40 lines)
Lines 184-189 Link Here
184
	 * <p>
184
	 * <p>
185
	 * Note that code completion does not involve evaluation.
185
	 * Note that code completion does not involve evaluation.
186
	 * <p>
186
	 * <p>
187
	 * <p>
188
	 * If {@link IProgressMonitor} is not <code>null</code> then some proposals which
189
	 * can be very long to compute are proposed. To avoid that the code assist operation
190
	 * take too much time a {@link IProgressMonitor} which automatically cancel the code
191
	 * assist operation when a specified amount of time is reached could be used.
192
	 * 
193
	 * <pre>
194
	 * new IProgressMonitor() {
195
	 *     private final static int TIMEOUT = 500; //ms
196
	 *     private long endTime;
197
	 *     public void beginTask(String name, int totalWork) {
198
	 *         fEndTime= System.currentTimeMillis() + TIMEOUT;
199
	 *     }
200
	 *     public boolean isCanceled() {
201
	 *         return endTime <= System.currentTimeMillis();
202
	 *     }
203
	 *     ...
204
	 * };
205
	 * </pre>
206
	 * <p>
187
	 *
207
	 *
188
	 * @param codeSnippet the code snippet to complete in
208
	 * @param codeSnippet the code snippet to complete in
189
	 * @param position the character position in the code snippet to complete at,
209
	 * @param position the character position in the code snippet to complete at,
Lines 252-257 Link Here
252
	 * <p>
272
	 * <p>
253
	 * Note that code completion does not involve evaluation.
273
	 * Note that code completion does not involve evaluation.
254
	 * <p>
274
	 * <p>
275
	 * <p>
276
	 * If {@link IProgressMonitor} is not <code>null</code> then some proposals which
277
	 * can be very long to compute are proposed. To avoid that the code assist operation
278
	 * take too much time a {@link IProgressMonitor} which automatically cancel the code
279
	 * assist operation when a specified amount of time is reached could be used.
280
	 * 
281
	 * <pre>
282
	 * new IProgressMonitor() {
283
	 *     private final static int TIMEOUT = 500; //ms
284
	 *     private long endTime;
285
	 *     public void beginTask(String name, int totalWork) {
286
	 *         fEndTime= System.currentTimeMillis() + TIMEOUT;
287
	 *     }
288
	 *     public boolean isCanceled() {
289
	 *         return endTime <= System.currentTimeMillis();
290
	 *     }
291
	 *     ...
292
	 * };
293
	 * </pre>
294
	 * <p>
255
	 *
295
	 *
256
	 * @param codeSnippet the code snippet to complete in
296
	 * @param codeSnippet the code snippet to complete in
257
	 * @param position the character position in the code snippet to complete at,
297
	 * @param position the character position in the code snippet to complete at,
(-)model/org/eclipse/jdt/core/CompletionProposal.java (-3 / +91 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2008 IBM Corporation and others.
2
 * Copyright (c) 2004, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 55-61 Link Here
55
	/**
55
	/**
56
	 * Completion is a declaration of an anonymous class.
56
	 * Completion is a declaration of an anonymous class.
57
	 * This kind of completion might occur in a context like
57
	 * This kind of completion might occur in a context like
58
	 * <code>"new List^;"</code> and complete it to
58
	 * <code>"new List(^;"</code> and complete it to
59
	 * <code>"new List() {}"</code>.
59
	 * <code>"new List() {}"</code>.
60
	 * <p>
60
	 * <p>
61
	 * The following additional context information is available
61
	 * The following additional context information is available
Lines 792-797 Link Here
792
	 * @since 3.4
792
	 * @since 3.4
793
	 */
793
	 */
794
	public static final int FIELD_REF_WITH_CASTED_RECEIVER = 25;
794
	public static final int FIELD_REF_WITH_CASTED_RECEIVER = 25;
795
	
796
	/**
797
	 * Completion is a reference to a constructor.
798
	 * This kind of completion might occur in a context like
799
	 * <code>"new Lis"</code> and complete it to
800
	 * <code>"new List();"</code> if List is a class that is not abstract.
801
	 * <p>
802
	 * The following additional context information is available
803
	 * for this kind of completion proposal at little extra cost:
804
	 * <ul>
805
	 * <li>{@link #getDeclarationSignature()} -
806
	 * the type signature of the type that declares the constructor that is referenced
807
	 * </li>
808
	 * <li>{@link #getFlags()} -
809
	 * the modifiers flags of the constructor that is referenced
810
	 * </li>
811
	 * <li>{@link #getName()} -
812
	 * the simple name of the constructor that is referenced
813
	 * </li>
814
	 * <li>{@link #getSignature()} -
815
	 * the method signature of the constructor that is referenced
816
	 * </li>
817
	 * </ul>
818
	 * </p>
819
	 * <p>
820
	 * This kind of proposal could require a long computation, so they are computed only if completion operation is called with a {@link IProgressMonitor}
821
	 * (eg. {@link ICodeAssist#codeComplete(int, CompletionRequestor, IProgressMonitor)}).<br>
822
	 * This kind of proposal is always is only proposals with a {@link #TYPE_REF} required proposal, so this kind of required proposal must be allowed:
823
	 * <code>requestor.setAllowsRequiredProposals(CONSTRUCTOR_INVOCATION, TYPE_REF, true)</code>.
824
	 * </p>
825
	 *
826
	 * @see #getKind()
827
	 * @see CompletionRequestor#setAllowsRequiredProposals(int, int, boolean)
828
	 * 
829
	 * @since 3.5
830
	 */
831
	public static final int CONSTRUCTOR_INVOCATION = 26;
832
	
833
	/**
834
	 * Completion is a reference of a constructor of an anonymous class.
835
	 * This kind of completion might occur in a context like
836
	 * <code>"new Lis^;"</code> and complete it to
837
	 * <code>"new List() {}"</code> if List is an interface or abstract class.
838
	 * <p>
839
	 * The following additional context information is available
840
	 * for this kind of completion proposal at little extra cost:
841
	 * <ul>
842
	 * <li>{@link #getDeclarationSignature()} -
843
	 * the type signature of the type being implemented or subclassed
844
	 * </li>
845
	 * <li>{@link #getDeclarationKey()} -
846
	 * the type unique key of the type being implemented or subclassed
847
	 * </li>
848
	 * <li>{@link #getSignature()} -
849
	 * the method signature of the constructor that is referenced
850
	 * </li>
851
	 * <li>{@link #getKey()} -
852
	 * the method unique key of the constructor that is referenced
853
	 * if the declaring type is not an interface
854
	 * </li>
855
	 * <li>{@link #getFlags()} -
856
	 * the modifiers flags of the constructor that is referenced
857
	 * </li>
858
	 * </ul>
859
	 * </p>
860
	 * <p>
861
	 * This kind of proposal could require a long computation, so they are computed only if completion operation is called with a {@link IProgressMonitor}
862
	 * (eg. {@link ICodeAssist#codeComplete(int, CompletionRequestor, IProgressMonitor)})<br>
863
	 * This kind of proposal is always is only proposals with a {@link #TYPE_REF} required proposal, so this kind of required proposal must be allowed:
864
	 * <code>requestor.setAllowsRequiredProposals(CONSTRUCTOR_INVOCATION, TYPE_REF, true)</code>.
865
	 * </p>
866
	 *
867
	 * @see #getKind()
868
	 * @see CompletionRequestor#setAllowsRequiredProposals(int, int, boolean)
869
	 * 
870
	 * @since 3.5
871
	 */
872
	public static final int ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION = 27;
795
873
796
	/**
874
	/**
797
	 * First valid completion kind.
875
	 * First valid completion kind.
Lines 805-811 Link Here
805
	 *
883
	 *
806
	 * @since 3.1
884
	 * @since 3.1
807
	 */
885
	 */
808
	protected static final int LAST_KIND = FIELD_REF_WITH_CASTED_RECEIVER;
886
	protected static final int LAST_KIND = ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION;
809
887
810
	/**
888
	/**
811
	 * Creates a basic completion proposal. All instance
889
	 * Creates a basic completion proposal. All instance
Lines 1463-1468 Link Here
1463
	 *    <li><code>TYPE_REF</code></li>
1541
	 *    <li><code>TYPE_REF</code></li>
1464
	 *   </ul>
1542
	 *   </ul>
1465
	 *  </li>
1543
	 *  </li>
1544
	 *  <li><code>CONSTRUCTOR_INVOCATION</code> - The allowed required proposals for this kind are:
1545
	 *   <ul>
1546
	 *    <li><code>TYPE_REF</code></li>
1547
	 *   </ul>
1548
	 *  </li>
1549
	 *  <li><code>ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION</code> - The allowed required proposals for this kind are:
1550
	 *   <ul>
1551
	 *    <li><code>TYPE_REF</code></li>
1552
	 *   </ul>
1553
	 *  </li>
1466
	 * </ul>
1554
	 * </ul>
1467
	 * </p>
1555
	 * </p>
1468
	 * <p>
1556
	 * <p>
(-)model/org/eclipse/jdt/core/ICodeAssist.java (+40 lines)
Lines 92-97 Link Here
92
	 * An <code>offset</code> of -1 indicates to code assist at the beginning of this
92
	 * An <code>offset</code> of -1 indicates to code assist at the beginning of this
93
	 * compilation unit.
93
	 * compilation unit.
94
	 * <p>
94
	 * <p>
95
	 * <p>
96
	 * If {@link IProgressMonitor} is not <code>null</code> then some proposals which
97
	 * can be very long to compute are proposed. To avoid that the code assist operation
98
	 * take too much time a {@link IProgressMonitor} which automatically cancel the code
99
	 * assist operation when a specified amount of time is reached could be used.
100
	 * 
101
	 * <pre>
102
	 * new IProgressMonitor() {
103
	 *     private final static int TIMEOUT = 500; //ms
104
	 *     private long endTime;
105
	 *     public void beginTask(String name, int totalWork) {
106
	 *         fEndTime= System.currentTimeMillis() + TIMEOUT;
107
	 *     }
108
	 *     public boolean isCanceled() {
109
	 *         return endTime <= System.currentTimeMillis();
110
	 *     }
111
	 *     ...
112
	 * };
113
	 * </pre>
114
	 * <p>
95
	 *
115
	 *
96
	 * @param offset the given offset position
116
	 * @param offset the given offset position
97
	 * @param requestor the given completion requestor
117
	 * @param requestor the given completion requestor
Lines 180-185 Link Here
180
	 * Note that if a working copy is empty, it will be as if the original compilation
200
	 * Note that if a working copy is empty, it will be as if the original compilation
181
	 * unit had been deleted.
201
	 * unit had been deleted.
182
	 * </p>
202
	 * </p>
203
	 * <p>
204
	 * If {@link IProgressMonitor} is not <code>null</code> then some proposals which
205
	 * can be very long to compute are proposed. To avoid that the code assist operation
206
	 * take too much time a {@link IProgressMonitor} which automatically cancel the code
207
	 * assist operation when a specified amount of time is reached could be used.
208
	 * 
209
	 * <pre>
210
	 * new IProgressMonitor() {
211
	 *     private final static int TIMEOUT = 500; //ms
212
	 *     private long endTime;
213
	 *     public void beginTask(String name, int totalWork) {
214
	 *         fEndTime= System.currentTimeMillis() + TIMEOUT;
215
	 *     }
216
	 *     public boolean isCanceled() {
217
	 *         return endTime <= System.currentTimeMillis();
218
	 *     }
219
	 *     ...
220
	 * };
221
	 * </pre>
222
	 * <p>
183
	 *
223
	 *
184
	 * @param offset the given offset position
224
	 * @param offset the given offset position
185
	 * @param requestor the given completion requestor
225
	 * @param requestor the given completion requestor
(-)model/org/eclipse/jdt/core/IType.java (+40 lines)
Lines 161-166 Link Here
161
	 * If the type has access to its source code and the insertion position is valid,
161
	 * If the type has access to its source code and the insertion position is valid,
162
	 * then completion is performed against the source. Otherwise the completion is performed
162
	 * then completion is performed against the source. Otherwise the completion is performed
163
	 * against the type structure and the given locals variables.
163
	 * against the type structure and the given locals variables.
164
	 * <p>
165
	 * If {@link IProgressMonitor} is not <code>null</code> then some proposals which
166
	 * can be very long to compute are proposed. To avoid that the code assist operation
167
	 * take too much time a {@link IProgressMonitor} which automatically cancel the code
168
	 * assist operation when a specified amount of time is reached could be used.
169
	 * 
170
	 * <pre>
171
	 * new IProgressMonitor() {
172
	 *     private final static int TIMEOUT = 500; //ms
173
	 *     private long endTime;
174
	 *     public void beginTask(String name, int totalWork) {
175
	 *         fEndTime= System.currentTimeMillis() + TIMEOUT;
176
	 *     }
177
	 *     public boolean isCanceled() {
178
	 *         return endTime <= System.currentTimeMillis();
179
	 *     }
180
	 *     ...
181
	 * };
182
	 * </pre>
183
	 * <p>
164
	 *
184
	 *
165
	 * @param snippet the code snippet
185
	 * @param snippet the code snippet
166
	 * @param insertion the position with in source where the snippet
186
	 * @param insertion the position with in source where the snippet
Lines 251-256 Link Here
251
	 * then completion is performed against the source. Otherwise the completion is performed
271
	 * then completion is performed against the source. Otherwise the completion is performed
252
	 * against the type structure and the given locals variables.
272
	 * against the type structure and the given locals variables.
253
	 * </p>
273
	 * </p>
274
	 * <p>
275
	 * If {@link IProgressMonitor} is not <code>null</code> then some proposals which
276
	 * can be very long to compute are proposed. To avoid that the code assist operation
277
	 * take too much time a {@link IProgressMonitor} which automatically cancel the code
278
	 * assist operation when a specified amount of time is reached could be used.
279
	 * 
280
	 * <pre>
281
	 * new IProgressMonitor() {
282
	 *     private final static int TIMEOUT = 500; //ms
283
	 *     private long endTime;
284
	 *     public void beginTask(String name, int totalWork) {
285
	 *         fEndTime= System.currentTimeMillis() + TIMEOUT;
286
	 *     }
287
	 *     public boolean isCanceled() {
288
	 *         return endTime <= System.currentTimeMillis();
289
	 *     }
290
	 *     ...
291
	 * };
292
	 * </pre>
293
	 * <p>
254
	 *
294
	 *
255
	 * @param snippet the code snippet
295
	 * @param snippet the code snippet
256
	 * @param insertion the position with in source where the snippet
296
	 * @param insertion the position with in source where the snippet
(-)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[] patternPkg, char[] patternTypeName, int matchRule, char[] pkg, char[] typeName) {
435
		
436
		boolean isCaseSensitive = (matchRule & SearchPattern.R_CASE_SENSITIVE) != 0;
437
		
438
		if (patternPkg != null && !CharOperation.equals(patternPkg, pkg, true))
439
			return false;
440
		
441
		if (patternTypeName != 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
				patternTypeName = CharOperation.toLowerCase(patternTypeName);
446
			}
447
			boolean matchFirstChar = !isCaseSensitive || patternTypeName[0] == typeName[0];
448
			switch(matchMode) {
449
				case SearchPattern.R_EXACT_MATCH :
450
					return matchFirstChar && CharOperation.equals(patternTypeName, typeName, isCaseSensitive);
451
				case SearchPattern.R_PREFIX_MATCH :
452
					return matchFirstChar && CharOperation.prefixEquals(patternTypeName, typeName, isCaseSensitive);
453
				case SearchPattern.R_PATTERN_MATCH :
454
					return CharOperation.match(patternTypeName, typeName, 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(patternTypeName, typeName, false)) {
460
						return true;
461
					}
462
					return !isCaseSensitive && matchFirstChar && CharOperation.prefixEquals(patternTypeName, typeName, false);
463
				case SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH:
464
					return matchFirstChar && CharOperation.camelCaseMatch(patternTypeName, typeName, 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.searchAllConstructorDeclarations(char[], char[], int, IJavaSearchScope, IRestrictedAccessConstructorRequestor, 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(packageName, typeName, validatedTypeMatchRule, packageDeclaration, simpleName) && !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(packageName, typeName, validatedTypeMatchRule, packageDeclaration, typeDeclaration.name)) {
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(packageName, typeName, validatedTypeMatchRule, packageDeclaration, typeDeclaration.name)) {
797
										Argument[] arguments = constructorDeclaration.arguments;
798
										int length = arguments == null ? 0 : arguments.length;
799
										char[][] parameterNames = new char[length][];
800
										char[][] parameterTypes = new char[length][];
801
										for (int l = 0; l < length; l++) {
802
											Argument argument = arguments[l];
803
											parameterNames[l] = argument.name;
804
											if (argument.type instanceof SingleTypeReference) {
805
												parameterTypes[l] = ((SingleTypeReference)argument.type).token;
806
											} else {
807
												parameterTypes[l] = CharOperation.concatWith(((QualifiedTypeReference)argument.type).tokens, '.');
808
											}
809
										}
810
										
811
										TypeDeclaration enclosing = typeDeclaration.enclosingType;
812
										char[][] enclosingTypeNames = CharOperation.NO_CHAR_CHAR;
813
										while (enclosing != null) {
814
											enclosingTypeNames = CharOperation.arrayConcat(new char[][] {enclosing.name}, enclosingTypeNames);
815
											if ((enclosing.bits & ASTNode.IsMemberType) != 0) {
816
												enclosing = enclosing.enclosingType;
817
											} else {
818
												enclosing = null;
819
											}
820
										}
821
										
822
										nameRequestor.acceptConstructor(
823
												constructorDeclaration.modifiers,
824
												typeName,
825
												parameterNames.length,
826
												null, // signature is not used for source type
827
												parameterTypes,
828
												parameterNames,
829
												typeDeclaration.modifiers,
830
												packageDeclaration,
831
												ExtraFlags.getExtraFlags(typeDeclaration),
832
												path,
833
												null);
834
									}
835
									return false; // no need to find constructors from local/anonymous type
836
								}
837
								public boolean visit(TypeDeclaration typeDeclaration, BlockScope blockScope) {
838
									return false; 
839
								}
840
								
841
								private boolean visit(TypeDeclaration typeDeclaration) {
842
									if(this.declaringTypes.length <= ++this.declaringTypesPtr) {
843
										int length = this.declaringTypesPtr;
844
										System.arraycopy(this.declaringTypes, 0, this.declaringTypes = new TypeDeclaration[length * 2 + 1], 0, length);
845
									}
846
									this.declaringTypes[this.declaringTypesPtr] = typeDeclaration;
847
									return true;
848
								}
849
								
850
								public boolean visit(TypeDeclaration typeDeclaration, CompilationUnitScope s) {
851
									return visit(typeDeclaration);
852
								}
853
								
854
								public boolean visit(TypeDeclaration memberTypeDeclaration, ClassScope s) {
855
									return visit(memberTypeDeclaration);
856
								}
857
							}
858
							parsedUnit.traverse(new AllConstructorDeclarationsVisitor(), parsedUnit.scope);
859
						}
860
					}
861
					if (progressMonitor != null) {
862
						if (progressMonitor.isCanceled()) throw new OperationCanceledException();
863
						progressMonitor.worked(1);
864
					}
865
				}
866
			}
867
		} finally {
868
			if (progressMonitor != null) {
869
				progressMonitor.done();
870
			}
871
		}
872
	}
508
873
509
	/**
874
	/**
510
	 * Searches for all secondary types in the given scope.
875
	 * Searches for all secondary types in the given scope.
(-)model/org/eclipse/jdt/internal/core/SearchableEnvironment.java (-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/matching/ConstructorPattern.java (-20 / +258 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 '/' Modifiers
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
	
120
	int typeNameLength = typeName == null ? 0 : typeName.length;
121
	int packageNameLength = packageName == null ? 0 : packageName.length;
122
	int countCharsLength = countChars.length;
123
	int parameterTypesLength = signature == null ? (parameterTypesChars == null ? 0 : parameterTypesChars.length): signature.length;
124
	int parameterNamesLength = parameterNamesChars == null ? 0 : parameterNamesChars.length;
125
	
126
	int resultLength = typeNameLength + countCharsLength + 3; // SEPARATOR=1 + TypeModifers=2
127
	if (!isMemberType) {
128
		resultLength += packageNameLength + 1; // SEPARATOR=1
129
		if (argCount >= 0) {
130
			resultLength += 3; // SEPARATOR=1 + Modifiers=2
131
		}
132
		
133
		if (argCount > 0) {
134
			resultLength += parameterTypesLength + parameterNamesLength + 2; //SEPARATOR=1 + SEPARATOR=1
135
		}
136
	}
137
	
138
	char[] result = new char[resultLength];
139
	
140
	int pos = 0;
141
	if (typeNameLength > 0) {
142
		System.arraycopy(typeName, 0, result, pos, typeNameLength);
143
		pos += typeNameLength;
144
	}
145
	
146
	if (countCharsLength > 0) {
147
		System.arraycopy(countChars, 0, result, pos, countCharsLength);
148
		pos += countCharsLength;
149
	}
150
	
151
	int typeModifiersWithExtraFlags = typeModifiers | encodeExtraFlags(extraFlags);
152
	result[pos++] = SEPARATOR;
153
	result[pos++] = (char) typeModifiersWithExtraFlags;
154
	result[pos++] = (char) (typeModifiersWithExtraFlags>>16);
155
	
156
	if (!isMemberType) {
157
		result[pos++] = SEPARATOR;
158
		if (packageNameLength > 0) {
159
			System.arraycopy(packageName, 0, result, pos, packageNameLength);
160
			pos += packageNameLength;
161
		}
162
		
163
		if (argCount == 0) {
164
			result[pos++] = SEPARATOR;
165
			result[pos++] = (char) modifiers;
166
			result[pos++] = (char) (modifiers>>16);
167
		} else if (argCount > 0) {
168
			result[pos++] = SEPARATOR;
169
			if (parameterTypesLength > 0) {
170
				if (signature == null) {
171
					System.arraycopy(parameterTypesChars, 0, result, pos, parameterTypesLength);
172
				} else {
173
					System.arraycopy(CharOperation.replaceOnCopy(signature, SEPARATOR, '\\'), 0, result, pos, parameterTypesLength);
174
				}
175
				pos += parameterTypesLength;
176
			}
177
			
178
			result[pos++] = SEPARATOR;
179
			if (parameterNamesLength > 0) {
180
				System.arraycopy(parameterNamesChars, 0, result, pos, parameterNamesLength);
181
				pos += parameterNamesLength;
182
			}
183
			
184
			result[pos++] = SEPARATOR;
185
			result[pos++] = (char) modifiers;
186
			result[pos++] = (char) (modifiers>>16);
187
		}
188
		
189
	}
190
	
191
	return result;
192
}
193
public static char[] createDefaultDeclarationIndexKey(
194
		char[] typeName,
195
		char[] packageName,
196
		int typeModifiers,
197
		int extraFlags) {
198
	return createDeclarationIndexKey(
199
			typeName,
200
			-1, // used to identify default constructor
201
			null,
202
			null,
203
			null,
204
			0, //
205
			packageName,
206
			typeModifiers,
207
			extraFlags);
208
}
209
55
/**
210
/**
56
 * Constructor entries are encoded as TypeName '/' Arity:
211
 * Constructor entries are encoded as TypeName '/' Arity:
57
 * e.g. 'X/0'
212
 * e.g. 'X/0'
Lines 62-68 Link Here
62
		: ("/" + String.valueOf(argCount)).toCharArray(); //$NON-NLS-1$
217
		: ("/" + String.valueOf(argCount)).toCharArray(); //$NON-NLS-1$
63
	return CharOperation.concat(typeName, countChars);
218
	return CharOperation.concat(typeName, countChars);
64
}
219
}
65
220
static int decodeExtraFlags(int modifiersWithExtraFlags) {
221
	int extraFlags = 0;
222
	
223
	if ((modifiersWithExtraFlags & ASTNode.Bit28) != 0) {
224
		extraFlags |= ExtraFlags.ParameterTypesStoredAsSignature;
225
	}
226
	
227
	if ((modifiersWithExtraFlags & ASTNode.Bit29) != 0) {
228
		extraFlags |= ExtraFlags.IsLocalType;
229
	}
230
	
231
	if ((modifiersWithExtraFlags & ASTNode.Bit30) != 0) {
232
		extraFlags |= ExtraFlags.IsMemberType;
233
	}
234
	
235
	if ((modifiersWithExtraFlags & ASTNode.Bit31) != 0) {
236
		extraFlags |= ExtraFlags.HasNonPrivateStaticMemberTypes;
237
	}
238
	
239
	return extraFlags;
240
}
241
static int decodeModifers(int modifiersWithExtraFlags) {
242
	return modifiersWithExtraFlags & ~(ASTNode.Bit31 | ASTNode.Bit30 | ASTNode.Bit29 | ASTNode.Bit28);
243
}
244
private static int encodeExtraFlags(int extraFlags) {
245
	int encodedExtraFlags = 0;
246
	
247
	if ((extraFlags & ExtraFlags.ParameterTypesStoredAsSignature) != 0) {
248
		encodedExtraFlags |= ASTNode.Bit28;
249
	}
250
	
251
	if ((extraFlags & ExtraFlags.IsLocalType) != 0) {
252
		encodedExtraFlags |= ASTNode.Bit29;
253
	}
254
	
255
	if ((extraFlags & ExtraFlags.IsMemberType) != 0) {
256
		encodedExtraFlags |= ASTNode.Bit30;
257
	}
258
	if ((extraFlags & ExtraFlags.HasNonPrivateStaticMemberTypes) != 0) {
259
		encodedExtraFlags |= ASTNode.Bit31;
260
	}
261
	
262
	return encodedExtraFlags;
263
}
264
private static char[] getTypeErasure(char[] typeName) {
265
	int index;
266
	if ((index = CharOperation.indexOf('<', typeName)) == -1) return typeName;
267
	
268
	int length = typeName.length;
269
	char[] typeErasurename = new char[length - 2];
270
	
271
	System.arraycopy(typeName, 0, typeErasurename, 0, index);
272
	
273
	int depth = 1;
274
	for (int i = index + 1; i < length; i++) {
275
		switch (typeName[i]) {
276
			case '<':
277
				depth++;
278
				break;
279
			case '>':
280
				depth--;
281
				break;
282
			default:
283
				if (depth == 0) {
284
					typeErasurename[index++] = typeName[i];
285
				}
286
				break;
287
		}
288
	}
289
	
290
	System.arraycopy(typeErasurename, 0, typeErasurename = new char[index], 0, index);
291
	return typeErasurename;
292
}
66
ConstructorPattern(int matchRule) {
293
ConstructorPattern(int matchRule) {
67
	super(CONSTRUCTOR_PATTERN, matchRule);
294
	super(CONSTRUCTOR_PATTERN, matchRule);
68
}
295
}
Lines 225-245 Link Here
225
	}
452
	}
226
	if (hasConstructorArguments())  this.mustResolve = true;
453
	if (hasConstructorArguments())  this.mustResolve = true;
227
}
454
}
455
228
public void decodeIndexKey(char[] key) {
456
public void decodeIndexKey(char[] key) {
229
	int last = key.length - 1;
457
	int last = key.length - 1;
230
	this.parameterCount = 0;
458
	int slash = CharOperation.indexOf(SEPARATOR, key, 0);
231
	this.declaringSimpleName = null;
459
	this.declaringSimpleName = CharOperation.subarray(key, 0, slash);
232
	int power = 1;
460
	
233
	for (int i=last; i>=0; i--) {
461
	int start = slash + 1;
234
		if (key[i] == SEPARATOR) {
462
	slash = CharOperation.indexOf(SEPARATOR, key, start);
235
			System.arraycopy(key, 0, this.declaringSimpleName = new char[i], 0, i);
463
	if (slash != -1) {
236
			break;
464
		last = slash - 1;
237
		}
465
	}
238
		if (i == last) {
466
	
239
			this.parameterCount = key[i] - '0';
467
	boolean isDefaultConstructor = key[last] == '#';
240
		} else {
468
	if (isDefaultConstructor) {
241
			power *= 10;
469
		this.parameterCount = -1;
242
			this.parameterCount += power * (key[i] - '0');
470
	} else {
471
		this.parameterCount = 0;
472
		int power = 1;
473
		for (int i = last; i >= start; i--) {
474
			if (i == last) {
475
				this.parameterCount = key[i] - '0';
476
			} else {
477
				power *= 10;
478
				this.parameterCount += power * (key[i] - '0');
479
			}
243
		}
480
		}
244
	}
481
	}
245
}
482
}
Lines 262-268 Link Here
262
public boolean matchesDecodedKey(SearchPattern decodedPattern) {
499
public boolean matchesDecodedKey(SearchPattern decodedPattern) {
263
	ConstructorPattern pattern = (ConstructorPattern) decodedPattern;
500
	ConstructorPattern pattern = (ConstructorPattern) decodedPattern;
264
501
265
	return (this.parameterCount == pattern.parameterCount || this.parameterCount == -1 || this.varargs)
502
	return pattern.parameterCount != -1
503
		&& (this.parameterCount == pattern.parameterCount || this.parameterCount == -1 || this.varargs)
266
		&& matchesName(this.declaringSimpleName, pattern.declaringSimpleName);
504
		&& matchesName(this.declaringSimpleName, pattern.declaringSimpleName);
267
}
505
}
268
protected boolean mustResolve() {
506
protected boolean mustResolve() {
Lines 280-291 Link Here
280
518
281
	switch(getMatchMode()) {
519
	switch(getMatchMode()) {
282
		case R_EXACT_MATCH :
520
		case R_EXACT_MATCH :
283
			if (this.declaringSimpleName != null && this.parameterCount >= 0 && !this.varargs)
521
			if (this.declaringSimpleName != null && this.parameterCount >= 0 && !this.varargs) {
284
				key = createIndexKey(this.declaringSimpleName, this.parameterCount);
522
				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
			}
523
			}
524
			matchRule &= ~R_EXACT_MATCH;
525
			matchRule |= R_PREFIX_MATCH;
289
			break;
526
			break;
290
		case R_PREFIX_MATCH :
527
		case R_PREFIX_MATCH :
291
			// do a prefix query with the declaringSimpleName
528
			// do a prefix query with the declaringSimpleName
Lines 295-300 Link Here
295
				key = createIndexKey(this.declaringSimpleName == null ? ONE_STAR : this.declaringSimpleName, this.parameterCount);
532
				key = createIndexKey(this.declaringSimpleName == null ? ONE_STAR : this.declaringSimpleName, this.parameterCount);
296
			else if (this.declaringSimpleName != null && this.declaringSimpleName[this.declaringSimpleName.length - 1] != '*')
533
			else if (this.declaringSimpleName != null && this.declaringSimpleName[this.declaringSimpleName.length - 1] != '*')
297
				key = CharOperation.concat(this.declaringSimpleName, ONE_STAR, SEPARATOR);
534
				key = CharOperation.concat(this.declaringSimpleName, ONE_STAR, SEPARATOR);
535
			key = CharOperation.concat(key, ONE_STAR);
298
			// else do a pattern query with just the declaringSimpleName
536
			// else do a pattern query with just the declaringSimpleName
299
			break;
537
			break;
300
		case R_REGEXP_MATCH :
538
		case R_REGEXP_MATCH :
(-)search/org/eclipse/jdt/internal/core/search/matching/ConstructorDeclarationPattern.java (+192 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.compiler.classfmt.ClassFileConstants;
19
import org.eclipse.jdt.internal.core.index.EntryResult;
20
import org.eclipse.jdt.internal.core.index.Index;
21
22
public class ConstructorDeclarationPattern extends ConstructorPattern {
23
	public int extraFlags;
24
	
25
	public int declaringTypeModifiers;
26
	public char[] declaringPackageName;
27
	
28
	public int modifiers;
29
	public char[] signature;
30
	public char[][] parameterTypes;
31
	public char[][] parameterNames;
32
33
public ConstructorDeclarationPattern(char[] declaringPackageName, char[] declaringSimpleName, int matchRule) {
34
	this(matchRule);
35
	this.declaringSimpleName = (this.isCaseSensitive || this.isCamelCase) ? declaringSimpleName : CharOperation.toLowerCase(declaringSimpleName);
36
	this.declaringPackageName = declaringPackageName;
37
	this.findDeclarations = true;
38
	this.findReferences = false;
39
	this.parameterCount = -1;
40
	this.mustResolve = false;
41
}
42
43
ConstructorDeclarationPattern(int matchRule) {
44
	super(matchRule);
45
}
46
public void decodeIndexKey(char[] key) {
47
	int last = key.length - 1;
48
	int slash = CharOperation.indexOf(SEPARATOR, key, 0);
49
	this.declaringSimpleName = CharOperation.subarray(key, 0, slash);
50
	
51
	int start = slash + 1;
52
	slash = CharOperation.indexOf(SEPARATOR, key, start);
53
	last = slash - 1;
54
	
55
	boolean isDefaultConstructor = key[last] == '#';
56
	if (isDefaultConstructor) {
57
		this.parameterCount = -1;
58
	} else {
59
		this.parameterCount = 0;
60
		int power = 1;
61
		for (int i = last; i >= start; i--) {
62
			if (i == last) {
63
				this.parameterCount = key[i] - '0';
64
			} else {
65
				power *= 10;
66
				this.parameterCount += power * (key[i] - '0');
67
			}
68
		}
69
	}
70
	
71
	slash = slash + 3;
72
	last = slash - 1;
73
	
74
	int typeModifiersWithExtraFlags = key[last-1] + (key[last]<<16);
75
	this.declaringTypeModifiers = decodeModifers(typeModifiersWithExtraFlags);
76
	this.extraFlags = decodeExtraFlags(typeModifiersWithExtraFlags);
77
	
78
	// initialize optional fields
79
	this.declaringPackageName = null;
80
	this.modifiers = 0;
81
	this.signature = null;
82
	this.parameterTypes = null;
83
	this.parameterNames = null;
84
	
85
	boolean isMemberType = (this.extraFlags & ExtraFlags.IsMemberType) != 0;
86
	
87
	if (!isMemberType) {
88
		start = slash + 1;
89
		if (this.parameterCount == -1) {
90
			slash = key.length;
91
			last = slash - 1;
92
		} else {
93
			slash = CharOperation.indexOf(SEPARATOR, key, start);
94
		}
95
		last = slash - 1;
96
		
97
		this.declaringPackageName = CharOperation.subarray(key, start, slash);
98
		
99
		start = slash + 1;
100
		if (this.parameterCount == 0) {
101
			slash = slash + 3;
102
			last = slash - 1;
103
			
104
			this.modifiers = key[last-1] + (key[last]<<16);
105
		} else if (this.parameterCount > 0){
106
			slash = CharOperation.indexOf(SEPARATOR, key, start);
107
			last = slash - 1;
108
			
109
			boolean hasParameterStoredAsSignature = (this.extraFlags & ExtraFlags.ParameterTypesStoredAsSignature) != 0;
110
			if (hasParameterStoredAsSignature) {
111
				this.signature  = CharOperation.subarray(key, start, slash);
112
				CharOperation.replace(this.signature , '\\', SEPARATOR);
113
			} else {
114
				this.parameterTypes = CharOperation.splitOn(PARAMETER_SEPARATOR, key, start, slash);
115
			}
116
			start = slash + 1;
117
			slash = CharOperation.indexOf(SEPARATOR, key, start);
118
			last = slash - 1;
119
			
120
			if (slash != start) {
121
				this.parameterNames = CharOperation.splitOn(PARAMETER_SEPARATOR, key, start, slash);
122
			}
123
			
124
			slash = slash + 3;
125
			last = slash - 1;
126
			
127
			this.modifiers = key[last-1] + (key[last]<<16);
128
		} else {
129
			this.modifiers = ClassFileConstants.AccPublic;
130
		}
131
	}
132
	
133
	removeInternalFlags(); // remove internal flags
134
}
135
136
public SearchPattern getBlankPattern() {
137
	return new ConstructorDeclarationPattern(R_EXACT_MATCH | R_CASE_SENSITIVE);
138
}
139
public char[][] getIndexCategories() {
140
	return DECL_CATEGORIES;
141
}
142
public boolean matchesDecodedKey(SearchPattern decodedPattern) {
143
	ConstructorDeclarationPattern pattern = (ConstructorDeclarationPattern) decodedPattern;
144
	
145
	// only top level types
146
	if ((pattern.extraFlags & ExtraFlags.IsMemberType) != 0) return false;
147
	
148
	// check package - exact match only
149
	if (this.declaringPackageName != null && !CharOperation.equals(this.declaringPackageName, pattern.declaringPackageName, true))
150
		return false;
151
152
	return (this.parameterCount == pattern.parameterCount || this.parameterCount == -1 || this.varargs)
153
		&& matchesName(this.declaringSimpleName, pattern.declaringSimpleName);
154
}
155
public EntryResult[] queryIn(Index index) throws IOException {
156
	char[] key = this.declaringSimpleName; // can be null
157
	int matchRule = getMatchRule();
158
159
	switch(getMatchMode()) {
160
		case R_EXACT_MATCH :
161
			if (this.declaringSimpleName != null && this.parameterCount >= 0 && !this.varargs) {
162
				key = createIndexKey(this.declaringSimpleName, this.parameterCount);
163
			} 
164
			matchRule &= ~R_EXACT_MATCH;
165
			matchRule |= R_PREFIX_MATCH;
166
			break;
167
		case R_PREFIX_MATCH :
168
			// do a prefix query with the declaringSimpleName
169
			break;
170
		case R_PATTERN_MATCH :
171
			if (this.parameterCount >= 0 && !this.varargs)
172
				key = createIndexKey(this.declaringSimpleName == null ? ONE_STAR : this.declaringSimpleName, this.parameterCount);
173
			else if (this.declaringSimpleName != null && this.declaringSimpleName[this.declaringSimpleName.length - 1] != '*')
174
				key = CharOperation.concat(this.declaringSimpleName, ONE_STAR, SEPARATOR);
175
			key = CharOperation.concat(key, ONE_STAR);
176
			// else do a pattern query with just the declaringSimpleName
177
			break;
178
		case R_REGEXP_MATCH :
179
			// TODO (frederic) implement regular expression match
180
			break;
181
		case R_CAMELCASE_MATCH:
182
		case R_CAMELCASE_SAME_PART_COUNT_MATCH:
183
			// do a prefix query with the declaringSimpleName
184
			break;
185
	}
186
187
	return index.query(getIndexCategories(), key, matchRule); // match rule is irrelevant when the key is null
188
}
189
private void removeInternalFlags() {
190
	this.extraFlags = this.extraFlags & ~ExtraFlags.ParameterTypesStoredAsSignature; // ParameterTypesStoredAsSignature is an internal flags only used to decode key
191
}
192
}
(-)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 / +2207 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 25-30 Link Here
25
import org.eclipse.core.runtime.CoreException;
25
import org.eclipse.core.runtime.CoreException;
26
import org.eclipse.core.runtime.IPath;
26
import org.eclipse.core.runtime.IPath;
27
import org.eclipse.core.runtime.IProgressMonitor;
27
import org.eclipse.core.runtime.IProgressMonitor;
28
import org.eclipse.core.runtime.NullProgressMonitor;
28
import org.eclipse.core.runtime.Path;
29
import org.eclipse.core.runtime.Path;
29
import org.eclipse.jdt.core.IAccessRule;
30
import org.eclipse.jdt.core.IAccessRule;
30
import org.eclipse.jdt.core.IClasspathAttribute;
31
import org.eclipse.jdt.core.IClasspathAttribute;
Lines 417-422 Link Here
417
		this.deleteProject("P3");
418
		this.deleteProject("P3");
418
	}
419
	}
419
}
420
}
421
public void testBug6930_01() throws Exception {
422
	Hashtable oldOptions = JavaCore.getOptions();
423
	
424
	try {
425
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL_LIB"}, "bin");
426
		
427
		createFolder("/P/src/p6930");
428
		
429
		this.workingCopies = new ICompilationUnit[3];
430
		
431
		this.workingCopies[1] = getWorkingCopy("/P/src/p6930/AllConstructors01.java",
432
			"package p6930;\n" +
433
			"public class AllConstructors01 {\n" +
434
			"  public AllConstructors01() {}\n" +
435
			"  public AllConstructors01(Object o) {}\n" +
436
			"  public AllConstructors01(int o) {}\n" +
437
			"  public AllConstructors01(Object o, String s) {}\n" +
438
			"}\n"
439
		);
440
		
441
		this.workingCopies[2] = getWorkingCopy("/P/src/p6930/AllConstructors01b.java",
442
			"package p6930;\n" +
443
			"public class AllConstructors01b {\n" +
444
			"}\n"
445
		);
446
		
447
		refresh(p);
448
		
449
		waitUntilIndexesReady();
450
		
451
		this.workingCopies[0] = getWorkingCopy(
452
				"/P/src/test/Test.java",
453
				"package test;"+
454
				"public class Test {\n" +
455
				"  void foo() {\n" +
456
				"    new AllConstructors\n" +
457
				"  }\n" +
458
				"}");
459
460
		// do completion
461
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true);
462
		requestor.allowAllRequiredProposals();
463
		NullProgressMonitor monitor = new NullProgressMonitor();
464
465
	    String str = this.workingCopies[0].getSource();
466
	    String completeBehind = "AllConstructors";
467
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
468
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
469
	    
470
	    assertResults(
471
			"AllConstructors01[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors01;, ()V, AllConstructors01, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
472
			"   AllConstructors01[TYPE_REF]{p6930.AllConstructors01, p6930, Lp6930.AllConstructors01;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
473
			"AllConstructors01[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors01;, (I)V, AllConstructors01, (o), "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
474
			"   AllConstructors01[TYPE_REF]{p6930.AllConstructors01, p6930, Lp6930.AllConstructors01;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
475
			"AllConstructors01[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors01;, (Ljava.lang.Object;)V, AllConstructors01, (o), "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
476
			"   AllConstructors01[TYPE_REF]{p6930.AllConstructors01, p6930, Lp6930.AllConstructors01;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
477
			"AllConstructors01[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors01;, (Ljava.lang.Object;Ljava.lang.String;)V, AllConstructors01, (o, s), "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
478
			"   AllConstructors01[TYPE_REF]{p6930.AllConstructors01, p6930, Lp6930.AllConstructors01;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
479
			"AllConstructors01b[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors01b;, ()V, AllConstructors01b, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
480
			"   AllConstructors01b[TYPE_REF]{p6930.AllConstructors01b, p6930, Lp6930.AllConstructors01b;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}",
481
			requestor.getResults());
482
	} finally {
483
		deleteProject("P");
484
		
485
		JavaCore.setOptions(oldOptions);
486
	}
487
}
488
public void testBug6930_02() throws Exception {
489
	Hashtable oldOptions = JavaCore.getOptions();
490
	
491
	try {
492
		Hashtable options = new Hashtable(oldOptions);
493
		options.put(JavaCore.CODEASSIST_VISIBILITY_CHECK, JavaCore.ENABLED);
494
		JavaCore.setOptions(options);
495
		
496
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL_LIB", "/P/lib6930.jar"}, "bin");
497
		
498
		createJar(new String[] {
499
			"p6930/AllConstructors02.java",
500
			"package p6930;\n" +
501
			"public class AllConstructors02 {\n" +
502
			"  public AllConstructors02() {}\n" +
503
			"  public AllConstructors02(Object o) {}\n" +
504
			"  public AllConstructors02(int o) {}\n" +
505
			"  public AllConstructors02(Object o, String s) {}\n" +
506
			"}",
507
			"p6930/AllConstructors02b.java",
508
			"package p6930;\n" +
509
			"public class AllConstructors02b {\n" +
510
			"}"
511
		}, p.getProject().getLocation().append("lib6930.jar").toOSString());
512
		
513
		refresh(p);
514
		
515
		waitUntilIndexesReady();
516
		
517
		this.workingCopies = new ICompilationUnit[1];
518
		this.workingCopies[0] = getWorkingCopy(
519
				"/P/src/test/Test.java",
520
				"package test;"+
521
				"public class Test {\n" +
522
				"  void foo() {\n" +
523
				"    new AllConstructors\n" +
524
				"  }\n" +
525
				"}");
526
527
		// do completion
528
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true);
529
		requestor.allowAllRequiredProposals();
530
		NullProgressMonitor monitor = new NullProgressMonitor();
531
532
	    String str = this.workingCopies[0].getSource();
533
	    String completeBehind = "AllConstructors";
534
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
535
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
536
	    
537
	    assertResults(
538
			"AllConstructors02[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors02;, ()V, AllConstructors02, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
539
			"   AllConstructors02[TYPE_REF]{p6930.AllConstructors02, p6930, Lp6930.AllConstructors02;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
540
			"AllConstructors02[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors02;, (I)V, AllConstructors02, (o), "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
541
			"   AllConstructors02[TYPE_REF]{p6930.AllConstructors02, p6930, Lp6930.AllConstructors02;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
542
			"AllConstructors02[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors02;, (Ljava.lang.Object;)V, AllConstructors02, (o), "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
543
			"   AllConstructors02[TYPE_REF]{p6930.AllConstructors02, p6930, Lp6930.AllConstructors02;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
544
			"AllConstructors02[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors02;, (Ljava.lang.Object;Ljava.lang.String;)V, AllConstructors02, (o, s), "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
545
			"   AllConstructors02[TYPE_REF]{p6930.AllConstructors02, p6930, Lp6930.AllConstructors02;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
546
			"AllConstructors02b[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors02b;, ()V, AllConstructors02b, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
547
			"   AllConstructors02b[TYPE_REF]{p6930.AllConstructors02b, p6930, Lp6930.AllConstructors02b;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}",
548
			requestor.getResults());
549
	} finally {
550
		deleteProject("P");
551
		
552
		JavaCore.setOptions(oldOptions);
553
	}
554
}
555
public void testBug6930_03() throws Exception {
556
	Hashtable oldOptions = JavaCore.getOptions();
557
	
558
	try {
559
		Hashtable options = new Hashtable(oldOptions);
560
		options.put(JavaCore.CODEASSIST_VISIBILITY_CHECK, JavaCore.ENABLED);
561
		JavaCore.setOptions(options);
562
		
563
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL_LIB"}, "bin");
564
		
565
		createFolder("/P/src/p6930");
566
		
567
		createFile(
568
				"/P/src/p6930/AllConstructors03.java",
569
				"package p6930;\n" +
570
				"public class AllConstructors03 {\n" +
571
				"  public AllConstructors03() {}\n" +
572
				"  public AllConstructors03(Object o) {}\n" +
573
				"  public AllConstructors03(int o) {}\n" +
574
				"  public AllConstructors03(Object o, String s) {}\n" +
575
				"}");
576
		
577
		createFile(
578
				"/P/src/p6930/AllConstructors03b.java",
579
				"package p6930;\n" +
580
				"public class AllConstructors03b {\n" +
581
				"}");
582
		refresh(p);
583
		
584
		waitUntilIndexesReady();
585
		
586
		this.workingCopies = new ICompilationUnit[1];
587
		this.workingCopies[0] = getWorkingCopy(
588
				"/P/src/test/Test.java",
589
				"package test;"+
590
				"public class Test {\n" +
591
				"  void foo() {\n" +
592
				"    new AllConstructors\n" +
593
				"  }\n" +
594
				"}");
595
596
		// do completion
597
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true);
598
		requestor.allowAllRequiredProposals();
599
		NullProgressMonitor monitor = new NullProgressMonitor();
600
601
	    String str = this.workingCopies[0].getSource();
602
	    String completeBehind = "AllConstructors";
603
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
604
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
605
	    
606
	    assertResults(
607
			"AllConstructors03[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors03;, ()V, AllConstructors03, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
608
			"   AllConstructors03[TYPE_REF]{p6930.AllConstructors03, p6930, Lp6930.AllConstructors03;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
609
			"AllConstructors03[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors03;, (I)V, AllConstructors03, (o), "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
610
			"   AllConstructors03[TYPE_REF]{p6930.AllConstructors03, p6930, Lp6930.AllConstructors03;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
611
			"AllConstructors03[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors03;, (Ljava.lang.Object;)V, AllConstructors03, (o), "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
612
			"   AllConstructors03[TYPE_REF]{p6930.AllConstructors03, p6930, Lp6930.AllConstructors03;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
613
			"AllConstructors03[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors03;, (Ljava.lang.Object;Ljava.lang.String;)V, AllConstructors03, (o, s), "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
614
			"   AllConstructors03[TYPE_REF]{p6930.AllConstructors03, p6930, Lp6930.AllConstructors03;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
615
			"AllConstructors03b[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors03b;, ()V, AllConstructors03b, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
616
			"   AllConstructors03b[TYPE_REF]{p6930.AllConstructors03b, p6930, Lp6930.AllConstructors03b;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}",
617
			requestor.getResults());
618
	} finally {
619
		deleteProject("P");
620
		
621
		JavaCore.setOptions(oldOptions);
622
	}
623
}
624
public void testBug6930_04() throws Exception {
625
	Hashtable oldOptions = JavaCore.getOptions();
626
	
627
	try {
628
		Hashtable options = new Hashtable(oldOptions);
629
		options.put(JavaCore.CODEASSIST_VISIBILITY_CHECK, JavaCore.ENABLED);
630
		JavaCore.setOptions(options);
631
		
632
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL_LIB"}, "bin");
633
		
634
		refresh(p);
635
		
636
		waitUntilIndexesReady();
637
		
638
		this.workingCopies = new ICompilationUnit[2];
639
		this.workingCopies[0] = getWorkingCopy(
640
				"/P/src/test/Test.java",
641
				"package test;"+
642
				"class AllConstructors04a {\n" +
643
				"  public class AllConstructors0b {\n" +
644
				"  }\n" +
645
				"}\n" +
646
				"public class Test {\n" +
647
				"  public class AllConstructors04c {\n" +
648
				"    public class AllConstructors04d {\n" +
649
				"    }\n" +
650
				"  }\n" +
651
				"  void foo() {\n" +
652
				"    class AllConstructors04e {\n" +
653
				"      class AllConstructors04f {\n" +
654
				"      }\n" +
655
				"    }\n" +
656
				"    new AllConstructors\n" +
657
				"  }\n" +
658
				"}");
659
		
660
		this.workingCopies[1] = getWorkingCopy(
661
				"/P/src/test/AllConstructors04g.java",
662
				"package test;"+
663
				"public class AllConstructors04g {\n" +
664
				"  public class AllConstructors0h {\n" +
665
				"  }\n" +
666
				"}");
667
668
		// do completion
669
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true);
670
		requestor.allowAllRequiredProposals();
671
		NullProgressMonitor monitor = new NullProgressMonitor();
672
673
	    String str = this.workingCopies[0].getSource();
674
	    String completeBehind = "AllConstructors";
675
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
676
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
677
	    
678
	    assertResults(
679
			"AllConstructors04a[CONSTRUCTOR_INVOCATION]{(), Ltest.AllConstructors04a;, ()V, AllConstructors04a, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
680
			"   AllConstructors04a[TYPE_REF]{AllConstructors04a, test, Ltest.AllConstructors04a;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
681
			"AllConstructors04c[CONSTRUCTOR_INVOCATION]{(), Ltest.Test$AllConstructors04c;, ()V, AllConstructors04c, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
682
			"   Test.AllConstructors04c[TYPE_REF]{AllConstructors04c, test, Ltest.Test$AllConstructors04c;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
683
			"AllConstructors04e[CONSTRUCTOR_INVOCATION]{(), LAllConstructors04e;, ()V, AllConstructors04e, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
684
			"   AllConstructors04e[TYPE_REF]{AllConstructors04e, null, LAllConstructors04e;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
685
			"AllConstructors04g[CONSTRUCTOR_INVOCATION]{(), Ltest.AllConstructors04g;, ()V, AllConstructors04g, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
686
			"   AllConstructors04g[TYPE_REF]{AllConstructors04g, test, Ltest.AllConstructors04g;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
687
			requestor.getResults());
688
	} finally {
689
		deleteProject("P");
690
		
691
		JavaCore.setOptions(oldOptions);
692
	}
693
}
694
public void testBug6930_05() throws Exception {
695
	Hashtable oldOptions = JavaCore.getOptions();
696
	
697
	try {
698
		Hashtable options = new Hashtable(oldOptions);
699
		options.put(JavaCore.CODEASSIST_VISIBILITY_CHECK, JavaCore.ENABLED);
700
		JavaCore.setOptions(options);
701
		
702
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL_LIB"}, "bin");
703
		
704
		refresh(p);
705
		
706
		waitUntilIndexesReady();
707
		
708
		this.workingCopies = new ICompilationUnit[2];
709
		this.workingCopies[0] = getWorkingCopy(
710
				"/P/src/test/Test.java",
711
				"package test;"+
712
				"class AllConstructors05a {\n" +
713
				"  public static class AllConstructors0b {\n" +
714
				"  }\n" +
715
				"}\n" +
716
				"public class Test {\n" +
717
				"  public static class AllConstructors05c {\n" +
718
				"    public static class AllConstructors05d {\n" +
719
				"    }\n" +
720
				"  }\n" +
721
				"  void foo() {\n" +
722
				"    new AllConstructors\n" +
723
				"  }\n" +
724
				"}");
725
		
726
		this.workingCopies[1] = getWorkingCopy(
727
				"/P/src/test/AllConstructors05g.java",
728
				"package test;"+
729
				"public class AllConstructors05g {\n" +
730
				"  public static class AllConstructors0h {\n" +
731
				"  }\n" +
732
				"}");
733
734
		// do completion
735
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true);
736
		requestor.allowAllRequiredProposals();
737
		NullProgressMonitor monitor = new NullProgressMonitor();
738
739
	    String str = this.workingCopies[0].getSource();
740
	    String completeBehind = "AllConstructors";
741
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
742
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
743
	    
744
	    assertResults(
745
			"AllConstructors05a[TYPE_REF]{AllConstructors05a, test, Ltest.AllConstructors05a;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
746
			"AllConstructors05a[CONSTRUCTOR_INVOCATION]{(), Ltest.AllConstructors05a;, ()V, AllConstructors05a, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
747
			"   AllConstructors05a[TYPE_REF]{AllConstructors05a, test, Ltest.AllConstructors05a;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
748
			"AllConstructors05c[CONSTRUCTOR_INVOCATION]{(), Ltest.Test$AllConstructors05c;, ()V, AllConstructors05c, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
749
			"   Test.AllConstructors05c[TYPE_REF]{AllConstructors05c, test, Ltest.Test$AllConstructors05c;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
750
			"AllConstructors05g[TYPE_REF]{AllConstructors05g, test, Ltest.AllConstructors05g;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
751
			"AllConstructors05g[CONSTRUCTOR_INVOCATION]{(), Ltest.AllConstructors05g;, ()V, AllConstructors05g, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
752
			"   AllConstructors05g[TYPE_REF]{AllConstructors05g, test, Ltest.AllConstructors05g;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
753
			"Test.AllConstructors05c[TYPE_REF]{AllConstructors05c, test, Ltest.Test$AllConstructors05c;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
754
			requestor.getResults());
755
	} finally {
756
		deleteProject("P");
757
		
758
		JavaCore.setOptions(oldOptions);
759
	}
760
}
761
public void testBug6930_06() throws Exception {
762
	Hashtable oldOptions = JavaCore.getOptions();
763
	
764
	try {
765
		Hashtable options = new Hashtable(oldOptions);
766
		options.put(JavaCore.CODEASSIST_VISIBILITY_CHECK, JavaCore.ENABLED);
767
		JavaCore.setOptions(options);
768
		
769
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL_LIB", "/P/lib6930.jar"}, "bin");
770
		
771
		createFolder("/P/src/p6930");
772
		
773
		createFile(
774
				"/P/src/p6930/AllConstructors06a.java",
775
				"package p6930;\n" +
776
				"public class AllConstructors06a {\n" +
777
				"}");
778
		
779
		createJar(new String[] {
780
			"p6930/AllConstructors06b.java",
781
			"package p6930;\n" +
782
			"public class AllConstructors06b {\n" +
783
			"}"
784
		}, p.getProject().getLocation().append("lib6930.jar").toOSString());
785
		
786
		refresh(p);
787
		
788
		waitUntilIndexesReady();
789
		
790
		this.workingCopies = new ICompilationUnit[2];
791
		this.workingCopies[0] = getWorkingCopy(
792
				"/P/src/test/Test.java",
793
				"package test;\n"+
794
				"import p6930.AllConstructors06a;\n"+
795
				"import p6930.AllConstructors06b;\n"+
796
				"import p6930.AllConstructors06c;\n"+
797
				"public class Test {\n" +
798
				"  void foo() {\n" +
799
				"    new AllConstructors\n" +
800
				"  }\n" +
801
				"}");
802
		
803
		this.workingCopies[1] = getWorkingCopy(
804
				"/P/src/p6930/AllConstructors06c.java",
805
				"package p6930;"+
806
				"public class AllConstructors06c {\n" +
807
				"}");
808
809
		// do completion
810
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true);
811
		requestor.allowAllRequiredProposals();
812
		NullProgressMonitor monitor = new NullProgressMonitor();
813
814
	    String str = this.workingCopies[0].getSource();
815
	    String completeBehind = "AllConstructors";
816
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
817
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
818
	    
819
	    assertResults(
820
			"AllConstructors06a[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors06a;, ()V, AllConstructors06a, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
821
			"   AllConstructors06a[TYPE_REF]{AllConstructors06a, p6930, Lp6930.AllConstructors06a;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
822
			"AllConstructors06b[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors06b;, ()V, AllConstructors06b, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
823
			"   AllConstructors06b[TYPE_REF]{AllConstructors06b, p6930, Lp6930.AllConstructors06b;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
824
			"AllConstructors06c[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors06c;, ()V, AllConstructors06c, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
825
			"   AllConstructors06c[TYPE_REF]{AllConstructors06c, p6930, Lp6930.AllConstructors06c;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
826
			requestor.getResults());
827
828
	} finally {
829
		deleteProject("P");
830
		
831
		JavaCore.setOptions(oldOptions);
832
	}
833
}
834
public void testBug6930_07() throws Exception {
835
	Hashtable oldOptions = JavaCore.getOptions();
836
	
837
	try {
838
		Hashtable options = new Hashtable(oldOptions);
839
		options.put(JavaCore.CODEASSIST_VISIBILITY_CHECK, JavaCore.ENABLED);
840
		JavaCore.setOptions(options);
841
		
842
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL_LIB", "/P/lib6930.jar"}, "bin");
843
		
844
		createFolder("/P/src/p6930");
845
		
846
		createFile(
847
				"/P/src/p6930/AllConstructors07a.java",
848
				"package p6930;\n" +
849
				"public class AllConstructors07a {\n" +
850
				"  public class AllConstructors07b {\n" +
851
				"  }\n" +
852
				"  public static class AllConstructors07c {\n" +
853
				"  }\n" +
854
				"}");
855
		
856
		createFile(
857
				"/P/src/p6930/AllConstructors07d.java",
858
				"package p6930;\n" +
859
				"public class AllConstructors07d {\n" +
860
				"  public class AllConstructors07e {\n" +
861
				"  }\n" +
862
				"  public static class AllConstructors07f {\n" +
863
				"  }\n" +
864
				"}");
865
		
866
		refresh(p);
867
		
868
		waitUntilIndexesReady();
869
		
870
		this.workingCopies = new ICompilationUnit[1];
871
		this.workingCopies[0] = getWorkingCopy(
872
				"/P/src/test/Test.java",
873
				"package test;\n"+
874
				"import p6930.*;\n"+
875
				"public class Test {\n" +
876
				"  void foo() {\n" +
877
				"    new AllConstructors\n" +
878
				"  }\n" +
879
				"}");
880
881
		// do completion
882
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true);
883
		requestor.allowAllRequiredProposals();
884
		NullProgressMonitor monitor = new NullProgressMonitor();
885
886
	    String str = this.workingCopies[0].getSource();
887
	    String completeBehind = "AllConstructors";
888
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
889
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
890
	    
891
	    assertResults(
892
			"AllConstructors07a[TYPE_REF]{AllConstructors07a, p6930, Lp6930.AllConstructors07a;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
893
			"AllConstructors07a[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors07a;, ()V, AllConstructors07a, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
894
			"   AllConstructors07a[TYPE_REF]{AllConstructors07a, p6930, Lp6930.AllConstructors07a;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
895
			"AllConstructors07d[TYPE_REF]{AllConstructors07d, p6930, Lp6930.AllConstructors07d;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
896
			"AllConstructors07d[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors07d;, ()V, AllConstructors07d, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
897
			"   AllConstructors07d[TYPE_REF]{AllConstructors07d, p6930, Lp6930.AllConstructors07d;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
898
			requestor.getResults());
899
	} finally {
900
		deleteProject("P");
901
		
902
		JavaCore.setOptions(oldOptions);
903
	}
904
}
905
public void testBug6930_08() throws Exception {
906
	Hashtable oldOptions = JavaCore.getOptions();
907
	
908
	try {
909
		Hashtable options = new Hashtable(oldOptions);
910
		options.put(JavaCore.CODEASSIST_VISIBILITY_CHECK, JavaCore.ENABLED);
911
		JavaCore.setOptions(options);
912
		
913
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL15_LIB", "/P/lib6930.jar"}, "bin", "1.5");
914
		
915
		createFolder("/P/src/p6930");
916
		
917
		createFile(
918
				"/P/src/p6930/AllConstructors08a.java",
919
				"package p6930;\n" +
920
				"public class AllConstructors08a {\n" +
921
				"  public class AllConstructors08b {\n" +
922
				"  }\n" +
923
				"  public static class AllConstructors08c {\n" +
924
				"  }\n" +
925
				"}");
926
		
927
		createFile(
928
				"/P/src/p6930/AllConstructors08d.java",
929
				"package p6930;\n" +
930
				"public class AllConstructors08d {\n" +
931
				"  public class AllConstructors08e {\n" +
932
				"  }\n" +
933
				"  public static class AllConstructors08f {\n" +
934
				"  }\n" +
935
				"}");
936
		
937
		refresh(p);
938
		
939
		waitUntilIndexesReady();
940
		
941
		this.workingCopies = new ICompilationUnit[1];
942
		this.workingCopies[0] = getWorkingCopy(
943
				"/P/src/test/Test.java",
944
				"package test;\n"+
945
				"import p6930.AllConstructors08a;\n"+
946
				"public class Test {\n" +
947
				"  void foo() {\n" +
948
				"    new AllConstructors\n" +
949
				"  }\n" +
950
				"}");
951
952
		// do completion
953
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true);
954
		requestor.allowAllRequiredProposals();
955
		NullProgressMonitor monitor = new NullProgressMonitor();
956
957
	    String str = this.workingCopies[0].getSource();
958
	    String completeBehind = "AllConstructors";
959
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
960
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
961
	    
962
	    assertResults(
963
			"AllConstructors08d[TYPE_REF]{p6930.AllConstructors08d, p6930, Lp6930.AllConstructors08d;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
964
			"AllConstructors08d[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors08d;, ()V, AllConstructors08d, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
965
			"   AllConstructors08d[TYPE_REF]{p6930.AllConstructors08d, p6930, Lp6930.AllConstructors08d;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
966
			"AllConstructors08a[TYPE_REF]{AllConstructors08a, p6930, Lp6930.AllConstructors08a;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
967
			"AllConstructors08a[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors08a;, ()V, AllConstructors08a, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
968
			"   AllConstructors08a[TYPE_REF]{AllConstructors08a, p6930, Lp6930.AllConstructors08a;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
969
			requestor.getResults());
970
	} finally {
971
		deleteProject("P");
972
		
973
		JavaCore.setOptions(oldOptions);
974
	}
975
}
976
977
public void testBug6930_09() throws Exception {
978
	Hashtable oldOptions = JavaCore.getOptions();
979
	
980
	try {
981
		Hashtable options = new Hashtable(oldOptions);
982
		options.put(JavaCore.CODEASSIST_VISIBILITY_CHECK, JavaCore.ENABLED);
983
		JavaCore.setOptions(options);
984
		
985
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL15_LIB", "/P/lib6930.jar"}, "bin", "1.5");
986
		
987
		createFolder("/P/src/p6930");
988
		
989
		createFile(
990
				"/P/src/p6930/AllConstructors09a.java",
991
				"package p6930;\n" +
992
				"public class AllConstructors09a {\n" +
993
				"  public class AllConstructors09b {\n" +
994
				"  }\n" +
995
				"  public static class AllConstructors09c {\n" +
996
				"  }\n" +
997
				"}");
998
		
999
		createFile(
1000
				"/P/src/p6930/AllConstructors09d.java",
1001
				"package p6930;\n" +
1002
				"public class AllConstructors09d {\n" +
1003
				"  public class AllConstructors09e {\n" +
1004
				"  }\n" +
1005
				"  public static class AllConstructors09f {\n" +
1006
				"    public static class AllConstructors09g {\n" +
1007
				"    }\n" +
1008
				"  }\n" +
1009
				"}");
1010
		
1011
		refresh(p);
1012
		
1013
		waitUntilIndexesReady();
1014
		
1015
		this.workingCopies = new ICompilationUnit[1];
1016
		this.workingCopies[0] = getWorkingCopy(
1017
				"/P/src/test/Test.java",
1018
				"package test;\n"+
1019
				"import p6930.AllConstructors09a.*;\n"+
1020
				"import static p6930.AllConstructors09d.*;\n"+
1021
				"public class Test {\n" +
1022
				"  void foo() {\n" +
1023
				"    new AllConstructors\n" +
1024
				"  }\n" +
1025
				"}");
1026
1027
		// do completion
1028
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true);
1029
		requestor.allowAllRequiredProposals();
1030
		NullProgressMonitor monitor = new NullProgressMonitor();
1031
1032
	    String str = this.workingCopies[0].getSource();
1033
	    String completeBehind = "AllConstructors";
1034
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1035
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
1036
	    
1037
	    assertResults(
1038
			"AllConstructors09a[TYPE_REF]{p6930.AllConstructors09a, p6930, Lp6930.AllConstructors09a;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1039
			"AllConstructors09a[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors09a;, ()V, AllConstructors09a, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1040
			"   AllConstructors09a[TYPE_REF]{p6930.AllConstructors09a, p6930, Lp6930.AllConstructors09a;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1041
			"AllConstructors09d[TYPE_REF]{p6930.AllConstructors09d, p6930, Lp6930.AllConstructors09d;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1042
			"AllConstructors09d[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors09d;, ()V, AllConstructors09d, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1043
			"   AllConstructors09d[TYPE_REF]{p6930.AllConstructors09d, p6930, Lp6930.AllConstructors09d;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1044
			"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" +
1045
			"AllConstructors09f[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors09d$AllConstructors09f;, ()V, AllConstructors09f, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
1046
			"   AllConstructors09d.AllConstructors09f[TYPE_REF]{AllConstructors09f, p6930, Lp6930.AllConstructors09d$AllConstructors09f;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
1047
			requestor.getResults());
1048
	} finally {
1049
		deleteProject("P");
1050
		
1051
		JavaCore.setOptions(oldOptions);
1052
	}
1053
}
1054
public void testBug6930_10() throws Exception {
1055
	Hashtable oldOptions = JavaCore.getOptions();
1056
	
1057
	try {
1058
		Hashtable options = new Hashtable(oldOptions);
1059
		options.put(JavaCore.CODEASSIST_VISIBILITY_CHECK, JavaCore.ENABLED);
1060
		JavaCore.setOptions(options);
1061
		
1062
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL15_LIB", "/P/lib6930.jar"}, "bin", "1.5");
1063
		
1064
		createFolder("/P/src/p6930");
1065
		
1066
		createFile(
1067
				"/P/src/p6930/AllConstructors10a.java",
1068
				"package p6930;\n" +
1069
				"public class AllConstructors10a {\n" +
1070
				"  public class AllConstructors10b {\n" +
1071
				"    public static class AllConstructors10bs {\n" +
1072
				"    }\n" +
1073
				"  }\n" +
1074
				"  public static class AllConstructors10c {\n" +
1075
				"    public static class AllConstructors10cs {\n" +
1076
				"    }\n" +
1077
				"  }\n" +
1078
				"}");
1079
		
1080
		createFile(
1081
				"/P/src/p6930/AllConstructors10d.java",
1082
				"package p6930;\n" +
1083
				"public class AllConstructors10d {\n" +
1084
				"  public class AllConstructors10e {\n" +
1085
				"    public static class AllConstructors10es {\n" +
1086
				"    }\n" +
1087
				"  }\n" +
1088
				"  public static class AllConstructors10f {\n" +
1089
				"    public static class AllConstructors10fs {\n" +
1090
				"    }\n" +
1091
				"  }\n" +
1092
				"}");
1093
		
1094
		refresh(p);
1095
		
1096
		waitUntilIndexesReady();
1097
		
1098
		this.workingCopies = new ICompilationUnit[1];
1099
		this.workingCopies[0] = getWorkingCopy(
1100
				"/P/src/test/Test.java",
1101
				"package test;\n"+
1102
				"import p6930.AllConstructors10a.AllConstructors10b;\n"+
1103
				"import p6930.AllConstructors10a.AllConstructors10c;\n"+
1104
				"import static p6930.AllConstructors10d.AllConstructors10e;\n"+
1105
				"import static p6930.AllConstructors10d.AllConstructors10f;\n"+
1106
				"public class Test {\n" +
1107
				"  void foo() {\n" +
1108
				"    new AllConstructors\n" +
1109
				"  }\n" +
1110
				"}");
1111
1112
		// do completion
1113
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true);
1114
		requestor.allowAllRequiredProposals();
1115
		NullProgressMonitor monitor = new NullProgressMonitor();
1116
1117
	    String str = this.workingCopies[0].getSource();
1118
	    String completeBehind = "AllConstructors";
1119
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1120
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
1121
	    
1122
	    assertResults(
1123
			"AllConstructors10a[TYPE_REF]{p6930.AllConstructors10a, p6930, Lp6930.AllConstructors10a;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1124
			"AllConstructors10a[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors10a;, ()V, AllConstructors10a, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1125
			"   AllConstructors10a[TYPE_REF]{p6930.AllConstructors10a, p6930, Lp6930.AllConstructors10a;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1126
			"AllConstructors10d[TYPE_REF]{p6930.AllConstructors10d, p6930, Lp6930.AllConstructors10d;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1127
			"AllConstructors10d[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors10d;, ()V, AllConstructors10d, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1128
			"   AllConstructors10d[TYPE_REF]{p6930.AllConstructors10d, p6930, Lp6930.AllConstructors10d;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1129
			"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" +
1130
			"AllConstructors10c[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors10a$AllConstructors10c;, ()V, AllConstructors10c, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
1131
			"   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" +
1132
			"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" +
1133
			"AllConstructors10f[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors10d$AllConstructors10f;, ()V, AllConstructors10f, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
1134
			"   AllConstructors10d.AllConstructors10f[TYPE_REF]{AllConstructors10f, p6930, Lp6930.AllConstructors10d$AllConstructors10f;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
1135
			requestor.getResults());
1136
	} finally {
1137
		deleteProject("P");
1138
		
1139
		JavaCore.setOptions(oldOptions);
1140
	}
1141
}
1142
public void testBug6930_11() throws Exception {
1143
	Hashtable oldOptions = JavaCore.getOptions();
1144
	
1145
	try {
1146
		Hashtable options = new Hashtable(oldOptions);
1147
		options.put(JavaCore.CODEASSIST_VISIBILITY_CHECK, JavaCore.ENABLED);
1148
		JavaCore.setOptions(options);
1149
		
1150
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL_LIB", "/P/lib6930.jar"}, "bin");
1151
		
1152
		createFolder("/P/src/p6930");
1153
		
1154
		createFile(
1155
				"/P/src/p6930/AllConstructors11a.java",
1156
				"package p6930;\n" +
1157
				"public class AllConstructors11a {\n" +
1158
				"}");
1159
1160
		
1161
		refresh(p);
1162
		
1163
		waitUntilIndexesReady();
1164
		
1165
		this.workingCopies = new ICompilationUnit[1];
1166
		this.workingCopies[0] = getWorkingCopy(
1167
				"/P/src/test/Test.java",
1168
				"package test;\n"+
1169
				"public class Test {\n" +
1170
				"  void foo() {\n" +
1171
				"    p6930.AllConstructors11a a = new \n" +
1172
				"  }\n" +
1173
				"}");
1174
1175
		// do completion
1176
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true);
1177
		requestor.allowAllRequiredProposals();
1178
		NullProgressMonitor monitor = new NullProgressMonitor();
1179
1180
	    String str = this.workingCopies[0].getSource();
1181
	    String completeBehind = "new ";
1182
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1183
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
1184
	    
1185
	    assertResults(
1186
			"Test[CONSTRUCTOR_INVOCATION]{(), Ltest.Test;, ()V, Test, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
1187
			"   Test[TYPE_REF]{Test, test, Ltest.Test;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
1188
			"AllConstructors11a[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors11a;, ()V, AllConstructors11a, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED)+"}\n" +
1189
			"   AllConstructors11a[TYPE_REF]{p6930.AllConstructors11a, p6930, Lp6930.AllConstructors11a;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED)+"}",
1190
			requestor.getResults());
1191
	} finally {
1192
		deleteProject("P");
1193
		
1194
		JavaCore.setOptions(oldOptions);
1195
	}
1196
}
1197
public void testBug6930_12() throws Exception {
1198
	Hashtable oldOptions = JavaCore.getOptions();
1199
	
1200
	try {
1201
		Hashtable options = new Hashtable(oldOptions);
1202
		options.put(JavaCore.CODEASSIST_VISIBILITY_CHECK, JavaCore.ENABLED);
1203
		JavaCore.setOptions(options);
1204
		
1205
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL_LIB", "/P/lib6930.jar"}, "bin");
1206
		
1207
		createFolder("/P/src/p6930");
1208
		
1209
		createFile(
1210
				"/P/src/p6930/AllConstructors12a.java",
1211
				"package p6930;\n" +
1212
				"public class AllConstructors12a {\n" +
1213
				"  public static class AllConstructors12b {\n" +
1214
				"  }\n" +
1215
				"}");
1216
		
1217
		refresh(p);
1218
		
1219
		waitUntilIndexesReady();
1220
		
1221
		this.workingCopies = new ICompilationUnit[1];
1222
		this.workingCopies[0] = getWorkingCopy(
1223
				"/P/src/test/Test.java",
1224
				"package test;\n"+
1225
				"public class Test {\n" +
1226
				"  void foo() {\n" +
1227
				"    p6930.AllConstructors12a a = new \n" +
1228
				"  }\n" +
1229
				"}");
1230
1231
		// do completion
1232
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true);
1233
		requestor.allowAllRequiredProposals();
1234
		NullProgressMonitor monitor = new NullProgressMonitor();
1235
1236
	    String str = this.workingCopies[0].getSource();
1237
	    String completeBehind = "new ";
1238
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1239
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
1240
	    
1241
	    assertResults(
1242
			"Test[CONSTRUCTOR_INVOCATION]{(), Ltest.Test;, ()V, Test, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
1243
			"   Test[TYPE_REF]{Test, test, Ltest.Test;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
1244
			"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" +
1245
			"AllConstructors12a[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors12a;, ()V, AllConstructors12a, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED)+"}\n" +
1246
			"   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)+"}",
1247
			requestor.getResults());
1248
	} finally {
1249
		deleteProject("P");
1250
		
1251
		JavaCore.setOptions(oldOptions);
1252
	}
1253
}
1254
public void testBug6930_13() throws Exception {
1255
	Hashtable oldOptions = JavaCore.getOptions();
1256
	
1257
	try {
1258
		Hashtable options = new Hashtable(oldOptions);
1259
		options.put(JavaCore.CODEASSIST_VISIBILITY_CHECK, JavaCore.ENABLED);
1260
		JavaCore.setOptions(options);
1261
		
1262
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL_LIB", "/P/lib6930.jar"}, "bin");
1263
		
1264
		createFolder("/P/src/p6930");
1265
		
1266
		createFile(
1267
				"/P/src/p6930/AllConstructors13a.java",
1268
				"package p6930;\n" +
1269
				"public class AllConstructors13a {\n" +
1270
				"}");
1271
1272
		
1273
		refresh(p);
1274
		
1275
		waitUntilIndexesReady();
1276
		
1277
		this.workingCopies = new ICompilationUnit[1];
1278
		this.workingCopies[0] = getWorkingCopy(
1279
				"/P/src/test/Test.java",
1280
				"package test;\n"+
1281
				"public class Test {\n" +
1282
				"  void foo() {\n" +
1283
				"    p6930.AllConstructors13a a = new AllConstructors\n" +
1284
				"  }\n" +
1285
				"}");
1286
1287
		// do completion
1288
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true);
1289
		requestor.allowAllRequiredProposals();
1290
		NullProgressMonitor monitor = new NullProgressMonitor();
1291
1292
	    String str = this.workingCopies[0].getSource();
1293
	    String completeBehind = "new AllConstructors";
1294
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1295
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
1296
	    
1297
	    assertResults(
1298
			"AllConstructors13a[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors13a;, ()V, AllConstructors13a, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED)+"}\n" +
1299
			"   AllConstructors13a[TYPE_REF]{p6930.AllConstructors13a, p6930, Lp6930.AllConstructors13a;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED)+"}",
1300
			requestor.getResults());
1301
	} finally {
1302
		deleteProject("P");
1303
		
1304
		JavaCore.setOptions(oldOptions);
1305
	}
1306
}
1307
public void testBug6930_14() throws Exception {
1308
	Hashtable oldOptions = JavaCore.getOptions();
1309
	
1310
	try {
1311
		Hashtable options = new Hashtable(oldOptions);
1312
		options.put(JavaCore.CODEASSIST_VISIBILITY_CHECK, JavaCore.ENABLED);
1313
		JavaCore.setOptions(options);
1314
		
1315
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL_LIB", "/P/lib6930.jar"}, "bin");
1316
		
1317
		createFolder("/P/src/p6930");
1318
		
1319
		createFile(
1320
				"/P/src/p6930/AllConstructors14a.java",
1321
				"package p6930;\n" +
1322
				"public class AllConstructors14a {\n" +
1323
				"  public static class AllConstructors14b {\n" +
1324
				"  }\n" +
1325
				"}");
1326
		
1327
		refresh(p);
1328
		
1329
		waitUntilIndexesReady();
1330
		
1331
		this.workingCopies = new ICompilationUnit[1];
1332
		this.workingCopies[0] = getWorkingCopy(
1333
				"/P/src/test/Test.java",
1334
				"package test;\n"+
1335
				"public class Test {\n" +
1336
				"  void foo() {\n" +
1337
				"    p6930.AllConstructors14a a = new AllConstructors\n" +
1338
				"  }\n" +
1339
				"}");
1340
1341
		// do completion
1342
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true);
1343
		requestor.allowAllRequiredProposals();
1344
		NullProgressMonitor monitor = new NullProgressMonitor();
1345
1346
	    String str = this.workingCopies[0].getSource();
1347
	    String completeBehind = "new AllConstructors";
1348
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1349
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
1350
	    
1351
	    assertResults(
1352
			"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" +
1353
			"AllConstructors14a[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors14a;, ()V, AllConstructors14a, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED)+"}\n" +
1354
			"   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)+"}",
1355
			requestor.getResults());
1356
	} finally {
1357
		deleteProject("P");
1358
		
1359
		JavaCore.setOptions(oldOptions);
1360
	}
1361
}
1362
public void testBug6930_15() throws Exception {
1363
	Hashtable oldOptions = JavaCore.getOptions();
1364
	
1365
	try {
1366
		Hashtable options = new Hashtable(oldOptions);
1367
		options.put(JavaCore.CODEASSIST_VISIBILITY_CHECK, JavaCore.ENABLED);
1368
		JavaCore.setOptions(options);
1369
		
1370
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL15_LIB", "/P/lib6930.jar"}, "bin", "1.5");
1371
		
1372
		createFolder("/P/src/p6930");
1373
		
1374
		createFile(
1375
				"/P/src/p6930/AllConstructors15a.java",
1376
				"package p6930;\n" +
1377
				"public class AllConstructors15a<T> {\n" +
1378
				"}");
1379
		
1380
		createJar(
1381
				new String[] {
1382
					"p6930/AllConstructors15b.java",
1383
					"package p6930;\n" +
1384
					"public class AllConstructors15b<T> {\n" +
1385
					"}"
1386
				},
1387
				p.getProject().getLocation().append("lib6930.jar").toOSString(),
1388
				new String[]{getExternalJCLPathString("1.5")},
1389
				"1.5");
1390
		
1391
		refresh(p);
1392
		
1393
		waitUntilIndexesReady();
1394
		
1395
		this.workingCopies = new ICompilationUnit[2];
1396
		this.workingCopies[0] = getWorkingCopy(
1397
				"/P/src/test/Test.java",
1398
				"package test;\n"+
1399
				"public class Test {\n" +
1400
				"  void foo() {\n" +
1401
				"    new AllConstructors\n" +
1402
				"  }\n" +
1403
				"}");
1404
		
1405
		this.workingCopies[1] = getWorkingCopy(
1406
				"/P/src/p6930/AllConstructors15c.java",
1407
				"package p6930;"+
1408
				"public class AllConstructors15c<T> {\n" +
1409
				"}");
1410
1411
		// do completion
1412
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true);
1413
		requestor.allowAllRequiredProposals();
1414
		NullProgressMonitor monitor = new NullProgressMonitor();
1415
1416
	    String str = this.workingCopies[0].getSource();
1417
	    String completeBehind = "AllConstructors";
1418
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1419
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
1420
	    
1421
	    assertResults(
1422
			"AllConstructors15a[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors15a;, ()V, AllConstructors15a, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1423
			"   AllConstructors15a[TYPE_REF]{p6930.AllConstructors15a, p6930, Lp6930.AllConstructors15a;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1424
			"AllConstructors15b[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors15b;, ()V, AllConstructors15b, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1425
			"   AllConstructors15b[TYPE_REF]{p6930.AllConstructors15b, p6930, Lp6930.AllConstructors15b;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1426
			"AllConstructors15c[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors15c;, ()V, AllConstructors15c, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1427
			"   AllConstructors15c[TYPE_REF]{p6930.AllConstructors15c, p6930, Lp6930.AllConstructors15c;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}",
1428
			requestor.getResults());
1429
	} finally {
1430
		deleteProject("P");
1431
		
1432
		JavaCore.setOptions(oldOptions);
1433
	}
1434
}
1435
public void testBug6930_16() throws Exception {
1436
	Hashtable oldOptions = JavaCore.getOptions();
1437
	
1438
	try {
1439
		Hashtable options = new Hashtable(oldOptions);
1440
		options.put(JavaCore.CODEASSIST_VISIBILITY_CHECK, JavaCore.ENABLED);
1441
		JavaCore.setOptions(options);
1442
		
1443
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL15_LIB", "/P/lib6930.jar"}, "bin", "1.5");
1444
		
1445
		createFolder("/P/src/p6930");
1446
		
1447
		createFile(
1448
				"/P/src/p6930/AllConstructors16a.java",
1449
				"package p6930;\n" +
1450
				"public class AllConstructors16a{\n" +
1451
				"  public <T> AllConstructors16a(){}\n" +
1452
				"}");
1453
		
1454
		createJar(
1455
				new String[] {
1456
					"p6930/AllConstructors16b.java",
1457
					"package p6930;\n" +
1458
					"public class AllConstructors16b {\n" +
1459
					"  public <T> AllConstructors16b(){}\n" +
1460
					"}"
1461
				},
1462
				p.getProject().getLocation().append("lib6930.jar").toOSString(),
1463
				new String[]{getExternalJCLPathString("1.5")},
1464
				"1.5");
1465
		
1466
		refresh(p);
1467
		
1468
		waitUntilIndexesReady();
1469
		
1470
		this.workingCopies = new ICompilationUnit[2];
1471
		this.workingCopies[0] = getWorkingCopy(
1472
				"/P/src/test/Test.java",
1473
				"package test;\n"+
1474
				"public class Test {\n" +
1475
				"  void foo() {\n" +
1476
				"    new AllConstructors\n" +
1477
				"  }\n" +
1478
				"}");
1479
		
1480
		this.workingCopies[1] = getWorkingCopy(
1481
				"/P/src/p6930/AllConstructors16c.java",
1482
				"package p6930;"+
1483
				"public class AllConstructors16c {\n" +
1484
				"  public <T> AllConstructors16c(){}\n" +
1485
				"}");
1486
1487
		// do completion
1488
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true);
1489
		requestor.allowAllRequiredProposals();
1490
		NullProgressMonitor monitor = new NullProgressMonitor();
1491
1492
	    String str = this.workingCopies[0].getSource();
1493
	    String completeBehind = "AllConstructors";
1494
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1495
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
1496
	    
1497
	    assertResults(
1498
			"AllConstructors16a[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors16a;, ()V, AllConstructors16a, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1499
			"   AllConstructors16a[TYPE_REF]{p6930.AllConstructors16a, p6930, Lp6930.AllConstructors16a;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1500
			"AllConstructors16b[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors16b;, ()V, AllConstructors16b, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1501
			"   AllConstructors16b[TYPE_REF]{p6930.AllConstructors16b, p6930, Lp6930.AllConstructors16b;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1502
			"AllConstructors16c[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors16c;, ()V, AllConstructors16c, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1503
			"   AllConstructors16c[TYPE_REF]{p6930.AllConstructors16c, p6930, Lp6930.AllConstructors16c;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}",
1504
			requestor.getResults());
1505
	} finally {
1506
		deleteProject("P");
1507
		
1508
		JavaCore.setOptions(oldOptions);
1509
	}
1510
}
1511
public void testBug6930_17() throws Exception {
1512
	Hashtable oldOptions = JavaCore.getOptions();
1513
	
1514
	try {
1515
		Hashtable options = new Hashtable(oldOptions);
1516
		options.put(JavaCore.CODEASSIST_VISIBILITY_CHECK, JavaCore.ENABLED);
1517
		JavaCore.setOptions(options);
1518
		
1519
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL15_LIB", "/P/lib6930.jar"}, "bin", "1.5");
1520
		
1521
		createFolder("/P/src/p6930");
1522
		
1523
		createFile(
1524
				"/P/src/p6930/AllConstructors17a.java",
1525
				"package p6930;\n" +
1526
				"public class AllConstructors17a{\n" +
1527
				"  public AllConstructors17a(java.util.Collection<Object> o){}\n" +
1528
				"}");
1529
		
1530
		createJar(
1531
				new String[] {
1532
					"p6930/AllConstructors17b.java",
1533
					"package p6930;\n" +
1534
					"public class AllConstructors17b {\n" +
1535
					"  public AllConstructors17b(java.util.Collection<Object> o){}\n" +
1536
					"}"
1537
				},
1538
				p.getProject().getLocation().append("lib6930.jar").toOSString(),
1539
				new String[]{getExternalJCLPathString("1.5")},
1540
				"1.5");
1541
		
1542
		refresh(p);
1543
		
1544
		waitUntilIndexesReady();
1545
		
1546
		this.workingCopies = new ICompilationUnit[2];
1547
		this.workingCopies[0] = getWorkingCopy(
1548
				"/P/src/test/Test.java",
1549
				"package test;\n"+
1550
				"public class Test {\n" +
1551
				"  void foo() {\n" +
1552
				"    new AllConstructors\n" +
1553
				"  }\n" +
1554
				"}");
1555
		
1556
		this.workingCopies[1] = getWorkingCopy(
1557
				"/P/src/p6930/AllConstructors17c.java",
1558
				"package p6930;"+
1559
				"public class AllConstructors17c {\n" +
1560
				"  public AllConstructors17c(java.util.Collection<Object> o){}\n" +
1561
				"}");
1562
1563
		// do completion
1564
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true);
1565
		requestor.allowAllRequiredProposals();
1566
		NullProgressMonitor monitor = new NullProgressMonitor();
1567
1568
	    String str = this.workingCopies[0].getSource();
1569
	    String completeBehind = "AllConstructors";
1570
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1571
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
1572
	    
1573
	    assertResults(
1574
			"AllConstructors17a[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors17a;, (Ljava.util.Collection<Ljava.lang.Object;>;)V, AllConstructors17a, (o), "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1575
			"   AllConstructors17a[TYPE_REF]{p6930.AllConstructors17a, p6930, Lp6930.AllConstructors17a;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1576
			"AllConstructors17b[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors17b;, (Ljava.util.Collection<Ljava.lang.Object;>;)V, AllConstructors17b, (o), "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1577
			"   AllConstructors17b[TYPE_REF]{p6930.AllConstructors17b, p6930, Lp6930.AllConstructors17b;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1578
			"AllConstructors17c[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors17c;, (Ljava.util.Collection<Ljava.lang.Object;>;)V, AllConstructors17c, (o), "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1579
			"   AllConstructors17c[TYPE_REF]{p6930.AllConstructors17c, p6930, Lp6930.AllConstructors17c;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}",
1580
			requestor.getResults());
1581
	} finally {
1582
		deleteProject("P");
1583
		
1584
		JavaCore.setOptions(oldOptions);
1585
	}
1586
}
1587
public void testBug6930_18() throws Exception {
1588
	Hashtable oldOptions = JavaCore.getOptions();
1589
	
1590
	try {
1591
		Hashtable options = new Hashtable(oldOptions);
1592
		options.put(JavaCore.CODEASSIST_VISIBILITY_CHECK, JavaCore.ENABLED);
1593
		JavaCore.setOptions(options);
1594
		
1595
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL_LIB", "/P/lib6930.jar"}, "bin");
1596
		
1597
		createFolder("/P/src/p6930");
1598
		
1599
		createFile(
1600
				"/P/src/p6930/AllConstructors18a.java",
1601
				"package p6930;\n" +
1602
				"public interface AllConstructors18a {\n" +
1603
				"}");
1604
		
1605
		createJar(new String[] {
1606
			"p6930/AllConstructors18b.java",
1607
			"package p6930;\n" +
1608
			"public interface AllConstructors18b {\n" +
1609
			"}"
1610
		}, p.getProject().getLocation().append("lib6930.jar").toOSString());
1611
		
1612
		refresh(p);
1613
		
1614
		waitUntilIndexesReady();
1615
		
1616
		this.workingCopies = new ICompilationUnit[2];
1617
		this.workingCopies[0] = getWorkingCopy(
1618
				"/P/src/test/Test.java",
1619
				"package test;\n"+
1620
				"public class Test {\n" +
1621
				"  void foo() {\n" +
1622
				"    new AllConstructors\n" +
1623
				"  }\n" +
1624
				"}");
1625
		
1626
		this.workingCopies[1] = getWorkingCopy(
1627
				"/P/src/p6930/AllConstructors18c.java",
1628
				"package p6930;"+
1629
				"public interface AllConstructors18c {\n" +
1630
				"}");
1631
1632
		// do completion
1633
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true);
1634
		requestor.allowAllRequiredProposals();
1635
		NullProgressMonitor monitor = new NullProgressMonitor();
1636
1637
	    String str = this.workingCopies[0].getSource();
1638
	    String completeBehind = "AllConstructors";
1639
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1640
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
1641
	    
1642
	    assertResults(
1643
			"AllConstructors18a[ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors18a;, ()V, AllConstructors18a, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1644
			"   AllConstructors18a[TYPE_REF]{p6930.AllConstructors18a, p6930, Lp6930.AllConstructors18a;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1645
			"AllConstructors18b[ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors18b;, ()V, AllConstructors18b, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1646
			"   AllConstructors18b[TYPE_REF]{p6930.AllConstructors18b, p6930, Lp6930.AllConstructors18b;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1647
			"AllConstructors18c[ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors18c;, ()V, AllConstructors18c, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1648
			"   AllConstructors18c[TYPE_REF]{p6930.AllConstructors18c, p6930, Lp6930.AllConstructors18c;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}",
1649
			requestor.getResults());
1650
	} finally {
1651
		deleteProject("P");
1652
		
1653
		JavaCore.setOptions(oldOptions);
1654
	}
1655
}
1656
public void testBug6930_19() throws Exception {
1657
	Hashtable oldOptions = JavaCore.getOptions();
1658
	
1659
	try {
1660
		Hashtable options = new Hashtable(oldOptions);
1661
		options.put(JavaCore.CODEASSIST_VISIBILITY_CHECK, JavaCore.ENABLED);
1662
		JavaCore.setOptions(options);
1663
		
1664
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL_LIB", "/P/lib6930.jar"}, "bin");
1665
		
1666
		createFolder("/P/src/p6930");
1667
		
1668
		createFile(
1669
				"/P/src/p6930/AllConstructors19a.java",
1670
				"package p6930;\n" +
1671
				"public interface AllConstructors19a {\n" +
1672
				"}");
1673
		
1674
		createJar(new String[] {
1675
			"p6930/AllConstructors19b.java",
1676
			"package p6930;\n" +
1677
			"public interface AllConstructors19b {\n" +
1678
			"}"
1679
		}, p.getProject().getLocation().append("lib6930.jar").toOSString());
1680
		
1681
		refresh(p);
1682
		
1683
		waitUntilIndexesReady();
1684
		
1685
		this.workingCopies = new ICompilationUnit[2];
1686
		this.workingCopies[0] = getWorkingCopy(
1687
				"/P/src/test/Test.java",
1688
				"package test;\n"+
1689
				"import p6930.AllConstructors19a;\n"+
1690
				"import p6930.AllConstructors19b;\n"+
1691
				"import p6930.AllConstructors19c;\n"+
1692
				"public class Test {\n" +
1693
				"  void foo() {\n" +
1694
				"    new AllConstructors\n" +
1695
				"  }\n" +
1696
				"}");
1697
		
1698
		this.workingCopies[1] = getWorkingCopy(
1699
				"/P/src/p6930/AllConstructors19c.java",
1700
				"package p6930;"+
1701
				"public interface AllConstructors19c {\n" +
1702
				"}");
1703
1704
		// do completion
1705
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true);
1706
		requestor.allowAllRequiredProposals();
1707
		NullProgressMonitor monitor = new NullProgressMonitor();
1708
1709
	    String str = this.workingCopies[0].getSource();
1710
	    String completeBehind = "AllConstructors";
1711
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1712
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
1713
	    
1714
	    assertResults(
1715
			"AllConstructors19a[ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors19a;, ()V, AllConstructors19a, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
1716
			"   AllConstructors19a[TYPE_REF]{AllConstructors19a, p6930, Lp6930.AllConstructors19a;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
1717
			"AllConstructors19b[ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors19b;, ()V, AllConstructors19b, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
1718
			"   AllConstructors19b[TYPE_REF]{AllConstructors19b, p6930, Lp6930.AllConstructors19b;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
1719
			"AllConstructors19c[ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors19c;, ()V, AllConstructors19c, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
1720
			"   AllConstructors19c[TYPE_REF]{AllConstructors19c, p6930, Lp6930.AllConstructors19c;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
1721
			requestor.getResults());
1722
	} finally {
1723
		deleteProject("P");
1724
		
1725
		JavaCore.setOptions(oldOptions);
1726
	}
1727
}
1728
public void testBug6930_20() throws Exception {
1729
	Hashtable oldOptions = JavaCore.getOptions();
1730
	
1731
	try {
1732
		Hashtable options = new Hashtable(oldOptions);
1733
		options.put(JavaCore.CODEASSIST_VISIBILITY_CHECK, JavaCore.ENABLED);
1734
		JavaCore.setOptions(options);
1735
		
1736
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL15_LIB", "/P/lib6930.jar"}, "bin", "1.5");
1737
		
1738
		createFolder("/P/src/p6930");
1739
		
1740
		createFile(
1741
				"/P/src/p6930/AllConstructors20a.java",
1742
				"package p6930;\n" +
1743
				"public enum AllConstructors20a {\n" +
1744
				"	ZZZ;\n" +
1745
				"}");
1746
		
1747
		createJar(new String[] {
1748
				"p6930/AllConstructors20b.java",
1749
				"package p6930;\n" +
1750
				"public enum AllConstructors20b {\n" +
1751
				"	ZZZ;\n" +
1752
				"}"
1753
			},
1754
			p.getProject().getLocation().append("lib6930.jar").toOSString(),
1755
			new String[]{getExternalJCLPathString("1.5")},
1756
			"1.5");
1757
		
1758
		refresh(p);
1759
		
1760
		waitUntilIndexesReady();
1761
		
1762
		this.workingCopies = new ICompilationUnit[2];
1763
		this.workingCopies[0] = getWorkingCopy(
1764
				"/P/src/test/Test.java",
1765
				"package test;\n"+
1766
				"public class Test {\n" +
1767
				"  void foo() {\n" +
1768
				"    new AllConstructors\n" +
1769
				"  }\n" +
1770
				"}");
1771
		
1772
		this.workingCopies[1] = getWorkingCopy(
1773
				"/P/src/p6930/AllConstructors20c.java",
1774
				"package p6930;"+
1775
				"public enum AllConstructors20c {\n" +
1776
				"	ZZZ;\n" +
1777
				"}");
1778
1779
		// do completion
1780
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true);
1781
		requestor.allowAllRequiredProposals();
1782
		NullProgressMonitor monitor = new NullProgressMonitor();
1783
1784
	    String str = this.workingCopies[0].getSource();
1785
	    String completeBehind = "AllConstructors";
1786
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1787
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
1788
	    
1789
	    assertResults(
1790
			"",
1791
			requestor.getResults());
1792
	} finally {
1793
		deleteProject("P");
1794
		
1795
		JavaCore.setOptions(oldOptions);
1796
	}
1797
}
1798
public void testBug6930_21() throws Exception {
1799
	Hashtable oldOptions = JavaCore.getOptions();
1800
	
1801
	try {
1802
		Hashtable options = new Hashtable(oldOptions);
1803
		options.put(JavaCore.CODEASSIST_VISIBILITY_CHECK, JavaCore.ENABLED);
1804
		JavaCore.setOptions(options);
1805
		
1806
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL15_LIB", "/P/lib6930.jar"}, "bin", "1.5");
1807
		
1808
		createFolder("/P/src/p6930");
1809
		
1810
		createFile(
1811
				"/P/src/p6930/AllConstructors21a.java",
1812
				"package p6930;\n" +
1813
				"public enum AllConstructors21a {\n" +
1814
				"	ZZZ;\n" +
1815
				"}");
1816
		
1817
		createJar(
1818
				new String[] {
1819
					"p6930/AllConstructors21b.java",
1820
					"package p6930;\n" +
1821
					"public enum AllConstructors21b {\n" +
1822
					"	ZZZ;\n" +
1823
					"}"
1824
				},
1825
				p.getProject().getLocation().append("lib6930.jar").toOSString(),
1826
				new String[]{getExternalJCLPathString("1.5")},
1827
				"1.5");
1828
		
1829
		refresh(p);
1830
		
1831
		waitUntilIndexesReady();
1832
		
1833
		this.workingCopies = new ICompilationUnit[2];
1834
		this.workingCopies[0] = getWorkingCopy(
1835
				"/P/src/test/Test.java",
1836
				"package test;\n"+
1837
				"import p6930.AllConstructors21a;\n"+
1838
				"import p6930.AllConstructors21b;\n"+
1839
				"import p6930.AllConstructors21c;\n"+
1840
				"public class Test {\n" +
1841
				"  void foo() {\n" +
1842
				"    new AllConstructors\n" +
1843
				"  }\n" +
1844
				"}");
1845
		
1846
		this.workingCopies[1] = getWorkingCopy(
1847
				"/P/src/p6930/AllConstructors21c.java",
1848
				"package p6930;"+
1849
				"public enum AllConstructors21c {\n" +
1850
				"	ZZZ;\n" +
1851
				"}");
1852
1853
		// do completion
1854
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true);
1855
		requestor.allowAllRequiredProposals();
1856
		NullProgressMonitor monitor = new NullProgressMonitor();
1857
1858
	    String str = this.workingCopies[0].getSource();
1859
	    String completeBehind = "AllConstructors";
1860
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1861
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
1862
	    
1863
	    assertResults(
1864
			"",
1865
			requestor.getResults());
1866
	} finally {
1867
		deleteProject("P");
1868
		
1869
		JavaCore.setOptions(oldOptions);
1870
	}
1871
}
1872
public void testBug6930_22() throws Exception {
1873
	Hashtable oldOptions = JavaCore.getOptions();
1874
	
1875
	try {
1876
		Hashtable options = new Hashtable(oldOptions);
1877
		options.put(JavaCore.CODEASSIST_VISIBILITY_CHECK, JavaCore.ENABLED);
1878
		JavaCore.setOptions(options);
1879
		
1880
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL_LIB", "/P/lib6930.jar"}, "bin");
1881
		
1882
		createFolder("/P/src/p6930");
1883
		
1884
		createFile(
1885
				"/P/src/p6930/AllConstructors22a.java",
1886
				"package p6930;\n" +
1887
				"public class AllConstructors22a {\n" +
1888
				"	private AllConstructors22a(){}\n" +
1889
				"	public static class AllConstructorsInner{}\n" +
1890
				"}");
1891
		
1892
		createJar(new String[] {
1893
			"p6930/AllConstructors22b.java",
1894
			"package p6930;\n" +
1895
			"public class AllConstructors22b {\n" +
1896
			"	private AllConstructors22b(){}\n" +
1897
			"	public static class AllConstructorsInner{}\n" +
1898
			"}"
1899
		}, p.getProject().getLocation().append("lib6930.jar").toOSString());
1900
		
1901
		refresh(p);
1902
		
1903
		waitUntilIndexesReady();
1904
		
1905
		this.workingCopies = new ICompilationUnit[2];
1906
		this.workingCopies[0] = getWorkingCopy(
1907
				"/P/src/test/Test.java",
1908
				"package test;\n"+
1909
				"public class Test {\n" +
1910
				"  void foo() {\n" +
1911
				"    new AllConstructors\n" +
1912
				"  }\n" +
1913
				"}");
1914
		
1915
		this.workingCopies[1] = getWorkingCopy(
1916
				"/P/src/p6930/AllConstructors22c.java",
1917
				"package p6930;"+
1918
				"public class AllConstructors22c {\n" +
1919
				"	private AllConstructors22c(){}\n" +
1920
				"	public static class AllConstructorsInner{}\n" +
1921
				"}");
1922
1923
		// do completion
1924
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true);
1925
		requestor.allowAllRequiredProposals();
1926
		NullProgressMonitor monitor = new NullProgressMonitor();
1927
1928
	    String str = this.workingCopies[0].getSource();
1929
	    String completeBehind = "AllConstructors";
1930
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1931
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
1932
	    
1933
	    assertResults(
1934
			"AllConstructors22a[TYPE_REF]{p6930.AllConstructors22a, p6930, Lp6930.AllConstructors22a;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1935
			"AllConstructors22b[TYPE_REF]{p6930.AllConstructors22b, p6930, Lp6930.AllConstructors22b;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1936
			"AllConstructors22c[TYPE_REF]{p6930.AllConstructors22c, p6930, Lp6930.AllConstructors22c;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}",
1937
			requestor.getResults());
1938
	} finally {
1939
		deleteProject("P");
1940
		
1941
		JavaCore.setOptions(oldOptions);
1942
	}
1943
}
1944
public void testBug6930_23() throws Exception {
1945
	Hashtable oldOptions = JavaCore.getOptions();
1946
	
1947
	try {
1948
		Hashtable options = new Hashtable(oldOptions);
1949
		options.put(JavaCore.CODEASSIST_VISIBILITY_CHECK, JavaCore.ENABLED);
1950
		JavaCore.setOptions(options);
1951
		
1952
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL_LIB", "/P/lib6930.jar"}, "bin");
1953
		
1954
		createFolder("/P/src/p6930");
1955
		
1956
		createFile(
1957
				"/P/src/p6930/AllConstructors23a.java",
1958
				"package p6930;\n" +
1959
				"public class AllConstructors23a {\n" +
1960
				"	private AllConstructors23a(){}\n" +
1961
				"	public static class AllConstructorsInner{}\n" +
1962
				"}");
1963
		
1964
		createJar(new String[] {
1965
			"p6930/AllConstructors23b.java",
1966
			"package p6930;\n" +
1967
			"public class AllConstructors23b {\n" +
1968
			"	private AllConstructors23b(){}\n" +
1969
			"	public static class AllConstructorsInner{}\n" +
1970
			"}"
1971
		}, p.getProject().getLocation().append("lib6930.jar").toOSString());
1972
		
1973
		refresh(p);
1974
		
1975
		waitUntilIndexesReady();
1976
		
1977
		this.workingCopies = new ICompilationUnit[2];
1978
		this.workingCopies[0] = getWorkingCopy(
1979
				"/P/src/test/Test.java",
1980
				"package test;\n"+
1981
				"import p6930.AllConstructors23a;\n"+
1982
				"import p6930.AllConstructors23b;\n"+
1983
				"import p6930.AllConstructors23c;\n"+
1984
				"public class Test {\n" +
1985
				"  void foo() {\n" +
1986
				"    new AllConstructors\n" +
1987
				"  }\n" +
1988
				"}");
1989
		
1990
		this.workingCopies[1] = getWorkingCopy(
1991
				"/P/src/p6930/AllConstructors23c.java",
1992
				"package p6930;"+
1993
				"public class AllConstructors23c {\n" +
1994
				"	private AllConstructors23c(){}\n" +
1995
				"	public static class AllConstructorsInner{}\n" +
1996
				"}");
1997
1998
		// do completion
1999
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true);
2000
		requestor.allowAllRequiredProposals();
2001
		NullProgressMonitor monitor = new NullProgressMonitor();
2002
2003
	    String str = this.workingCopies[0].getSource();
2004
	    String completeBehind = "AllConstructors";
2005
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2006
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
2007
	    
2008
	    assertResults(
2009
			"AllConstructors23a[TYPE_REF]{AllConstructors23a, p6930, Lp6930.AllConstructors23a;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
2010
			"AllConstructors23b[TYPE_REF]{AllConstructors23b, p6930, Lp6930.AllConstructors23b;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
2011
			"AllConstructors23c[TYPE_REF]{AllConstructors23c, p6930, Lp6930.AllConstructors23c;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
2012
			requestor.getResults());
2013
	} finally {
2014
		deleteProject("P");
2015
		
2016
		JavaCore.setOptions(oldOptions);
2017
	}
2018
}
2019
public void testBug6930_24() throws Exception {
2020
	Hashtable oldOptions = JavaCore.getOptions();
2021
	
2022
	try {
2023
		Hashtable options = new Hashtable(oldOptions);
2024
		options.put(JavaCore.CODEASSIST_VISIBILITY_CHECK, JavaCore.ENABLED);
2025
		JavaCore.setOptions(options);
2026
		
2027
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL_LIB", "/P/lib6930.jar"}, "bin");
2028
		
2029
		createFolder("/P/src/p6930");
2030
		
2031
		createFile(
2032
				"/P/src/p6930/AllConstructors24a.java",
2033
				"package p6930;\n" +
2034
				"public class AllConstructors24a {\n" +
2035
				"	public AllConstructors24a(){}\n" +
2036
				"	private static class AllConstructorsInner{}\n" +
2037
				"}");
2038
		
2039
		createJar(new String[] {
2040
			"p6930/AllConstructors24b.java",
2041
			"package p6930;\n" +
2042
			"public class AllConstructors24b {\n" +
2043
			"	public AllConstructors24b(){}\n" +
2044
			"	private static class AllConstructorsInner{}\n" +
2045
			"}"
2046
		}, p.getProject().getLocation().append("lib6930.jar").toOSString());
2047
		
2048
		refresh(p);
2049
		
2050
		waitUntilIndexesReady();
2051
		
2052
		this.workingCopies = new ICompilationUnit[2];
2053
		this.workingCopies[0] = getWorkingCopy(
2054
				"/P/src/test/Test.java",
2055
				"package test;\n"+
2056
				"public class Test {\n" +
2057
				"  void foo() {\n" +
2058
				"    new AllConstructors\n" +
2059
				"  }\n" +
2060
				"}");
2061
		
2062
		this.workingCopies[1] = getWorkingCopy(
2063
				"/P/src/p6930/AllConstructors24c.java",
2064
				"package p6930;"+
2065
				"public class AllConstructors24c {\n" +
2066
				"	public AllConstructors24c(){}\n" +
2067
				"	private static class AllConstructorsInner{}\n" +
2068
				"}");
2069
2070
		// do completion
2071
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true);
2072
		requestor.allowAllRequiredProposals();
2073
		NullProgressMonitor monitor = new NullProgressMonitor();
2074
2075
	    String str = this.workingCopies[0].getSource();
2076
	    String completeBehind = "AllConstructors";
2077
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2078
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
2079
	    
2080
	    assertResults(
2081
			"AllConstructors24a[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors24a;, ()V, AllConstructors24a, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
2082
			"   AllConstructors24a[TYPE_REF]{p6930.AllConstructors24a, p6930, Lp6930.AllConstructors24a;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
2083
			"AllConstructors24b[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors24b;, ()V, AllConstructors24b, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
2084
			"   AllConstructors24b[TYPE_REF]{p6930.AllConstructors24b, p6930, Lp6930.AllConstructors24b;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
2085
			"AllConstructors24c[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors24c;, ()V, AllConstructors24c, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
2086
			"   AllConstructors24c[TYPE_REF]{p6930.AllConstructors24c, p6930, Lp6930.AllConstructors24c;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}",
2087
			requestor.getResults());
2088
	} finally {
2089
		deleteProject("P");
2090
		
2091
		JavaCore.setOptions(oldOptions);
2092
	}
2093
}
2094
public void testBug6930_25() throws Exception {
2095
	Hashtable oldOptions = JavaCore.getOptions();
2096
	
2097
	try {
2098
		Hashtable options = new Hashtable(oldOptions);
2099
		options.put(JavaCore.CODEASSIST_VISIBILITY_CHECK, JavaCore.ENABLED);
2100
		JavaCore.setOptions(options);
2101
		
2102
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL_LIB", "/P/lib6930.jar"}, "bin");
2103
		
2104
		createFolder("/P/src/p6930");
2105
		
2106
		createFile(
2107
				"/P/src/p6930/AllConstructors25a.java",
2108
				"package p6930;\n" +
2109
				"public class AllConstructors25a {\n" +
2110
				"	public AllConstructors25a(){}\n" +
2111
				"	private static class AllConstructorsInner{}\n" +
2112
				"}");
2113
		
2114
		createJar(new String[] {
2115
			"p6930/AllConstructors25b.java",
2116
			"package p6930;\n" +
2117
			"public class AllConstructors25b {\n" +
2118
			"	public AllConstructors25b(){}\n" +
2119
			"	private static class AllConstructorsInner{}\n" +
2120
			"}"
2121
		}, p.getProject().getLocation().append("lib6930.jar").toOSString());
2122
		
2123
		refresh(p);
2124
		
2125
		waitUntilIndexesReady();
2126
		
2127
		this.workingCopies = new ICompilationUnit[2];
2128
		this.workingCopies[0] = getWorkingCopy(
2129
				"/P/src/test/Test.java",
2130
				"package test;\n"+
2131
				"import p6930.AllConstructors25a;\n"+
2132
				"import p6930.AllConstructors25b;\n"+
2133
				"import p6930.AllConstructors25c;\n"+
2134
				"public class Test {\n" +
2135
				"  void foo() {\n" +
2136
				"    new AllConstructors\n" +
2137
				"  }\n" +
2138
				"}");
2139
		
2140
		this.workingCopies[1] = getWorkingCopy(
2141
				"/P/src/p6930/AllConstructors25c.java",
2142
				"package p6930;"+
2143
				"public class AllConstructors25c {\n" +
2144
				"	public AllConstructors25c(){}\n" +
2145
				"	private static class AllConstructorsInner{}\n" +
2146
				"}");
2147
2148
		// do completion
2149
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true);
2150
		requestor.allowAllRequiredProposals();
2151
		NullProgressMonitor monitor = new NullProgressMonitor();
2152
2153
	    String str = this.workingCopies[0].getSource();
2154
	    String completeBehind = "AllConstructors";
2155
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2156
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
2157
	    
2158
	    assertResults(
2159
			"AllConstructors25a[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors25a;, ()V, AllConstructors25a, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
2160
			"   AllConstructors25a[TYPE_REF]{AllConstructors25a, p6930, Lp6930.AllConstructors25a;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
2161
			"AllConstructors25b[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors25b;, ()V, AllConstructors25b, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
2162
			"   AllConstructors25b[TYPE_REF]{AllConstructors25b, p6930, Lp6930.AllConstructors25b;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
2163
			"AllConstructors25c[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors25c;, ()V, AllConstructors25c, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
2164
			"   AllConstructors25c[TYPE_REF]{AllConstructors25c, p6930, Lp6930.AllConstructors25c;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
2165
			requestor.getResults());
2166
	} finally {
2167
		deleteProject("P");
2168
		
2169
		JavaCore.setOptions(oldOptions);
2170
	}
2171
}
2172
public void testBug6930_26() throws Exception {
2173
	Hashtable oldOptions = JavaCore.getOptions();
2174
	
2175
	try {
2176
		Hashtable options = new Hashtable(oldOptions);
2177
		options.put(JavaCore.CODEASSIST_VISIBILITY_CHECK, JavaCore.ENABLED);
2178
		JavaCore.setOptions(options);
2179
		
2180
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL_LIB"}, "bin");
2181
		
2182
		refresh(p);
2183
		
2184
		waitUntilIndexesReady();
2185
		
2186
		this.workingCopies = new ICompilationUnit[2];
2187
		this.workingCopies[0] = getWorkingCopy(
2188
				"/P/src/test/Test.java",
2189
				"package test;\n"+
2190
				"public class Test {\n" +
2191
				"  void foo(p6930.AllConstructors26a var) {\n" +
2192
				"    var.new AllConstructors\n" +
2193
				"  }\n" +
2194
				"}");
2195
		
2196
		this.workingCopies[1] = getWorkingCopy(
2197
				"/P/src/p6930/AllConstructors26a.java",
2198
				"package p6930;"+
2199
				"public class AllConstructors26a {\n" +
2200
				"	public class AllConstructors26b {\n" +
2201
				"	  public AllConstructors26b(int i) {}\n" +
2202
				"	}\n" +
2203
				"}");
2204
2205
		// do completion
2206
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true);
2207
		requestor.allowAllRequiredProposals();
2208
		NullProgressMonitor monitor = new NullProgressMonitor();
2209
2210
	    String str = this.workingCopies[0].getSource();
2211
	    String completeBehind = "AllConstructors";
2212
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2213
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
2214
	    
2215
	    assertResults(
2216
			"AllConstructors26b[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors26a$AllConstructors26b;, (I)V, AllConstructors26b, (i), "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
2217
			"   AllConstructors26a.AllConstructors26b[TYPE_REF]{AllConstructors26b, p6930, Lp6930.AllConstructors26a$AllConstructors26b;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
2218
			requestor.getResults());
2219
	} finally {
2220
		deleteProject("P");
2221
		
2222
		JavaCore.setOptions(oldOptions);
2223
	}
2224
}
2225
public void testBug6930_27() throws Exception {
2226
	Hashtable oldOptions = JavaCore.getOptions();
2227
	
2228
	try {
2229
		Hashtable options = new Hashtable(oldOptions);
2230
		options.put(JavaCore.CODEASSIST_VISIBILITY_CHECK, JavaCore.ENABLED);
2231
		JavaCore.setOptions(options);
2232
		
2233
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL_LIB"}, "bin");
2234
		
2235
		refresh(p);
2236
		
2237
		waitUntilIndexesReady();
2238
		
2239
		this.workingCopies = new ICompilationUnit[2];
2240
		this.workingCopies[0] = getWorkingCopy(
2241
				"/P/src/test/Test.java",
2242
				"package test;\n"+
2243
				"public class Test {\n" +
2244
				"  void foo() {\n" +
2245
				"    new p6930.AllConstructors27a.AllConstructors\n" +
2246
				"  }\n" +
2247
				"}");
2248
		
2249
		this.workingCopies[1] = getWorkingCopy(
2250
				"/P/src/p6930/AllConstructors27a.java",
2251
				"package p6930;"+
2252
				"public class AllConstructors27a {\n" +
2253
				"	public static class AllConstructors27b {\n" +
2254
				"	  public AllConstructors27b(int i) {}\n" +
2255
				"	}\n" +
2256
				"}");
2257
2258
		// do completion
2259
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true);
2260
		requestor.allowAllRequiredProposals();
2261
		NullProgressMonitor monitor = new NullProgressMonitor();
2262
2263
	    String str = this.workingCopies[0].getSource();
2264
	    String completeBehind = "AllConstructors";
2265
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2266
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
2267
	    
2268
	    assertResults(
2269
			"AllConstructors27b[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors27a$AllConstructors27b;, (I)V, AllConstructors27b, (i), "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
2270
			"   AllConstructors27a.AllConstructors27b[TYPE_REF]{AllConstructors27b, p6930, Lp6930.AllConstructors27a$AllConstructors27b;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}",
2271
			requestor.getResults());
2272
	} finally {
2273
		deleteProject("P");
2274
		
2275
		JavaCore.setOptions(oldOptions);
2276
	}
2277
}
2278
public void testBug6930_28() throws Exception {
2279
	Hashtable oldOptions = JavaCore.getOptions();
2280
	
2281
	try {
2282
		Hashtable options = new Hashtable(oldOptions);
2283
		options.put(JavaCore.CODEASSIST_VISIBILITY_CHECK, JavaCore.ENABLED);
2284
		JavaCore.setOptions(options);
2285
		
2286
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL_LIB"}, "bin");
2287
		
2288
		refresh(p);
2289
		
2290
		waitUntilIndexesReady();
2291
		
2292
		this.workingCopies = new ICompilationUnit[3];
2293
		this.workingCopies[0] = getWorkingCopy(
2294
				"/P/src/p6930/Test.java",
2295
				"package p6930;\n"+
2296
				"class AllConstructors28a {\n" +
2297
				"	public AllConstructors28a(int i) {}\n" +
2298
				"}\n" +
2299
				"public class Test {\n" +
2300
				"  void foo() {\n" +
2301
				"    new p6930.AllConstructors\n" +
2302
				"  }\n" +
2303
				"}");
2304
		
2305
		this.workingCopies[1] = getWorkingCopy(
2306
				"/P/src/p6930/AllConstructors28b.java",
2307
				"package p6930;"+
2308
				"public class AllConstructors28b {\n" +
2309
				"	public AllConstructors28b(int i) {}\n" +
2310
				"}");
2311
		
2312
		this.workingCopies[2] = getWorkingCopy(
2313
				"/P/src/p6930b/AllConstructors28c.java",
2314
				"package p6930b;"+
2315
				"public class AllConstructors28c {\n" +
2316
				"	public AllConstructors28c(int i) {}\n" +
2317
				"}");
2318
2319
		// do completion
2320
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true);
2321
		requestor.allowAllRequiredProposals();
2322
		NullProgressMonitor monitor = new NullProgressMonitor();
2323
2324
	    String str = this.workingCopies[0].getSource();
2325
	    String completeBehind = "AllConstructors";
2326
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2327
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
2328
	    
2329
	    assertResults(
2330
			"AllConstructors28a[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors28a;, (I)V, AllConstructors28a, (i), "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
2331
			"   AllConstructors28a[TYPE_REF]{AllConstructors28a, p6930, Lp6930.AllConstructors28a;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
2332
			"AllConstructors28b[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors28b;, (I)V, AllConstructors28b, (i), "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
2333
			"   AllConstructors28b[TYPE_REF]{AllConstructors28b, p6930, Lp6930.AllConstructors28b;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}",
2334
			requestor.getResults());
2335
	} finally {
2336
		deleteProject("P");
2337
		
2338
		JavaCore.setOptions(oldOptions);
2339
	}
2340
}
2341
public void testBug6930_29() throws Exception {
2342
	Hashtable oldOptions = JavaCore.getOptions();
2343
	
2344
	try {
2345
		Hashtable options = new Hashtable(oldOptions);
2346
		options.put(JavaCore.CODEASSIST_VISIBILITY_CHECK, JavaCore.ENABLED);
2347
		JavaCore.setOptions(options);
2348
		
2349
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL_LIB", "/P/lib6930.jar"}, "bin");
2350
		
2351
		createJar(new String[] {
2352
			"p6930/AllConstructors29.java",
2353
			"package p6930;\n" +
2354
			"public class AllConstructors29 {\n" +
2355
			"  public AllConstructors29() {}\n" +
2356
			"  public AllConstructors29(Object o) {}\n" +
2357
			"  public AllConstructors29(Object o, String s) {}\n" +
2358
			"}"
2359
		}, p.getProject().getLocation().append("lib6930.jar").toOSString());
2360
		
2361
		refresh(p);
2362
		
2363
		waitUntilIndexesReady();
2364
		
2365
		this.workingCopies = new ICompilationUnit[1];
2366
		this.workingCopies[0] = getWorkingCopy(
2367
				"/P/src/test/Test.java",
2368
				"package test;"+
2369
				"public class Test {\n" +
2370
				"  void foo() {\n" +
2371
				"    p6930.AllConstructors29 var = new AllConstructors\n" +
2372
				"  }\n" +
2373
				"}");
2374
2375
		// do completion
2376
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true);
2377
		requestor.allowAllRequiredProposals();
2378
		NullProgressMonitor monitor = new NullProgressMonitor();
2379
2380
	    String str = this.workingCopies[0].getSource();
2381
	    String completeBehind = "AllConstructors";
2382
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2383
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
2384
	    
2385
	    assertResults(
2386
			"AllConstructors29[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors29;, ()V, AllConstructors29, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED)+"}\n" +
2387
			"   AllConstructors29[TYPE_REF]{p6930.AllConstructors29, p6930, Lp6930.AllConstructors29;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED)+"}\n" +
2388
			"AllConstructors29[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors29;, (Ljava.lang.Object;)V, AllConstructors29, (o), "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED)+"}\n" +
2389
			"   AllConstructors29[TYPE_REF]{p6930.AllConstructors29, p6930, Lp6930.AllConstructors29;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED)+"}\n" +
2390
			"AllConstructors29[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors29;, (Ljava.lang.Object;Ljava.lang.String;)V, AllConstructors29, (o, s), "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED)+"}\n" +
2391
			"   AllConstructors29[TYPE_REF]{p6930.AllConstructors29, p6930, Lp6930.AllConstructors29;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED)+"}",
2392
			requestor.getResults());
2393
	} finally {
2394
		deleteProject("P");
2395
		
2396
		JavaCore.setOptions(oldOptions);
2397
	}
2398
}
2399
public void testBug6930_30() throws Exception {
2400
	Hashtable oldOptions = JavaCore.getOptions();
2401
	
2402
	try {
2403
		Hashtable options = new Hashtable(oldOptions);
2404
		options.put(JavaCore.CODEASSIST_VISIBILITY_CHECK, JavaCore.ENABLED);
2405
		JavaCore.setOptions(options);
2406
		
2407
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL_LIB"}, "bin");
2408
		
2409
		refresh(p);
2410
		
2411
		waitUntilIndexesReady();
2412
		
2413
		this.workingCopies = new ICompilationUnit[1];
2414
		this.workingCopies[0] = getWorkingCopy(
2415
				"/P/src/test/AllConstructors30.java",
2416
				"package test;"+
2417
				"class AllConstructors30b {\n" +
2418
				"  private class Innerb {}\n" +
2419
				"}\n" +
2420
				"public class AllConstructors30 {\n" +
2421
				"  private class Inner {}\n" +
2422
				"  void foo() {\n" +
2423
				"    new AllConstructors\n" +
2424
				"  }\n" +
2425
				"}");
2426
2427
		// do completion
2428
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true);
2429
		requestor.allowAllRequiredProposals();
2430
		NullProgressMonitor monitor = new NullProgressMonitor();
2431
2432
	    String str = this.workingCopies[0].getSource();
2433
	    String completeBehind = "AllConstructors";
2434
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2435
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
2436
	    
2437
	    assertResults(
2438
			"AllConstructors30[TYPE_REF]{AllConstructors30, test, Ltest.AllConstructors30;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
2439
			"AllConstructors30[CONSTRUCTOR_INVOCATION]{(), Ltest.AllConstructors30;, ()V, AllConstructors30, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
2440
			"   AllConstructors30[TYPE_REF]{AllConstructors30, test, Ltest.AllConstructors30;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
2441
			"AllConstructors30b[CONSTRUCTOR_INVOCATION]{(), Ltest.AllConstructors30b;, ()V, AllConstructors30b, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
2442
			"   AllConstructors30b[TYPE_REF]{AllConstructors30b, test, Ltest.AllConstructors30b;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
2443
			requestor.getResults());
2444
	} finally {
2445
		deleteProject("P");
2446
		
2447
		JavaCore.setOptions(oldOptions);
2448
	}
2449
}
2450
public void testBug6930_31() throws Exception {
2451
	Hashtable oldOptions = JavaCore.getOptions();
2452
	
2453
	try {
2454
		Hashtable options = new Hashtable(oldOptions);
2455
		options.put(JavaCore.CODEASSIST_VISIBILITY_CHECK, JavaCore.ENABLED);
2456
		JavaCore.setOptions(options);
2457
		
2458
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL_LIB"}, "bin");
2459
		
2460
		refresh(p);
2461
		
2462
		waitUntilIndexesReady();
2463
		
2464
		this.workingCopies = new ICompilationUnit[1];
2465
		this.workingCopies[0] = getWorkingCopy(
2466
				"/P/src/test/AllConstructors31.java",
2467
				"package test;"+
2468
				"class AllConstructors31b {\n" +
2469
				"  private class Innerb {}\n" +
2470
				"}\n" +
2471
				"public class AllConstructors31 {\n" +
2472
				"  public class Inner {\n" +
2473
				"  }\n" +
2474
				"  void foo() {\n" +
2475
				"    AllConstructors31.Inner var = new AllConstructors\n" +
2476
				"  }\n" +
2477
				"}");
2478
2479
		// do completion
2480
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true);
2481
		requestor.allowAllRequiredProposals();
2482
		NullProgressMonitor monitor = new NullProgressMonitor();
2483
2484
	    String str = this.workingCopies[0].getSource();
2485
	    String completeBehind = "AllConstructors";
2486
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2487
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
2488
	    
2489
	    assertResults(
2490
			"AllConstructors31[TYPE_REF]{AllConstructors31, test, Ltest.AllConstructors31;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
2491
			"AllConstructors31[CONSTRUCTOR_INVOCATION]{(), Ltest.AllConstructors31;, ()V, AllConstructors31, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
2492
			"   AllConstructors31[TYPE_REF]{AllConstructors31, test, Ltest.AllConstructors31;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
2493
			"AllConstructors31b[CONSTRUCTOR_INVOCATION]{(), Ltest.AllConstructors31b;, ()V, AllConstructors31b, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
2494
			"   AllConstructors31b[TYPE_REF]{AllConstructors31b, test, Ltest.AllConstructors31b;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
2495
			requestor.getResults());
2496
	} finally {
2497
		deleteProject("P");
2498
		
2499
		JavaCore.setOptions(oldOptions);
2500
	}
2501
}
2502
public void testBug6930_32() throws Exception {
2503
	Hashtable oldOptions = JavaCore.getOptions();
2504
	
2505
	try {
2506
		Hashtable options = new Hashtable(oldOptions);
2507
		options.put(JavaCore.CODEASSIST_VISIBILITY_CHECK, JavaCore.ENABLED);
2508
		JavaCore.setOptions(options);
2509
		
2510
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL_LIB"}, "bin");
2511
		
2512
		refresh(p);
2513
		
2514
		waitUntilIndexesReady();
2515
		
2516
		this.workingCopies = new ICompilationUnit[1];
2517
		this.workingCopies[0] = getWorkingCopy(
2518
				"/P/src/test/Test.java",
2519
				"package test;"+
2520
				"public class Test {\n" +
2521
				"  public class AllConstructors32b {\n" +
2522
				"    private class Innerb {}\n" +
2523
				"  }\n" +
2524
				"  public class AllConstructors32 {\n" +
2525
				"    public class Inner {}\n" +
2526
				"    void foo() {\n" +
2527
				"      new Test.AllConstructors\n" +
2528
				"    }\n" +
2529
				"  }\n" +
2530
				"}");
2531
2532
		// do completion
2533
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true);
2534
		requestor.allowAllRequiredProposals();
2535
		NullProgressMonitor monitor = new NullProgressMonitor();
2536
2537
	    String str = this.workingCopies[0].getSource();
2538
	    String completeBehind = "AllConstructors";
2539
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2540
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
2541
	    
2542
	    assertResults(
2543
			"AllConstructors32[CONSTRUCTOR_INVOCATION]{(), Ltest.Test$AllConstructors32;, ()V, AllConstructors32, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
2544
			"   Test.AllConstructors32[TYPE_REF]{AllConstructors32, test, Ltest.Test$AllConstructors32;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
2545
			"AllConstructors32b[CONSTRUCTOR_INVOCATION]{(), Ltest.Test$AllConstructors32b;, ()V, AllConstructors32b, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
2546
			"   Test.AllConstructors32b[TYPE_REF]{AllConstructors32b, test, Ltest.Test$AllConstructors32b;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
2547
			"Test.AllConstructors32[TYPE_REF]{AllConstructors32, test, Ltest.Test$AllConstructors32;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}",
2548
			requestor.getResults());
2549
	} finally {
2550
		deleteProject("P");
2551
		
2552
		JavaCore.setOptions(oldOptions);
2553
	}
2554
}
2555
public void testBug6930_33() throws Exception {
2556
	Hashtable oldOptions = JavaCore.getOptions();
2557
	
2558
	try {
2559
		Hashtable options = new Hashtable(oldOptions);
2560
		options.put(JavaCore.CODEASSIST_VISIBILITY_CHECK, JavaCore.ENABLED);
2561
		JavaCore.setOptions(options);
2562
		
2563
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL_LIB"}, "bin");
2564
		
2565
		createFolder("/P/src/p6930");
2566
		createFolder("/P/src/p6930_1");
2567
		createFolder("/P/src/p6930_2");
2568
		
2569
		createFile(
2570
				"/P/src/p6930/AllConstructors33.java",
2571
				"package p6930;\n" +
2572
				"import p6930_2.ParamType;\n" +
2573
				"public class AllConstructors33 {\n" +
2574
				"  public AllConstructors33(ParamType p11, ParamType p12) {}\n" +
2575
				"  public AllConstructors33(p6930_1.ParamType p21, ParamType p22) {}\n" +
2576
				"}");
2577
		
2578
		createFile(
2579
				"/P/src/p6930_1/ParamType.java",
2580
				"package p6930_1;\n" +
2581
				"public class ParamType {\n" +
2582
				"}");
2583
		
2584
		createFile(
2585
				"/P/src/p6930_2/ParamType.java",
2586
				"package p6930_2;\n" +
2587
				"public class ParamType {\n" +
2588
				"}");
2589
		
2590
		refresh(p);
2591
		
2592
		waitUntilIndexesReady();
2593
		
2594
		this.workingCopies = new ICompilationUnit[1];
2595
		this.workingCopies[0] = getWorkingCopy(
2596
				"/P/src/test/Test.java",
2597
				"package test;"+
2598
				"public class Test {\n" +
2599
				"  void foo() {\n" +
2600
				"    new AllConstructors\n" +
2601
				"  }\n" +
2602
				"}");
2603
2604
		// do completion
2605
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true);
2606
		requestor.allowAllRequiredProposals();
2607
		NullProgressMonitor monitor = new NullProgressMonitor();
2608
2609
	    String str = this.workingCopies[0].getSource();
2610
	    String completeBehind = "AllConstructors";
2611
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2612
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
2613
	    
2614
	    assertResults(
2615
			"AllConstructors33[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors33;, (Lp6930_1.ParamType;Lp6930_2.ParamType;)V, AllConstructors33, (p21, p22), "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
2616
			"   AllConstructors33[TYPE_REF]{p6930.AllConstructors33, p6930, Lp6930.AllConstructors33;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
2617
			"AllConstructors33[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors33;, (Lp6930_1.ParamType;Lp6930_2.ParamType;)V, AllConstructors33, (p11, p12), "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
2618
			"   AllConstructors33[TYPE_REF]{p6930.AllConstructors33, p6930, Lp6930.AllConstructors33;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}",
2619
			requestor.getResults());
2620
	} finally {
2621
		deleteProject("P");
2622
		
2623
		JavaCore.setOptions(oldOptions);
2624
	}
2625
}
420
public void testBug79288() throws Exception {
2626
public void testBug79288() throws Exception {
421
	try {
2627
	try {
422
		// create variable
2628
		// 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 / +11 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2008 IBM Corporation and others.
2
 * Copyright (c) 2004, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 84-90 Link Here
84
		this.shortContext = shortContext;
84
		this.shortContext = shortContext;
85
		this.showMissingTypes = showMissingTypes;
85
		this.showMissingTypes = showMissingTypes;
86
		this.showModifiers = showModifiers;
86
		this.showModifiers = showModifiers;
87
88
	}
87
	}
89
	public void acceptContext(CompletionContext cc) {
88
	public void acceptContext(CompletionContext cc) {
90
		this.context = cc;
89
		this.context = cc;
Lines 98-105 Link Here
98
	}
97
	}
99
98
100
	public void allowAllRequiredProposals() {
99
	public void allowAllRequiredProposals() {
101
		for (int i = CompletionProposal.ANONYMOUS_CLASS_DECLARATION; i <= CompletionProposal.TYPE_IMPORT; i++) {
100
		for (int i = CompletionProposal.ANONYMOUS_CLASS_DECLARATION; i <= CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION; i++) {
102
			for (int j = CompletionProposal.ANONYMOUS_CLASS_DECLARATION; j <= CompletionProposal.FIELD_REF_WITH_CASTED_RECEIVER; j++) {
101
			for (int j = CompletionProposal.ANONYMOUS_CLASS_DECLARATION; j <= CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION; j++) {
103
				setAllowsRequiredProposals(i, j, true);
102
				setAllowsRequiredProposals(i, j, true);
104
			}
103
			}
105
		}
104
		}
Lines 394-399 Link Here
394
			case CompletionProposal.TYPE_IMPORT :
393
			case CompletionProposal.TYPE_IMPORT :
395
				buffer.append("TYPE_IMPORT"); //$NON-NLS-1$
394
				buffer.append("TYPE_IMPORT"); //$NON-NLS-1$
396
				break;
395
				break;
396
			case CompletionProposal.CONSTRUCTOR_INVOCATION :
397
				buffer.append("CONSTRUCTOR_INVOCATION"); //$NON-NLS-1$
398
				break;
399
			case CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION :
400
				buffer.append("ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION"); //$NON-NLS-1$
401
				break;
397
			default :
402
			default :
398
				buffer.append("PROPOSAL"); //$NON-NLS-1$
403
				buffer.append("PROPOSAL"); //$NON-NLS-1$
399
				break;
404
				break;
Lines 572-577 Link Here
572
			case CompletionProposal.JAVADOC_VALUE_REF :
577
			case CompletionProposal.JAVADOC_VALUE_REF :
573
			case CompletionProposal.FIELD_IMPORT :
578
			case CompletionProposal.FIELD_IMPORT :
574
			case CompletionProposal.METHOD_IMPORT :
579
			case CompletionProposal.METHOD_IMPORT :
580
			case CompletionProposal.CONSTRUCTOR_INVOCATION :
581
			case CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION :
575
				return new String(proposal.getName());
582
				return new String(proposal.getName());
576
			case CompletionProposal.PACKAGE_REF:
583
			case CompletionProposal.PACKAGE_REF:
577
				return new String(proposal.getDeclarationSignature());
584
				return new String(proposal.getDeclarationSignature());
(-)src/org/eclipse/jdt/core/tests/model/AbstractJavaSearchTests.java (-1 / +101 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 17-32 Link Here
17
import java.util.Collections;
17
import java.util.Collections;
18
import java.util.Comparator;
18
import java.util.Comparator;
19
import java.util.List;
19
import java.util.List;
20
import java.util.Vector;
20
21
21
import org.eclipse.core.resources.*;
22
import org.eclipse.core.resources.*;
22
import org.eclipse.core.runtime.*;
23
import org.eclipse.core.runtime.*;
23
import org.eclipse.jdt.core.*;
24
import org.eclipse.jdt.core.*;
24
import org.eclipse.jdt.core.compiler.CharOperation;
25
import org.eclipse.jdt.core.compiler.CharOperation;
25
import org.eclipse.jdt.core.search.*;
26
import org.eclipse.jdt.core.search.*;
27
import org.eclipse.jdt.internal.compiler.ExtraFlags;
28
import org.eclipse.jdt.internal.compiler.env.AccessRestriction;
26
import org.eclipse.jdt.internal.compiler.problem.AbortCompilationUnit;
29
import org.eclipse.jdt.internal.compiler.problem.AbortCompilationUnit;
27
import org.eclipse.jdt.internal.core.Member;
30
import org.eclipse.jdt.internal.core.Member;
28
import org.eclipse.jdt.internal.core.PackageFragment;
31
import org.eclipse.jdt.internal.core.PackageFragment;
29
import org.eclipse.jdt.internal.core.SourceRefElement;
32
import org.eclipse.jdt.internal.core.SourceRefElement;
33
import org.eclipse.jdt.internal.core.search.BasicSearchEngine;
34
import org.eclipse.jdt.internal.core.search.IRestrictedAccessConstructorRequestor;
30
import org.eclipse.jdt.internal.core.search.matching.PatternLocator;
35
import org.eclipse.jdt.internal.core.search.matching.PatternLocator;
31
36
32
/**
37
/**
Lines 60-65 Link Here
60
	static protected final int SHOW_MATCH_KIND	= 0x0200;
65
	static protected final int SHOW_MATCH_KIND	= 0x0200;
61
	static protected final int SHOW_JAR_FILE			= 0x0400;
66
	static protected final int SHOW_JAR_FILE			= 0x0400;
62
67
68
	public static class ConstructorDeclarationsCollector implements IRestrictedAccessConstructorRequestor {
69
		Vector results = new Vector();
70
		
71
		public void acceptConstructor(
72
				int modifiers,
73
				char[] simpleTypeName,
74
				int parameterCount,
75
				char[] signature,
76
				char[][] parameterTypes,
77
				char[][] parameterNames,
78
				int typeModifiers,
79
				char[] packageName,
80
				int extraFlags,
81
				String path,
82
				AccessRestriction access) {
83
			StringBuffer buffer = new StringBuffer();
84
			
85
			boolean isMemberType = (extraFlags & ExtraFlags.IsMemberType) != 0;
86
			
87
			buffer.append(packageName == null ? CharOperation.NO_CHAR : packageName);
88
			if (isMemberType) {
89
				buffer.append('.');
90
				buffer.append('?'); // enclosing type names are not stored in the indexes
91
				buffer.append('?');
92
				buffer.append('?');
93
			}
94
			buffer.append('.');
95
			buffer.append(simpleTypeName);
96
			buffer.append('#');
97
			buffer.append(simpleTypeName);
98
			buffer.append('(');
99
			
100
			parameterTypes = signature == null ? parameterTypes : Signature.getParameterTypes(signature);
101
			
102
			for (int i = 0; i < parameterCount; i++) {
103
				if (i != 0) buffer.append(',');
104
				
105
				if (parameterTypes != null) {
106
					char[] parameterType;
107
					if (signature != null) {
108
						parameterType = Signature.toCharArray(parameterTypes[i]);
109
						CharOperation.replace(parameterType, '/', '.');
110
					} else {
111
						parameterType = parameterTypes[i];
112
					}
113
					buffer.append(parameterType);
114
				} else {
115
					buffer.append('?'); // parameter type names are not stored in the indexes
116
					buffer.append('?');
117
					buffer.append('?');
118
				}
119
				buffer.append(' ');
120
				if (parameterNames != null) {
121
					buffer.append(parameterNames[i]);
122
				} else {
123
					buffer.append("arg"+i);
124
				}
125
			}
126
			buffer.append(')');
127
			
128
			if (parameterCount < 0) {
129
				buffer.append('*');
130
			}
131
			
132
			this.results.addElement(buffer.toString());
133
		}
134
		
135
		public String toString(){
136
			int length = this.results.size();
137
			String[] strings = new String[length];
138
			this.results.toArray(strings);
139
			org.eclipse.jdt.internal.core.util.Util.sort(strings);
140
			StringBuffer buffer = new StringBuffer(100);
141
			for (int i = 0; i < length; i++){
142
				buffer.append(strings[i]);
143
				if (i != length-1) {
144
					buffer.append('\n');
145
				}
146
			}
147
			return buffer.toString();
148
		}
149
		public int size() {
150
			return this.results.size();
151
		}
152
	}
63
	/**
153
	/**
64
	 * Collects results as a string.
154
	 * Collects results as a string.
65
	 */
155
	 */
Lines 767-772 Link Here
767
	protected void search(String patternString, int searchFor, int limitTo, int matchRule) throws CoreException {
857
	protected void search(String patternString, int searchFor, int limitTo, int matchRule) throws CoreException {
768
		search(patternString, searchFor, limitTo, matchRule, getJavaSearchScope(), this.resultCollector);
858
		search(patternString, searchFor, limitTo, matchRule, getJavaSearchScope(), this.resultCollector);
769
	}
859
	}
860
	protected void searchAllConstructorDeclarations(String pattern, int matchRule, IRestrictedAccessConstructorRequestor requestor) throws JavaModelException {
861
		new BasicSearchEngine(this.workingCopies).searchAllConstructorDeclarations(
862
				null,
863
				pattern.toCharArray(),
864
				matchRule,
865
				SearchEngine.createWorkspaceScope(),
866
				requestor,
867
				IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,
868
				null);
869
	}
770
	protected void searchAllTypeNames(String pattern, int matchRule, TypeNameRequestor requestor) throws JavaModelException {
870
	protected void searchAllTypeNames(String pattern, int matchRule, TypeNameRequestor requestor) throws JavaModelException {
771
		new SearchEngine(this.workingCopies).searchAllTypeNames(
871
		new SearchEngine(this.workingCopies).searchAllTypeNames(
772
			null,
872
			null,
(-)src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java (-1 / +5 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 1128-1133 Link Here
1128
	protected void createJar(String[] javaPathsAndContents, String jarPath) throws IOException {
1128
	protected void createJar(String[] javaPathsAndContents, String jarPath) throws IOException {
1129
		org.eclipse.jdt.core.tests.util.Util.createJar(javaPathsAndContents, jarPath, "1.4");
1129
		org.eclipse.jdt.core.tests.util.Util.createJar(javaPathsAndContents, jarPath, "1.4");
1130
	}
1130
	}
1131
	
1132
	protected void createJar(String[] javaPathsAndContents, String jarPath, String[] classpath, String compliance) throws IOException {
1133
		org.eclipse.jdt.core.tests.util.Util.createJar(javaPathsAndContents, null,jarPath, classpath, compliance);
1134
	}
1131
1135
1132
	/*
1136
	/*
1133
	}
1137
	}

Return to bug 6930