Navigate among files in a project

Answered

Hi,

Is there an API in IDEA to navigate within files in the same project. As an example I can get the PsiFile/ virtual file which I want to open in a new editor view. But how can I open that file in a new editor view and navigate the user tot hat newly opened editor view?

5 comments
Comment actions Permalink

Hello Sajith,

to navigate from a symbol in code (e.g. symbol which points to a file), you can resolve symbol to that file. Then you can navigate to file by ctrl click

PsiFile subclasses PsiElement.

0
Comment actions Permalink

Hi Imants,

I want to navigate the user to that file opened in a new editor view, programatically. Further, I want the user to be navigated when a button is clicked, rather than clicked on a symbol in editor view (I have written a custom editor provider and it will show the button in the editor view)

0
Comment actions Permalink

this might work (not tested):

EditorFactory.getInstance().createEditor(...)

0
Comment actions Permalink

PsiFile extends Navigatable interface, so it has 'navigate' method, which should do what you need.

0
Comment actions Permalink

Hi Dimitry,

It worked like a charm. Thank you.

0

Please sign in to leave a comment.