ITextRegionList regions = structuredDocumentRegion.getRegions();
int nRegions = regions.size();
StyleRange styleRange = null;
for (int i = 0; i < nRegions; i++) {
region = regions.get(i);
TextAttribute attr = null;
TextAttribute previousAttr = null;
if (structuredDocumentRegion.getStartOffset(region) > partitionEndOffset)
break;
if (structuredDocumentRegion.getEndOffset(region) <= partitionStartOffset)
continue;
if (region instanceof ITextRegionCollection) {
boolean handledCollection = (prepareTextRegion((ITextRegionCollection) region, partitionStartOffset, partitionLength, holdResults));
handled = (!handled) ? handledCollection : handled;
} else {
attr = getAttributeFor(structuredDocumentRegion, region);
if (attr != null) {
handled = true;
// if this region's attr is the same as previous one,
// then just adjust the previous style range
// instead of creating a new instance of one
// note: to use 'equals' in this case is important,
// since sometimes
// different instances of attributes are associated
// with a region, even the
// the attribute has the same values.
// TODO: this needs to be improved to handle readonly
// regions correctly
if ((styleRange != null) && (previousAttr != null) && (previousAttr.equals(attr))) {
styleRange.length += region.getLength();
} else {
styleRange = createStyleRange(structuredDocumentRegion, region, attr, partitionStartOffset, partitionLength);
holdResults.add(styleRange);
// technically speaking, we don't need to update