public static ResourceRelevance getRelevance(VirtualFile resource,
                                               @Nullable Module module,
                                               ProjectFileIndex fileIndex,
                                               @Nullable GlobalSearchScope additionalScope) {
    boolean inTest = fileIndex.isInTestSourceContent(resource);
    if (module != null) {
      GlobalSearchScope scope = module.getModuleRuntimeScope(inTest);
      Module resourceModule = fileIndex.getModuleForFile(resource);
      if (resourceModule != null &&
          (resourceModule == module || scope.isSearchInModuleContent(resourceModule)) ||
        scope.contains(resource) || (additionalScope != null && additionalScope.contains(resource))) {
        return inTest || fileIndex.isInSource(resource) ? SOURCE : LIBRARY;
      }
    }
    else if (inTest ||  fileIndex.isInSource(resource)) {
      return SOURCE;
    }
    else if (fileIndex.isInLibraryClasses(resource)) {
      return LIBRARY;
    }
    ExternalResourceManagerEx resourceManager = (ExternalResourceManagerEx)ExternalResourceManager.getInstance();
    return resourceManager.isUserResource(resource) ? MAPPED : STANDARD;
  }
public static ResourceRelevance getRelevance(VirtualFile resource,
                                               @Nullable Module module,
                                               ProjectFileIndex fileIndex,
                                               @Nullable GlobalSearchScope additionalScope)