public static boolean hasTest(PsiModifierListOwner element) {
   return CachedValuesManager.getCachedValue(
       element,
       () ->
           CachedValueProvider.Result.create(
               hasTest(element, true), PsiModificationTracker.MODIFICATION_COUNT));
 }
 @Override
 public CachedValueProvider.Result<PsiExpression> compute(
     Pair<Project, PsiExpression> pair) {
   PsiExpression param = pair.second;
   Project project = pair.first;
   PsiExpression topLevel = getTopLevel(project, param);
   ParameterizedCachedValue<PsiExpression, Pair<Project, PsiExpression>> cachedValue =
       param.getUserData(TOP_LEVEL_EXPRESSION);
   assert cachedValue != null;
   int i = 0;
   for (PsiElement element = param;
       element != topLevel;
       element = element.getParent(), i++) {
     if (i % 10
         == 0) { // optimization: store up link to the top level expression in each 10nth
                 // element
       element.putUserData(TOP_LEVEL_EXPRESSION, cachedValue);
     }
   }
   return CachedValueProvider.Result.create(
       topLevel, PsiManager.getInstance(project).getModificationTracker());
 }
  private static MultiHostRegistrarImpl probeElementsUp(
      @NotNull PsiElement element, @NotNull PsiFile hostPsiFile, boolean probeUp) {
    PsiManager psiManager = hostPsiFile.getManager();
    final Project project = psiManager.getProject();
    InjectedLanguageManagerImpl injectedManager =
        InjectedLanguageManagerImpl.getInstanceImpl(project);
    if (injectedManager == null) {
      return null; // for tests
    }
    MultiHostRegistrarImpl registrar = null;
    PsiElement current = element;
    nextParent:
    while (current != null && current != hostPsiFile) {
      ProgressManager.checkCanceled();
      if ("EL".equals(current.getLanguage().getID())) break;
      ParameterizedCachedValue<MultiHostRegistrarImpl, PsiElement> data =
          current.getUserData(INJECTED_PSI);
      if (data == null) {
        registrar =
            InjectedPsiCachedValueProvider.doCompute(
                current, injectedManager, project, hostPsiFile);
      } else {
        registrar = data.getValue(current);
      }

      current = current.getParent(); // cache no injection for current

      if (registrar != null) {
        List<Pair<Place, PsiFile>> places = registrar.getResult();
        // check that injections found intersect with queried element
        TextRange elementRange = element.getTextRange();
        for (Pair<Place, PsiFile> pair : places) {
          Place place = pair.first;
          for (PsiLanguageInjectionHost.Shred shred : place) {
            if (shred.getHost().getTextRange().intersects(elementRange)) {
              if (place.isValid()) break nextParent;
            }
          }
        }
      }
      if (!probeUp) {
        break;
      }
    }

    if (probeUp) {
      // cache only if we walked all parents
      for (PsiElement e = element;
          e != current && e != null && e != hostPsiFile;
          e = e.getParent()) {
        ProgressManager.checkCanceled();
        if (registrar == null) {
          e.putUserData(INJECTED_PSI, null);
        } else {
          ParameterizedCachedValue<MultiHostRegistrarImpl, PsiElement> cachedValue =
              CachedValuesManager.getManager(project)
                  .createParameterizedCachedValue(INJECTED_PSI_PROVIDER, false);

          CachedValueProvider.Result<MultiHostRegistrarImpl> result =
              CachedValueProvider.Result.create(
                  registrar, PsiModificationTracker.MODIFICATION_COUNT, registrar);
          ((PsiParameterizedCachedValue<MultiHostRegistrarImpl, PsiElement>) cachedValue)
              .setValue(result);

          e.putUserData(INJECTED_PSI, cachedValue);
        }
      }
    }
    return registrar;
  }