return document.getLineInformationOfOffset(invocationLocation);
}
public static int collectQuickFixableAnnotations(ITextEditor editor, int invocationLocation,
boolean goToClosest, ArrayList resultingAnnotations) throws BadLocationException {
IAnnotationModel model = DLTKUIPlugin.getDocumentProvider().getAnnotationModel(
editor.getEditorInput());
if (model == null) {
return invocationLocation;
}
ensureUpdatedAnnotations(editor);
Iterator iter = model.getAnnotationIterator();
if (goToClosest) {
IRegion lineInfo = getRegionOfInterest(editor, invocationLocation);
if (lineInfo == null) {
return invocationLocation;
}
int rangeStart = lineInfo.getOffset();
int rangeEnd = rangeStart + lineInfo.getLength();
ArrayList allAnnotations = new ArrayList();
ArrayList allPositions = new ArrayList();
int bestOffset = Integer.MAX_VALUE;
while (iter.hasNext()) {
Annotation annot = (Annotation) iter.next();
if (RutaCorrectionProcessor.isQuickFixableType(annot)) {
Position pos = model.getPosition(annot);
if (pos != null && isInside(pos.offset, rangeStart, rangeEnd)) { // inside
// our
// range?
allAnnotations.add(annot);
allPositions.add(pos);
bestOffset = processAnnotation(annot, pos, invocationLocation, bestOffset);
}
}
}
if (bestOffset == Integer.MAX_VALUE) {
return invocationLocation;
}
for (int i = 0; i < allPositions.size(); i++) {
Position pos = (Position) allPositions.get(i);
if (isInside(bestOffset, pos.offset, pos.offset + pos.length)) {
resultingAnnotations.add(allAnnotations.get(i));
}
}
return bestOffset;
} else {
while (iter.hasNext()) {
Annotation annot = (Annotation) iter.next();
if (RutaCorrectionProcessor.isQuickFixableType(annot)) {
Position pos = model.getPosition(annot);
if (pos != null && isInside(invocationLocation, pos.offset, pos.offset + pos.length)) {
resultingAnnotations.add(annot);
}
}
}