public static <T> T getCachedValue(final @NotNull PsiElement context, @NotNull Key<CachedValue<T>> key, final @NotNull CachedValueProvider<T> provider) {
    CachedValue<T> value = context.getUserData(key);
    if (value != null) {
      Supplier<T> data = value.getUpToDateOrNull();
      if (data != null) {
        return data.get();
      }
    }

    return getManager(context.getProject()).getCachedValue(context, key, new CachedValueProvider<T>() {
      @Override
      public @Nullable Result<T> compute() {
        CachedValueProvider.Result<T> result = provider.compute();
        if (result != null && !context.isPhysical()) {
          PsiFile file = context.getContainingFile();
          if (file != null) {
            Result<T> adjusted = Result.create(
              result.getValue(), ArrayUtil.append(result.getDependencyItems(), file, ArrayUtil.OBJECT_ARRAY_FACTORY));
            CachedValueProfiler.onResultCreated(adjusted, result);
            return adjusted;
          }
        }
        return result;
      }

      @Override
      public String toString() {
        return provider.toString();
      }
    }, false);
  }
public static <T> T getCachedValue(final @NotNull PsiElement context, @NotNull Key<CachedValue<T>> key, final @NotNull CachedValueProvider<T> provider)