@Override
  public @Nullable Element export(@NotNull RefEntity entity) {
    Element element = export(entity, -1);
    if (element == null) return null;

    if (!(entity instanceof RefElement)) return element;

    SmartPsiElementPointer<?> pointer = ((RefElement)entity).getPointer();

    PsiElement psiElement = pointer.getElement();

    Element language = new Element(DefaultInspectionToolResultExporter.INSPECTION_RESULTS_LANGUAGE);
    language.addContent(psiElement != null ? psiElement.getLanguage().getID() : "");
    element.addContent(language);

    PsiFile psiFile = pointer.getContainingFile();

    if (psiFile == null) return element;

    Document document = PsiDocumentManager.getInstance(pointer.getProject()).getDocument(psiFile);
    if (document == null) return element;

    Segment range = pointer.getRange();
    if (range == null) return element;

    int firstRangeLine = document.getLineNumber(range.getStartOffset());
    int lineStartOffset = document.getLineStartOffset(firstRangeLine);
    int endOffset = Math.min(range.getEndOffset(), document.getLineEndOffset(firstRangeLine));

    TextRange exportedRange = new TextRange(range.getStartOffset(), endOffset);
    String text = ProblemDescriptorUtil.extractHighlightedText(exportedRange, psiFile);

    element.addContent(new Element("offset").addContent(String.valueOf(exportedRange.getStartOffset() - lineStartOffset)));
    element.addContent(new Element("length").addContent(String.valueOf(exportedRange.getLength())));
    element.addContent(new Element("highlighted_element").addContent(ProblemDescriptorUtil.sanitizeIllegalXmlChars(text)));

    return element;
  }
@Override
  public @Nullable Element export(@NotNull RefEntity entity)