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

(-)search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java (-1 / +30 lines)
Lines 519-525 Link Here
519
519
520
	return createMethodHandle(type, new String(method.selector), parameterTypeSignatures);
520
	return createMethodHandle(type, new String(method.selector), parameterTypeSignatures);
521
}
521
}
522
522
/*
523
 * Create binary method handle
524
 */
525
IMethod createBinaryMethodHandle(IType type, char[] methodSelector, char[][] argumentTypeNames, MatchLocator locator) {
526
	ClassFileReader reader = MatchLocator.classFileReader(type);
527
	if (reader != null) {
528
		IBinaryMethod[] methods = reader.getMethods();
529
		if (methods != null) {
530
			int argCount = argumentTypeNames == null ? 0 : argumentTypeNames.length;
531
			nextMethod : for (int i = 0, methodsLength = methods.length; i < methodsLength; i++) {
532
				IBinaryMethod binaryMethod = methods[i];
533
				char[] selector = binaryMethod.getSelector();
534
				if (CharOperation.equals(selector, methodSelector)) {
535
					char[] signature = binaryMethod.getGenericSignature();
536
					if (signature == null) signature = binaryMethod.getMethodDescriptor();
537
					char[][] parameterTypes = Signature.getParameterTypes(signature);
538
					if (argCount != parameterTypes.length) continue nextMethod;
539
					for (int j = 0; j < argCount; j++) {
540
						char[] parameterTypeName = ClassFileMatchLocator.convertClassFileFormat(parameterTypes[j]);
541
						if (!CharOperation.endsWith(Signature.toCharArray(Signature.getTypeErasure(parameterTypeName)), argumentTypeNames[j]))
542
							continue nextMethod;
543
						parameterTypes[j] = parameterTypeName;
544
					}
545
					return (IMethod) locator.createMethodHandle(type, new String(selector), CharOperation.toStrings(parameterTypes));
546
				}
547
			}
548
		}
549
	}
550
	return null;
551
}
523
/*
552
/*
524
 * Create method handle.
553
 * Create method handle.
525
 * Store occurences for create handle to retrieve possible duplicate ones.
554
 * Store occurences for create handle to retrieve possible duplicate ones.
(-)search/org/eclipse/jdt/internal/core/search/matching/MethodLocator.java (-8 / +21 lines)
Lines 483-504 Link Here
483
	if (type == null) return; // case of a secondary type
483
	if (type == null) return; // case of a secondary type
484
484
485
	char[] bindingSelector = methodBinding.selector;
485
	char[] bindingSelector = methodBinding.selector;
486
	boolean isBinary = type.isBinary();
487
	IMethod method = null;
486
	TypeBinding[] parameters = methodBinding.original().parameters;
488
	TypeBinding[] parameters = methodBinding.original().parameters;
487
	int parameterLength = parameters.length;
489
	int parameterLength = parameters.length;
488
	String[] parameterTypes = new String[parameterLength];
490
	if (isBinary) {
489
	for (int i = 0; i  < parameterLength; i++) {
491
		char[][] parameterTypes = new char[parameterLength][];
490
		char[] typeName = parameters[i].shortReadableName();
492
		for (int i = 0; i<parameterLength; i++) {
491
		if (parameters[i].isMemberType()) {
493
			char[] typeName = parameters[i].qualifiedSourceName();
492
			typeName = CharOperation.subarray(typeName, CharOperation.indexOf('.', typeName)+1, typeName.length);
494
			for (int j=0, dim=parameters[i].dimensions(); j<dim; j++) {
495
				typeName = CharOperation.concat(typeName, new char[] {'[', ']'});
496
			}
497
			parameterTypes[i] = typeName;
493
		}
498
		}
494
		parameterTypes[i] = Signature.createTypeSignature(typeName, false);
499
		method = locator.createBinaryMethodHandle(type, methodBinding.selector, parameterTypes, locator);
500
	} else {
501
		String[] parameterTypes = new String[parameterLength];
502
		for (int i = 0; i  < parameterLength; i++) {
503
			char[] typeName = parameters[i].shortReadableName();
504
			if (parameters[i].isMemberType()) {
505
				typeName = CharOperation.subarray(typeName, CharOperation.indexOf('.', typeName)+1, typeName.length);
506
			}
507
			parameterTypes[i] = Signature.createTypeSignature(typeName, false);
508
		}
509
		method = type.getMethod(new String(bindingSelector), parameterTypes);
495
	}
510
	}
496
	IMethod method = type.getMethod(new String(bindingSelector), parameterTypes);
497
	if (knownMethods.includes(method)) return;
511
	if (knownMethods.includes(method)) return;
498
512
499
	knownMethods.add(method);
513
	knownMethods.add(method);
500
	IResource resource = type.getResource();
514
	IResource resource = type.getResource();
501
	boolean isBinary = type.isBinary();
502
	IBinaryType info = null;
515
	IBinaryType info = null;
503
	if (isBinary) {
516
	if (isBinary) {
504
		if (resource == null)
517
		if (resource == null)
(-)src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java (-1 / +23 lines)
Lines 46-52 Link Here
46
//	org.eclipse.jdt.internal.codeassist.SelectionEngine.DEBUG = true;
46
//	org.eclipse.jdt.internal.codeassist.SelectionEngine.DEBUG = true;
47
//	TESTS_PREFIX =  "testBug110336";
47
//	TESTS_PREFIX =  "testBug110336";
48
//	TESTS_NAMES = new String[] { "testBug110336e" };
48
//	TESTS_NAMES = new String[] { "testBug110336e" };
49
//	TESTS_NUMBERS = new int[] { 79267 };
49
	TESTS_NUMBERS = new int[] { 119545 };
50
//	TESTS_RANGE = new int[] { 83304, -1 };
50
//	TESTS_RANGE = new int[] { 83304, -1 };
51
	}
51
	}
52
52
Lines 5549-5552 Link Here
5549
		collector
5549
		collector
5550
	);
5550
	);
5551
}
5551
}
5552
5553
/**
5554
 * @test Bug 119545: [search] Binary java method model elements returned by SearchEngine have unresolved parameter types
5555
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=119545"
5556
 */
5557
public void testBug119545() throws CoreException {
5558
	workingCopies = new ICompilationUnit[1];
5559
	workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b119545/Test.java",
5560
		"package b119545;\n" + 
5561
		"class Test {\n" + 
5562
		"	void foo(Object o1, Object o2){\n" + 
5563
		"		if (o1.equals(o2)) {}\n" + 
5564
		"	}\n" + 
5565
		"}\n"
5566
	);
5567
	IType type = workingCopies[0].getType("Test");
5568
	IMethod method = type.getMethods()[0];
5569
	searchDeclarationsOfSentMessages(method, this.resultCollector);
5570
	assertSearchResults(
5571
		"???"
5572
	);
5573
}
5552
}
5574
}

Return to bug 119545