Update SCL-editor annotations asynchronously 28/2528/2
authorjsimomaa <jani.simomaa@gmail.com>
Fri, 7 Dec 2018 06:53:37 +0000 (08:53 +0200)
committerJani Simomaa <jani.simomaa@semantum.fi>
Fri, 7 Dec 2018 06:53:53 +0000 (06:53 +0000)
gitlab #225

Change-Id: Iec9fce3432b701b540526b1bd95ada331252951a

bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/editor2/SCLAnnotationModel.java

index 43e4a80a0b80d8d91cf65120a286700970ae0587..1a0e7bcc7033c2e01444d0ab1ab30c3e6e00f47b 100644 (file)
@@ -3,6 +3,7 @@ package org.simantics.scl.ui.editor2;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
+import java.util.concurrent.ForkJoinPool;
 
 import org.eclipse.jface.text.IDocument;
 import org.eclipse.jface.text.Position;
@@ -38,15 +39,19 @@ public class SCLAnnotationModel extends AnnotationModel {
     };
     
     private void updateAnnotations() {
-        Failable<Module> result = repository.getModule(input.getModuleName(), updateListener);
-        if(result instanceof Failure) {
-            Failure failure = (Failure)result;
-            setAnnotations(Arrays.asList(failure.errors));
-        }
-        else if(result == DoesNotExist.INSTANCE)
-            setAnnotations(Collections.<CompilationError>emptyList());
-        else
-            setAnnotations(Arrays.asList(result.getResult().getWarnings()));
+        ForkJoinPool.commonPool().submit(() -> {
+            if (!connected)
+                return;
+            Failable<Module> result = repository.getModule(input.getModuleName(), updateListener);
+            if(result instanceof Failure) {
+                Failure failure = (Failure)result;
+                setAnnotations(Arrays.asList(failure.errors));
+            }
+            else if(result == DoesNotExist.INSTANCE)
+                setAnnotations(Collections.<CompilationError>emptyList());
+            else
+                setAnnotations(Arrays.asList(result.getResult().getWarnings()));
+        });
     }
     
     protected void setAnnotations(List<CompilationError> errors) {