@Override
  public Module getModule() {
    if (!isValid()) return null;
    VirtualFile virtualFile = getFile();
    if (virtualFile == null) return null;

    ProjectRootManager projectRootManager = ProjectRootManager.getInstance(getProject());
    ProjectFileIndex fileIndex = projectRootManager.getFileIndex();
    return fileIndex.getModuleForFile(virtualFile);
  }
  private boolean isExcludeRoot(VirtualFile file) {
    VirtualFile parent = file.getParent();
    if (parent == null) return false;

    Module module = myProjectRootManager.getFileIndex().getModuleForFile(parent);
    if (module == null) return false;
    VirtualFile[] excludeRoots = ModuleRootManager.getInstance(module).getExcludeRoots();
    for (VirtualFile root : excludeRoots) {
      if (root.equals(file)) return true;
    }
    return false;
  }
  @Override
  public OrderEntry getLibraryEntry() {
    if (!isValid()) return null;
    PsiFile psiFile = getPsiFile();
    VirtualFile virtualFile = getFile();
    if (virtualFile == null) return null;

    ProjectRootManager projectRootManager = ProjectRootManager.getInstance(getProject());
    ProjectFileIndex fileIndex = projectRootManager.getFileIndex();

    if (psiFile instanceof PsiCompiledElement || fileIndex.isInLibrarySource(virtualFile)) {
      List<OrderEntry> orders = fileIndex.getOrderEntriesForFile(virtualFile);
      for (OrderEntry order : orders) {
        if (order instanceof LibraryOrderEntry || order instanceof JdkOrderEntry) {
          return order;
        }
      }
    }

    return null;
  }
 @NotNull
 @Override
 public Collection<String> getNonTrivialPackagePrefixes() {
   Set<String> names = myNontrivialPackagePrefixes;
   if (names == null) {
     names = new HashSet<>();
     final ProjectRootManager rootManager = ProjectRootManager.getInstance(myManager.getProject());
     final List<VirtualFile> sourceRoots =
         rootManager.getModuleSourceRoots(JavaModuleSourceRootTypes.SOURCES);
     final ProjectFileIndex fileIndex = rootManager.getFileIndex();
     for (final VirtualFile sourceRoot : sourceRoots) {
       if (sourceRoot.isDirectory()) {
         final String packageName = fileIndex.getPackageNameByDirectory(sourceRoot);
         if (packageName != null && !packageName.isEmpty()) {
           names.add(packageName);
         }
       }
     }
     myNontrivialPackagePrefixes = names;
   }
   return names;
 }