void updateMapping(int tokenIndex, @NotNull MappedRange oldMapping) {
      CharSequence tokenText = getTokenText(tokenIndex);

      int start = oldMapping.range.getStartOffset();
      int end = oldMapping.range.getEndOffset();
      if (Comparing.equal(doc.getCharsSequence().subSequence(start, end), tokenText)) return;

      doc.replaceString(start, end, tokenText);

      int newEnd = start + tokenText.length();
      if (oldMapping.range.getStartOffset() != start || oldMapping.range.getEndOffset() != newEnd) {
        assert oldMapping.range.getDocument() == doc;
        oldMapping.range.dispose();
        oldMapping.range = doc.createRangeMarker(start, newEnd);
      }
    }
void updateMapping(int tokenIndex, @NotNull MappedRange oldMapping)