void (String packageName, String newPackageName) { PsiPackage aPackage = JavaPsiFacade.getInstance(myPsiManager.getProject()).findPackage(packageName); assertNotNull("Package " + packageName + " not found", aPackage); //PsiDirectory dir = aPackage.getDirectories()[0]; //to rename dir with classes move is used new RenameProcessor(myProject, aPackage, newPackageName, true, true).run(); FileDocumentManager.getInstance().saveAllDocuments(); }