ITypedRegion[] regions = partitioner.computePartitioning(0, document.getLength());
List<StyleRange> styleRanges = new ArrayList<>();
for( ITypedRegion r : regions ) {
ITokenScanner scanner = tokenScanners.get(r.getType());
// System.err.println("REGION: " + System.identityHashCode(r) + " => " + r.getOffset() + "/" + r.getLength());
if( scanner != null ) {
int lastStart= r.getOffset();
int length= 0;
boolean firstToken= true;
TextAttribute lastAttribute = null;
scanner.setRange(document, r.getOffset(), r.getLength());
while( true ) {
IToken token= scanner.nextToken();
if (token.isEOF())
break;
TextAttribute attribute = getTokenTextAttribute(token);
if (lastAttribute != null && lastAttribute.equals(attribute)) {
length += scanner.getTokenLength();
firstToken= false;
} else {
if (!firstToken) {
// try {
// System.err.println("TOKEN: " + lastStart + "/" + length + " => " + document.get(lastStart, length));
// } catch (BadLocationException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
styleRanges.add(createStyleRange(lastStart, length, lastAttribute));
}
firstToken= false;
lastAttribute= attribute;
lastStart= scanner.getTokenOffset();
length= scanner.getTokenLength();
}
}
// try {
// System.err.println("TOKEN: " + lastStart + "/" + length + " => " + document.get(lastStart, length));