boolean (@NotNull Usage usage, @NotNull SearchScope searchScope) { if (searchScope instanceof AcceptEveryUsageScope) 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); }); }