Java Code Examples for com.intellij.refactoring.move.moveFilesOrDirectories.MoveFilesOrDirectoriesProcessor

The following examples show how to use com.intellij.refactoring.move.moveFilesOrDirectories.MoveFilesOrDirectoriesProcessor. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: intellij-haxe   Source File:    License: Apache License 2.0 5 votes vote down vote up
private void doTest(final String[] toMove, final String targetDirName) throws Exception {
  doTest(new PerformAction() {
    public void performAction(VirtualFile rootDir, VirtualFile rootAfter) throws Exception {
      Collection<PsiElement> files = new ArrayList<PsiElement>();
      for (String s : toMove) {
        final VirtualFile child = VfsUtil.findRelativeFile(s, rootDir);
        assertNotNull("Neither class nor file " + s + " not found", child);
        PsiElement file = myPsiManager.findFile(child);
        if (file == null) file = JavaPsiFacade.getInstance(myProject).findPackage(s);
      final VirtualFile child1 = VfsUtil.findRelativeFile(targetDirName, rootDir);
      assertNotNull("Target dir " + targetDirName + " not found", child1);
      final PsiDirectory targetDirectory = myPsiManager.findDirectory(child1);

      if (files.iterator().next() instanceof PsiFile) {
        new MoveFilesOrDirectoriesProcessor(myProject, PsiUtilCore.toPsiElementArray(files), targetDirectory,
                                            false, false, null, null).run();
      else if (files.iterator().next() instanceof PsiPackage) {
        PsiPackage newParentPackage = JavaPsiFacade.getInstance(myPsiManager.getProject()).findPackage(targetDirName);
        final PsiDirectory[] dirs = newParentPackage.getDirectories();
        assertEquals(dirs.length, 1);

        new MoveClassesOrPackagesProcessor(myProject, PsiUtilCore.toPsiElementArray(files),
                                           new SingleSourceRootMoveDestination(PackageWrapper.create(newParentPackage),
                                           true, true, null).run();