use of com.intellij.openapi.editor.actionSystem.DocCommandGroupId in project intellij-community by JetBrains.
the class BaseRefactoringAction method actionPerformed.
@Override
public final void actionPerformed(@NotNull AnActionEvent e) {
DataContext dataContext = e.getDataContext();
Project project = e.getProject();
if (project == null)
return;
PsiDocumentManager.getInstance(project).commitAllDocuments();
final Editor editor = e.getData(CommonDataKeys.EDITOR);
final PsiElement[] elements = getPsiElementArray(dataContext);
int eventCount = IdeEventQueue.getInstance().getEventCount();
RefactoringActionHandler handler;
try {
handler = getHandler(dataContext);
} catch (ProcessCanceledException ignored) {
return;
}
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;
}
InplaceRefactoring activeInplaceRenamer = InplaceRefactoring.getActiveInplaceRenamer(editor);
if (!InplaceRefactoring.canStartAnotherRefactoring(editor, project, handler, elements) && activeInplaceRenamer != null) {
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, "Completion", group, UndoConfirmationPolicy.DEFAULT, doc);
}
}
IdeEventQueue.getInstance().setEventCount(eventCount);
if (editor != null) {
final PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument());
if (file == null)
return;
DaemonCodeAnalyzer.getInstance(project).autoImportReferenceAtCursor(editor, file);
handler.invoke(project, editor, file, dataContext);
} else {
handler.invoke(project, elements, dataContext);
}
}
Aggregations