com.intellij.psi.impl.file.PsiDirectoryImpl Java Examples

The following examples show how to use com.intellij.psi.impl.file.PsiDirectoryImpl. 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 File: HaxeMoveTest.java    From intellij-haxe with Apache License 2.0 6 votes vote down vote up
public void testMoveClass() throws Exception {
  final String testHx = "pack1/Moved.hx";
  final String targetDirName = "pack2";
  doTest((rootDir, rootAfter) -> {
    final VirtualFile src = VfsUtil.findRelativeFile(testHx, rootDir);
    assertNotNull("Class pack1.Moved not found", src);


    PsiElement file = myPsiManager.findFile(src);
    assertNotNull("Psi for " + testHx + " not found", file);
    PsiElement cls = file.getNode().getPsi(HaxeFile.class).findChildByClass(HaxeClassDeclaration.class);

    PackageWrapper pack = new PackageWrapper(myPsiManager, targetDirName);
    VirtualFile targetDir = VfsUtil.findRelativeFile(targetDirName, rootDir);
    PsiDirectoryImpl dir = new PsiDirectoryImpl(myPsiManager, targetDir);

    ArrayList<PsiElement> list = new ArrayList<>();
    list.add(cls);
    new MoveClassesOrPackagesProcessor(myProject, PsiUtilCore.toPsiElementArray(list),
                                       new SingleSourceRootMoveDestination(pack, dir),
                                       true, true, null).run();
    FileDocumentManager.getInstance().saveAllDocuments();
  });
}