Skip to content

Commit

Permalink
Lazily initialize inspections stuff
Browse files Browse the repository at this point in the history
Seems it's only going to work with Java >= 11 from now on…
  • Loading branch information
alexarchambault committed May 29, 2024
1 parent e5ef096 commit 76edd00
Showing 1 changed file with 18 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,22 @@ final class ScalaInterpreter(
if (params.extraClassPath.nonEmpty)
frames0().head.addClasspath(params.extraClassPath.map(_.toNIO.toUri.toURL))

private val inspections = new ScalaInterpreterInspections(
logCtx,
params.metabrowse,
params.metabrowseHost,
params.metabrowsePort,
ammonite.compiler.CompilerBuilder.scalaVersion,
ammInterp
.compilerManager
.asInstanceOf[ammonite.compiler.CompilerLifecycleManager],
frames0()
)
private var inspectionsInitialized = false
private lazy val inspections = {
val value = new ScalaInterpreterInspections(
logCtx,
params.metabrowse,
params.metabrowseHost,
params.metabrowsePort,
ammonite.compiler.CompilerBuilder.scalaVersion,
ammInterp
.compilerManager
.asInstanceOf[ammonite.compiler.CompilerLifecycleManager],
frames0()
)
inspectionsInitialized = true
value
}

private val colors0: Ref[Colors] = Ref(params.initialColors)

Expand Down Expand Up @@ -306,7 +311,8 @@ final class ScalaInterpreter(
case NonFatal(e) =>
log.warn("Caught exception while trying to run exit hooks", e)
}
inspections.shutdown()
if (inspectionsInitialized)
inspections.shutdown()
}

}

0 comments on commit 76edd00

Please sign in to comment.