void (@NotNull final Project project, @NotNull final ProblemDescriptor descriptor) { DictionarySuggestionProvider provider = findProvider(); if (provider != null) { provider.setActive(true); } PsiElement psiElement = descriptor.getPsiElement(); if (psiElement == null) return; final Editor editor = getEditor(psiElement, project); if (editor == null) return; SimpleDataContext.Builder builder = SimpleDataContext.builder(); if (editor instanceof EditorWindow) { builder.add(CommonDataKeys.EDITOR, editor); builder.add(CommonDataKeys.PSI_ELEMENT, psiElement); } else if (ApplicationManager.getApplication().isUnitTestMode()) { // TextEditorComponent / FiledEditorManagerImpl give away the data in real life PsiElement data = (PsiElement)new TextEditorPsiDataProvider() .getData(CommonDataKeys.PSI_ELEMENT.getName(), editor, editor.getCaretModel().getCurrentCaret()); builder.add(CommonDataKeys.PSI_ELEMENT, data); } final Boolean selectAll = editor.getUserData(RenameHandlerRegistry.SELECT_ALL); try { editor.putUserData(RenameHandlerRegistry.SELECT_ALL, true); DataContext dataContext = builder.setParent(EditorUtil.getEditorDataContext(editor)).build(); AnAction action = new RenameElementAction(); AnActionEvent event = AnActionEvent.createFromAnAction(action, null, "", dataContext); action.actionPerformed(event); if (provider != null) { provider.setActive(false); } } finally { editor.putUserData(RenameHandlerRegistry.SELECT_ALL, selectAll); } }