void (@NotNull Project project, @NotNull DataContext dataContext, @Nullable RefactoringActionHandler handler) { final Editor editor = dataContext.getData(CommonDataKeys.EDITOR); if (handler == null) { String message = RefactoringBundle.getCannotRefactorMessage(RefactoringBundle.message("error.wrong.caret.position.symbol.to.refactor")); CommonRefactoringUtil.showErrorHint(project, editor, message, RefactoringBundle.getCannotRefactorMessage(null), null); return; } final PsiElement[] elements = getPsiElementArray(dataContext); InplaceRefactoring activeInplaceRenamer = InplaceRefactoring.getActiveInplaceRenamer(editor); if (activeInplaceRenamer != null && !InplaceRefactoring.canStartAnotherRefactoring(editor, handler, elements)) { InplaceRefactoring.unableToStartWarning(project, editor); return; } if (activeInplaceRenamer == null) { final LookupEx lookup = LookupManager.getActiveLookup(editor); if (lookup instanceof LookupImpl) { Runnable command = () -> ((LookupImpl)lookup).finishLookup(Lookup.NORMAL_SELECT_CHAR); Document doc = editor.getDocument(); DocCommandGroupId group = DocCommandGroupId.noneGroupId(doc); CommandProcessor.getInstance() .executeCommand(editor.getProject(), command, ApplicationBundle.message("title.code.completion"), group, UndoConfirmationPolicy.DEFAULT, doc); } } final PsiFile file = editor != null ? PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument()) : null; final Language language = file != null ? file.getLanguage() : (elements.length > 0 ? elements[0].getLanguage() : null); ArrayList<EventPair<?>> data = new ArrayList<>(); data.add(RefactoringUsageCollector.HANDLER.with(handler.getClass())); data.add(EventFields.Language.with(language)); if (elements.length > 0) { data.add(RefactoringUsageCollector.ELEMENT.with(elements[0].getClass())); } RefactoringUsageCollector.HANDLER_INVOKED.log(project, data); if (editor != null) { if (file == null) return; DaemonCodeAnalyzer.getInstance(project).autoImportReferenceAtCursor(editor, file); handler.invoke(project, editor, file, dataContext); } else { handler.invoke(project, elements, dataContext); } }