@Override
  public void handleQualifiedNameChange(
      final PsiPackage psiPackage, final String newQualifiedName) {
    ApplicationManager.getApplication().assertWriteAccessAllowed();
    final String oldQualifedName = psiPackage.getQualifiedName();
    final boolean anyChanged = changePackagePrefixes(psiPackage, oldQualifedName, newQualifiedName);
    if (anyChanged) {
      UndoManager.getInstance(psiPackage.getProject())
          .undoableActionPerformed(
              new GlobalUndoableAction() {
                @Override
                public void undo() {
                  changePackagePrefixes(psiPackage, newQualifiedName, oldQualifedName);
                }

                @Override
                public void redo() {
                  changePackagePrefixes(psiPackage, oldQualifedName, newQualifiedName);
                }
              });
    }
  }
  @Override
  public VirtualFile[] occursInPackagePrefixes(PsiPackage psiPackage) {
    List<VirtualFile> result = new ArrayList<VirtualFile>();
    final Module[] modules = ModuleManager.getInstance(psiPackage.getProject()).getModules();

    for (final Module module : modules) {
      for (final ContentEntry contentEntry :
          ModuleRootManager.getInstance(module).getContentEntries()) {
        final List<SourceFolder> sourceFolders =
            contentEntry.getSourceFolders(JavaModuleSourceRootTypes.SOURCES);
        for (final SourceFolder sourceFolder : sourceFolders) {
          final String packagePrefix = sourceFolder.getPackagePrefix();
          if (packagePrefix.startsWith(psiPackage.getQualifiedName())) {
            final VirtualFile file = sourceFolder.getFile();
            if (file != null) {
              result.add(file);
            }
          }
        }
      }
    }

    return VfsUtil.toVirtualFileArray(result);
  }
 @Override
 public boolean packagePrefixExists(PsiPackage psiPackage) {
   return PackagePrefixElementFinder.getInstance(psiPackage.getProject())
       .packagePrefixExists(psiPackage.getQualifiedName());
 }