void (Project project, Editor editor, PsiElement element) { final String refactoringId = getRefactoringId(element); RefactoringEventData beforeData = new RefactoringEventData(); PsiElement scope = getScope(element); beforeData.addElement(element); beforeData.addElement(scope); project.getMessageBus().syncPublisher(RefactoringEventListener.REFACTORING_EVENT_TOPIC) .refactoringStarted(refactoringId, beforeData); try { ActionContext context = ActionContext.from(editor, element.getContainingFile()).withElement(element); String name = getActionName(element); ModCommand command = ProgressManager.getInstance().runProcessWithProgressSynchronously(() -> { return ReadAction.nonBlocking(() -> perform(context)).executeSynchronously(); }, name, true, context.project()); if (command == null) return; CommandProcessor.getInstance().executeCommand( context.project(), () -> ModCommandExecutor.getInstance().executeInteractively(context, command, editor), name, null); } finally { final RefactoringEventData afterData = new RefactoringEventData(); afterData.addElement(scope); project.getMessageBus().syncPublisher(RefactoringEventListener.REFACTORING_EVENT_TOPIC).refactoringDone(refactoringId, afterData); } }