X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.scl.ui%2Fsrc%2Forg%2Fsimantics%2Fscl%2Fui%2Feditor2%2FSCLAnnotationModel.java;h=2a04c41cf1f1169721208c0eabce52ce58c31de2;hp=47b203d613e1b871e8a3762f008c11906fb3298b;hb=3906e743a8c4717ffae6add4715cade396c6196c;hpb=0ae2b770234dfc3cbb18bd38f324125cf0faca07 diff --git a/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/editor2/SCLAnnotationModel.java b/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/editor2/SCLAnnotationModel.java index 47b203d61..2a04c41cf 100644 --- a/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/editor2/SCLAnnotationModel.java +++ b/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/editor2/SCLAnnotationModel.java @@ -9,6 +9,8 @@ import org.eclipse.jface.text.Position; 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; @@ -41,19 +43,27 @@ public class SCLAnnotationModel extends AnnotationModel { Failure failure = (Failure)result; setAnnotations(Arrays.asList(failure.errors)); } - else { + else if(result == DoesNotExist.INSTANCE) setAnnotations(Collections.emptyList()); - } + else + setAnnotations(Arrays.asList(result.getResult().getWarnings())); } protected void setAnnotations(List 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); } @@ -70,6 +80,7 @@ public class SCLAnnotationModel extends AnnotationModel { @Override public void disconnect(IDocument document) { connected = false; + updateListener.stopListening(); super.disconnect(document); } }