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:

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
at com.intellij.codeInsight.navigation.actions.GotoDeclarationAction.chooseAmbiguousTarget(
at com.intellij.codeInsight.navigation.actions.GotoDeclarationAction.a(
at com.intellij.codeInsight.navigation.actions.GotoDeclarationAction.invoke(
at com.intellij.codeInsight.actions.CodeInsightAction$1$
at com.intellij.codeInsight.actions.CodeInsightAction$
at com.intellij.openapi.command.impl.CommandProcessorImpl.executeCommand(
at com.intellij.openapi.command.impl.CommandProcessorImpl.executeCommand(
at com.intellij.openapi.command.impl.CommandProcessorImpl.executeCommand(
at com.intellij.codeInsight.actions.CodeInsightAction.actionPerformedImpl(
at com.intellij.codeInsight.actions.CodeInsightAction.actionPerformed(
at com.intellij.openapi.keymap.impl.IdeMouseEventDispatcher.dispatchMouseEvent(
at com.intellij.ide.IdeEventQueue._dispatchEvent(
at com.intellij.ide.IdeEventQueue.b(
at com.intellij.ide.IdeEventQueue.dispatchEvent(
at java.awt.EventDispatchThread.pumpOneEventForFilters(
at java.awt.EventDispatchThread.pumpEventsForFilter(
at java.awt.EventDispatchThread.pumpEventsForHierarchy(
at java.awt.EventDispatchThread.pumpEvents(
at java.awt.EventDispatchThread.pumpEvents(
[  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


Hi Julian,

Your stack trace doesn't correspond to the source code - GotoDeclarationAction



As mentioned, I'm running idea/117.1037 for testing.

You can find the GoToDeclarationHandler at that version here:

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 :)


Please sign in to leave a comment.