use of org.eclipse.wst.sse.ui.internal.reconcile.ReconcileAnnotationKey in project webtools.sourceediting by eclipse.
the class ReconcileStepForValidator method createAnnotations.
protected IReconcileResult[] createAnnotations(AnnotationInfo[] infos) {
List annotations = new ArrayList();
for (int i = 0; i < infos.length; i++) {
AnnotationInfo info = infos[i];
IMessage validationMessage = info.getMessage();
int offset = validationMessage.getOffset();
if (offset < 0)
continue;
String messageText = null;
try {
messageText = validationMessage.getText(validationMessage.getClass().getClassLoader());
} catch (Exception t) {
// $NON-NLS-1$
Logger.logException("exception reporting message from validator", t);
continue;
}
String type = getSeverity(validationMessage);
// this position seems like it would be possibly be the wrong
// length
int length = validationMessage.getLength();
if (length >= 0) {
Position p = new Position(offset, length);
ReconcileAnnotationKey key = createKey(getPartitionType(getDocument(), offset), getScope());
// create an annotation w/ problem ID and fix info
TemporaryAnnotation annotation = new TemporaryAnnotation(p, type, messageText, key);
Object extraInfo = info.getAdditionalFixInfo();
// add quick fix information
if (extraInfo == null) {
extraInfo = validationMessage.getAttribute(QUICKASSISTPROCESSOR);
}
annotation.setAdditionalFixInfo(extraInfo);
annotation.setAttributes(validationMessage.getAttributes());
annotations.add(annotation);
}
}
return (IReconcileResult[]) annotations.toArray(new IReconcileResult[annotations.size()]);
}
use of org.eclipse.wst.sse.ui.internal.reconcile.ReconcileAnnotationKey in project webtools.sourceediting by eclipse.
the class SpellcheckStrategy method getSpellingAnnotationsToRemove.
private TemporaryAnnotation[] getSpellingAnnotationsToRemove(IRegion region) {
List toRemove = new ArrayList();
IAnnotationModel annotationModel = getAnnotationModel();
// can be null when closing the editor
if (annotationModel != null) {
Iterator i = null;
boolean annotationOverlaps = false;
if (annotationModel instanceof IAnnotationModelExtension2) {
i = ((IAnnotationModelExtension2) annotationModel).getAnnotationIterator(region.getOffset(), region.getLength(), true, true);
annotationOverlaps = true;
} else {
i = annotationModel.getAnnotationIterator();
}
while (i.hasNext()) {
Object obj = i.next();
if (!(obj instanceof TemporaryAnnotation))
continue;
TemporaryAnnotation annotation = (TemporaryAnnotation) obj;
ReconcileAnnotationKey key = (ReconcileAnnotationKey) annotation.getKey();
// partition type
if (key != null && key.equals(fReconcileAnnotationKey)) {
if (key.getScope() == ReconcileAnnotationKey.PARTIAL && (annotationOverlaps || annotation.getPosition().overlapsWith(region.getOffset(), region.getLength()))) {
toRemove.add(annotation);
} else if (key.getScope() == ReconcileAnnotationKey.TOTAL) {
toRemove.add(annotation);
}
}
}
}
return (TemporaryAnnotation[]) toRemove.toArray(new TemporaryAnnotation[toRemove.size()]);
}
Aggregations