Skip to content

Commit

Permalink
Merge pull request #659 from adpi2/rename-to-class-updates
Browse files Browse the repository at this point in the history
rename to observeClassUpdates
  • Loading branch information
adpi2 authored Feb 15, 2024
2 parents 4e6f758 + fd98a59 commit fa93d2a
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ trait Debuggee {
def libraries: Seq[Library]
def unmanagedEntries: Seq[UnmanagedEntry]
def javaRuntime: Option[JavaRuntime]
def observeClassesToUpdate(updateClasses: Seq[String] => Unit): Closeable
def observeClassUpdates(onClassUpdate: Seq[String] => Unit): Closeable

def managedEntries: Seq[ManagedEntry] = modules ++ libraries
def classPathEntries: Seq[ClassPathEntry] = managedEntries ++ unmanagedEntries
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class HotCodeReplaceProvider(
override def initialize(context: IDebugAdapterContext, options: ju.Map[String, Object]): Unit = {
this.context = context
this.currentDebugSession = context.getDebugSession
this.subscription = debuggee.observeClassesToUpdate(classes => classesAccumulator.updateAndGet(_ ++ classes))
this.subscription = debuggee.observeClassUpdates(classes => classesAccumulator.updateAndGet(_ ++ classes))
this.sourceLookUp = context.getProvider(classOf[ISourceLookUpProvider]).asInstanceOf[SourceLookUpProvider]
this.stackTraceProvider = context.getProvider(classOf[IStackTraceProvider]).asInstanceOf[StackTraceProvider]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,8 @@ object DebugAdapterPlugin extends sbt.AutoPlugin {
inputKey[URI]("Start a debug session for running test suites").withRank(KeyRanks.DTask)
val startRemoteDebugSession =
inputKey[URI]("Start a debug session on a remote process").withRank(KeyRanks.DTask)
val debugAdapterConfig =
settingKey[DebugConfig]("Configure the debug session").withRank(KeyRanks.DTask)
val debugAdapterClassesToUpdate =
val debugAdapterConfig = settingKey[DebugConfig]("Configure the debug session").withRank(KeyRanks.DTask)
val debugAdapterClassUpdates =
settingKey[PublishSubject[Seq[String]]]("Observe the classes to be reloaded by the debuggee")
.withRank(KeyRanks.DTask)
val stopDebugSession =
Expand Down Expand Up @@ -108,7 +107,7 @@ object DebugAdapterPlugin extends sbt.AutoPlugin {
startMainClassDebugSession := mainClassSessionTask.evaluated,
startRemoteDebugSession := remoteSessionTask.evaluated,
stopDebugSession := stopSessionTask.value,
debugAdapterClassesToUpdate := PublishSubject.create(),
debugAdapterClassUpdates := PublishSubject.create(),
Keys.compile / Keys.javacOptions := {
val jo = (Keys.compile / Keys.javacOptions).value
if (jo.exists(_.startsWith("-g"))) jo
Expand All @@ -117,10 +116,10 @@ object DebugAdapterPlugin extends sbt.AutoPlugin {
Keys.compile := {
val currentAnalysis: CompileAnalysis = Keys.compile.value
val previousAnalysis = Keys.previousCompile.value.analysis
val classesToUpdate = debugAdapterClassesToUpdate.value
val classesToUpdate = debugAdapterClassUpdates.value
val fileConverter = Keys.fileConverter.value
val classDir = Keys.classDirectory.value.toPath
if (previousAnalysis.isPresent) {
if (previousAnalysis.isPresent && classesToUpdate.hasObservers) {
val currentStamps = currentAnalysis.readStamps
val previousStamps = previousAnalysis.get.readStamps
val newClasses = getNewClasses(currentStamps, previousStamps, fileConverter, classDir)
Expand Down Expand Up @@ -283,7 +282,7 @@ object DebugAdapterPlugin extends sbt.AutoPlugin {
InternalTasks.libraries.value,
InternalTasks.unmanagedEntries.value,
InternalTasks.javaRuntime.value,
InternalTasks.classesToUpdate.value,
InternalTasks.allClassUpdates.value,
mainClass.`class`,
mainClass.arguments,
new LoggerAdapter(logger)
Expand Down Expand Up @@ -389,7 +388,7 @@ object DebugAdapterPlugin extends sbt.AutoPlugin {
InternalTasks.libraries.value,
InternalTasks.unmanagedEntries.value,
InternalTasks.javaRuntime.value,
InternalTasks.classesToUpdate.value,
InternalTasks.allClassUpdates.value,
cleanups,
parallel,
testRunners,
Expand Down Expand Up @@ -455,7 +454,7 @@ object DebugAdapterPlugin extends sbt.AutoPlugin {
InternalTasks.libraries.value,
InternalTasks.unmanagedEntries.value,
InternalTasks.javaRuntime.value,
InternalTasks.classesToUpdate.value,
InternalTasks.allClassUpdates.value,
new LoggerAdapter(logger)
)
startServer(jobService, scope, state, target, debuggee, debugToolsResolver, debugAdapterConfig.value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ private[sbtplugin] object InternalTasks {
modules.join(_.join)
}

lazy val classesToUpdate: Def.Initialize[Observable[Seq[String]]] = Def.settingDyn {
lazy val allClassUpdates: Def.Initialize[Observable[Seq[String]]] = Def.settingDyn {
val internalDependencies = Keys.bspInternalDependencyConfigurations
val observables = for {
(proj, configs) <- Keys.bspInternalDependencyConfigurations.value
config <- configs
} yield (proj / config / debugAdapterClassesToUpdate)
} yield (proj / config / debugAdapterClassUpdates)
Def.setting {
observables.join.value.fold(Observable.empty[Seq[String]])(_ mergeWith _)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ private[debugadapter] sealed trait SbtDebuggee extends Debuggee {
val logger: LoggerAdapter
val classesToUpdate: Observable[Seq[String]]

override def observeClassesToUpdate(updateClasses: Seq[String] => Unit): Closeable = {
val subscription = classesToUpdate.subscribe(updateClasses(_))
override def observeClassUpdates(onClassUpdate: Seq[String] => Unit): Closeable = {
val subscription = classesToUpdate.subscribe(onClassUpdate(_))
() => if (!subscription.isDisposed) subscription.dispose
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class MockDebuggee extends Debuggee {

override def javaRuntime: Option[JavaRuntime] = None

override def observeClassesToUpdate(updateClasses: Seq[String] => Unit): Closeable = () => ()
override def observeClassUpdates(onClassUpdate: Seq[String] => Unit): Closeable = () => ()
}

class MockCancelableFuture() extends CancelableFuture[Unit] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ case class TestingDebuggee(
with TestingContext {

val classesToUpdate: Subject[Seq[String]] = PublishSubject.create()
override def observeClassesToUpdate(updateClasses: Seq[String] => Unit): Closeable = {
val subscription = classesToUpdate.subscribe(updateClasses(_))
override def observeClassUpdates(onClassUpdate: Seq[String] => Unit): Closeable = {
val subscription = classesToUpdate.subscribe(onClassUpdate(_))
() => if (!subscription.isDisposed) subscription.dispose
}
def mainSource: Path = sourceFiles.head
Expand Down

0 comments on commit fa93d2a

Please sign in to comment.