@Override
 @Nullable
 public PsiPackage findPackage(@NotNull String packageName) {
   Query<VirtualFile> dirs = myPackageIndex.getDirsByPackageName(packageName, true);
   if (dirs.findFirst() == null) return null;
   return new PsiPackageImpl(myManager, packageName);
 }
 public JavaFileManagerImpl(Project project) {
   myManager = PsiManagerEx.getInstanceEx(project);
   myPackageIndex = PackageIndex.getInstance(myManager.getProject());
   project
       .getMessageBus()
       .connect()
       .subscribe(
           ProjectTopics.PROJECT_ROOTS,
           new ModuleRootAdapter() {
             @Override
             public void rootsChanged(final ModuleRootEvent event) {
               myNontrivialPackagePrefixes = null;
             }
           });
 }