How to imitate "goto declaration"?

I am writing a plugin and want to emulate the behavior of the "CTRL-CLICK" or goto declaration so that when you press the control key and mouse over a string literal the text is underlined and clicking on that text takes you to the resource file.

Is there a way to piggy-back on the existing CTRL-CLICK behavior or do I need to add a mouse listener to the editor? If the later, how do I get access to the editor? Does that have to be done in an action or can I get access in a module component?

]]>

Thanks
8 comments

If your press Ctrl-Click with mouse on element then IDE:
- searches a PsiReferenceProvider instance for this element
- constructs PsiReference using reference provider
- calls the PsiReference.resolve() method that returns element to navigate

So you need to register the provider (for example, in the ProjectComponent.projectOpened() method):

and implement PsiReferenceProvider and PsiReference like this:

0

Thanks for your response. However, I cannot find ReferenceProvidersRegistry or PsiReferenceProvider. Have they been renamed in IntelliJ 6?

0

Jeff Sabin wrote:

Thanks for your response. However, I cannot find ReferenceProvidersRegistry or PsiReferenceProvider. Have they been renamed in IntelliJ 6?


They're not in OpenAPI yet so you have to add idea.jar to your IDEA SDK
manually. Be sure to add this jar to SDK, not your plugin module.

0

Thank you. You have been most helpful.

0

Hi, is it legal that we use API of idea.jar in our plugin?

0

It is often right way to make plugin native to idea ...

0

LiXiao wrote:

Hi, is it legal that we use API of idea.jar in our plugin?


Yes it's perfect from legal point of view.

0

Please sign in to leave a comment.