use of org.eclipse.jface.text.AbstractDocument in project eclipse.platform.text by eclipse.
the class AnnotationModel method getRegionAnnotationIterator.
/**
* Returns an iterator as specified in {@link IAnnotationModelExtension2#getAnnotationIterator(int, int, boolean, boolean)}
*
* @param offset region start
* @param length region length
* @param canStartBefore position can start before region
* @param canEndAfter position can end after region
* @return an iterator to iterate over annotations in region
* @see IAnnotationModelExtension2#getAnnotationIterator(int, int, boolean, boolean)
* @since 3.4
*/
private Iterator<Annotation> getRegionAnnotationIterator(int offset, int length, boolean canStartBefore, boolean canEndAfter) {
if (!(fDocument instanceof AbstractDocument))
return new RegionIterator(getAnnotationIterator(true), this, offset, length, canStartBefore, canEndAfter);
AbstractDocument document = (AbstractDocument) fDocument;
cleanup(true);
try {
Position[] positions = document.getPositions(IDocument.DEFAULT_CATEGORY, offset, length, canStartBefore, canEndAfter);
return new AnnotationsInterator(positions, fPositions);
} catch (BadPositionCategoryException e) {
// can happen if e.g. the document doesn't contain such a category, or when removed in a different thread
return Collections.<Annotation>emptyList().iterator();
}
}
Aggregations