X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.scl.compiler%2Fsrc%2Forg%2Fsimantics%2Fscl%2Fcompiler%2Fcommands%2FCommandSession.java;h=d0e44a9c7b263a36c0a75b60cc5f678432081165;hb=97f45e9a3ae331ef93550f0163777a79d6dd1b89;hp=1cf6d0de9c5f0786fe4df80072602e22670f514e;hpb=36799f7fc9a4793236d9085aa87ee5baff167376;p=simantics%2Fplatform.git 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 1cf6d0de9..d0e44a9c7 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; @@ -33,6 +32,7 @@ import org.simantics.scl.compiler.environment.Environment; import org.simantics.scl.compiler.environment.LocalEnvironment; import org.simantics.scl.compiler.environment.specification.EnvironmentSpecification; import org.simantics.scl.compiler.errors.CompilationError; +import org.simantics.scl.compiler.errors.ErrorSeverity; import org.simantics.scl.compiler.errors.Locations; import org.simantics.scl.compiler.internal.codegen.utils.NameMangling; import org.simantics.scl.compiler.internal.parsing.exceptions.SCLSyntaxErrorException; @@ -43,6 +43,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 +77,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 +110,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) { @@ -119,7 +124,8 @@ public class CommandSession { defaultHandler.printError(failure.toString()); if(failure.reason instanceof CompilationError[]) for(CompilationError error : (CompilationError[])failure.reason) { - defaultHandler.printError(" " + error.description); + if(error.severity != ErrorSeverity.WARNING) + defaultHandler.printError(" " + error.description); } } for(CommandSessionImportEntry entry : importEntries) @@ -129,7 +135,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()); @@ -423,10 +429,9 @@ public class CommandSession { void finishBlock() { if(currentBlock != null) { checkInterrupted(); - LinkedList statements = currentBlock.getStatements(); currentBlock.location = Locations.combine( - statements.getFirst().location, - statements.getLast().location); + currentBlock.getFirst().location, + currentBlock.getLast().location); execute(reader, currentBlock, handler); currentBlock = null; } @@ -508,7 +513,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 @@ -595,7 +600,9 @@ public class CommandSession { b.append("\tat "); if("_SCL_Module".equals(fileName) || "_SCL_TypeClassInstance".equals(fileName)) - b.append(NameMangling.demangle(methodName)) + b.append(className) + .append('.') + .append(NameMangling.demangle(methodName)) .append('(').append(element.getLineNumber()).append(')'); else b.append(element); @@ -652,7 +659,7 @@ public class CommandSession { formatException(handler, e); } } - + public static CompilationError[] validate(ModuleRepository moduleRepository,StringReader commandReader) { CommandSession session = new CommandSession(moduleRepository, null); return session.validate(commandReader); @@ -666,4 +673,7 @@ public class CommandSession { return validate(new StringReader(command)); } + public void setDependenciesListener(UpdateListener dependenciesListener) { + this.dependenciesListener = dependenciesListener; + } }