LOG.assertTrue(start <= end);
List<TextChunk> result = new ArrayList<TextChunk>();
appendPrefix(result);
Lexer lexer = highlighter.getHighlightingLexer();
lexer.start(chars, 0, chars.length(), 0);
for (int offset = start; offset < end; offset++) {
if (chars.charAt(offset) == '\n') {
end = offset;
break;
}
}
boolean isBeginning = true;
while (lexer.getTokenType() != null) {
try {
int hiStart = lexer.getTokenStart();
int hiEnd = lexer.getTokenEnd();
if (hiStart >= end) break;
hiStart = Math.max(hiStart, start);
hiEnd = Math.min(hiEnd, end);
if (hiStart >= hiEnd) { continue; }
String text = chars.subSequence(hiStart, hiEnd).toString();
if (isBeginning && text.trim().length() == 0) continue;
isBeginning = false;
IElementType tokenType = lexer.getTokenType();
TextAttributesKey[] tokenHighlights = highlighter.getTokenHighlights(tokenType);
processIntersectingRange(chars, hiStart, hiEnd, tokenHighlights, result);
//result.add(new TextChunk(convertAttributes(tokenHighlights), text));
}
finally {
lexer.advance();
}
}
return result.toArray(new TextChunk[result.size()]);
}