private static @NotNull @InspectionMessage @NlsContexts.Tooltip String renderDescriptionMessage(@NotNull CommonProblemDescriptor descriptor,
                                                                                                  @Nullable PsiElement element,
                                                                                                  @FlagConstant int flags,
                                                                                                  @InspectionMessage String template) {
    String message = template;
    if ((flags & APPEND_LINE_NUMBER) != 0 &&
        descriptor instanceof ProblemDescriptor &&
        !message.contains(REF_REFERENCE) &&
        message.contains(LOC_REFERENCE)) {
      final int lineNumber = ((ProblemDescriptor)descriptor).getLineNumber();
      if (lineNumber >= 0) {
        message = StringUtil.replace(message, LOC_REFERENCE, "(" + AnalysisBundle.message("inspection.export.results.at.line") + " " + (lineNumber + 1) + ")");
      }
    }
    message = unescapeTags(message);
    message = removeLocReference(message);

    if ((flags & TRIM_AT_TREE_END) != 0) {
      if (XmlStringUtil.isWrappedInHtml(message)) {
        message = StringUtil.removeHtmlTags(message, true);
      }

      final int endIndex = message.indexOf("#treeend");
      if (endIndex > 0) {
        message = message.substring(0, endIndex);
      }
    }

    if (message.contains(REF_REFERENCE)) {
      String ref = extractHighlightedText(descriptor, element);
      message = StringUtil.replace(message, REF_REFERENCE, ref);
    }

    message = StringUtil.replace(message, "#end", "");
    message = StringUtil.replace(message, "#treeend", "");

    return message.trim();
  }
private static @NotNull @InspectionMessage @NlsContexts.Tooltip String renderDescriptionMessage(@NotNull CommonProblemDescriptor descriptor,
                                                                                                  @Nullable PsiElement element,
                                                                                                  @FlagConstant int flags,
                                                                                                  @InspectionMessage String template)