Object () { PsiFile file = getPsiFile(); if (file == null) return null; if (file.getViewProvider() instanceof TemplateLanguageFileViewProvider) { return super.getSelectorInFile(); } Editor editor = getEditor(); if (editor == null) { return super.getSelectorInFile(); } int offset = TargetElementUtil.adjustOffset(file, editor.getDocument(), editor.getCaretModel().getOffset()); PsiElement element = file.findElementAt(offset); return element != null ? element : super.getSelectorInFile(); }