boolean (final PsiElement psiElement, final boolean ignoreScope) { if (psiElement == null || !psiElement.isValid()) return false; if (psiElement instanceof PsiCompiledElement) return false; final PsiFile containingFile = ReadAction.compute(psiElement::getContainingFile); if (containingFile == null) { return false; } for (RefManagerExtension<?> extension : myExtensions.values()) { if (!extension.belongsToScope(psiElement)) return false; } final Boolean inProject = ReadAction.compute(() -> psiElement.getManager().isInProject(psiElement)); return (inProject.booleanValue() || ScratchUtil.isScratch(containingFile.getVirtualFile())) && (ignoreScope || getScope() == null || getScope().contains(psiElement)); }