private static List<TextContent> obtainContents(Set<TextContent.TextDomain> allowedDomains,
                                                  Language fileLanguage,
                                                  PsiElement psi) {
    CachedValue<Cache> cv = psi.getUserData(QUERY_CACHE);
    if (cv != null) {
      List<TextContent> result = cv.getValue().getCached(allowedDomains);
      if (!result.isEmpty()) return result;
    }

    RecursionGuard.StackStamp stamp = RecursionManager.markStack();

    Language psiLanguage = psi.getLanguage();
    List<TextContent> contents = doExtract(psi, allowedDomains, psiLanguage);
    if (contents.isEmpty() && fileLanguage != psiLanguage) {
      contents = doExtract(psi, allowedDomains, fileLanguage);
    }

    for (TextContent content : contents) {
      if (shouldIgnore(content)) {
        content.putUserData(IGNORED, true);
      }
    }

    if (!contents.isEmpty() && stamp.mayCacheNow()) {
      obtainCache(psi, QUERY_CACHE).register(allowedDomains, contents);
    }
    return contents;
  }
private static List<TextContent> obtainContents(Set<TextContent.TextDomain> allowedDomains,
                                                  Language fileLanguage,
                                                  PsiElement psi)