public void paint(@Nullable Int2ObjectMap<? extends PsiReference> refMap, @NotNull Writer writer, boolean isStandalone) throws IOException {
    HighlighterIterator hIterator = myHighlighter.createIterator(myOffset);
    if (hIterator.atEnd()) {
      return;
    }

    lineCount = myFirstLineNumber;
    TextAttributes prevAttributes = null;
    IntIterator refKeys = null;
    int refOffset = -1;
    PsiReference ref = null;
    if (refMap != null) {
      refKeys = refMap.keySet().iterator();
      if (refKeys.hasNext()) {
        int key = refKeys.nextInt();
        ref = refMap.get(key);
        refOffset = key;
      }
    }

    int referenceEnd = -1;
    if (isStandalone) {
      writeHeader(writer, new File(myFileName).getName());
    }
    else {
      ensureStyles();
    }
    writer.write("<pre>");
    if (myFirstLineNumber == 0) {
      writeLineNumber(writer);
    }
    String closeTag = null;

    getMethodSeparator(hIterator.getStart());

    while (!hIterator.atEnd()) {
      int hStart = hIterator.getStart();
      int hEnd = hIterator.getEnd();
      if (hEnd > mySegmentEnd) {
        break;
      }

      // write whitespace as is
      for (; hStart < hEnd; hStart++) {
        char c = myText.charAt(hStart);
        if (Character.isWhitespace(c)) {
          if (closeTag != null && c == '\n') {
            writer.write(closeTag);
            closeTag = null;
            prevAttributes = null;
          }
          if (c == '\n') {
            writeLineSeparatorAndNumber(writer, hStart);
          }
          else {
            writer.write(c);
          }
        }
        else {
          break;
        }
      }

      if (hStart == hEnd) {
        hIterator.advance();
        continue;
      }

      if (refOffset > 0 && hStart <= refOffset && hEnd > refOffset) {
        referenceEnd = writeReferenceTag(writer, ref);
      }

      TextAttributes textAttributes = hIterator.getTextAttributes();
      // for non-standalone always write attributes to ensure that we don't depend on surrounding context
      if (isStandalone && htmlStyleManager.isDefaultAttributes(textAttributes)) {
        textAttributes = null;
      }

      if (!equals(prevAttributes, textAttributes) && referenceEnd < 0) {
        if (closeTag != null) {
          writer.write(closeTag);
          closeTag = null;
        }
        if (textAttributes != null) {
          htmlStyleManager.writeTextStyle(writer, textAttributes);
          closeTag = "</span>";
        }
        prevAttributes = textAttributes;
      }

      writeString(writer, myText, hStart, hEnd - hStart, myPsiFile);
      if (referenceEnd > 0 && hEnd >= referenceEnd) {
        writer.write("</a>");
        referenceEnd = -1;
        if (refKeys.hasNext()) {
          int key = refKeys.nextInt();
          ref = refMap.get(key);
          refOffset = key;
        }
      }
      hIterator.advance();
    }

    if (closeTag != null) {
      writer.write(closeTag);
    }

    writer.write("</pre>\n");
    if (isStandalone) {
      writer.write("</body>\n");
      writer.write("</html>");
    }
  }
public void paint(@Nullable Int2ObjectMap<? extends PsiReference> refMap, @NotNull Writer writer, boolean isStandalone)