Search in sources :

Example 6 with DocumentReference

use of com.intellij.openapi.command.undo.DocumentReference in project intellij-community by JetBrains.

the class DiffUtil method putNonundoableOperation.

public static void putNonundoableOperation(@Nullable Project project, @NotNull Document document) {
    UndoManager undoManager = project != null ? UndoManager.getInstance(project) : UndoManager.getGlobalInstance();
    if (undoManager != null) {
        DocumentReference ref = DocumentReferenceManager.getInstance().create(document);
        undoManager.nonundoableActionPerformed(ref, false);
    }
}
Also used : UndoManager(com.intellij.openapi.command.undo.UndoManager) DocumentReference(com.intellij.openapi.command.undo.DocumentReference)

Example 7 with DocumentReference

use of com.intellij.openapi.command.undo.DocumentReference in project android by JetBrains.

the class AndroidResourceRenameResourceProcessor method renameElement.

@Override
public void renameElement(PsiElement element, final String newName, UsageInfo[] usages, @Nullable RefactoringElementListener listener) throws IncorrectOperationException {
    if (element instanceof PsiField) {
        new RenameJavaVariableProcessor().renameElement(element, newName, usages, listener);
    } else {
        if (element instanceof PsiNamedElement) {
            super.renameElement(element, newName, usages, listener);
            if (element instanceof PsiFile) {
                VirtualFile virtualFile = ((PsiFile) element).getVirtualFile();
                if (virtualFile != null && !LocalHistory.getInstance().isUnderControl(virtualFile)) {
                    DocumentReference ref = DocumentReferenceManager.getInstance().create(virtualFile);
                    UndoManager.getInstance(element.getProject()).nonundoableActionPerformed(ref, false);
                }
            }
        } else if (element instanceof XmlAttributeValue) {
            new RenameXmlAttributeProcessor().renameElement(element, newName, usages, listener);
        }
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) RenameJavaVariableProcessor(com.intellij.refactoring.rename.RenameJavaVariableProcessor) RenameXmlAttributeProcessor(com.intellij.refactoring.rename.RenameXmlAttributeProcessor) XmlAttributeValue(com.intellij.psi.xml.XmlAttributeValue) DocumentReference(com.intellij.openapi.command.undo.DocumentReference)

Example 8 with DocumentReference

use of com.intellij.openapi.command.undo.DocumentReference in project intellij-community by JetBrains.

the class CommandMerger method flushCurrentCommand.

void flushCurrentCommand() {
    if (hasActions()) {
        if (!myAdditionalAffectedDocuments.isEmpty()) {
            DocumentReference[] refs = myAdditionalAffectedDocuments.toArray(new DocumentReference[myAdditionalAffectedDocuments.size()]);
            myCurrentActions.add(new BasicUndoableAction(refs) {

                @Override
                public void undo() {
                }

                @Override
                public void redo() {
                }
            });
        }
        myManager.getUndoStacksHolder().addToStacks(new UndoableGroup(myCommandName, isGlobal(), myManager, myStateBefore, myStateAfter, myCurrentActions, myUndoConfirmationPolicy, isTransparent(), myValid));
    }
    reset();
}
Also used : BasicUndoableAction(com.intellij.openapi.command.undo.BasicUndoableAction) DocumentReference(com.intellij.openapi.command.undo.DocumentReference)

Example 9 with DocumentReference

use of com.intellij.openapi.command.undo.DocumentReference in project intellij-community by JetBrains.

the class CommandMerger method affectsMultiplePhysicalDocs.

private boolean affectsMultiplePhysicalDocs() {
    Set<VirtualFile> affectedFiles = new HashSet<>();
    for (DocumentReference each : myAllAffectedDocuments) {
        VirtualFile file = each.getFile();
        if (isVirtualDocumentChange(file))
            continue;
        affectedFiles.add(file);
        if (affectedFiles.size() > 1)
            return true;
    }
    return false;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) LightVirtualFile(com.intellij.testFramework.LightVirtualFile) DocumentReference(com.intellij.openapi.command.undo.DocumentReference) THashSet(gnu.trove.THashSet)

Example 10 with DocumentReference

use of com.intellij.openapi.command.undo.DocumentReference in project intellij-community by JetBrains.

the class DocumentReferenceManagerImpl method createFromDocument.

@NotNull
private DocumentReference createFromDocument(@NotNull final Document document) {
    DocumentReference result = myDocToRef.get(document);
    if (result == null) {
        result = new DocumentReferenceByDocument(document);
        myDocToRef.put(document, result);
    }
    return result;
}
Also used : DocumentReference(com.intellij.openapi.command.undo.DocumentReference) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

DocumentReference (com.intellij.openapi.command.undo.DocumentReference)13 VirtualFile (com.intellij.openapi.vfs.VirtualFile)5 NotNull (org.jetbrains.annotations.NotNull)3 BasicUndoableAction (com.intellij.openapi.command.undo.BasicUndoableAction)2 THashSet (gnu.trove.THashSet)2 UndoManager (com.intellij.openapi.command.undo.UndoManager)1 Document (com.intellij.openapi.editor.Document)1 DocumentEx (com.intellij.openapi.editor.ex.DocumentEx)1 Project (com.intellij.openapi.project.Project)1 ReadonlyStatusHandler (com.intellij.openapi.vfs.ReadonlyStatusHandler)1 PsiFile (com.intellij.psi.PsiFile)1 XmlAttributeValue (com.intellij.psi.xml.XmlAttributeValue)1 RenameJavaVariableProcessor (com.intellij.refactoring.rename.RenameJavaVariableProcessor)1 RenameXmlAttributeProcessor (com.intellij.refactoring.rename.RenameXmlAttributeProcessor)1 LightVirtualFile (com.intellij.testFramework.LightVirtualFile)1 HashMap (com.intellij.util.containers.HashMap)1 File (java.io.File)1