X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.scl.compiler%2Fsrc%2Forg%2Fsimantics%2Fscl%2Fcompiler%2Fcommands%2FCommandSession.java;h=9ff2ebabb0b3492c27814e0d0dd013b552b50044;hp=a8f3d2045efb105928e18c951d1322410bd13a0f;hb=c26cba49344b973fba8022c9e6d12adea93abd48;hpb=78f577368ba4c71ad6fb3d9f16c03c634585cf7b diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/commands/CommandSession.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/commands/CommandSession.java index a8f3d2045..9ff2ebabb 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/commands/CommandSession.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/commands/CommandSession.java @@ -11,7 +11,6 @@ import java.io.UnsupportedEncodingException; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; -import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Set; @@ -43,6 +42,7 @@ import org.simantics.scl.compiler.module.ImportDeclaration; import org.simantics.scl.compiler.module.repository.ImportFailure; import org.simantics.scl.compiler.module.repository.ImportFailureException; import org.simantics.scl.compiler.module.repository.ModuleRepository; +import org.simantics.scl.compiler.module.repository.UpdateListener; import org.simantics.scl.compiler.runtime.RuntimeEnvironment; import org.simantics.scl.compiler.top.ExpressionEvaluator; import org.simantics.scl.compiler.top.LocalStorage; @@ -76,6 +76,7 @@ public class CommandSession { THashMap variableTypes = new THashMap(); PrintStream fileOutput; + private UpdateListener dependenciesListener; /** * Only checks the commands for compilation errors but does not run them. @@ -108,10 +109,13 @@ public class CommandSession { runtimeEnvironment = null; try { + if(dependenciesListener != null) + dependenciesListener.stopListening(); try { runtimeEnvironment = moduleRepository.createRuntimeEnvironment( environmentSpecification, - getClass().getClassLoader()); + getClass().getClassLoader(), + dependenciesListener); } catch(ImportFailureException e) { THashSet failedModules = new THashSet(); for(ImportFailure failure : e.failures) { @@ -129,7 +133,7 @@ public class CommandSession { try { runtimeEnvironment = moduleRepository.createRuntimeEnvironment( environmentSpecification, - getClass().getClassLoader()); + getClass().getClassLoader()); // no listener here, because should listen also failed modules } catch (ImportFailureException e1) { for(ImportFailure failure : e1.failures) defaultHandler.printError(failure.toString()); @@ -507,7 +511,7 @@ public class CommandSession { if(e.location != Locations.NO_LOCATION) handler.printError(parser.reader.locationUnderlining(e.location)); handler.printError(e.getMessage()); - } catch(Exception e) { + } catch (Exception | AssertionError e) { if(e instanceof InterruptedException) handler.printError("Execution interrupted."); else @@ -665,4 +669,7 @@ public class CommandSession { return validate(new StringReader(command)); } + public void setDependenciesListener(UpdateListener dependenciesListener) { + this.dependenciesListener = dependenciesListener; + } }