private static void diagnoseIncorrectRange(@NotNull PsiFile file,
                                             @NotNull Document document,
                                             @NotNull Language language,
                                             @NotNull FoldingBuilder foldingBuilder,
                                             @NotNull FoldingDescriptor descriptor, @NotNull PsiElement psiElement) {
    String message = "Folding descriptor " + descriptor + " made by " + foldingBuilder +
                     " for " + language + " is outside document range, PSI element: " + psiElement +
                     ", PSI element range: " + psiElement.getTextRange() + "; " + DebugUtil.diagnosePsiDocumentInconsistency(psiElement, document);
    LOG.error(message, ApplicationManager.getApplication().isInternal()
                       ? new Attachment[]{CoreAttachmentFactory.createAttachment(document), new Attachment("psiTree.txt", DebugUtil.psiToString(file, true, true))}
                       : Attachment.EMPTY_ARRAY);
  }
private static void diagnoseIncorrectRange(@NotNull PsiFile file,
                                             @NotNull Document document,
                                             @NotNull Language language,
                                             @NotNull FoldingBuilder foldingBuilder,
                                             @NotNull FoldingDescriptor descriptor, @NotNull PsiElement psiElement)