void (@NotNull UsageInfo2UsageAdapter usageInfo2UsageAdapter, @NotNull CharSequence chars, int hiStart, int hiEnd, TextAttributesKey @NotNull [] tokenHighlights, boolean selectUsageWithBold, @NotNull List<? super @NotNull TextChunk> result) { TextAttributes originalAttrs = convertAttributes(tokenHighlights); if (selectUsageWithBold) { originalAttrs.setFontType(Font.PLAIN); } int[] lastOffset = {hiStart}; usageInfo2UsageAdapter.processRangeMarkers(segment -> { int usageStart = segment.getStartOffset(); int usageEnd = segment.getEndOffset(); if (rangeIntersect(lastOffset[0], hiEnd, usageStart, usageEnd)) { addChunk(chars, lastOffset[0], Math.max(lastOffset[0], usageStart), originalAttrs, false, result); addChunk(chars, Math.max(lastOffset[0], usageStart), Math.min(hiEnd, usageEnd), originalAttrs, selectUsageWithBold, result); lastOffset[0] = usageEnd; return usageEnd <= hiEnd; } return true; }); if (lastOffset[0] < hiEnd) { addChunk(chars, lastOffset[0], hiEnd, originalAttrs, false, result); } }