public void actionPerformedImpl(@NotNull final Project project, final Editor editor) { if (editor == null) return; // final PsiFile psiFile = // PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument()); final PsiFile psiFile = PsiUtilBase.getPsiFileInEditor(editor, project); if (psiFile == null) return; CommandProcessor.getInstance() .executeCommand( project, () -> { final CodeInsightActionHandler handler = getHandler(); final Runnable action = () -> { if (!ApplicationManager.getApplication().isUnitTestMode() && !editor.getContentComponent().isShowing()) return; handler.invoke(project, editor, psiFile); }; if (handler.startInWriteAction()) { ApplicationManager.getApplication().runWriteAction(action); } else { action.run(); } }, getCommandName(), DocCommandGroupId.noneGroupId(editor.getDocument())); }
// mouse events public void mouseClicked(final MouseEvent e) { CommandProcessor.getInstance() .executeCommand( myEditor.getProject(), new Runnable() { public void run() { doMouseClicked(e); } }, EditorBundle.message("move.caret.command.name"), DocCommandGroupId.noneGroupId(getDocument()), UndoConfirmationPolicy.DEFAULT, getDocument()); }
public void actionPerformed(AnActionEvent e) { final BaseRefactorHandler handler = initHandler(e.getProject(), e.getDataContext()); boolean processChooser = handler.processChooser(); if (processChooser) { final Editor editor = getEditor(e); CommandProcessor.getInstance() .executeCommand( e.getProject(), new Runnable() { @Override public void run() { ApplicationManager.getApplication().runWriteAction(handler); } }, getClass().getName() + "-Commandname", DocCommandGroupId.noneGroupId(editor.getDocument())); } }