use of com.intellij.refactoring.rename.inplace.InplaceRefactoring in project intellij-community by JetBrains.
the class ReassignVariableUtil method finishTemplate.
private static void finishTemplate(Editor editor) {
final TemplateState templateState = TemplateManagerImpl.getTemplateState(editor);
final InplaceRefactoring renamer = editor.getUserData(InplaceRefactoring.INPLACE_RENAMER);
if (templateState != null && renamer != null) {
templateState.gotoEnd(true);
editor.putUserData(InplaceRefactoring.INPLACE_RENAMER, null);
}
}
use of com.intellij.refactoring.rename.inplace.InplaceRefactoring 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