use of com.intellij.refactoring.move.moveClassesOrPackages.SingleSourceRootMoveDestination in project intellij-community by JetBrains.
the class GroovyMoveScriptTest method performAction.
private void performAction(String[] fileNames, String newDirName, String dir) {
final PsiFile[] files = new PsiFile[fileNames.length];
for (int i = 0; i < files.length; i++) {
String fileName = fileNames[i];
final VirtualFile file = myFixture.getTempDirFixture().getFile(dir + "/" + fileName);
assertNotNull("File " + fileName + " not found", file);
files[i] = PsiManager.getInstance(getProject()).findFile(file);
assertNotNull("File " + fileName + " not found", files[i]);
}
final VirtualFile virDir = myFixture.getTempDirFixture().getFile(dir + "/" + newDirName);
assertNotNull("Directory " + newDirName + " not found", virDir);
final PsiDirectory psiDirectory = PsiManager.getInstance(getProject()).findDirectory(virDir);
assertNotNull("Directory " + newDirName + " not found", psiDirectory);
final PsiPackage pkg = JavaDirectoryService.getInstance().getPackage(psiDirectory);
List<PsiClass> classList = new ArrayList<>();
for (PsiFile file : files) {
Collections.addAll(classList, ((PsiClassOwner) file).getClasses());
}
final PsiClass[] classes = classList.toArray(new PsiClass[classList.size()]);
new MoveClassesOrPackagesProcessor(getProject(), classes, new SingleSourceRootMoveDestination(PackageWrapper.create(pkg), psiDirectory), true, true, null).run();
PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
FileDocumentManager.getInstance().saveAllDocuments();
}
use of com.intellij.refactoring.move.moveClassesOrPackages.SingleSourceRootMoveDestination in project android by JetBrains.
the class AndroidRenameTest method doMoveClass.
private void doMoveClass(String className, String newParentPackageName) throws Exception {
final JavaPsiFacade facade = JavaPsiFacade.getInstance(getProject());
final PsiClass psiClass = facade.findClass(className, GlobalSearchScope.projectScope(getProject()));
final PsiPackage newParentPackage = facade.findPackage(newParentPackageName);
assertNotNull(newParentPackage);
final PsiDirectory[] dirs = newParentPackage.getDirectories();
assertEquals(dirs.length, 1);
new MoveClassesOrPackagesProcessor(getProject(), new PsiElement[] { psiClass }, new SingleSourceRootMoveDestination(PackageWrapper.create(newParentPackage), dirs[0]), true, false, null).run();
FileDocumentManager.getInstance().saveAllDocuments();
}
use of com.intellij.refactoring.move.moveClassesOrPackages.SingleSourceRootMoveDestination in project android by JetBrains.
the class AndroidRenameTest method moveClass.
private void moveClass(final String className, final String newPackageName) throws Throwable {
PsiClass aClass = JavaPsiFacade.getInstance(getProject()).findClass(className, GlobalSearchScope.projectScope(getProject()));
PsiPackage aPackage = JavaPsiFacade.getInstance(getProject()).findPackage(newPackageName);
assertNotNull(aPackage);
final PsiDirectory[] dirs = aPackage.getDirectories();
assertEquals(dirs.length, 1);
new MoveClassesOrPackagesProcessor(getProject(), new PsiElement[] { aClass }, new SingleSourceRootMoveDestination(PackageWrapper.create(JavaDirectoryService.getInstance().getPackage(dirs[0])), dirs[0]), true, true, null).run();
}
Aggregations