Community
Participate
Working Groups
I believe there is a bug in the org.eclipse.jdt.internal.codeassist.CompletionEngine. When I am code assisting in the detail pane of the variables view for a class such as "Sample$1 $InnerClass" I get the following NPE. I believe the completion engine should be using the topLevelType instead of the type at line 598 to generate the typeDeclaration. NPE: java.lang.NullPointerException at org.eclipse.jdt.internal.codeassist.CompletionEngine.complete (CompletionEngine.java:605) at org.eclipse.jdt.internal.core.SourceType.codeComplete (SourceType.java:68) at org.eclipse.jdt.internal.debug.ui.display.DetailsCompletionProcessor.computeComp letionProposals(DetailsCompletionProcessor.java:64) at org.eclipse.jface.text.contentassist.ContentAssistant.computeCompletionProposals (ContentAssistant.java:1197) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.computeProposals (CompletionProposalPopup.java:103) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.access$3 (CompletionProposalPopup.java:102) at org.eclipse.jface.text.contentassist.CompletionProposalPopup$1.run (CompletionProposalPopup.java:71) at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:56) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.showProposals (CompletionProposalPopup.java:66) at org.eclipse.jface.text.contentassist.ContentAssistant$2.run (ContentAssistant.java:265) at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:29) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages (Synchronizer.java:93) at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:1397) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1211) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:755) at org.eclipse.ui.internal.Workbench.run(Workbench.java:738) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:777) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:319) at EclipseRuntimeLauncher.main(EclipseRuntimeLauncher.java:14)
I can not reproduce this problem. Could you give me a more accurate test case ?
Created attachment 543 [details] Sample.java
Test Case (using latest code in HEAD on dev.eclipse.org): Use the attached source (Sample.java), breakpoint on line 32. Debug, hit breakpoint Go to the variables view showing the detail pane Select the "this" variable Code assist in the detail pane (popup menu or ctrl-space)
There is an error in my code. I correct it and now NPE does not occur. But with this test case no completion proposal are possible because the completion is on the member type Sample.InnerClass and this type does not exist. Fixed.
Doing a code completion in the Java Editor at line 36 with "this." gives the following completions: innerClassVar1 innerClassIVar1 innerMethod1(String innerArg1) <<all the methods inherited from Object>> Doing it with the "this" variable selected in the variables view with "this." entered in the detail pane we get no completions why is this different?
In DisplayCompletionProcessor#getType you use IType#getType. This method can give a handle on member type, but not local type and not anonymous type. In fact it is not possible to create a handle on local or anonymous. DisplayCompletionProcessor ------------------------------------------------------ protected IType getType( ... ) throws DebugException { ... try { ... for (int i = 1; i < typeNames.length; i++) { String innerTypeName= typeNames[i]; try { Integer.parseInt(innerTypeName); continue; //loop over anonymous types } catch (NumberFormatException e) { } type = type.getType(innerTypeName); } } catch (JavaModelException e) { throw new DebugException(e.getStatus()); } return type; } ------------------------------------------------------ The enclosing type of the completion is the local type Sample$1$InnerClass. But in this algorithm the result is a handle on member type Sample$InnerClass and this member type does not exist. That's why there is no completion.