@Override
  public PsiPackage getPackage(@NotNull PsiDirectory dir) {
    Project project = dir.getProject();
    VirtualFile file = VirtualFileUtil.originalFileOrSelf(dir.getVirtualFile());
    String packageName = PackageIndex.getInstance(project).getPackageNameByDirectory(file);
    if (packageName == null) return null;
    return JavaPsiFacade.getInstance(project).findPackage(packageName);
  }
@Override
  public PsiPackage getPackage(@NotNull PsiDirectory dir)