use of com.intellij.refactoring.move.moveClassesOrPackages.MoveDirectoryWithClassesProcessor in project intellij-community by JetBrains.
the class RenamePsiPackageProcessor method createRenameMoveProcessor.
public static MoveDirectoryWithClassesProcessor createRenameMoveProcessor(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) {
@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;
}
@Override
protected String getCommandName() {
return "Rename package";
}
};
}
Aggregations