Search in sources :

Example 1 with RefactoringTransaction

use of com.intellij.refactoring.listeners.impl.RefactoringTransaction in project intellij-community by JetBrains.

the class ChangeSignatureProcessorBase method performRefactoring.

@Override
protected void performRefactoring(@NotNull UsageInfo[] usages) {
    RefactoringTransaction transaction = getTransaction();
    final ChangeInfo changeInfo = myChangeInfo;
    final RefactoringElementListener elementListener = transaction == null ? null : transaction.getElementListener(changeInfo.getMethod());
    final String fqn = CopyReferenceAction.elementToFqn(changeInfo.getMethod());
    if (fqn != null) {
        UndoableAction action = new BasicUndoableAction() {

            @Override
            public void undo() {
                if (elementListener instanceof UndoRefactoringElementListener) {
                    ((UndoRefactoringElementListener) elementListener).undoElementMovedOrRenamed(changeInfo.getMethod(), fqn);
                }
            }

            @Override
            public void redo() {
            }
        };
        UndoManager.getInstance(myProject).undoableActionPerformed(action);
    }
    try {
        doChangeSignature(changeInfo, usages);
        final PsiElement method = changeInfo.getMethod();
        LOG.assertTrue(method.isValid());
        if (elementListener != null && changeInfo.isNameChanged()) {
            elementListener.elementRenamed(method);
        }
    } catch (IncorrectOperationException e) {
        LOG.error(e);
    }
}
Also used : RefactoringElementListener(com.intellij.refactoring.listeners.RefactoringElementListener) UndoRefactoringElementListener(com.intellij.refactoring.listeners.UndoRefactoringElementListener) RefactoringTransaction(com.intellij.refactoring.listeners.impl.RefactoringTransaction) UndoRefactoringElementListener(com.intellij.refactoring.listeners.UndoRefactoringElementListener) BasicUndoableAction(com.intellij.openapi.command.undo.BasicUndoableAction) UndoableAction(com.intellij.openapi.command.undo.UndoableAction) IncorrectOperationException(com.intellij.util.IncorrectOperationException) BasicUndoableAction(com.intellij.openapi.command.undo.BasicUndoableAction) PsiElement(com.intellij.psi.PsiElement)

Aggregations

BasicUndoableAction (com.intellij.openapi.command.undo.BasicUndoableAction)1 UndoableAction (com.intellij.openapi.command.undo.UndoableAction)1 PsiElement (com.intellij.psi.PsiElement)1 RefactoringElementListener (com.intellij.refactoring.listeners.RefactoringElementListener)1 UndoRefactoringElementListener (com.intellij.refactoring.listeners.UndoRefactoringElementListener)1 RefactoringTransaction (com.intellij.refactoring.listeners.impl.RefactoringTransaction)1 IncorrectOperationException (com.intellij.util.IncorrectOperationException)1