]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/editor2/SCLAnnotationModel.java
Showing compilation warnings in SCL issue view and editors
[simantics/platform.git] / bundles / org.simantics.scl.ui / src / org / simantics / scl / ui / editor2 / SCLAnnotationModel.java
index 47b203d613e1b871e8a3762f008c11906fb3298b..b8010ef828a23868ba0b24b7820c53be38ef2dfa 100644 (file)
@@ -9,9 +9,12 @@ 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;
+import org.simantics.scl.compiler.errors.Success;
 import org.simantics.scl.compiler.module.Module;
 import org.simantics.scl.compiler.module.repository.ModuleRepository;
 import org.simantics.scl.compiler.module.repository.UpdateListener;
@@ -41,17 +44,21 @@ public class SCLAnnotationModel extends AnnotationModel {
             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);
                 Position position = new Position(begin, end - begin);
@@ -70,6 +77,7 @@ public class SCLAnnotationModel extends AnnotationModel {
     @Override
     public void disconnect(IDocument document) {
         connected = false;
+        updateListener.stopListening();
         super.disconnect(document);
     }
 }