View | Details | Raw Unified | Return to bug 272148
Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/model/CompletionTests.java (+30 lines)
Lines 15738-15743 Link Here
15738
			"   TestConstructor1[TYPE_REF]{TestConstructor1, test, Ltest.TestConstructor1;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
15738
			"   TestConstructor1[TYPE_REF]{TestConstructor1, test, Ltest.TestConstructor1;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
15739
			requestor.getResults());
15739
			requestor.getResults());
15740
}
15740
}
15741
public void testConstructor7() throws JavaModelException {
15742
	this.workingCopies = new ICompilationUnit[2];
15743
	this.workingCopies[0] = getWorkingCopy(
15744
		"/Completion/src/test/Test.java",
15745
		"package test;"+
15746
		"public class Test {\n" +
15747
		"        public void foo(Object o) {\n" +
15748
		"                new TestConstructor\n" +
15749
		"        }\n" +
15750
		"}");
15751
	this.workingCopies[1] = getWorkingCopy(
15752
		"/Completion/src/test/TestConstructor1.java",
15753
		"package test;"+
15754
		"public class TestConstructor1 {\n" +
15755
		"        public TestConstructor1(int[] i) {\n" +
15756
		"        }\n" +
15757
		"}");
15758
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true);
15759
	requestor.allowAllRequiredProposals();
15760
	NullProgressMonitor monitor = new NullProgressMonitor();
15761
	String str = this.workingCopies[0].getSource();
15762
	String completeBehind = "TestConstructor";
15763
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
15764
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
15765
15766
	assertResults(
15767
			"TestConstructor1[CONSTRUCTOR_INVOCATION]{(), Ltest.TestConstructor1;, ([I)V, TestConstructor1, (i), "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
15768
			"   TestConstructor1[TYPE_REF]{TestConstructor1, test, Ltest.TestConstructor1;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
15769
			requestor.getResults());
15770
}
15741
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=127296
15771
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=127296
15742
public void testDeprecationCheck1() throws JavaModelException {
15772
public void testDeprecationCheck1() throws JavaModelException {
15743
	Hashtable options = JavaCore.getOptions();
15773
	Hashtable options = JavaCore.getOptions();
(-)codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java (-23 / +46 lines)
Lines 390-395 Link Here
390
		return result;
390
		return result;
391
	}
391
	}
392
	
392
	
393
	private static char[] getTypeName(TypeReference typeReference) {
394
		char[] typeName = CharOperation.concatWith(typeReference.getTypeName(), '.');
395
		int dims = typeReference.dimensions();
396
		if (dims > 0) {
397
			int length = typeName.length;
398
			int newLength = length + (dims*2);
399
			System.arraycopy(typeName, 0, typeName = new char[newLength], 0, length);
400
			for (int k = length; k < newLength; k += 2) {
401
				typeName[k] = '[';
402
				typeName[k+1] = ']';
403
			}
404
		}
405
		
406
		return typeName;
407
	}
408
	
393
	private static boolean hasStaticMemberTypes(ReferenceBinding typeBinding, SourceTypeBinding invocationType, CompilationUnitScope unitScope) {
409
	private static boolean hasStaticMemberTypes(ReferenceBinding typeBinding, SourceTypeBinding invocationType, CompilationUnitScope unitScope) {
394
		ReferenceBinding[] memberTypes = typeBinding.memberTypes();
410
		ReferenceBinding[] memberTypes = typeBinding.memberTypes();
395
		int length = memberTypes == null ? 0 : memberTypes.length;
411
		int length = memberTypes == null ? 0 : memberTypes.length;
Lines 5244-5284 Link Here
5244
					guessedType = ref.resolveType((ClassScope)scope);
5260
					guessedType = ref.resolveType((ClassScope)scope);
5245
					break;
5261
					break;
5246
			}
5262
			}
5247
		} finally {
5263
		
5248
			this.lookupEnvironment.nameEnvironment = oldNameEnvironment;
5249
		}
5250
5264
5251
		if (guessedType != null && guessedType.isValidBinding()) {
5265
			if (guessedType != null && guessedType.isValidBinding()) {
5252
			if (guessedType instanceof SourceTypeBinding) {
5266
				if (guessedType instanceof SourceTypeBinding) {
5253
				SourceTypeBinding refBinding = (SourceTypeBinding) guessedType;
5267
					SourceTypeBinding refBinding = (SourceTypeBinding) guessedType;
5254
				
5255
				refBinding.methods(); // force resolution
5256
				if (refBinding.scope == null || refBinding.scope.referenceContext == null) return null;
5257
				TypeDeclaration typeDeclaration = refBinding.scope.referenceContext;
5258
				AbstractMethodDeclaration[] methods = typeDeclaration.methods;
5259
				next : for (int i = 0; i < methods.length; i++) {
5260
					AbstractMethodDeclaration method = methods[i];
5261
					
5268
					
5262
					if (method.binding == null || !method.isConstructor()) continue next;
5269
					if (refBinding.scope == null || refBinding.scope.referenceContext == null) return null;
5263
					
5270
					
5264
					Argument[] arguments = method.arguments;
5271
					TypeDeclaration typeDeclaration = refBinding.scope.referenceContext;
5265
					int argumentsLength = arguments == null ? 0 : arguments.length;
5272
					AbstractMethodDeclaration[] methods = typeDeclaration.methods;
5266
					if (parameterCount != argumentsLength) continue next;
5267
					
5273
					
5268
					for (int j = 0; j < argumentsLength; j++) {
5274
					next : for (int i = 0; i < methods.length; i++) {
5269
						if (!CharOperation.equals(CharOperation.concatWith(arguments[j].type.getTypeName(), '.'), parameterTypes[j])) {
5275
						AbstractMethodDeclaration method = methods[i];
5270
							continue next;
5276
						
5277
						if (!method.isConstructor()) continue next;
5278
						
5279
						Argument[] arguments = method.arguments;
5280
						int argumentsLength = arguments == null ? 0 : arguments.length;
5281
						
5282
						if (parameterCount != argumentsLength) continue next;
5283
						
5284
						for (int j = 0; j < argumentsLength; j++) {
5285
							char[] argumentTypeName = getTypeName(arguments[j].type);
5286
	
5287
							if (!CharOperation.equals(argumentTypeName, parameterTypes[j])) {
5288
								continue next;
5289
							}
5271
						}
5290
						}
5291
						
5292
						refBinding.resolveTypesFor(method.binding); // force resolution
5293
						if (method.binding == null) continue next;
5294
						return getSignature(method.binding);
5272
					}
5295
					}
5273
					
5274
					return getSignature(method.binding);
5275
				}
5296
				}
5276
			}
5297
			}
5298
		} finally {
5299
			this.lookupEnvironment.nameEnvironment = oldNameEnvironment;
5277
		}
5300
		}
5278
		
5301
		
5279
		return null;
5302
		return null;
5280
	}
5303
	}
5281
5304
	
5282
	private void findConstructorsOrAnonymousTypes(
5305
	private void findConstructorsOrAnonymousTypes(
5283
			ReferenceBinding currentType,
5306
			ReferenceBinding currentType,
5284
			Scope scope,
5307
			Scope scope,

Return to bug 272148