How to follow to some psi element in file?

Hi,

Unfortunately can't find any information about it.  

I create some psi element in psi file and I need to go to this psi element (to move cursor in editor).

What API can I use to complete the task?

 

0

Hi Evgeniy,

if element is com.intellij.pom.Navigatable, then you can call navigate. If the element is not, then you need to element.getTextRange() to get the offset of the element and editor.getCaretModel().moveToOffset(). You need to ensure that the editor is opened, like

```

OpenFileDescriptor descriptor = new OpenFileDescriptor(project, containingFile.getVirtualFile());
return FileEditorManager.getInstance(project).openTextEditor(descriptor, true);

```

Anna

 

0

请先登录再写评论。