mirror of
https://github.com/enso-org/enso.git
synced 2024-10-06 01:28:15 +03:00
Enable check for warnings when runMain
This commit is contained in:
parent
2cc7ef516f
commit
7df58efc3a
@ -30,6 +30,7 @@ import org.slf4j.event.Level;
|
||||
* @param options additional options for the Context
|
||||
* @param executionEnvironment optional name of the execution environment to use during execution
|
||||
* @param warningsLimit maximal number of warnings reported to the user
|
||||
* @param checkForWarnings name of method to check for warnings
|
||||
*/
|
||||
public final class ContextFactory {
|
||||
private String projectRoot;
|
||||
@ -47,6 +48,7 @@ public final class ContextFactory {
|
||||
private boolean useGlobalIrCacheLocation = true;
|
||||
private boolean enableAutoParallelism;
|
||||
private String executionEnvironment;
|
||||
private String checkForWarnings;
|
||||
private int warningsLimit = 100;
|
||||
private java.util.Map<String, String> options = java.util.Collections.emptyMap();
|
||||
|
||||
@ -141,6 +143,11 @@ public final class ContextFactory {
|
||||
return this;
|
||||
}
|
||||
|
||||
public ContextFactory checkForWarnings(String fqnOfMethod) {
|
||||
this.checkForWarnings = fqnOfMethod;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Context build() {
|
||||
if (executionEnvironment != null) {
|
||||
options.put("enso.ExecutionEnvironment", executionEnvironment);
|
||||
@ -169,6 +176,9 @@ public final class ContextFactory {
|
||||
.out(out)
|
||||
.err(err)
|
||||
.in(in);
|
||||
if (checkForWarnings != null) {
|
||||
builder.option("enso-debug-server.fn", checkForWarnings);
|
||||
}
|
||||
if (messageTransport != null) {
|
||||
builder.serverTransport(messageTransport);
|
||||
}
|
||||
|
@ -688,6 +688,25 @@ public class Main {
|
||||
}
|
||||
var projectMode = fileAndProject._1();
|
||||
var file = fileAndProject._2();
|
||||
var mainFile = file;
|
||||
if (projectMode) {
|
||||
var result = PackageManager$.MODULE$.Default().loadPackage(file);
|
||||
if (result.isSuccess()) {
|
||||
var s = (scala.util.Success) result;
|
||||
@SuppressWarnings("unchecked")
|
||||
var pkg = (org.enso.pkg.Package<java.io.File>) s.get();
|
||||
|
||||
mainFile = pkg.mainFile();
|
||||
if (!mainFile.exists()) {
|
||||
println("Main file does not exist.");
|
||||
throw exitFail();
|
||||
}
|
||||
} else {
|
||||
println(((scala.util.Failure) result).exception().getMessage());
|
||||
throw exitFail();
|
||||
}
|
||||
}
|
||||
|
||||
var projectRoot = fileAndProject._3();
|
||||
var options = new HashMap<String, String>();
|
||||
|
||||
@ -699,6 +718,7 @@ public class Main {
|
||||
.enableIrCaches(enableIrCaches)
|
||||
.disablePrivateCheck(disablePrivateCheck)
|
||||
.strictErrors(true)
|
||||
.checkForWarnings(mainFile.getName().replace(".enso", "") + ".main")
|
||||
.enableAutoParallelism(enableAutoParallelism)
|
||||
.enableStaticAnalysis(enableStaticAnalysis)
|
||||
.executionEnvironment(executionEnvironment != null ? executionEnvironment : "live")
|
||||
@ -724,12 +744,6 @@ public class Main {
|
||||
var s = (scala.util.Success) result;
|
||||
@SuppressWarnings("unchecked")
|
||||
var pkg = (org.enso.pkg.Package<java.io.File>) s.get();
|
||||
var main = pkg.mainFile();
|
||||
if (!main.exists()) {
|
||||
println("Main file does not exist.");
|
||||
context.context().close();
|
||||
throw exitFail();
|
||||
}
|
||||
var mainModuleName = pkg.moduleNameForFile(pkg.mainFile()).toString();
|
||||
runPackage(context, mainModuleName, file, additionalArgs);
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user