public @Nullable RefElement getReference(PsiElement elem, final boolean ignoreScope) {
    if (ReadAction.compute(() -> elem == null || !elem.isValid() ||
                                 elem instanceof LightElement || !(elem instanceof PsiDirectory) && !belongsToScope(elem, ignoreScope))) {
      return null;
    }

    return getFromRefTableOrCache(
      elem,
      () -> ReadAction.compute(() -> {
        final RefManagerExtension<?> extension = getExtension(elem.getLanguage());
        if (extension != null) {
          final RefElement refElement = extension.createRefElement(elem);
          if (refElement != null) return (RefElementImpl)refElement;
        }
        if (elem instanceof PsiFile) {
          return new RefFileImpl((PsiFile)elem, this);
        }
        if (elem instanceof PsiDirectory) {
          return new RefDirectoryImpl((PsiDirectory)elem, this);
        }
        return null;
      }),
      element -> ReadAction.run(() -> element.initializeIfNeeded()));
  }
public @Nullable RefElement getReference(PsiElement elem, final boolean ignoreScope)