void (@NotNull final PsiPackage psiPackage, @NotNull final String newQualifiedName) { ApplicationManager.getApplication().assertWriteAccessAllowed(); final String oldQualifedName = psiPackage.getQualifiedName(); final boolean anyChanged = changePackagePrefixes(psiPackage, oldQualifedName, newQualifiedName); if (anyChanged) { UndoManager.getInstance(psiPackage.getProject()).undoableActionPerformed(new GlobalUndoableAction() { @Override public void undo() { changePackagePrefixes(psiPackage, newQualifiedName, oldQualifedName); } @Override public void redo() { changePackagePrefixes(psiPackage, oldQualifedName, newQualifiedName); } }); } }