MoveDirectoryWithClassesProcessor (final String newName, final PsiPackage psiPackage, final boolean searchInComments, final boolean searchInNonJavaFiles) { final Project project = psiPackage.getProject(); final ProjectFileIndex index = ProjectRootManager.getInstance(project).getFileIndex(); final PsiDirectory[] directories = psiPackage.getDirectories(); return new MoveDirectoryWithClassesProcessor(project, directories, null, searchInComments, searchInNonJavaFiles, false, null) { @NotNull @Override public TargetDirectoryWrapper getTargetDirectory(final PsiDirectory dir) { final VirtualFile vFile = dir.getVirtualFile(); final VirtualFile sourceRoot = index.getSourceRootForFile(vFile); LOG.assertTrue(sourceRoot != null, vFile.getPath()); return new TargetDirectoryWrapper(dir.getManager().findDirectory(sourceRoot), newName.replaceAll("\\.", "\\/")); } @Override protected String getTargetName() { return newName; } @NotNull @Override protected String getCommandName() { return JavaBundle.message("rename.package.command.name"); } }; }