GoToDeclarationHandler - Inconsistent behavior between single element and multi-element return values
Here is a Gist of a demonstration of the problem that I'm running into: https://gist.github.com/anonymous/403f05eee87ad81ffb01
When line 14 is commented out, the behavior is as expected. With that line, however, an exception is thrown.
Upon further investigation, it seems that the reason that this error is being generated is that the PSIElement that I'm returning does not have a PSIReference associated with it. Is this something that I can fix? Preferably without writing a custom language plugin. Is it possible to extend an existing language plugin?
Of note, I'm using idea/117.1037 for testing.
The exception generated is:
[ 17137] ERROR - com.intellij.ide.IdeEventQueue - Error during dispatching of java.awt.event.MouseEvent[MOUSE_RELEASED,(537,334),absolute(536,361),button=1,modifiers=Ctrl+Button1,extModifiers=Ctrl,clickCount=1] on frame0
java.lang.NullPointerException
at com.intellij.codeInsight.navigation.actions.GotoDeclarationAction.chooseAmbiguousTarget(GotoDeclarationAction.java:149)
at com.intellij.codeInsight.navigation.actions.GotoDeclarationAction.a(GotoDeclarationAction.java:118)
at com.intellij.codeInsight.navigation.actions.GotoDeclarationAction.invoke(GotoDeclarationAction.java:81)
at com.intellij.codeInsight.actions.CodeInsightAction$1$1.run(CodeInsightAction.java:60)
at com.intellij.codeInsight.actions.CodeInsightAction$1.run(CodeInsightAction.java:67)
at com.intellij.openapi.command.impl.CommandProcessorImpl.executeCommand(CommandProcessorImpl.java:117)
at com.intellij.openapi.command.impl.CommandProcessorImpl.executeCommand(CommandProcessorImpl.java:93)
at com.intellij.openapi.command.impl.CommandProcessorImpl.executeCommand(CommandProcessorImpl.java:81)
at com.intellij.codeInsight.actions.CodeInsightAction.actionPerformedImpl(CodeInsightAction.java:54)
at com.intellij.codeInsight.actions.CodeInsightAction.actionPerformed(CodeInsightAction.java:40)
at com.intellij.openapi.keymap.impl.IdeMouseEventDispatcher.dispatchMouseEvent(IdeMouseEventDispatcher.java:209)
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:533)
at com.intellij.ide.IdeEventQueue.b(IdeEventQueue.java:420)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:378)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
[ 17138] ERROR - com.intellij.ide.IdeEventQueue - IntelliJ IDEA 11.1.5 Build #IU-117.1037
[ 17138] ERROR - com.intellij.ide.IdeEventQueue - JDK: 1.7.0_13
[ 17138] ERROR - com.intellij.ide.IdeEventQueue - VM: Java HotSpot(TM) 64-Bit Server VM
[ 17138] ERROR - com.intellij.ide.IdeEventQueue - Vendor: Oracle Corporation
[ 17138] ERROR - com.intellij.ide.IdeEventQueue - OS: Linux
[ 17138] ERROR - com.intellij.ide.IdeEventQueue - Last Action: GotoDeclaration
Please sign in to leave a comment.
Hi Julian,
Your stack trace doesn't correspond to the source code - GotoDeclarationAction
Denis
As mentioned, I'm running idea/117.1037 for testing.
You can find the GoToDeclarationHandler at that version here: GotoDeclarationAction.java
Alternatively with a local copy of the repository, "git checkout idea/117.1037" will put your working copy at this version.
Sorry, didn't notice the build info at first.
The problem has been fixed at v.12 - GotoDeclarationAction:
if (reference == null) { title = titlePattern; }Awesome, thanks!
Guess I'll be asking for a new key.. haha :)