void (final PsiElement psiElement, String packageName) { VirtualFile pkgFile = mySource.createPackageDir(packageName); final PsiDirectory toDir = PsiManager.getInstance(myProject).findDirectory(pkgFile); assertNotNull(toDir); PackageWrapper wrapper = PackageWrapper.create(JavaDirectoryService.getInstance().getPackage(toDir)); new MoveClassesOrPackagesProcessor(myProject, new PsiElement[]{psiElement}, new SingleSourceRootMoveDestination(wrapper, toDir), false, false, null).run(); }