@ApiStatus.Internal
  public static boolean isInScope(@NotNull Usage usage, @NotNull SearchScope searchScope, @NotNull SearchScope everythingScope) {
    if (searchScope.equals(everythingScope)) return true;
    return ReadAction.compute(() -> {
      VirtualFile file;
      if (usage instanceof PsiElementUsage psiElementUsage) {
        PsiElement element = psiElementUsage.getElement();
        if (element == null) return false;
        if (searchScope instanceof EverythingGlobalScope ||
            searchScope instanceof ProjectScopeImpl ||
            searchScope instanceof ProjectAndLibrariesScope) return true;
        file = PsiUtilCore.getVirtualFile(element);
      }
      else if (usage instanceof UsageInFile usageInFile){
        file = usageInFile.getFile(); 
      }
      else {
        return false;
      }
      return file != null && isFileInScope(file, searchScope);
    });
  }
@ApiStatus.Internal
  public static boolean isInScope(@NotNull Usage usage, @NotNull SearchScope searchScope, @NotNull SearchScope everythingScope)