acejump / AceJump

🅰️ single character search, select, and jump
https://plugins.jetbrains.com/plugin/7086-acejump
GNU General Public License v3.0
1.21k stars 91 forks source link

"Cannot find declaration to go to" in Rider #379

Closed Pilvinen closed 3 years ago

Pilvinen commented 3 years ago

Describe the bug "Cannot find declaration to go to" every time when using Declaration Mode. Using the IDEs "Go To" menu does not result in the same error.

To Reproduce Steps to reproduce the behavior:

  1. Tap to declaration mode.
  2. Type in the name and select.
  3. See error.

Expected behavior

  1. Tap to declaration mode.
  2. Type in the name and select.
  3. AceJump jumps to the declaration as if I were using the "Go To" menu.

Screenshots image

Desktop (please complete the following information):

Additional context Awesome addon!

Pilvinen commented 3 years ago

I noticed that this seems to be an issue with "Declaration" but not with "Declaration and Usages":

image

The declaration alone seems to have been removed from Riders "Go To" menu and it now has only "Declaration and Usages" available. To use the "Declaration" only option I have to look it up through Riders "search everywhere" (in other words, the "Declaration" only option cannot be accessed from the normal menus by default). And the "Declaration" only never seems to work - with or without AceJump.

Maybe it's been phased out in favor of "Declaration and Usages"? But that's just my guess.

Pilvinen commented 3 years ago

I asked about it further from JetBrains support: image

And they told me that: image

breandan commented 3 years ago

Thank you for looking into this. Jumping in AceJump's Declaration mode is intended to produce the same result as pressing Ctrl/+[Click] on the token in the editor -- we currently use the GotoDeclarationAction to simulate this, but if I understand what @Pilvinen is saying correctly, this is not a cross-platform solution across all IntelliJ Platform products. In particular, GotoDeclarationAction does not work in Rider. @igor-akhmetov Can you please clarify what is the correct IntelliJ Platform action we should invoke to simulate the default mouse-click navigation event in a cross-platform way? Thank you.

igor-akhmetov commented 3 years ago

@breandan, I believe you should be using ActionManager to instantiate the required actions instead of creating them directly. I.e. in your case you should use ActionManager.getInstance().getAction(id) where id is "GotoDeclaration" or "GotoTypeDeclaration". This approach will also work in Rider, which has its own "goto declaration" actions which communicate with the Rider backend process.

chylex commented 3 years ago

In case you don't want to use hardcoded strings, there are constants in com.intellij.openapi.actionSystem.IdeActions:

IdeActions.ACTION_GOTO_DECLARATION
IdeActions.ACTION_GOTO_TYPE_DECLARATION