Go To / Find Usages / Rename between files

Hello,

Having Go To (ctrl click) / Find Usages (alt f7) / Rename (shift f6) working within a file for a custom language - how do I enable these resolve-based features to work within all project files of the custom language?

Thanks in advance for any tip.

Cheers,
Steve.

4 comments

Hello Steve,

First of all, you need to have resolve between files working correctly. There
is no single recipe for how to implement that - this depends on your language,
whether it has import statements or some implicit way to refer from one file
to another, etc. I can give you some advice if you provide more details.

After you have that, inter-file find usages/rename mostly comes for free.

I have resolve / find usages / rename working within a file for a
custom language - how do I enable this to work within all project
files of the custom language?


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


0

Hi Dmitry,

Yes, it will be fairly quick and simple to search through other project files for the declaration if it does not exist in the same Psi tree.

So I really just need a pointer on how to find the PsiFiles of the other project source files for the custom language type.

I had ideas on 2 approaches - either using ReferencesSearch (the default implementation, or perhaps plug in my own), or calling getFilesFromAllModules(OrderRootType.SOURCES) from the ProjectRootManager (if it is easy to get the PsiFile from a VirtualFile and know that the Psi tree has been built).

Cheers from Australia,
Steve

0

Hello Steve,

ReferencesSearch is implemented on top of resolve, so you already have to
have resolve working correctly before you can make use of ReferencesSearch.
:)

getFilesFromAllModules() is certainly a possibility if your projects are
small and you think it would be OK from the performance point of view. To
get PSI for a virtual file, use PsiManager.findFile() - it will build the
PSI tree automatically if needed.

Yes, it will be fairly quick and simple to search through other
project files for the declaration if it does not exist in the same Psi
tree.

So I really just need a pointer on how to find the other project
source files for the custom language type.

I had ideas on 2 approaches - either using ReferencesSearch (the
default implementation, or perhaps plug in my own), or calling
getFilesFromAllModules(OrderRootType.SOURCES) from the
ProjectRootManager (if it is easy to get the PsiFile from a
VirtualFile and know that the Psi tree has been built).


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


0

Please sign in to leave a comment.