Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Intellij GoToDeclarationHandler
public class MyGoToDeclarationHandler extends GotoDeclarationHandlerBase {
public PsiElement[] getGotoDeclarationTargets(PsiElement sourceElement, int offset, Editor editor) {
if (sourceElement.getParent().getParent().getParent() instanceof XmlTag) {
XmlTag tag = (XmlTag)sourceElement.getParent().getParent().getParent();
if (tag.getName().equals("custom:include")) {
VirtualFile currentFile = PsiUtilCore.getVirtualFile(sourceElement);
LinkedList<PsiElement> elements = new LinkedList<PsiElement>();
//this is a silly behavior for demonstration, just take the first file(s) in this directory
return elements.toArray(new PsiElement[0]);
return null;
public PsiElement getGotoDeclarationTarget(PsiElement sourceElement, Editor editor) {
return null;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.