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

Collapse All | Expand All

(-)codeassist/org/eclipse/jdt/internal/codeassist/InternalCompletionProposal.java (-30 / +23 lines)
Lines 215-231 Link Here
215
			// https://bugs.eclipse.org/bugs/show_bug.cgi?id=316937
215
			// https://bugs.eclipse.org/bugs/show_bug.cgi?id=316937
216
			// BinaryType#getMethod() creates a new instance of BinaryMethod, which is a dummy.
216
			// BinaryType#getMethod() creates a new instance of BinaryMethod, which is a dummy.
217
			// Instead we have to use IType#findMethods() to get a handle to the method of our interest.
217
			// Instead we have to use IType#findMethods() to get a handle to the method of our interest.
218
			IMethod method = findMethod(type, selector, paramTypeNames);
218
			try {
219
			
219
				IMethod method = findMethod(type, selector, paramTypeNames);
220
			if (this.hasNoParameterNamesFromIndex) {
220
				if (this.hasNoParameterNamesFromIndex) {
221
				IPackageFragmentRoot packageFragmentRoot = (IPackageFragmentRoot)type.getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT);
221
222
				if (packageFragmentRoot.isArchive() ||
222
					IPackageFragmentRoot packageFragmentRoot = (IPackageFragmentRoot)type.getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT);
223
						this.completionEngine.openedBinaryTypes < getOpenedBinaryTypesThreshold()) {
223
					if (packageFragmentRoot.isArchive() ||
224
					SourceMapper mapper = ((JavaElement)method).getSourceMapper();
224
							this.completionEngine.openedBinaryTypes < getOpenedBinaryTypesThreshold()) {
225
					if (mapper != null) {
225
						SourceMapper mapper = ((JavaElement)method).getSourceMapper();
226
						try {
226
						if (mapper != null) {
227
							char[][] paramNames = mapper.getMethodParameterNames(method);
227
							char[][] paramNames = mapper.getMethodParameterNames(method);
228
					
228
229
							// map source and try to find parameter names
229
							// map source and try to find parameter names
230
							if(paramNames == null) {
230
							if(paramNames == null) {
231
								if (!packageFragmentRoot.isArchive()) this.completionEngine.openedBinaryTypes++;
231
								if (!packageFragmentRoot.isArchive()) this.completionEngine.openedBinaryTypes++;
Lines 236-271 Link Here
236
								}
236
								}
237
								paramNames = mapper.getMethodParameterNames(method);
237
								paramNames = mapper.getMethodParameterNames(method);
238
							}
238
							}
239
							
239
240
							if(paramNames != null) {
240
							if(paramNames != null) {
241
								parameters = paramNames;
241
								parameters = paramNames;
242
							}
242
							}
243
						} catch(JavaModelException e){
244
							//parameters == null;
245
						}
243
						}
246
					}
244
					}
247
				}
245
				} else {
248
			} else {
249
				try{
250
					IBinaryMethod info = (IBinaryMethod) ((JavaElement)method).getElementInfo();
246
					IBinaryMethod info = (IBinaryMethod) ((JavaElement)method).getElementInfo();
251
					char[][] argumentNames = info.getArgumentNames();
247
					char[][] argumentNames = info.getArgumentNames();
252
					if (argumentNames != null && argumentNames.length == length) {
248
					if (argumentNames != null && argumentNames.length == length) {
253
						parameters = argumentNames;
249
						parameters = argumentNames;
254
						return parameters;
250
						return parameters;
255
					}
251
					}
256
				} catch(JavaModelException e){
252
257
					//parameters == null;
258
				}
259
				
260
				try{
261
					parameters = new char[length][];
253
					parameters = new char[length][];
262
					String[] params = method.getParameterNames();
254
					String[] params = method.getParameterNames();
263
					for(int i = 0;	i< length ; i++){
255
					for(int i = 0;	i< length ; i++){
264
						parameters[i] = params[i].toCharArray();
256
						parameters[i] = params[i].toCharArray();
265
					}
257
					}
266
				} catch(JavaModelException e){
267
					parameters = null;
268
				}
258
				}
259
			} catch(JavaModelException e){
260
				parameters = null;
269
			}
261
			}
270
		}
262
		}
271
263
Lines 313-320 Link Here
313
			// https://bugs.eclipse.org/bugs/show_bug.cgi?id=316937
305
			// https://bugs.eclipse.org/bugs/show_bug.cgi?id=316937
314
			// BinaryType#getMethod() creates a new instance of BinaryMethod, which is a dummy.
306
			// BinaryType#getMethod() creates a new instance of BinaryMethod, which is a dummy.
315
			// Instead we have to use IType#findMethods() to get a handle to the method of our interest.
307
			// Instead we have to use IType#findMethods() to get a handle to the method of our interest.
316
			IMethod method = findMethod(type, selector, paramTypeNames);
317
			try{
308
			try{
309
				IMethod method = findMethod(type, selector, paramTypeNames);
318
				parameters = new char[length][];
310
				parameters = new char[length][];
319
				String[] params = method.getParameterNames();
311
				String[] params = method.getParameterNames();
320
				for(int i = 0;	i< length ; i++){
312
				for(int i = 0;	i< length ; i++){
Lines 333-351 Link Here
333
		return parameters;
325
		return parameters;
334
	}
326
	}
335
327
336
	private IMethod findMethod(IType type, char[] selector, char[][] paramTypeNames) {
328
	private IMethod findMethod(IType type, char[] selector, char[][] paramTypeNames) throws JavaModelException {
337
		IMethod method = null;
329
		IMethod method = null;
338
		int startingIndex = 0;
330
		int startingIndex = 0;
339
		String[] args;
331
		String[] args;
340
		IType enclosingType = type.getDeclaringType();
332
		IType enclosingType = type.getDeclaringType();
341
		// If the method is a constructor of an inner type, add the enclosing type as an 
333
		// If the method is a constructor of a non-static inner type, add the enclosing type as an 
342
		// additional parameter to the constructor.
334
		// additional parameter to the constructor
343
		if (enclosingType != null && CharOperation.equals(type.getElementName().toCharArray(), selector)) {
335
		if (enclosingType != null
336
				&& CharOperation.equals(type.getElementName().toCharArray(), selector)
337
				&& !Flags.isStatic(type.getFlags())) {
344
			args = new String[paramTypeNames.length+1];
338
			args = new String[paramTypeNames.length+1];
345
			startingIndex = 1;
339
			startingIndex = 1;
346
			args[0] = Signature.createTypeSignature(enclosingType.getFullyQualifiedName(), true);
340
			args[0] = Signature.createTypeSignature(enclosingType.getFullyQualifiedName(), true);
347
		}
341
		} else {
348
		else {
349
			args = new String[paramTypeNames.length];
342
			args = new String[paramTypeNames.length];
350
		}
343
		}
351
		int length = args.length;
344
		int length = args.length;

Return to bug 325270