MappedRange (int tokenIndex, @NotNull IElementType outerToken) { CharSequence tokenText = getTokenText(tokenIndex); int length = tokenText.length(); MappedRange predecessor = findPredecessor(tokenIndex, getSegments()); int insertOffset = predecessor != null ? predecessor.range.getEndOffset() : 0; doc.insertString(insertOffset, new MergingCharSequence(mySeparator, tokenText)); insertOffset += mySeparator.length(); RangeMarker marker = doc.createRangeMarker(insertOffset, insertOffset + length); return new MappedRange(this, marker, outerToken); }