Skip to content

Commit

Permalink
Turning ContextFactory into (Java) builder
Browse files Browse the repository at this point in the history
  • Loading branch information
JaroslavTulach committed Dec 29, 2023
1 parent a21c006 commit f603a33
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 197 deletions.
153 changes: 0 additions & 153 deletions engine/runner/src/main/scala/org/enso/runner/ContextFactory.scala

This file was deleted.

96 changes: 52 additions & 44 deletions engine/runner/src/main/scala/org/enso/runner/Main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -546,17 +546,19 @@ object Main {
exitFail()
}

val context = new ContextFactory().create(
packagePath,
System.in,
System.out,
Repl(makeTerminalForRepl()),
logLevel,
logMasking,
enableIrCaches = true,
strictErrors = true,
useGlobalIrCacheLocation = shouldUseGlobalCache
)
val context = ContextFactory
.create()
.projectRoot(packagePath)
.in(System.in)
.out(System.out)
.repl(Repl(makeTerminalForRepl()))
.logLevel(logLevel)
.logMasking(logMasking)
.enableIrCaches(true)
.strictErrors(true)
.useGlobalIrCacheLocation(shouldUseGlobalCache)
.build

val topScope = context.getTopScope
try {
topScope.compile(shouldCompileDependencies)
Expand Down Expand Up @@ -628,21 +630,25 @@ object Main {
if (inspect) {
options.put("inspect", "")
}
val context = new ContextFactory().create(
projectRoot,
System.in,
System.out,
Repl(makeTerminalForRepl()),
logLevel,
logMasking,
enableIrCaches,
disablePrivateCheck,
strictErrors = true,
enableAutoParallelism = enableAutoParallelism,
executionEnvironment = executionEnvironment,
warningsLimit = warningsLimit,
options = options
)
val context = ContextFactory
.create()
.projectRoot(projectRoot)
.in(System.in)
.out(System.out)
.repl(Repl(makeTerminalForRepl()))
.logLevel(logLevel)
.logMasking(logMasking)
.enableIrCaches(enableIrCaches)
.disablePrivateCheck(disablePrivateCheck)
.strictErrors(true)
.enableAutoParallelism(enableAutoParallelism)
.executionEnvironment(
if (executionEnvironment.isDefined) executionEnvironment.get else null
)
.warningsLimit(warningsLimit)
.options(options)
.build

if (projectMode) {
PackageManager.Default.loadPackage(file) match {
case Success(pkg) =>
Expand Down Expand Up @@ -703,15 +709,16 @@ object Main {
logMasking: Boolean,
enableIrCaches: Boolean
): Unit = {
val executionContext = new ContextFactory().create(
path,
System.in,
System.out,
Repl(makeTerminalForRepl()),
logLevel,
logMasking,
enableIrCaches
)
val executionContext = ContextFactory
.create()
.projectRoot(path)
.in(System.in)
.out(System.out)
.repl(Repl(makeTerminalForRepl()))
.logLevel(logLevel)
.logMasking(logMasking)
.enableIrCaches(enableIrCaches)
.build

val file = new File(path)
val pkg = PackageManager.Default.fromDirectory(file)
Expand Down Expand Up @@ -911,15 +918,16 @@ object Main {
val replModuleName = "Internal_Repl_Module___"
val projectRoot = projectPath.getOrElse("")
val context =
new ContextFactory().create(
projectRoot,
System.in,
System.out,
Repl(makeTerminalForRepl()),
logLevel,
logMasking,
enableIrCaches
)
ContextFactory
.create()
.projectRoot(projectRoot)
.in(System.in)
.out(System.out)
.repl(Repl(makeTerminalForRepl()))
.logLevel(logLevel)
.logMasking(logMasking)
.enableIrCaches(enableIrCaches)
.build
val mainModule =
context.evalModule(dummySourceToTriggerRepl, replModuleName)
runMain(
Expand Down

0 comments on commit f603a33

Please sign in to comment.