for (Annotation annotation : holder) {
if (annotation.getSeverity() != HighlightSeverity.INFORMATION) {
continue;
}
TextAttributesKey tak = annotation.getTextAttributes();
if (!keys.contains(tak)) {
continue;
}
String tokenText = document.getText(new TextRange(annotation.getStartOffset(), annotation.getEndOffset()));
if (pos > annotation.getStartOffset()) {
int line = document.getLineNumber(annotation.getStartOffset()) + 1;
fail(String.format("Token \"%s\" at line %d was highlighted multiple times.", tokenText, line));
}
sb.append(document.getText(new TextRange(pos, annotation.getStartOffset())))
.append("/*begin*/")
.append(tokenText)
.append("/*end.")
.append(tak.getExternalName())
.append("*/");
pos = annotation.getEndOffset();
}
sb.append(document.getText(new TextRange(pos, document.getTextLength())));
return sb.toString();