How to implement references to elements not in project?

Hi all,

In my plugin, I have references working correctly. However frequently I'd like to identify symbols that come from the underlying implementation, such as built in functions. The user can't navigate to these symbols since the source code is not available, but otherwise I'd like them to act as normal symbols, i.e. participate in Find Usages. I can't see a way to do this without having a PsiElement for them. Is there a way to do this?

Thanks,
Colin

6 comments
Comment actions Permalink

Hello Colin,

In my plugin, I have references working correctly. However frequently
I'd like to identify symbols that come from the underlying
implementation, such as built in functions. The user can't navigate to
these symbols since the source code is not available, but otherwise
I'd like them to act as normal symbols, i.e. participate in Find
Usages. I can't see a way to do this without having a PsiElement for
them. Is there a way to do this?


No, you do need to have PsiElements for the built-in symbols. The way we
usually solve this problem is by generating stubs for built-in functions
as source code in the same language, and including them in the plugin / IDE
distribution.

--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0
Comment actions Permalink

Hi Dmitry,

Ok, thanks. How do I stop users navigating to them, then? And how do I load the source files - as a resource from the plugin jar?

Cheers,
Colin

0
Comment actions Permalink

Hello Colin,

Ok, thanks. How do I stop users navigating to them, then?


Do you really need to? We don't. :)

And how do I
load the source files - as a resource from the plugin jar?


Yes, for example. Or put them side-by-side with the plugin jar in the plugin
zip.

--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0
Comment actions Permalink

Hi Dmitry,

Do you really need to? We don't. :)


Maybe not - it seems a little weird though :-)

Yes, for example. Or put them side-by-side with the plugin jar in the plugin

zip.


Ok, I'll try that. How/when would I load these files?

Thanks,
Colin

0
Comment actions Permalink

BTW is there a public example of this technique I could look at?

Thanks,
Colin

0
Comment actions Permalink

Hello Colin,

BTW is there a public example of this technique I could look at?


You can look at how this works in the Ruby plugin. You don't get to see the
source code, but the principle should be clear from the UI.

--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0

Please sign in to leave a comment.