Navigatable () { PsiElement element = (PsiElement)myTreeElement.getValue(); if (element == null) return null; int offset = element.getTextRange().getStartOffset(); final Language dataLanguage = ((TemplateLanguageFileViewProvider)myMainFile.getViewProvider()).getTemplateDataLanguage(); final PsiFile dataFile = myMainFile.getViewProvider().getPsi(dataLanguage); if (dataFile == null) return null; PsiElement tlElement = dataFile.findElementAt(offset); while (tlElement != null && tlElement.getTextRange().getStartOffset() == offset) { if (tlElement instanceof Navigatable) { return (Navigatable)tlElement; } tlElement = tlElement.getParent(); } return null; }