@Override
  public FoldingDescriptor @NotNull [] buildFoldRegions(@NotNull PsiElement element, @NotNull Document document, boolean quick) {
    if (!(element instanceof PsiFile file) || quick || !isFoldingsOn()) {
      return FoldingDescriptor.EMPTY_ARRAY;
    }
    final List<FoldingDescriptor> result = new ArrayList<>();
    boolean hasJsp = ContainerUtil.exists(file.getViewProvider().getLanguages(), (l) -> l instanceof JspLanguage || l instanceof JspxLanguage);
    //hack here because JspFile PSI elements are not threaded correctly via nextSibling/prevSibling
    file.accept(hasJsp ? new JavaRecursiveElementWalkingVisitor() {
      @Override
      public void visitLiteralExpression(@NotNull PsiLiteralExpression expression) {
        ProgressManager.checkCanceled();
        UInjectionHost injectionHost = UastContextKt.toUElement(expression, UInjectionHost.class);
        if (injectionHost != null) {
          checkLiteral(document, injectionHost, result);
        }
      }
    } : new PsiRecursiveElementWalkingVisitor() {

      @Override
      public void visitElement(@NotNull PsiElement element) {
        ProgressManager.checkCanceled();
        UInjectionHost injectionHost = UastContextKt.toUElement(element, UInjectionHost.class);
        if (injectionHost != null) {
          checkLiteral(document, injectionHost, result);
        }
        super.visitElement(element);
      }
    });

    return result.toArray(FoldingDescriptor.EMPTY_ARRAY);
  }
@Override
  public FoldingDescriptor @NotNull [] buildFoldRegions(@NotNull PsiElement element, @NotNull Document document, boolean quick)