|
|
NPE using quickfix in Aspect opened with java editor |
| Description: | Opened: 2004-10-13 04:51 |
To recreate:
- Check out the QuickFix project from ajdt.test project
- Open TestAspect.java in the Java Editor (right click > open with > Java
Editor)
- Click on the lightbulb with the error marker (the same line as File f = new
File("tmp");
- An Internal Error appear in the Error log with the following stack trace:
java.lang.NullPointerException
at
org.eclipse.jdt.internal.ui.text.correction.UnresolvedElementsSubProcessor.getT
ypeProposals(UnresolvedElementsSubProcessor.java:395)
at org.eclipse.jdt.internal.ui.text.correction.QuickFixProcessor.process
(QuickFixProcessor.java:270)
at org.eclipse.jdt.internal.ui.text.correction.QuickFixProcessor.getCorrections
(QuickFixProcessor.java:202)
at
org.eclipse.jdt.internal.ui.text.correction.JavaCorrectionProcessor.collectCorr
ections(JavaCorrectionProcessor.java:240)
at
org.eclipse.jdt.internal.ui.text.correction.JavaCorrectionProcessor.processAnno
tations(JavaCorrectionProcessor.java:208)
at
org.eclipse.jdt.internal.ui.text.correction.JavaCorrectionProcessor.computeComp
letionProposals(JavaCorrectionProcessor.java:177)
at
org.eclipse.jface.text.contentassist.ContentAssistant.computeCompletionProposal
s(ContentAssistant.java:1472)
at
org.eclipse.jface.text.contentassist.CompletionProposalPopup.computeProposals
(CompletionProposalPopup.java:242)
at org.eclipse.jface.text.contentassist.CompletionProposalPopup.access$7
(CompletionProposalPopup.java:238)
at org.eclipse.jface.text.contentassist.CompletionProposalPopup$1.run
(CompletionProposalPopup.java:197)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:69)
at org.eclipse.jface.text.contentassist.CompletionProposalPopup.showProposals
(CompletionProposalPopup.java:192)
at
org.eclipse.jface.text.contentassist.ContentAssistant.showPossibleCompletions
(ContentAssistant.java:1320)
at
org.eclipse.jdt.internal.ui.text.correction.JavaCorrectionAssistant.showPossibl
eCompletions(JavaCorrectionAssistant.java:159)
at
org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor$AdaptedSourceViewe
r.doOperation(CompilationUnitEditor.java:184)
at org.eclipse.jdt.internal.ui.javaeditor.JavaSelectAnnotationRulerAction.run
(JavaSelectAnnotationRulerAction.java:78)
at org.eclipse.ui.texteditor.AbstractRulerActionDelegate.run
(AbstractRulerActionDelegate.java:99)
at org.eclipse.ui.internal.PluginAction.runWithEvent(PluginAction.java:276)
at org.eclipse.ui.internal.PluginAction.run(PluginAction.java:238)
at org.eclipse.ui.texteditor.AbstractTextEditor$11.triggerAction
(AbstractTextEditor.java:2110)
at org.eclipse.ui.texteditor.AbstractTextEditor$11.mouseUp
(AbstractTextEditor.java:2117)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:136)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:796)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2772)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2431)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1377)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1348)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:254)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:141)
at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:96)
at org.eclipse.core.internal.runtime.PlatformActivator$1.run
(PlatformActivator.java:335)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:273)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:129)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.eclipse.core.launcher.Main.basicRun(Main.java:183)
at org.eclipse.core.launcher.Main.run(Main.java:644)
at org.eclipse.core.launcher.Main.main(Main.java:628)
Looking at the jdt code in UnresolvedElementsSubProcessor.java, at line 395,
the parent field is null:
ASTNode parent= selectedNode.getParent();
while (parent.getLength() == selectedNode.getLength()) { // line 395
parent= parent.getParent();
}
There just needs to be a null check as there is above:
ASTNode selectedNode= problem.getCoveringNode(context.getASTRoot());
if (selectedNode == null) {
return;
}
int kind= SimilarElementsRequestor.ALL_TYPES;
ASTNode parent= selectedNode.getParent();
while (parent.getLength() == selectedNode.getLength()) {
parent= parent.getParent();
}
should become:
ASTNode selectedNode= problem.getCoveringNode(context.getASTRoot());
if (selectedNode == null) {
return;
}
int kind= SimilarElementsRequestor.ALL_TYPES;
ASTNode parent= selectedNode.getParent();
if (parent == null) {
return;
}
while (parent.getLength() == selectedNode.getLength()) {
parent= parent.getParent();
}
This needs to be raised as a jdt bug, since we don't pass through any ajdt
code in order to get here.
Raising this bug against ajdt is just for tracking.
(note this happens on 1.1.12, but also on the latest AJDT dev build).
|