DomElement (@Nullable final Editor editor) { if(editor == null) return null; final Project project = editor.getProject(); if (project == null) return null; final PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument()); if (!(file instanceof XmlFile)) { return null; } return getDomElement(file.findElementAt(editor.getCaretModel().getOffset())); }