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

Collapse All | Expand All

(-)codeassist/org/eclipse/jdt/internal/codeassist/InternalCompletionProposal.java (-10 / +36 lines)
Lines 210-220 Link Here
210
		}
210
		}
211
211
212
		if(type != null) {
212
		if(type != null) {
213
			String[] args = new String[length];
213
			// https://bugs.eclipse.org/bugs/show_bug.cgi?id=316937
214
			for(int i = 0;	i< length ; i++){
214
			// BinaryType#getMethod() creates a new instance of BinaryMethod, which is a dummy.
215
				args[i] = new String(paramTypeNames[i]);
215
			// Instead we have to use IType#findMethods() to get a handle to the method of our interest.
216
			}
216
			IMethod method = findMethod(type, selector, paramTypeNames);
217
			IMethod method = type.getMethod(new String(selector),args);
218
			
217
			
219
			if (this.hasNoParameterNamesFromIndex) {
218
			if (this.hasNoParameterNamesFromIndex) {
220
				IPackageFragmentRoot packageFragmentRoot = (IPackageFragmentRoot)type.getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT);
219
				IPackageFragmentRoot packageFragmentRoot = (IPackageFragmentRoot)type.getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT);
Lines 307-317 Link Here
307
		}
306
		}
308
307
309
		if(type != null) {
308
		if(type != null) {
310
			String[] args = new String[length];
309
			// https://bugs.eclipse.org/bugs/show_bug.cgi?id=316937
311
			for(int i = 0;	i< length ; i++){
310
			// BinaryType#getMethod() creates a new instance of BinaryMethod, which is a dummy.
312
				args[i] = new String(paramTypeNames[i]);
311
			// Instead we have to use IType#findMethods() to get a handle to the method of our interest.
313
			}
312
			IMethod method = findMethod(type, selector, paramTypeNames);
314
			IMethod method = type.getMethod(new String(selector),args);
315
			try{
313
			try{
316
				parameters = new char[length][];
314
				parameters = new char[length][];
317
				String[] params = method.getParameterNames();
315
				String[] params = method.getParameterNames();
Lines 331-336 Link Here
331
		return parameters;
329
		return parameters;
332
	}
330
	}
333
331
332
	private IMethod findMethod(IType type, char[] selector, char[][] paramTypeNames) {
333
		IMethod method = null;
334
		int startingIndex = 0;
335
		String[] args;
336
		IType enclosingType = type.getDeclaringType();
337
		// If the method is a constructor of an inner type, add the enclosing type as an 
338
		// additional parameter to the constructor.
339
		if (enclosingType != null && CharOperation.equals(type.getElementName().toCharArray(), selector)) {
340
			args = new String[paramTypeNames.length+1];
341
			startingIndex = 1;
342
			args[0] = Signature.createTypeSignature(enclosingType.getFullyQualifiedName(), true);
343
		}
344
		else {
345
			args = new String[paramTypeNames.length];
346
		}
347
		int length = args.length;
348
		for(int i = startingIndex;	i< length ; i++){
349
			args[i] = new String(paramTypeNames[i-startingIndex]);
350
		}
351
		method = type.getMethod(new String(selector), args);
352
		
353
		IMethod[] methods = type.findMethods(method);
354
		if (methods != null && methods.length > 0) {
355
			method = methods[0];
356
		}
357
		return method;
358
	}
359
334
	protected char[] getDeclarationPackageName() {
360
	protected char[] getDeclarationPackageName() {
335
		return this.declarationPackageName;
361
		return this.declarationPackageName;
336
	}
362
	}
(-)model/org/eclipse/jdt/internal/core/BinaryMethod.java (-1 / +4 lines)
Lines 181-187 Link Here
181
181
182
	// try to see if we can retrieve the names from the attached javadoc
182
	// try to see if we can retrieve the names from the attached javadoc
183
	IBinaryMethod info = (IBinaryMethod) getElementInfo();
183
	IBinaryMethod info = (IBinaryMethod) getElementInfo();
184
	final int paramCount = Signature.getParameterCount(new String(info.getMethodDescriptor()));
184
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=316937
185
	// Use Signature#getParameterCount() only if the argument names are not already available.
186
	final int paramCount = info.getArgumentNames() == null ? info.getArgumentNames().length : 
187
										Signature.getParameterCount(new String(info.getMethodDescriptor()));
185
	if (paramCount != 0) {
188
	if (paramCount != 0) {
186
		// don't try to look for javadoc for synthetic methods
189
		// don't try to look for javadoc for synthetic methods
187
		int modifiers = getFlags();
190
		int modifiers = getFlags();

Return to bug 316937