void (@NotNull AnActionEvent event) { final Project project = event.getProject(); if (project == null) { // no active project LOG.debug("No project"); return; } Editor editor = event.getData(CommonDataKeys.EDITOR); if (editor == null) { FileEditorManager fem = FileEditorManager.getInstance(project); editor = fem.getSelectedTextEditor(); } if (editor == null) { // no editor available LOG.debug("No editor"); return; } // do we have an xml file? final PsiDocumentManager pdm = PsiDocumentManager.getInstance(project); final PsiFile psiFile = pdm.getPsiFile(editor.getDocument()); if (!(psiFile instanceof XmlFile)) { // not xml LOG.debug("No XML-File: " + psiFile); return; } // make sure PSI is in sync with document pdm.commitDocument(editor.getDocument()); execute(editor); }