import org.eclipse.jface.text.source.Annotation;
import org.eclipse.jface.text.source.AnnotationModel;
import org.simantics.scl.compiler.errors.CompilationError;
+import org.simantics.scl.compiler.errors.DoesNotExist;
+import org.simantics.scl.compiler.errors.ErrorSeverity;
import org.simantics.scl.compiler.errors.Failable;
import org.simantics.scl.compiler.errors.Failure;
import org.simantics.scl.compiler.errors.Locations;
Failure failure = (Failure)result;
setAnnotations(Arrays.asList(failure.errors));
}
- else {
+ else if(result == DoesNotExist.INSTANCE)
setAnnotations(Collections.<CompilationError>emptyList());
- }
+ else
+ setAnnotations(Arrays.asList(result.getResult().getWarnings()));
}
protected void setAnnotations(List<CompilationError> errors) {
synchronized(getLockObject()) {
removeAllAnnotations();
for(CompilationError error : errors) {
- Annotation annotation = new Annotation("org.eclipse.ui.workbench.texteditor.error", true,
- error.description);
+ Annotation annotation = new Annotation(
+ error.severity == ErrorSeverity.ERROR ?
+ "org.eclipse.ui.workbench.texteditor.error" :
+ "org.eclipse.ui.workbench.texteditor.warning",
+ true, error.description);
int begin = Locations.beginOf(error.location);
int end = Locations.endOf(error.location);
+ if(begin < 0 || end < begin) {
+ begin = 0;
+ end = 1;
+ }
Position position = new Position(begin, end - begin);
addAnnotation(annotation, position);
}