CodeInsightActionHandler () { return new CodeInsightActionHandler() { @Override public void invoke(@NotNull final Project project, @NotNull final Editor editor, @NotNull final PsiFile file) { final Runnable runnable = () -> { final DomElement element = myProvider.generate(project, editor, file); myProvider.navigate(element); }; if (GenerateDomElementAction.this.startInWriteAction()) { WriteCommandAction.writeCommandAction(project, file).run(() -> runnable.run()); } else { runnable.run(); } } @Override public boolean startInWriteAction() { return false; } }; }