Community
Participate
Working Groups
Created attachment 99066 [details] call stack cf attached stack trace
Any steps to reproduce?
Looked through the call hierarchy and it seems that org.eclipse.jdt.core.CompletionContext.getVisibleElements(String) returns 'null'.
Looking at the code, I don't see a path were it could possibly return null. David can you please confirm?
I can reproduce the NPE with a debug instance of Eclipse. In ParameterGuesser.parameterProposals(), 'suggestions' is an array of 3 elements. The first element is null. If you tell me where to put breakpoints I can try to provide more information.
It is not possible to getVisibleElements() return null. An array is always returned but looking at the code i found a path where the array can contain a null value. Currently i have no real test case to reproduce the bug.
Can you put a breakpoint in InternalExtendedCompletionContext#getJavaElement() and look if this method is called and return null ?
Yes, it is called and returns null because of the following statement (line 250): if (parent == null) return null;
The first branch is taken ('referenceContext instanceof AbstractMethodDeclaration'), meaning that 'parent' remains null after the call to getJavaElementOfCompilationUnit(). 'methodDeclaration.binding' is null.
Philippe, a test case demonstrating the problem would help even more. David, I think we should still protect ourselves and shrink the array if it contains nulls.
I can reproduce the NPE with the following class: public class Foo { private void addDepencency(int source, int target, int depth) { } private void addDataDependencies(int source) { addD } private void addDataDependencies(int source) { } } Just trigger the completion after "addD".
Thanks Philippe. I was able to reproduce. David please investigate for RC1.
Created attachment 99725 [details] Proposed fix With this patch: - getVisibleElements() can not return an array with a null value. - getVisibleElements() return elements which have a parent with no corresponding binding (like duplicate methods) - AssistSourceField#getKey() and AssistSourceMethod#getKey() andAssistSourceType#getKey() always return a key and never return null.
Jerome - Could you review my patch ?
Patch looks good. +1
Released for 3.4RC1. Tests added CompletionContextTests#test0163() -> test0164()
Verified for 3.4RC1 using I20080513-2000