in remoting/server/web/web.ui/src/org/netbeans/modules/jackpot30/backend/ui/UI.java [199:238]
static HighlightData colorTokens(TokenSequence<?> ts, Map<Token, Coloring> semanticHighlights) throws IOException, InterruptedException {
List<Long> spans = new ArrayList<Long>(ts.tokenCount());
List<String> cats = new ArrayList<String>(ts.tokenCount());
long currentOffset = 0;
ts.moveStart();
while (ts.moveNext()) {
long endOffset = ts.offset() + ts.token().length();
spans.add(endOffset - currentOffset);
String category = ts.token().id().primaryCategory();
switch (category) {
case "literal":
case "keyword-directive": category = "keyword"; break;
case "xml-attribute": category = "markup-attribute"; break;
case "xml-comment": category = "comment"; break;
case "xml-error": category = "error"; break;
case "xml-operator": category = "operator"; break;
case "xml-ref": category = "entity-reference"; break;
case "xml-tag": category = "markup-element"; break;
case "xml-value": category = "markup-attribute-value"; break;
}
Coloring coloring = semanticHighlights.get(ts.token());
if (coloring != null) {
for (ColoringAttributes ca : coloring) {
if (!category.isEmpty()) category += " ";
category += ca.name().toLowerCase();
}
}
cats.add(category);
currentOffset = endOffset;
}
return new HighlightData(cats, spans);
}