From ed5a8c118b23b2df9b13eb5687c3956439c1aa6a Mon Sep 17 00:00:00 2001 From: Dale Wijnand Date: Thu, 8 Mar 2018 12:39:43 +0000 Subject: [PATCH 01/19] Upgrade to contraband 0.3.3 --- main-command/src/main/contraband-scala/sbt/Exec.scala | 4 ++-- project/plugins.sbt | 2 +- .../src/main/contraband-scala/sbt/protocol/ExecCommand.scala | 2 +- run/src/main/contraband-scala/sbt/ForkOptions.scala | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/main-command/src/main/contraband-scala/sbt/Exec.scala b/main-command/src/main/contraband-scala/sbt/Exec.scala index 829c885ae..a3a6a38e7 100644 --- a/main-command/src/main/contraband-scala/sbt/Exec.scala +++ b/main-command/src/main/contraband-scala/sbt/Exec.scala @@ -42,8 +42,8 @@ final class Exec private ( } object Exec { def newExecId: String = java.util.UUID.randomUUID.toString - def apply(commandLine: String, source: Option[sbt.CommandSource]): Exec = new Exec(commandLine, None, source) - def apply(commandLine: String, source: sbt.CommandSource): Exec = new Exec(commandLine, None, Option(source)) + def apply(commandLine: String, source: Option[sbt.CommandSource]): Exec = new Exec(commandLine, source) + def apply(commandLine: String, source: sbt.CommandSource): Exec = new Exec(commandLine, Option(source)) def apply(commandLine: String, execId: Option[String], source: Option[sbt.CommandSource]): Exec = new Exec(commandLine, execId, source) def apply(commandLine: String, execId: String, source: sbt.CommandSource): Exec = new Exec(commandLine, Option(execId), Option(source)) } diff --git a/project/plugins.sbt b/project/plugins.sbt index 8988c3d05..5ed8cbf57 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -2,6 +2,6 @@ scalaVersion := "2.12.4" scalacOptions ++= Seq("-feature", "-language:postfixOps") addSbtPlugin("org.scala-sbt" % "sbt-houserules" % "0.3.5") -addSbtPlugin("org.scala-sbt" % "sbt-contraband" % "0.3.2") +addSbtPlugin("org.scala-sbt" % "sbt-contraband" % "0.3.3") addSbtPlugin("de.heikoseeberger" % "sbt-header" % "3.0.2") addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.8.0") diff --git a/protocol/src/main/contraband-scala/sbt/protocol/ExecCommand.scala b/protocol/src/main/contraband-scala/sbt/protocol/ExecCommand.scala index df022897d..142e7282b 100644 --- a/protocol/src/main/contraband-scala/sbt/protocol/ExecCommand.scala +++ b/protocol/src/main/contraband-scala/sbt/protocol/ExecCommand.scala @@ -36,7 +36,7 @@ final class ExecCommand private ( } object ExecCommand { - def apply(commandLine: String): ExecCommand = new ExecCommand(commandLine, None) + def apply(commandLine: String): ExecCommand = new ExecCommand(commandLine) def apply(commandLine: String, execId: Option[String]): ExecCommand = new ExecCommand(commandLine, execId) def apply(commandLine: String, execId: String): ExecCommand = new ExecCommand(commandLine, Option(execId)) } diff --git a/run/src/main/contraband-scala/sbt/ForkOptions.scala b/run/src/main/contraband-scala/sbt/ForkOptions.scala index ece8ca699..e20277b72 100644 --- a/run/src/main/contraband-scala/sbt/ForkOptions.scala +++ b/run/src/main/contraband-scala/sbt/ForkOptions.scala @@ -79,7 +79,7 @@ final class ForkOptions private ( } object ForkOptions { - def apply(): ForkOptions = new ForkOptions(None, None, Vector(), None, Vector(), false, Map()) + def apply(): ForkOptions = new ForkOptions() def apply(javaHome: Option[java.io.File], outputStrategy: Option[sbt.OutputStrategy], bootJars: Vector[java.io.File], workingDirectory: Option[java.io.File], runJVMOptions: Vector[String], connectInput: Boolean, envVars: scala.collection.immutable.Map[String, String]): ForkOptions = new ForkOptions(javaHome, outputStrategy, bootJars, workingDirectory, runJVMOptions, connectInput, envVars) def apply(javaHome: java.io.File, outputStrategy: sbt.OutputStrategy, bootJars: Vector[java.io.File], workingDirectory: java.io.File, runJVMOptions: Vector[String], connectInput: Boolean, envVars: scala.collection.immutable.Map[String, String]): ForkOptions = new ForkOptions(Option(javaHome), Option(outputStrategy), bootJars, Option(workingDirectory), runJVMOptions, connectInput, envVars) } From 5df1d8e23f8283fe56786784339d1ff1fcce6f8e Mon Sep 17 00:00:00 2001 From: Ethan Atkins Date: Fri, 1 Dec 2017 12:39:59 -0800 Subject: [PATCH 02/19] Cache watch service I noticed that my custom WatchService was never cleaned up by sbt and realized that after every build we were making a new WatchService. At the same time, we were reusing the WatchState from the previous run, which was using the original WatchService. This was particularly problematic because it prevented us from registering any paths with the new watch service. This may have prevented some of the file updates from being seen by the watch service. Moreover, because we lost the reference to the original WatchService, there was no way to clean it up, which was a resource leak. May be related to #3775, #3695 --- main-command/src/main/scala/sbt/Watched.scala | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/main-command/src/main/scala/sbt/Watched.scala b/main-command/src/main/scala/sbt/Watched.scala index fa1dee03f..8b8385b61 100644 --- a/main-command/src/main/scala/sbt/Watched.scala +++ b/main-command/src/main/scala/sbt/Watched.scala @@ -94,7 +94,7 @@ object Watched { @tailrec def shouldTerminate: Boolean = (System.in.available > 0) && (watched.terminateWatch(System.in.read()) || shouldTerminate) val sources = watched.watchSources(s) - val service = watched.watchService() + val service = s get ContinuousWatchService getOrElse watched.watchService() val watchState = s get ContinuousState getOrElse WatchState.empty(service, sources) if (watchState.count > 0) @@ -115,15 +115,21 @@ object Watched { if (triggered) { printIfDefined(watched triggeredMessage newWatchState) - (ClearOnFailure :: next :: FailureWall :: repeat :: s).put(ContinuousState, newWatchState) + (ClearOnFailure :: next :: FailureWall :: repeat :: s) + .put(ContinuousState, newWatchState) + .put(ContinuousWatchService, service) } else { while (System.in.available() > 0) System.in.read() service.close() - s.remove(ContinuousState) + s.remove(ContinuousState).remove(ContinuousWatchService) } } val ContinuousState = AttributeKey[WatchState]("watch state", "Internal: tracks state for continuous execution.") + + val ContinuousWatchService = + AttributeKey[WatchService]("watch service", + "Internal: tracks watch service for continuous execution.") val Configuration = AttributeKey[Watched]("watched-configuration", "Configures continuous execution.") From dd4de14593f1a68258d10a1fb2d8a9c1d1e5f6c3 Mon Sep 17 00:00:00 2001 From: Dale Wijnand Date: Mon, 12 Mar 2018 15:18:42 +0000 Subject: [PATCH 03/19] Upgrade to contraband 0.4.0 --- build.sbt | 60 +++++++++++++++++++ .../contraband-scala/sbt/CommandSource.scala | 2 +- .../src/main/contraband-scala/sbt/Exec.scala | 2 +- .../scala/sbt/internal/server/Server.scala | 3 +- project/plugins.sbt | 2 +- .../langserver/ClientCapabilities.scala | 2 +- .../sbt/internal/langserver/Diagnostic.scala | 2 +- .../langserver/InitializeParams.scala | 2 +- .../langserver/InitializeResult.scala | 2 +- .../sbt/internal/langserver/Location.scala | 2 +- .../langserver/LogMessageParams.scala | 2 +- .../sbt/internal/langserver/Position.scala | 2 +- .../langserver/PublishDiagnosticsParams.scala | 2 +- .../sbt/internal/langserver/Range.scala | 2 +- .../sbt/internal/langserver/SaveOptions.scala | 2 +- .../internal/langserver/SbtExecParams.scala | 2 +- .../langserver/ServerCapabilities.scala | 2 +- .../langserver/TextDocumentIdentifier.scala | 2 +- .../TextDocumentPositionParams.scala | 2 +- .../langserver/TextDocumentSyncOptions.scala | 2 +- .../internal/protocol/InitializeOption.scala | 2 +- .../protocol/JsonRpcNotificationMessage.scala | 2 +- .../protocol/JsonRpcRequestMessage.scala | 2 +- .../protocol/JsonRpcResponseError.scala | 2 +- .../protocol/JsonRpcResponseMessage.scala | 2 +- .../sbt/internal/protocol/PortFile.scala | 2 +- .../sbt/internal/protocol/TokenFile.scala | 2 +- .../sbt/protocol/ChannelAcceptedEvent.scala | 2 +- .../sbt/protocol/ExecCommand.scala | 2 +- .../sbt/protocol/ExecStatusEvent.scala | 2 +- .../sbt/protocol/ExecutionEvent.scala | 2 +- .../sbt/protocol/InitCommand.scala | 2 +- .../sbt/protocol/LogEvent.scala | 2 +- .../sbt/protocol/SettingQuery.scala | 2 +- .../sbt/protocol/SettingQueryFailure.scala | 2 +- .../sbt/protocol/SettingQuerySuccess.scala | 2 +- .../contraband-scala/sbt/ForkOptions.scala | 2 +- run/src/main/scala/sbt/OutputStrategy.scala | 6 +- .../testing/EndTestGroupErrorEvent.scala | 2 +- .../protocol/testing/EndTestGroupEvent.scala | 2 +- .../testing/StartTestGroupEvent.scala | 2 +- .../protocol/testing/TestCompleteEvent.scala | 2 +- .../sbt/protocol/testing/TestInitEvent.scala | 2 +- .../sbt/protocol/testing/TestItemDetail.scala | 2 +- .../sbt/protocol/testing/TestItemEvent.scala | 2 +- .../protocol/testing/TestStringEvent.scala | 2 +- 46 files changed, 108 insertions(+), 47 deletions(-) diff --git a/build.sbt b/build.sbt index bb6df2c9d..5e50c04aa 100644 --- a/build.sbt +++ b/build.sbt @@ -203,6 +203,24 @@ lazy val testingProj = (project in file("testing")) sourceManaged in (Compile, generateContrabands) := baseDirectory.value / "src" / "main" / "contraband-scala", contrabandFormatsForType in generateContrabands in Compile := ContrabandConfig.getFormats, mimaSettings, + mimaBinaryIssueFilters ++= Seq( + // copy method was never meant to be public + exclude[DirectMissingMethodProblem]("sbt.protocol.testing.EndTestGroupErrorEvent.copy"), + exclude[DirectMissingMethodProblem]("sbt.protocol.testing.EndTestGroupErrorEvent.copy$default$*"), + exclude[DirectMissingMethodProblem]("sbt.protocol.testing.EndTestGroupEvent.copy"), + exclude[DirectMissingMethodProblem]("sbt.protocol.testing.EndTestGroupEvent.copy$default$*"), + exclude[DirectMissingMethodProblem]("sbt.protocol.testing.StartTestGroupEvent.copy"), + exclude[DirectMissingMethodProblem]("sbt.protocol.testing.StartTestGroupEvent.copy$default$*"), + exclude[DirectMissingMethodProblem]("sbt.protocol.testing.TestCompleteEvent.copy"), + exclude[DirectMissingMethodProblem]("sbt.protocol.testing.TestCompleteEvent.copy$default$*"), + exclude[DirectMissingMethodProblem]("sbt.protocol.testing.TestInitEvent.copy"), + exclude[DirectMissingMethodProblem]("sbt.protocol.testing.TestItemDetail.copy"), + exclude[DirectMissingMethodProblem]("sbt.protocol.testing.TestItemDetail.copy$default$*"), + exclude[DirectMissingMethodProblem]("sbt.protocol.testing.TestItemEvent.copy"), + exclude[DirectMissingMethodProblem]("sbt.protocol.testing.TestItemEvent.copy$default$*"), + exclude[DirectMissingMethodProblem]("sbt.protocol.testing.TestStringEvent.copy"), + exclude[DirectMissingMethodProblem]("sbt.protocol.testing.TestStringEvent.copy$default$1"), + ) ) .configure(addSbtIO, addSbtCompilerClasspath, addSbtUtilLogging) @@ -251,6 +269,17 @@ lazy val runProj = (project in file("run")) baseDirectory.value / "src" / "main" / "contraband-scala", sourceManaged in (Compile, generateContrabands) := baseDirectory.value / "src" / "main" / "contraband-scala", mimaSettings, + mimaBinaryIssueFilters ++= Seq( + // copy method was never meant to be public + exclude[DirectMissingMethodProblem]("sbt.ForkOptions.copy"), + exclude[DirectMissingMethodProblem]("sbt.ForkOptions.copy$default$*"), + exclude[DirectMissingMethodProblem]("sbt.OutputStrategy#BufferedOutput.copy"), + exclude[DirectMissingMethodProblem]("sbt.OutputStrategy#BufferedOutput.copy$default$*"), + exclude[DirectMissingMethodProblem]("sbt.OutputStrategy#CustomOutput.copy"), + exclude[DirectMissingMethodProblem]("sbt.OutputStrategy#CustomOutput.copy$default$*"), + exclude[DirectMissingMethodProblem]("sbt.OutputStrategy#LoggedOutput.copy"), + exclude[DirectMissingMethodProblem]("sbt.OutputStrategy#LoggedOutput.copy$default$*"), + ) ) .configure(addSbtIO, addSbtUtilLogging, addSbtCompilerClasspath) @@ -307,6 +336,31 @@ lazy val protocolProj = (project in file("protocol")) sourceManaged in (Compile, generateContrabands) := baseDirectory.value / "src" / "main" / "contraband-scala", contrabandFormatsForType in generateContrabands in Compile := ContrabandConfig.getFormats, mimaSettings, + mimaBinaryIssueFilters ++= Seq( + // copy method was never meant to be public + exclude[DirectMissingMethodProblem]("sbt.protocol.ChannelAcceptedEvent.copy"), + exclude[DirectMissingMethodProblem]("sbt.protocol.ChannelAcceptedEvent.copy$default$1"), + exclude[DirectMissingMethodProblem]("sbt.protocol.ExecCommand.copy"), + exclude[DirectMissingMethodProblem]("sbt.protocol.ExecCommand.copy$default$1"), + exclude[DirectMissingMethodProblem]("sbt.protocol.ExecCommand.copy$default$2"), + exclude[DirectMissingMethodProblem]("sbt.protocol.ExecStatusEvent.copy"), + exclude[DirectMissingMethodProblem]("sbt.protocol.ExecStatusEvent.copy$default$*"), + exclude[DirectMissingMethodProblem]("sbt.protocol.ExecutionEvent.copy"), + exclude[DirectMissingMethodProblem]("sbt.protocol.ExecutionEvent.copy$default$*"), + exclude[DirectMissingMethodProblem]("sbt.protocol.InitCommand.copy"), + exclude[DirectMissingMethodProblem]("sbt.protocol.InitCommand.copy$default$*"), + exclude[DirectMissingMethodProblem]("sbt.protocol.LogEvent.copy"), + exclude[DirectMissingMethodProblem]("sbt.protocol.LogEvent.copy$default$*"), + exclude[DirectMissingMethodProblem]("sbt.protocol.SettingQuery.copy"), + exclude[DirectMissingMethodProblem]("sbt.protocol.SettingQuery.copy$default$1"), + exclude[DirectMissingMethodProblem]("sbt.protocol.SettingQueryFailure.copy"), + exclude[DirectMissingMethodProblem]("sbt.protocol.SettingQueryFailure.copy$default$*"), + exclude[DirectMissingMethodProblem]("sbt.protocol.SettingQuerySuccess.copy"), + exclude[DirectMissingMethodProblem]("sbt.protocol.SettingQuerySuccess.copy$default$*"), + + // ignore missing methods in sbt.internal + exclude[DirectMissingMethodProblem]("sbt.internal.*"), + ) ) .configure(addSbtUtilLogging) @@ -336,6 +390,12 @@ lazy val commandProj = (project in file("main-command")) // Replace nailgun socket stuff exclude[MissingClassProblem]("sbt.internal.NG*"), exclude[MissingClassProblem]("sbt.internal.ReferenceCountedFileDescriptor"), + + // copy method was never meant to be public + exclude[DirectMissingMethodProblem]("sbt.CommandSource.copy"), + exclude[DirectMissingMethodProblem]("sbt.CommandSource.copy$default$*"), + exclude[DirectMissingMethodProblem]("sbt.Exec.copy"), + exclude[DirectMissingMethodProblem]("sbt.Exec.copy$default$*"), ), unmanagedSources in (Compile, headerCreate) := { val old = (unmanagedSources in (Compile, headerCreate)).value diff --git a/main-command/src/main/contraband-scala/sbt/CommandSource.scala b/main-command/src/main/contraband-scala/sbt/CommandSource.scala index e57e91857..b15193ab1 100644 --- a/main-command/src/main/contraband-scala/sbt/CommandSource.scala +++ b/main-command/src/main/contraband-scala/sbt/CommandSource.scala @@ -19,7 +19,7 @@ final class CommandSource private ( override def toString: String = { "CommandSource(" + channelName + ")" } - protected[this] def copy(channelName: String = channelName): CommandSource = { + private[this] def copy(channelName: String = channelName): CommandSource = { new CommandSource(channelName) } def withChannelName(channelName: String): CommandSource = { diff --git a/main-command/src/main/contraband-scala/sbt/Exec.scala b/main-command/src/main/contraband-scala/sbt/Exec.scala index a3a6a38e7..5b5398bff 100644 --- a/main-command/src/main/contraband-scala/sbt/Exec.scala +++ b/main-command/src/main/contraband-scala/sbt/Exec.scala @@ -21,7 +21,7 @@ final class Exec private ( override def toString: String = { "Exec(" + commandLine + ", " + execId + ", " + source + ")" } - protected[this] def copy(commandLine: String = commandLine, execId: Option[String] = execId, source: Option[sbt.CommandSource] = source): Exec = { + private[this] def copy(commandLine: String = commandLine, execId: Option[String] = execId, source: Option[sbt.CommandSource] = source): Exec = { new Exec(commandLine, execId, source) } def withCommandLine(commandLine: String): Exec = { diff --git a/main-command/src/main/scala/sbt/internal/server/Server.scala b/main-command/src/main/scala/sbt/internal/server/Server.scala index 05b86c48a..c2bccb886 100644 --- a/main-command/src/main/scala/sbt/internal/server/Server.scala +++ b/main-command/src/main/scala/sbt/internal/server/Server.scala @@ -63,7 +63,8 @@ private[sbt] object Server { val maxSocketLength = new UnixDomainSocketLibrary.SockaddrUn().sunPath.length - 1 val path = socketfile.getAbsolutePath if (path.length > maxSocketLength) - sys.error("socket file absolute path too long; " + + sys.error( + "socket file absolute path too long; " + "either switch to another connection type " + "or define a short \"SBT_GLOBAL_SERVER_DIR\" value. " + s"Current path: ${path}") diff --git a/project/plugins.sbt b/project/plugins.sbt index 5ed8cbf57..c91a3bc6f 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -2,6 +2,6 @@ scalaVersion := "2.12.4" scalacOptions ++= Seq("-feature", "-language:postfixOps") addSbtPlugin("org.scala-sbt" % "sbt-houserules" % "0.3.5") -addSbtPlugin("org.scala-sbt" % "sbt-contraband" % "0.3.3") +addSbtPlugin("org.scala-sbt" % "sbt-contraband" % "0.4.0") addSbtPlugin("de.heikoseeberger" % "sbt-header" % "3.0.2") addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.8.0") diff --git a/protocol/src/main/contraband-scala/sbt/internal/langserver/ClientCapabilities.scala b/protocol/src/main/contraband-scala/sbt/internal/langserver/ClientCapabilities.scala index 8e046ede9..7b6e32313 100644 --- a/protocol/src/main/contraband-scala/sbt/internal/langserver/ClientCapabilities.scala +++ b/protocol/src/main/contraband-scala/sbt/internal/langserver/ClientCapabilities.scala @@ -18,7 +18,7 @@ override def hashCode: Int = { override def toString: String = { "ClientCapabilities()" } -protected[this] def copy(): ClientCapabilities = { +private[this] def copy(): ClientCapabilities = { new ClientCapabilities() } diff --git a/protocol/src/main/contraband-scala/sbt/internal/langserver/Diagnostic.scala b/protocol/src/main/contraband-scala/sbt/internal/langserver/Diagnostic.scala index c28bc9b38..033fae3cf 100644 --- a/protocol/src/main/contraband-scala/sbt/internal/langserver/Diagnostic.scala +++ b/protocol/src/main/contraband-scala/sbt/internal/langserver/Diagnostic.scala @@ -38,7 +38,7 @@ final class Diagnostic private ( override def toString: String = { "Diagnostic(" + range + ", " + severity + ", " + code + ", " + source + ", " + message + ")" } - protected[this] def copy(range: sbt.internal.langserver.Range = range, severity: Option[Long] = severity, code: Option[String] = code, source: Option[String] = source, message: String = message): Diagnostic = { + private[this] def copy(range: sbt.internal.langserver.Range = range, severity: Option[Long] = severity, code: Option[String] = code, source: Option[String] = source, message: String = message): Diagnostic = { new Diagnostic(range, severity, code, source, message) } def withRange(range: sbt.internal.langserver.Range): Diagnostic = { diff --git a/protocol/src/main/contraband-scala/sbt/internal/langserver/InitializeParams.scala b/protocol/src/main/contraband-scala/sbt/internal/langserver/InitializeParams.scala index b96dc9478..7c53991c0 100644 --- a/protocol/src/main/contraband-scala/sbt/internal/langserver/InitializeParams.scala +++ b/protocol/src/main/contraband-scala/sbt/internal/langserver/InitializeParams.scala @@ -25,7 +25,7 @@ final class InitializeParams private ( override def toString: String = { "InitializeParams(" + processId + ", " + rootPath + ", " + rootUri + ", " + initializationOptions + ", " + capabilities + ", " + trace + ")" } - protected[this] def copy(processId: Option[Long] = processId, rootPath: Option[String] = rootPath, rootUri: Option[String] = rootUri, initializationOptions: Option[sjsonnew.shaded.scalajson.ast.unsafe.JValue] = initializationOptions, capabilities: Option[sbt.internal.langserver.ClientCapabilities] = capabilities, trace: Option[String] = trace): InitializeParams = { + private[this] def copy(processId: Option[Long] = processId, rootPath: Option[String] = rootPath, rootUri: Option[String] = rootUri, initializationOptions: Option[sjsonnew.shaded.scalajson.ast.unsafe.JValue] = initializationOptions, capabilities: Option[sbt.internal.langserver.ClientCapabilities] = capabilities, trace: Option[String] = trace): InitializeParams = { new InitializeParams(processId, rootPath, rootUri, initializationOptions, capabilities, trace) } def withProcessId(processId: Option[Long]): InitializeParams = { diff --git a/protocol/src/main/contraband-scala/sbt/internal/langserver/InitializeResult.scala b/protocol/src/main/contraband-scala/sbt/internal/langserver/InitializeResult.scala index 440844dd6..a7c797870 100644 --- a/protocol/src/main/contraband-scala/sbt/internal/langserver/InitializeResult.scala +++ b/protocol/src/main/contraband-scala/sbt/internal/langserver/InitializeResult.scala @@ -20,7 +20,7 @@ final class InitializeResult private ( override def toString: String = { "InitializeResult(" + capabilities + ")" } - protected[this] def copy(capabilities: sbt.internal.langserver.ServerCapabilities = capabilities): InitializeResult = { + private[this] def copy(capabilities: sbt.internal.langserver.ServerCapabilities = capabilities): InitializeResult = { new InitializeResult(capabilities) } def withCapabilities(capabilities: sbt.internal.langserver.ServerCapabilities): InitializeResult = { diff --git a/protocol/src/main/contraband-scala/sbt/internal/langserver/Location.scala b/protocol/src/main/contraband-scala/sbt/internal/langserver/Location.scala index 900a426d4..0fdb66043 100644 --- a/protocol/src/main/contraband-scala/sbt/internal/langserver/Location.scala +++ b/protocol/src/main/contraband-scala/sbt/internal/langserver/Location.scala @@ -21,7 +21,7 @@ final class Location private ( override def toString: String = { "Location(" + uri + ", " + range + ")" } - protected[this] def copy(uri: String = uri, range: sbt.internal.langserver.Range = range): Location = { + private[this] def copy(uri: String = uri, range: sbt.internal.langserver.Range = range): Location = { new Location(uri, range) } def withUri(uri: String): Location = { diff --git a/protocol/src/main/contraband-scala/sbt/internal/langserver/LogMessageParams.scala b/protocol/src/main/contraband-scala/sbt/internal/langserver/LogMessageParams.scala index a13045afa..3755c84d0 100644 --- a/protocol/src/main/contraband-scala/sbt/internal/langserver/LogMessageParams.scala +++ b/protocol/src/main/contraband-scala/sbt/internal/langserver/LogMessageParams.scala @@ -22,7 +22,7 @@ final class LogMessageParams private ( override def toString: String = { "LogMessageParams(" + `type` + ", " + message + ")" } - protected[this] def copy(`type`: Long = `type`, message: String = message): LogMessageParams = { + private[this] def copy(`type`: Long = `type`, message: String = message): LogMessageParams = { new LogMessageParams(`type`, message) } def withType(`type`: Long): LogMessageParams = { diff --git a/protocol/src/main/contraband-scala/sbt/internal/langserver/Position.scala b/protocol/src/main/contraband-scala/sbt/internal/langserver/Position.scala index f36a278f1..caf248768 100644 --- a/protocol/src/main/contraband-scala/sbt/internal/langserver/Position.scala +++ b/protocol/src/main/contraband-scala/sbt/internal/langserver/Position.scala @@ -26,7 +26,7 @@ final class Position private ( override def toString: String = { "Position(" + line + ", " + character + ")" } - protected[this] def copy(line: Long = line, character: Long = character): Position = { + private[this] def copy(line: Long = line, character: Long = character): Position = { new Position(line, character) } def withLine(line: Long): Position = { diff --git a/protocol/src/main/contraband-scala/sbt/internal/langserver/PublishDiagnosticsParams.scala b/protocol/src/main/contraband-scala/sbt/internal/langserver/PublishDiagnosticsParams.scala index 25f7ab729..3c18fbbab 100644 --- a/protocol/src/main/contraband-scala/sbt/internal/langserver/PublishDiagnosticsParams.scala +++ b/protocol/src/main/contraband-scala/sbt/internal/langserver/PublishDiagnosticsParams.scala @@ -23,7 +23,7 @@ final class PublishDiagnosticsParams private ( override def toString: String = { "PublishDiagnosticsParams(" + uri + ", " + diagnostics + ")" } - protected[this] def copy(uri: String = uri, diagnostics: Vector[sbt.internal.langserver.Diagnostic] = diagnostics): PublishDiagnosticsParams = { + private[this] def copy(uri: String = uri, diagnostics: Vector[sbt.internal.langserver.Diagnostic] = diagnostics): PublishDiagnosticsParams = { new PublishDiagnosticsParams(uri, diagnostics) } def withUri(uri: String): PublishDiagnosticsParams = { diff --git a/protocol/src/main/contraband-scala/sbt/internal/langserver/Range.scala b/protocol/src/main/contraband-scala/sbt/internal/langserver/Range.scala index 929bbec5b..fab914ef5 100644 --- a/protocol/src/main/contraband-scala/sbt/internal/langserver/Range.scala +++ b/protocol/src/main/contraband-scala/sbt/internal/langserver/Range.scala @@ -26,7 +26,7 @@ final class Range private ( override def toString: String = { "Range(" + start + ", " + end + ")" } - protected[this] def copy(start: sbt.internal.langserver.Position = start, end: sbt.internal.langserver.Position = end): Range = { + private[this] def copy(start: sbt.internal.langserver.Position = start, end: sbt.internal.langserver.Position = end): Range = { new Range(start, end) } def withStart(start: sbt.internal.langserver.Position): Range = { diff --git a/protocol/src/main/contraband-scala/sbt/internal/langserver/SaveOptions.scala b/protocol/src/main/contraband-scala/sbt/internal/langserver/SaveOptions.scala index 347dfca25..7f66646de 100644 --- a/protocol/src/main/contraband-scala/sbt/internal/langserver/SaveOptions.scala +++ b/protocol/src/main/contraband-scala/sbt/internal/langserver/SaveOptions.scala @@ -20,7 +20,7 @@ final class SaveOptions private ( override def toString: String = { "SaveOptions(" + includeText + ")" } - protected[this] def copy(includeText: Option[Boolean] = includeText): SaveOptions = { + private[this] def copy(includeText: Option[Boolean] = includeText): SaveOptions = { new SaveOptions(includeText) } def withIncludeText(includeText: Option[Boolean]): SaveOptions = { diff --git a/protocol/src/main/contraband-scala/sbt/internal/langserver/SbtExecParams.scala b/protocol/src/main/contraband-scala/sbt/internal/langserver/SbtExecParams.scala index d60cc441b..97f4c5aae 100644 --- a/protocol/src/main/contraband-scala/sbt/internal/langserver/SbtExecParams.scala +++ b/protocol/src/main/contraband-scala/sbt/internal/langserver/SbtExecParams.scala @@ -20,7 +20,7 @@ final class SbtExecParams private ( override def toString: String = { "SbtExecParams(" + commandLine + ")" } - protected[this] def copy(commandLine: String = commandLine): SbtExecParams = { + private[this] def copy(commandLine: String = commandLine): SbtExecParams = { new SbtExecParams(commandLine) } def withCommandLine(commandLine: String): SbtExecParams = { diff --git a/protocol/src/main/contraband-scala/sbt/internal/langserver/ServerCapabilities.scala b/protocol/src/main/contraband-scala/sbt/internal/langserver/ServerCapabilities.scala index 802428214..4aa6c698d 100644 --- a/protocol/src/main/contraband-scala/sbt/internal/langserver/ServerCapabilities.scala +++ b/protocol/src/main/contraband-scala/sbt/internal/langserver/ServerCapabilities.scala @@ -23,7 +23,7 @@ final class ServerCapabilities private ( override def toString: String = { "ServerCapabilities(" + textDocumentSync + ", " + hoverProvider + ", " + definitionProvider + ")" } - protected[this] def copy(textDocumentSync: Option[sbt.internal.langserver.TextDocumentSyncOptions] = textDocumentSync, hoverProvider: Option[Boolean] = hoverProvider, definitionProvider: Option[Boolean] = definitionProvider): ServerCapabilities = { + private[this] def copy(textDocumentSync: Option[sbt.internal.langserver.TextDocumentSyncOptions] = textDocumentSync, hoverProvider: Option[Boolean] = hoverProvider, definitionProvider: Option[Boolean] = definitionProvider): ServerCapabilities = { new ServerCapabilities(textDocumentSync, hoverProvider, definitionProvider) } def withTextDocumentSync(textDocumentSync: Option[sbt.internal.langserver.TextDocumentSyncOptions]): ServerCapabilities = { diff --git a/protocol/src/main/contraband-scala/sbt/internal/langserver/TextDocumentIdentifier.scala b/protocol/src/main/contraband-scala/sbt/internal/langserver/TextDocumentIdentifier.scala index bb29b3d7f..dd5a2887f 100644 --- a/protocol/src/main/contraband-scala/sbt/internal/langserver/TextDocumentIdentifier.scala +++ b/protocol/src/main/contraband-scala/sbt/internal/langserver/TextDocumentIdentifier.scala @@ -21,7 +21,7 @@ final class TextDocumentIdentifier private ( override def toString: String = { "TextDocumentIdentifier(" + uri + ")" } - protected[this] def copy(uri: String = uri): TextDocumentIdentifier = { + private[this] def copy(uri: String = uri): TextDocumentIdentifier = { new TextDocumentIdentifier(uri) } def withUri(uri: String): TextDocumentIdentifier = { diff --git a/protocol/src/main/contraband-scala/sbt/internal/langserver/TextDocumentPositionParams.scala b/protocol/src/main/contraband-scala/sbt/internal/langserver/TextDocumentPositionParams.scala index 5d7d3edd8..10717f0fc 100644 --- a/protocol/src/main/contraband-scala/sbt/internal/langserver/TextDocumentPositionParams.scala +++ b/protocol/src/main/contraband-scala/sbt/internal/langserver/TextDocumentPositionParams.scala @@ -23,7 +23,7 @@ final class TextDocumentPositionParams private ( override def toString: String = { "TextDocumentPositionParams(" + textDocument + ", " + position + ")" } - protected[this] def copy(textDocument: sbt.internal.langserver.TextDocumentIdentifier = textDocument, position: sbt.internal.langserver.Position = position): TextDocumentPositionParams = { + private[this] def copy(textDocument: sbt.internal.langserver.TextDocumentIdentifier = textDocument, position: sbt.internal.langserver.Position = position): TextDocumentPositionParams = { new TextDocumentPositionParams(textDocument, position) } def withTextDocument(textDocument: sbt.internal.langserver.TextDocumentIdentifier): TextDocumentPositionParams = { diff --git a/protocol/src/main/contraband-scala/sbt/internal/langserver/TextDocumentSyncOptions.scala b/protocol/src/main/contraband-scala/sbt/internal/langserver/TextDocumentSyncOptions.scala index d94f50428..4822a9aec 100644 --- a/protocol/src/main/contraband-scala/sbt/internal/langserver/TextDocumentSyncOptions.scala +++ b/protocol/src/main/contraband-scala/sbt/internal/langserver/TextDocumentSyncOptions.scala @@ -23,7 +23,7 @@ final class TextDocumentSyncOptions private ( override def toString: String = { "TextDocumentSyncOptions(" + openClose + ", " + change + ", " + willSave + ", " + willSaveWaitUntil + ", " + save + ")" } - protected[this] def copy(openClose: Option[Boolean] = openClose, change: Option[Long] = change, willSave: Option[Boolean] = willSave, willSaveWaitUntil: Option[Boolean] = willSaveWaitUntil, save: Option[sbt.internal.langserver.SaveOptions] = save): TextDocumentSyncOptions = { + private[this] def copy(openClose: Option[Boolean] = openClose, change: Option[Long] = change, willSave: Option[Boolean] = willSave, willSaveWaitUntil: Option[Boolean] = willSaveWaitUntil, save: Option[sbt.internal.langserver.SaveOptions] = save): TextDocumentSyncOptions = { new TextDocumentSyncOptions(openClose, change, willSave, willSaveWaitUntil, save) } def withOpenClose(openClose: Option[Boolean]): TextDocumentSyncOptions = { diff --git a/protocol/src/main/contraband-scala/sbt/internal/protocol/InitializeOption.scala b/protocol/src/main/contraband-scala/sbt/internal/protocol/InitializeOption.scala index eeda8fa2c..ff2f27c9c 100644 --- a/protocol/src/main/contraband-scala/sbt/internal/protocol/InitializeOption.scala +++ b/protocol/src/main/contraband-scala/sbt/internal/protocol/InitializeOption.scala @@ -19,7 +19,7 @@ final class InitializeOption private ( override def toString: String = { "InitializeOption(" + token + ")" } - protected[this] def copy(token: Option[String] = token): InitializeOption = { + private[this] def copy(token: Option[String] = token): InitializeOption = { new InitializeOption(token) } def withToken(token: Option[String]): InitializeOption = { diff --git a/protocol/src/main/contraband-scala/sbt/internal/protocol/JsonRpcNotificationMessage.scala b/protocol/src/main/contraband-scala/sbt/internal/protocol/JsonRpcNotificationMessage.scala index aa55a3639..b3edb6b9d 100644 --- a/protocol/src/main/contraband-scala/sbt/internal/protocol/JsonRpcNotificationMessage.scala +++ b/protocol/src/main/contraband-scala/sbt/internal/protocol/JsonRpcNotificationMessage.scala @@ -23,7 +23,7 @@ final class JsonRpcNotificationMessage private ( override def toString: String = { s"""JsonRpcNotificationMessage($jsonrpc, $method, ${sbt.protocol.Serialization.compactPrintJsonOpt(params)})""" } - protected[this] def copy(jsonrpc: String = jsonrpc, method: String = method, params: Option[sjsonnew.shaded.scalajson.ast.unsafe.JValue] = params): JsonRpcNotificationMessage = { + private[this] def copy(jsonrpc: String = jsonrpc, method: String = method, params: Option[sjsonnew.shaded.scalajson.ast.unsafe.JValue] = params): JsonRpcNotificationMessage = { new JsonRpcNotificationMessage(jsonrpc, method, params) } def withJsonrpc(jsonrpc: String): JsonRpcNotificationMessage = { diff --git a/protocol/src/main/contraband-scala/sbt/internal/protocol/JsonRpcRequestMessage.scala b/protocol/src/main/contraband-scala/sbt/internal/protocol/JsonRpcRequestMessage.scala index f5943e1f7..d40611379 100644 --- a/protocol/src/main/contraband-scala/sbt/internal/protocol/JsonRpcRequestMessage.scala +++ b/protocol/src/main/contraband-scala/sbt/internal/protocol/JsonRpcRequestMessage.scala @@ -25,7 +25,7 @@ final class JsonRpcRequestMessage private ( override def toString: String = { s"""JsonRpcRequestMessage($jsonrpc, $id, $method, ${sbt.protocol.Serialization.compactPrintJsonOpt(params)}})""" } - protected[this] def copy(jsonrpc: String = jsonrpc, id: String = id, method: String = method, params: Option[sjsonnew.shaded.scalajson.ast.unsafe.JValue] = params): JsonRpcRequestMessage = { + private[this] def copy(jsonrpc: String = jsonrpc, id: String = id, method: String = method, params: Option[sjsonnew.shaded.scalajson.ast.unsafe.JValue] = params): JsonRpcRequestMessage = { new JsonRpcRequestMessage(jsonrpc, id, method, params) } def withJsonrpc(jsonrpc: String): JsonRpcRequestMessage = { diff --git a/protocol/src/main/contraband-scala/sbt/internal/protocol/JsonRpcResponseError.scala b/protocol/src/main/contraband-scala/sbt/internal/protocol/JsonRpcResponseError.scala index 9ece99852..68541873e 100644 --- a/protocol/src/main/contraband-scala/sbt/internal/protocol/JsonRpcResponseError.scala +++ b/protocol/src/main/contraband-scala/sbt/internal/protocol/JsonRpcResponseError.scala @@ -27,7 +27,7 @@ final class JsonRpcResponseError private ( override def toString: String = { s"""JsonRpcResponseError($code, $message, ${sbt.protocol.Serialization.compactPrintJsonOpt(data)})""" } - protected[this] def copy(code: Long = code, message: String = message, data: Option[sjsonnew.shaded.scalajson.ast.unsafe.JValue] = data): JsonRpcResponseError = { + private[this] def copy(code: Long = code, message: String = message, data: Option[sjsonnew.shaded.scalajson.ast.unsafe.JValue] = data): JsonRpcResponseError = { new JsonRpcResponseError(code, message, data) } def withCode(code: Long): JsonRpcResponseError = { diff --git a/protocol/src/main/contraband-scala/sbt/internal/protocol/JsonRpcResponseMessage.scala b/protocol/src/main/contraband-scala/sbt/internal/protocol/JsonRpcResponseMessage.scala index dd01ae0d3..b2d1596b4 100644 --- a/protocol/src/main/contraband-scala/sbt/internal/protocol/JsonRpcResponseMessage.scala +++ b/protocol/src/main/contraband-scala/sbt/internal/protocol/JsonRpcResponseMessage.scala @@ -28,7 +28,7 @@ final class JsonRpcResponseMessage private ( override def toString: String = { s"""JsonRpcResponseMessage($jsonrpc, $id, ${sbt.protocol.Serialization.compactPrintJsonOpt(result)}, $error)""" } - protected[this] def copy(jsonrpc: String = jsonrpc, id: Option[String] = id, result: Option[sjsonnew.shaded.scalajson.ast.unsafe.JValue] = result, error: Option[sbt.internal.protocol.JsonRpcResponseError] = error): JsonRpcResponseMessage = { + private[this] def copy(jsonrpc: String = jsonrpc, id: Option[String] = id, result: Option[sjsonnew.shaded.scalajson.ast.unsafe.JValue] = result, error: Option[sbt.internal.protocol.JsonRpcResponseError] = error): JsonRpcResponseMessage = { new JsonRpcResponseMessage(jsonrpc, id, result, error) } def withJsonrpc(jsonrpc: String): JsonRpcResponseMessage = { diff --git a/protocol/src/main/contraband-scala/sbt/internal/protocol/PortFile.scala b/protocol/src/main/contraband-scala/sbt/internal/protocol/PortFile.scala index 218aefdfb..8354bc5b4 100644 --- a/protocol/src/main/contraband-scala/sbt/internal/protocol/PortFile.scala +++ b/protocol/src/main/contraband-scala/sbt/internal/protocol/PortFile.scala @@ -26,7 +26,7 @@ final class PortFile private ( override def toString: String = { "PortFile(" + uri + ", " + tokenfilePath + ", " + tokenfileUri + ")" } - protected[this] def copy(uri: String = uri, tokenfilePath: Option[String] = tokenfilePath, tokenfileUri: Option[String] = tokenfileUri): PortFile = { + private[this] def copy(uri: String = uri, tokenfilePath: Option[String] = tokenfilePath, tokenfileUri: Option[String] = tokenfileUri): PortFile = { new PortFile(uri, tokenfilePath, tokenfileUri) } def withUri(uri: String): PortFile = { diff --git a/protocol/src/main/contraband-scala/sbt/internal/protocol/TokenFile.scala b/protocol/src/main/contraband-scala/sbt/internal/protocol/TokenFile.scala index e2019147e..88c218a7d 100644 --- a/protocol/src/main/contraband-scala/sbt/internal/protocol/TokenFile.scala +++ b/protocol/src/main/contraband-scala/sbt/internal/protocol/TokenFile.scala @@ -20,7 +20,7 @@ final class TokenFile private ( override def toString: String = { "TokenFile(" + uri + ", " + token + ")" } - protected[this] def copy(uri: String = uri, token: String = token): TokenFile = { + private[this] def copy(uri: String = uri, token: String = token): TokenFile = { new TokenFile(uri, token) } def withUri(uri: String): TokenFile = { diff --git a/protocol/src/main/contraband-scala/sbt/protocol/ChannelAcceptedEvent.scala b/protocol/src/main/contraband-scala/sbt/protocol/ChannelAcceptedEvent.scala index 8bb6dffcb..65191d029 100644 --- a/protocol/src/main/contraband-scala/sbt/protocol/ChannelAcceptedEvent.scala +++ b/protocol/src/main/contraband-scala/sbt/protocol/ChannelAcceptedEvent.scala @@ -19,7 +19,7 @@ final class ChannelAcceptedEvent private ( override def toString: String = { "ChannelAcceptedEvent(" + channelName + ")" } - protected[this] def copy(channelName: String = channelName): ChannelAcceptedEvent = { + private[this] def copy(channelName: String = channelName): ChannelAcceptedEvent = { new ChannelAcceptedEvent(channelName) } def withChannelName(channelName: String): ChannelAcceptedEvent = { diff --git a/protocol/src/main/contraband-scala/sbt/protocol/ExecCommand.scala b/protocol/src/main/contraband-scala/sbt/protocol/ExecCommand.scala index 142e7282b..142d44975 100644 --- a/protocol/src/main/contraband-scala/sbt/protocol/ExecCommand.scala +++ b/protocol/src/main/contraband-scala/sbt/protocol/ExecCommand.scala @@ -21,7 +21,7 @@ final class ExecCommand private ( override def toString: String = { "ExecCommand(" + commandLine + ", " + execId + ")" } - protected[this] def copy(commandLine: String = commandLine, execId: Option[String] = execId): ExecCommand = { + private[this] def copy(commandLine: String = commandLine, execId: Option[String] = execId): ExecCommand = { new ExecCommand(commandLine, execId) } def withCommandLine(commandLine: String): ExecCommand = { diff --git a/protocol/src/main/contraband-scala/sbt/protocol/ExecStatusEvent.scala b/protocol/src/main/contraband-scala/sbt/protocol/ExecStatusEvent.scala index 5ce579397..9af91314f 100644 --- a/protocol/src/main/contraband-scala/sbt/protocol/ExecStatusEvent.scala +++ b/protocol/src/main/contraband-scala/sbt/protocol/ExecStatusEvent.scala @@ -23,7 +23,7 @@ final class ExecStatusEvent private ( override def toString: String = { "ExecStatusEvent(" + status + ", " + channelName + ", " + execId + ", " + commandQueue + ")" } - protected[this] def copy(status: String = status, channelName: Option[String] = channelName, execId: Option[String] = execId, commandQueue: Vector[String] = commandQueue): ExecStatusEvent = { + private[this] def copy(status: String = status, channelName: Option[String] = channelName, execId: Option[String] = execId, commandQueue: Vector[String] = commandQueue): ExecStatusEvent = { new ExecStatusEvent(status, channelName, execId, commandQueue) } def withStatus(status: String): ExecStatusEvent = { diff --git a/protocol/src/main/contraband-scala/sbt/protocol/ExecutionEvent.scala b/protocol/src/main/contraband-scala/sbt/protocol/ExecutionEvent.scala index f47c3b741..fdcac9975 100644 --- a/protocol/src/main/contraband-scala/sbt/protocol/ExecutionEvent.scala +++ b/protocol/src/main/contraband-scala/sbt/protocol/ExecutionEvent.scala @@ -21,7 +21,7 @@ final class ExecutionEvent private ( override def toString: String = { "ExecutionEvent(" + success + ", " + commandLine + ")" } - protected[this] def copy(success: String = success, commandLine: String = commandLine): ExecutionEvent = { + private[this] def copy(success: String = success, commandLine: String = commandLine): ExecutionEvent = { new ExecutionEvent(success, commandLine) } def withSuccess(success: String): ExecutionEvent = { diff --git a/protocol/src/main/contraband-scala/sbt/protocol/InitCommand.scala b/protocol/src/main/contraband-scala/sbt/protocol/InitCommand.scala index e45b25c84..b454552d5 100644 --- a/protocol/src/main/contraband-scala/sbt/protocol/InitCommand.scala +++ b/protocol/src/main/contraband-scala/sbt/protocol/InitCommand.scala @@ -20,7 +20,7 @@ final class InitCommand private ( override def toString: String = { "InitCommand(" + token + ", " + execId + ")" } - protected[this] def copy(token: Option[String] = token, execId: Option[String] = execId): InitCommand = { + private[this] def copy(token: Option[String] = token, execId: Option[String] = execId): InitCommand = { new InitCommand(token, execId) } def withToken(token: Option[String]): InitCommand = { diff --git a/protocol/src/main/contraband-scala/sbt/protocol/LogEvent.scala b/protocol/src/main/contraband-scala/sbt/protocol/LogEvent.scala index 694635252..27acd0656 100644 --- a/protocol/src/main/contraband-scala/sbt/protocol/LogEvent.scala +++ b/protocol/src/main/contraband-scala/sbt/protocol/LogEvent.scala @@ -21,7 +21,7 @@ final class LogEvent private ( override def toString: String = { "LogEvent(" + level + ", " + message + ")" } - protected[this] def copy(level: String = level, message: String = message): LogEvent = { + private[this] def copy(level: String = level, message: String = message): LogEvent = { new LogEvent(level, message) } def withLevel(level: String): LogEvent = { diff --git a/protocol/src/main/contraband-scala/sbt/protocol/SettingQuery.scala b/protocol/src/main/contraband-scala/sbt/protocol/SettingQuery.scala index a00fd05d6..2846234ef 100644 --- a/protocol/src/main/contraband-scala/sbt/protocol/SettingQuery.scala +++ b/protocol/src/main/contraband-scala/sbt/protocol/SettingQuery.scala @@ -19,7 +19,7 @@ final class SettingQuery private ( override def toString: String = { "SettingQuery(" + setting + ")" } - protected[this] def copy(setting: String = setting): SettingQuery = { + private[this] def copy(setting: String = setting): SettingQuery = { new SettingQuery(setting) } def withSetting(setting: String): SettingQuery = { diff --git a/protocol/src/main/contraband-scala/sbt/protocol/SettingQueryFailure.scala b/protocol/src/main/contraband-scala/sbt/protocol/SettingQueryFailure.scala index 9c5305b96..16102225d 100644 --- a/protocol/src/main/contraband-scala/sbt/protocol/SettingQueryFailure.scala +++ b/protocol/src/main/contraband-scala/sbt/protocol/SettingQueryFailure.scala @@ -19,7 +19,7 @@ final class SettingQueryFailure private ( override def toString: String = { "SettingQueryFailure(" + message + ")" } - protected[this] def copy(message: String = message): SettingQueryFailure = { + private[this] def copy(message: String = message): SettingQueryFailure = { new SettingQueryFailure(message) } def withMessage(message: String): SettingQueryFailure = { diff --git a/protocol/src/main/contraband-scala/sbt/protocol/SettingQuerySuccess.scala b/protocol/src/main/contraband-scala/sbt/protocol/SettingQuerySuccess.scala index be6af35fc..ab9c6d2ee 100644 --- a/protocol/src/main/contraband-scala/sbt/protocol/SettingQuerySuccess.scala +++ b/protocol/src/main/contraband-scala/sbt/protocol/SettingQuerySuccess.scala @@ -20,7 +20,7 @@ final class SettingQuerySuccess private ( override def toString: String = { "SettingQuerySuccess(" + value + ", " + contentType + ")" } - protected[this] def copy(value: sjsonnew.shaded.scalajson.ast.unsafe.JValue = value, contentType: String = contentType): SettingQuerySuccess = { + private[this] def copy(value: sjsonnew.shaded.scalajson.ast.unsafe.JValue = value, contentType: String = contentType): SettingQuerySuccess = { new SettingQuerySuccess(value, contentType) } def withValue(value: sjsonnew.shaded.scalajson.ast.unsafe.JValue): SettingQuerySuccess = { diff --git a/run/src/main/contraband-scala/sbt/ForkOptions.scala b/run/src/main/contraband-scala/sbt/ForkOptions.scala index e20277b72..b8f30ab15 100644 --- a/run/src/main/contraband-scala/sbt/ForkOptions.scala +++ b/run/src/main/contraband-scala/sbt/ForkOptions.scala @@ -43,7 +43,7 @@ final class ForkOptions private ( override def toString: String = { "ForkOptions(" + javaHome + ", " + outputStrategy + ", " + bootJars + ", " + workingDirectory + ", " + runJVMOptions + ", " + connectInput + ", " + envVars + ")" } - protected[this] def copy(javaHome: Option[java.io.File] = javaHome, outputStrategy: Option[sbt.OutputStrategy] = outputStrategy, bootJars: Vector[java.io.File] = bootJars, workingDirectory: Option[java.io.File] = workingDirectory, runJVMOptions: Vector[String] = runJVMOptions, connectInput: Boolean = connectInput, envVars: scala.collection.immutable.Map[String, String] = envVars): ForkOptions = { + private[this] def copy(javaHome: Option[java.io.File] = javaHome, outputStrategy: Option[sbt.OutputStrategy] = outputStrategy, bootJars: Vector[java.io.File] = bootJars, workingDirectory: Option[java.io.File] = workingDirectory, runJVMOptions: Vector[String] = runJVMOptions, connectInput: Boolean = connectInput, envVars: scala.collection.immutable.Map[String, String] = envVars): ForkOptions = { new ForkOptions(javaHome, outputStrategy, bootJars, workingDirectory, runJVMOptions, connectInput, envVars) } def withJavaHome(javaHome: Option[java.io.File]): ForkOptions = { diff --git a/run/src/main/scala/sbt/OutputStrategy.scala b/run/src/main/scala/sbt/OutputStrategy.scala index be1031e30..1f6d819cf 100644 --- a/run/src/main/scala/sbt/OutputStrategy.scala +++ b/run/src/main/scala/sbt/OutputStrategy.scala @@ -37,7 +37,7 @@ object OutputStrategy { override def toString: String = { "BufferedOutput(" + logger + ")" } - protected[this] def copy(logger: Logger = logger): BufferedOutput = { + private[this] def copy(logger: Logger = logger): BufferedOutput = { new BufferedOutput(logger) } def withLogger(logger: Logger): BufferedOutput = { @@ -63,7 +63,7 @@ object OutputStrategy { override def toString: String = { "LoggedOutput(" + logger + ")" } - protected[this] def copy(logger: Logger = logger): LoggedOutput = { + private[this] def copy(logger: Logger = logger): LoggedOutput = { new LoggedOutput(logger) } def withLogger(logger: Logger): LoggedOutput = { @@ -91,7 +91,7 @@ object OutputStrategy { override def toString: String = { "CustomOutput(" + output + ")" } - protected[this] def copy(output: OutputStream = output): CustomOutput = { + private[this] def copy(output: OutputStream = output): CustomOutput = { new CustomOutput(output) } def withOutput(output: OutputStream): CustomOutput = { diff --git a/testing/src/main/contraband-scala/sbt/protocol/testing/EndTestGroupErrorEvent.scala b/testing/src/main/contraband-scala/sbt/protocol/testing/EndTestGroupErrorEvent.scala index afeeef6ac..b6cf91afa 100644 --- a/testing/src/main/contraband-scala/sbt/protocol/testing/EndTestGroupErrorEvent.scala +++ b/testing/src/main/contraband-scala/sbt/protocol/testing/EndTestGroupErrorEvent.scala @@ -21,7 +21,7 @@ final class EndTestGroupErrorEvent private ( override def toString: String = { "EndTestGroupErrorEvent(" + name + ", " + error + ")" } - protected[this] def copy(name: String = name, error: String = error): EndTestGroupErrorEvent = { + private[this] def copy(name: String = name, error: String = error): EndTestGroupErrorEvent = { new EndTestGroupErrorEvent(name, error) } def withName(name: String): EndTestGroupErrorEvent = { diff --git a/testing/src/main/contraband-scala/sbt/protocol/testing/EndTestGroupEvent.scala b/testing/src/main/contraband-scala/sbt/protocol/testing/EndTestGroupEvent.scala index db3893a84..802a64843 100644 --- a/testing/src/main/contraband-scala/sbt/protocol/testing/EndTestGroupEvent.scala +++ b/testing/src/main/contraband-scala/sbt/protocol/testing/EndTestGroupEvent.scala @@ -21,7 +21,7 @@ final class EndTestGroupEvent private ( override def toString: String = { "EndTestGroupEvent(" + name + ", " + result + ")" } - protected[this] def copy(name: String = name, result: sbt.protocol.testing.TestResult = result): EndTestGroupEvent = { + private[this] def copy(name: String = name, result: sbt.protocol.testing.TestResult = result): EndTestGroupEvent = { new EndTestGroupEvent(name, result) } def withName(name: String): EndTestGroupEvent = { diff --git a/testing/src/main/contraband-scala/sbt/protocol/testing/StartTestGroupEvent.scala b/testing/src/main/contraband-scala/sbt/protocol/testing/StartTestGroupEvent.scala index 156c4ba57..ed1ca2f9a 100644 --- a/testing/src/main/contraband-scala/sbt/protocol/testing/StartTestGroupEvent.scala +++ b/testing/src/main/contraband-scala/sbt/protocol/testing/StartTestGroupEvent.scala @@ -20,7 +20,7 @@ final class StartTestGroupEvent private ( override def toString: String = { "StartTestGroupEvent(" + name + ")" } - protected[this] def copy(name: String = name): StartTestGroupEvent = { + private[this] def copy(name: String = name): StartTestGroupEvent = { new StartTestGroupEvent(name) } def withName(name: String): StartTestGroupEvent = { diff --git a/testing/src/main/contraband-scala/sbt/protocol/testing/TestCompleteEvent.scala b/testing/src/main/contraband-scala/sbt/protocol/testing/TestCompleteEvent.scala index e44188084..c3d0fb4f6 100644 --- a/testing/src/main/contraband-scala/sbt/protocol/testing/TestCompleteEvent.scala +++ b/testing/src/main/contraband-scala/sbt/protocol/testing/TestCompleteEvent.scala @@ -20,7 +20,7 @@ final class TestCompleteEvent private ( override def toString: String = { "TestCompleteEvent(" + result + ")" } - protected[this] def copy(result: sbt.protocol.testing.TestResult = result): TestCompleteEvent = { + private[this] def copy(result: sbt.protocol.testing.TestResult = result): TestCompleteEvent = { new TestCompleteEvent(result) } def withResult(result: sbt.protocol.testing.TestResult): TestCompleteEvent = { diff --git a/testing/src/main/contraband-scala/sbt/protocol/testing/TestInitEvent.scala b/testing/src/main/contraband-scala/sbt/protocol/testing/TestInitEvent.scala index b6178c40f..cf96623d9 100644 --- a/testing/src/main/contraband-scala/sbt/protocol/testing/TestInitEvent.scala +++ b/testing/src/main/contraband-scala/sbt/protocol/testing/TestInitEvent.scala @@ -19,7 +19,7 @@ override def hashCode: Int = { override def toString: String = { "TestInitEvent()" } -protected[this] def copy(): TestInitEvent = { +private[this] def copy(): TestInitEvent = { new TestInitEvent() } diff --git a/testing/src/main/contraband-scala/sbt/protocol/testing/TestItemDetail.scala b/testing/src/main/contraband-scala/sbt/protocol/testing/TestItemDetail.scala index 50762dcb5..904cdc258 100644 --- a/testing/src/main/contraband-scala/sbt/protocol/testing/TestItemDetail.scala +++ b/testing/src/main/contraband-scala/sbt/protocol/testing/TestItemDetail.scala @@ -31,7 +31,7 @@ final class TestItemDetail private ( override def toString: String = { "TestItemDetail(" + fullyQualifiedName + ", " + status + ", " + duration + ")" } - protected[this] def copy(fullyQualifiedName: String = fullyQualifiedName, status: sbt.testing.Status = status, duration: Option[Long] = duration): TestItemDetail = { + private[this] def copy(fullyQualifiedName: String = fullyQualifiedName, status: sbt.testing.Status = status, duration: Option[Long] = duration): TestItemDetail = { new TestItemDetail(fullyQualifiedName, status, duration) } def withFullyQualifiedName(fullyQualifiedName: String): TestItemDetail = { diff --git a/testing/src/main/contraband-scala/sbt/protocol/testing/TestItemEvent.scala b/testing/src/main/contraband-scala/sbt/protocol/testing/TestItemEvent.scala index d7f343f7b..6910d1b16 100644 --- a/testing/src/main/contraband-scala/sbt/protocol/testing/TestItemEvent.scala +++ b/testing/src/main/contraband-scala/sbt/protocol/testing/TestItemEvent.scala @@ -21,7 +21,7 @@ final class TestItemEvent private ( override def toString: String = { "TestItemEvent(" + result + ", " + detail + ")" } - protected[this] def copy(result: Option[sbt.protocol.testing.TestResult] = result, detail: Vector[sbt.protocol.testing.TestItemDetail] = detail): TestItemEvent = { + private[this] def copy(result: Option[sbt.protocol.testing.TestResult] = result, detail: Vector[sbt.protocol.testing.TestItemDetail] = detail): TestItemEvent = { new TestItemEvent(result, detail) } def withResult(result: Option[sbt.protocol.testing.TestResult]): TestItemEvent = { diff --git a/testing/src/main/contraband-scala/sbt/protocol/testing/TestStringEvent.scala b/testing/src/main/contraband-scala/sbt/protocol/testing/TestStringEvent.scala index 618faf180..6b3f5d973 100644 --- a/testing/src/main/contraband-scala/sbt/protocol/testing/TestStringEvent.scala +++ b/testing/src/main/contraband-scala/sbt/protocol/testing/TestStringEvent.scala @@ -19,7 +19,7 @@ final class TestStringEvent private ( override def toString: String = { value } - protected[this] def copy(value: String = value): TestStringEvent = { + private[this] def copy(value: String = value): TestStringEvent = { new TestStringEvent(value) } def withValue(value: String): TestStringEvent = { From 89722878923ae5db49021d15743dc53aecaf331a Mon Sep 17 00:00:00 2001 From: Dale Wijnand Date: Wed, 14 Mar 2018 11:27:16 +0000 Subject: [PATCH 04/19] Cleanup ErrorCodes --- .../sbt/internal/langserver/ErrorCodes.scala | 45 ++++++++++++++----- 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/protocol/src/main/scala/sbt/internal/langserver/ErrorCodes.scala b/protocol/src/main/scala/sbt/internal/langserver/ErrorCodes.scala index 952cf7896..b7f9afc94 100644 --- a/protocol/src/main/scala/sbt/internal/langserver/ErrorCodes.scala +++ b/protocol/src/main/scala/sbt/internal/langserver/ErrorCodes.scala @@ -9,18 +9,39 @@ package sbt package internal package langserver +/** Holds the error codes for the LSP implementation here. */ object ErrorCodes { - // Defined by JSON RPC - val ParseError = -32700L - val InvalidRequest = -32600L - val MethodNotFound = -32601L - val InvalidParams = -32602L - val InternalError = -32603L - val serverErrorStart = -32099L - val serverErrorEnd = -32000L - val ServerNotInitialized = -32002L - val UnknownErrorCode = -32001L + // this is essentially a lookup table encoded in Scala, + // so heavy usage of vertical alignment is beneficial + // format: off - // Defined by the protocol. - val RequestCancelled = -32800L + // Defined by the JSON-RPC 2.0 Specification + // http://www.jsonrpc.org/specification#error_object + // + // The error codes from and including -32768 to -32000 are reserved for pre-defined errors. + // Any code within this range, but not defined explicitly below is reserved for future use. + // + // The error codes are nearly the same as those suggested for XML-RPC at the following url: + // http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php + // + val ParseError = -32700L // Invalid JSON was received by the server. + // An error occurred on the server while parsing the JSON text. + val InvalidRequest = -32600L // The JSON sent is not a valid Request object. + val MethodNotFound = -32601L // The method does not exist / is not available. + val InvalidParams = -32602L // Invalid method parameter(s). + val InternalError = -32603L // Internal JSON-RPC error. + + + // The range -32000 to -32099 are reserved for implementation-defined server-errors. + val serverErrorStart = -32099L // from LSP's spec code snippet + val serverErrorEnd = -32000L // from LSP's spec code snippet + + val UnknownErrorCode = -32001L // Defined by LSP + val ServerNotInitialized = -32002L // Defined by LSP + + + // The remainder of the space is available for application defined errors. + val RequestCancelled = -32800L // Defined by LSP + + // format: on } From 3530349e9ac6e0ea492678479ed2bb584503a598 Mon Sep 17 00:00:00 2001 From: Dale Wijnand Date: Wed, 14 Mar 2018 11:41:58 +0000 Subject: [PATCH 05/19] Rename ErrorCodes' UnknownErrorCode to UnknownServerError Allows for a non-server-specific unknown error code to be defined. --- .../src/main/scala/sbt/internal/langserver/ErrorCodes.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protocol/src/main/scala/sbt/internal/langserver/ErrorCodes.scala b/protocol/src/main/scala/sbt/internal/langserver/ErrorCodes.scala index b7f9afc94..6128b25ba 100644 --- a/protocol/src/main/scala/sbt/internal/langserver/ErrorCodes.scala +++ b/protocol/src/main/scala/sbt/internal/langserver/ErrorCodes.scala @@ -36,7 +36,7 @@ object ErrorCodes { val serverErrorStart = -32099L // from LSP's spec code snippet val serverErrorEnd = -32000L // from LSP's spec code snippet - val UnknownErrorCode = -32001L // Defined by LSP + val UnknownServerError = -32001L // Defined by LSP val ServerNotInitialized = -32002L // Defined by LSP From 7baf97d2a63985290cfe321f0855c86363c114ed Mon Sep 17 00:00:00 2001 From: Dale Wijnand Date: Wed, 14 Mar 2018 11:42:32 +0000 Subject: [PATCH 06/19] Introduce ErrorCodes.UnknownError Defined in the application defined errors range. --- protocol/src/main/scala/sbt/internal/langserver/ErrorCodes.scala | 1 + 1 file changed, 1 insertion(+) diff --git a/protocol/src/main/scala/sbt/internal/langserver/ErrorCodes.scala b/protocol/src/main/scala/sbt/internal/langserver/ErrorCodes.scala index 6128b25ba..4b67ee90a 100644 --- a/protocol/src/main/scala/sbt/internal/langserver/ErrorCodes.scala +++ b/protocol/src/main/scala/sbt/internal/langserver/ErrorCodes.scala @@ -42,6 +42,7 @@ object ErrorCodes { // The remainder of the space is available for application defined errors. val RequestCancelled = -32800L // Defined by LSP + val UnknownError = -33000L // A generic error, unknown if the user or server is at fault. // format: on } From bde6365013a5303379f3b224235e544124d14365 Mon Sep 17 00:00:00 2001 From: Dale Wijnand Date: Mon, 12 Mar 2018 19:00:24 +0000 Subject: [PATCH 07/19] Add an optional exitCode to ExecStatusEvent so clients can use it --- .../sbt/protocol/ExecStatusEvent.scala | 23 +++++++++++++------ .../codec/ExecStatusEventFormats.scala | 4 +++- protocol/src/main/contraband/server.contra | 1 + 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/protocol/src/main/contraband-scala/sbt/protocol/ExecStatusEvent.scala b/protocol/src/main/contraband-scala/sbt/protocol/ExecStatusEvent.scala index 9af91314f..3f42e0316 100644 --- a/protocol/src/main/contraband-scala/sbt/protocol/ExecStatusEvent.scala +++ b/protocol/src/main/contraband-scala/sbt/protocol/ExecStatusEvent.scala @@ -9,22 +9,23 @@ final class ExecStatusEvent private ( val status: String, val channelName: Option[String], val execId: Option[String], - val commandQueue: Vector[String]) extends sbt.protocol.EventMessage() with Serializable { - + val commandQueue: Vector[String], + val exitCode: Option[Long]) extends sbt.protocol.EventMessage() with Serializable { + private def this(status: String, channelName: Option[String], execId: Option[String], commandQueue: Vector[String]) = this(status, channelName, execId, commandQueue, None) override def equals(o: Any): Boolean = o match { - case x: ExecStatusEvent => (this.status == x.status) && (this.channelName == x.channelName) && (this.execId == x.execId) && (this.commandQueue == x.commandQueue) + case x: ExecStatusEvent => (this.status == x.status) && (this.channelName == x.channelName) && (this.execId == x.execId) && (this.commandQueue == x.commandQueue) && (this.exitCode == x.exitCode) case _ => false } override def hashCode: Int = { - 37 * (37 * (37 * (37 * (37 * (17 + "sbt.protocol.ExecStatusEvent".##) + status.##) + channelName.##) + execId.##) + commandQueue.##) + 37 * (37 * (37 * (37 * (37 * (37 * (17 + "sbt.protocol.ExecStatusEvent".##) + status.##) + channelName.##) + execId.##) + commandQueue.##) + exitCode.##) } override def toString: String = { - "ExecStatusEvent(" + status + ", " + channelName + ", " + execId + ", " + commandQueue + ")" + "ExecStatusEvent(" + status + ", " + channelName + ", " + execId + ", " + commandQueue + ", " + exitCode + ")" } - private[this] def copy(status: String = status, channelName: Option[String] = channelName, execId: Option[String] = execId, commandQueue: Vector[String] = commandQueue): ExecStatusEvent = { - new ExecStatusEvent(status, channelName, execId, commandQueue) + private[this] def copy(status: String = status, channelName: Option[String] = channelName, execId: Option[String] = execId, commandQueue: Vector[String] = commandQueue, exitCode: Option[Long] = exitCode): ExecStatusEvent = { + new ExecStatusEvent(status, channelName, execId, commandQueue, exitCode) } def withStatus(status: String): ExecStatusEvent = { copy(status = status) @@ -44,9 +45,17 @@ final class ExecStatusEvent private ( def withCommandQueue(commandQueue: Vector[String]): ExecStatusEvent = { copy(commandQueue = commandQueue) } + def withExitCode(exitCode: Option[Long]): ExecStatusEvent = { + copy(exitCode = exitCode) + } + def withExitCode(exitCode: Long): ExecStatusEvent = { + copy(exitCode = Option(exitCode)) + } } object ExecStatusEvent { def apply(status: String, channelName: Option[String], execId: Option[String], commandQueue: Vector[String]): ExecStatusEvent = new ExecStatusEvent(status, channelName, execId, commandQueue) def apply(status: String, channelName: String, execId: String, commandQueue: Vector[String]): ExecStatusEvent = new ExecStatusEvent(status, Option(channelName), Option(execId), commandQueue) + def apply(status: String, channelName: Option[String], execId: Option[String], commandQueue: Vector[String], exitCode: Option[Long]): ExecStatusEvent = new ExecStatusEvent(status, channelName, execId, commandQueue, exitCode) + def apply(status: String, channelName: String, execId: String, commandQueue: Vector[String], exitCode: Long): ExecStatusEvent = new ExecStatusEvent(status, Option(channelName), Option(execId), commandQueue, Option(exitCode)) } diff --git a/protocol/src/main/contraband-scala/sbt/protocol/codec/ExecStatusEventFormats.scala b/protocol/src/main/contraband-scala/sbt/protocol/codec/ExecStatusEventFormats.scala index 7b906fb1a..0f9c1f10e 100644 --- a/protocol/src/main/contraband-scala/sbt/protocol/codec/ExecStatusEventFormats.scala +++ b/protocol/src/main/contraband-scala/sbt/protocol/codec/ExecStatusEventFormats.scala @@ -15,8 +15,9 @@ implicit lazy val ExecStatusEventFormat: JsonFormat[sbt.protocol.ExecStatusEvent val channelName = unbuilder.readField[Option[String]]("channelName") val execId = unbuilder.readField[Option[String]]("execId") val commandQueue = unbuilder.readField[Vector[String]]("commandQueue") + val exitCode = unbuilder.readField[Option[Long]]("exitCode") unbuilder.endObject() - sbt.protocol.ExecStatusEvent(status, channelName, execId, commandQueue) + sbt.protocol.ExecStatusEvent(status, channelName, execId, commandQueue, exitCode) case None => deserializationError("Expected JsObject but found None") } @@ -27,6 +28,7 @@ implicit lazy val ExecStatusEventFormat: JsonFormat[sbt.protocol.ExecStatusEvent builder.addField("channelName", obj.channelName) builder.addField("execId", obj.execId) builder.addField("commandQueue", obj.commandQueue) + builder.addField("exitCode", obj.exitCode) builder.endObject() } } diff --git a/protocol/src/main/contraband/server.contra b/protocol/src/main/contraband/server.contra index 2976be229..63c7b816d 100644 --- a/protocol/src/main/contraband/server.contra +++ b/protocol/src/main/contraband/server.contra @@ -43,6 +43,7 @@ type ExecStatusEvent implements EventMessage { channelName: String execId: String commandQueue: [String] + exitCode: Long @since("1.1.2") } interface SettingQueryResponse implements EventMessage {} From 98332c0891ace1ea826fab8f2e4054c08de0b791 Mon Sep 17 00:00:00 2001 From: Dale Wijnand Date: Mon, 12 Mar 2018 19:00:47 +0000 Subject: [PATCH 08/19] Reply to sbt/exec w/ a Response/Error w/ error code --- main/src/main/scala/sbt/MainLoop.scala | 55 ++++++++++++++++++- .../sbt/internal/server/NetworkChannel.scala | 8 ++- 2 files changed, 60 insertions(+), 3 deletions(-) diff --git a/main/src/main/scala/sbt/MainLoop.scala b/main/src/main/scala/sbt/MainLoop.scala index 83b38b4c8..2ff80e17e 100644 --- a/main/src/main/scala/sbt/MainLoop.scala +++ b/main/src/main/scala/sbt/MainLoop.scala @@ -15,6 +15,7 @@ import jline.TerminalFactory import sbt.io.{ IO, Using } import sbt.internal.util.{ ErrorHandling, GlobalLogBacking } import sbt.internal.util.complete.DefaultParsers +import sbt.internal.langserver.ErrorCodes import sbt.util.Logger import sbt.protocol._ @@ -155,13 +156,63 @@ object MainLoop { state.log error errMsg state.fail } - StandardMain.exchange publishEventMessage ExecStatusEvent( + val doneEvent = ExecStatusEvent( "Done", channelName, exec.execId, - newState.remainingCommands.toVector map (_.commandLine)) + newState.remainingCommands.toVector map (_.commandLine), + exitCode(newState, state), + ) + if (doneEvent.execId.isDefined) { // send back a response or error + import sbt.protocol.codec.JsonProtocol._ + StandardMain.exchange publishEvent doneEvent + } else { // send back a notification + StandardMain.exchange publishEventMessage doneEvent + } newState } def logFullException(e: Throwable, log: Logger): Unit = State.logFullException(e, log) + + private[this] type ExitCode = Option[Long] + private[this] object ExitCode { + def apply(n: Long): ExitCode = Option(n) + val Success: ExitCode = ExitCode(0) + val Unknown: ExitCode = None + } + + private[this] def exitCode(state: State, prevState: State): ExitCode = { + exitCodeFromStateNext(state) match { + case ExitCode.Success => exitCodeFromStateOnFailure(state, prevState) + case x => x + } + } + + // State's "next" field indicates the next action for the command processor to take + // we'll use that to determine if the command failed + private[this] def exitCodeFromStateNext(state: State): ExitCode = { + state.next match { + case State.Continue => ExitCode.Success + case State.ClearGlobalLog => ExitCode.Success + case State.KeepLastLog => ExitCode.Success + case ret: State.Return => + ret.result match { + case exit: xsbti.Exit => ExitCode(exit.code().toLong) + case _: xsbti.Continue => ExitCode.Success + case _: xsbti.Reboot => ExitCode.Success + case x => + val clazz = if (x eq null) "" else " (class: " + x.getClass + ")" + state.log debug s"Unknown main result: $x$clazz" + ExitCode.Unknown + } + } + } + + // the shell command specifies an onFailure so that if an exception is thrown + // it's handled by executing the shell again, instead of the state failing + // so we also use that to indicate that the execution failed + private[this] def exitCodeFromStateOnFailure(state: State, prevState: State): ExitCode = + if (prevState.onFailure.isDefined && state.onFailure.isEmpty) ExitCode(ErrorCodes.UnknownError) + else ExitCode.Success + } diff --git a/main/src/main/scala/sbt/internal/server/NetworkChannel.scala b/main/src/main/scala/sbt/internal/server/NetworkChannel.scala index 7c27063de..f8dfdf784 100644 --- a/main/src/main/scala/sbt/internal/server/NetworkChannel.scala +++ b/main/src/main/scala/sbt/internal/server/NetworkChannel.scala @@ -240,7 +240,13 @@ final class NetworkChannel(val name: String, if (isLanguageServerProtocol) { event match { case entry: StringEvent => logMessage(entry.level, entry.message) - case _ => langRespond(event, execId) + case entry: ExecStatusEvent => + entry.exitCode match { + case None => langRespond(event, entry.execId) + case Some(0) => langRespond(event, entry.execId) + case Some(exitCode) => langError(entry.execId, exitCode, "") + } + case _ => langRespond(event, execId) } } else { contentType match { From 04ab2d30e15b456a6842594bdc7fb5b021b85c23 Mon Sep 17 00:00:00 2001 From: Hiroshi Ito Date: Fri, 16 Mar 2018 14:54:34 +0900 Subject: [PATCH 09/19] Improve instruction for locally built sbt in CONTRIBUTING.md --- CONTRIBUTING.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 190d5a0cc..7dc91fcdd 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -188,10 +188,12 @@ sbt:sbtRoot> publishLocal ### Using the locally built sbt -To use the locally built sbt, set the version in `build.properties` file to `1.$MINOR.$PATCH-SNAPSHOT`. +The `publishLocal` above will build and publish version `1.$MINOR.$PATCH-SNAPSHOT` (e.g. 1.1.2-SNAPSHOT) to your local ivy repository. + +To use the locally built sbt, set the version in `build.properties` file in your project to `1.$MINOR.$PATCH-SNAPSHOT` then launch `sbt` (this can be the `sbt` launcher installed in your machine). ``` -$ cd ../hello +$ cd $YOUR_OWN_PROJECT $ sbt > compile ``` From 77ffbe896d461b98bab262b12ca86bb3045c7e88 Mon Sep 17 00:00:00 2001 From: tmiyamon Date: Fri, 16 Mar 2018 18:03:52 +0900 Subject: [PATCH 10/19] support test compile on saving in vscode --- .../main/scala/sbt/internal/server/LanguageServerProtocol.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/src/main/scala/sbt/internal/server/LanguageServerProtocol.scala b/main/src/main/scala/sbt/internal/server/LanguageServerProtocol.scala index ce1131d0f..77314890a 100644 --- a/main/src/main/scala/sbt/internal/server/LanguageServerProtocol.scala +++ b/main/src/main/scala/sbt/internal/server/LanguageServerProtocol.scala @@ -38,7 +38,7 @@ private[sbt] trait LanguageServerProtocol extends CommandChannel { log.debug(s"onNotification: $notification") notification.method match { case "textDocument/didSave" => - append(Exec(";compile; collectAnalyses", None, Some(CommandSource(name)))) + append(Exec(";Test/compile; collectAnalyses", None, Some(CommandSource(name)))) case u => log.debug(s"Unhandled notification received: $u") } } From a5119a411c409cb0ce1f054253ec3d143c053da0 Mon Sep 17 00:00:00 2001 From: tiqwab Date: Fri, 16 Mar 2018 21:46:09 +0900 Subject: [PATCH 11/19] Fix handling id in jsonrpc model Fix #3861 --- .../codec/JsonRpcRequestMessageFormats.scala | 5 ++- .../codec/JsonRpcResponseMessageFormats.scala | 33 ++++++++++++++++--- 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/protocol/src/main/scala/sbt/internal/protocol/codec/JsonRpcRequestMessageFormats.scala b/protocol/src/main/scala/sbt/internal/protocol/codec/JsonRpcRequestMessageFormats.scala index dac0987e4..2c1273534 100644 --- a/protocol/src/main/scala/sbt/internal/protocol/codec/JsonRpcRequestMessageFormats.scala +++ b/protocol/src/main/scala/sbt/internal/protocol/codec/JsonRpcRequestMessageFormats.scala @@ -24,7 +24,10 @@ trait JsonRpcRequestMessageFormats { val id = try { unbuilder.readField[String]("id") } catch { - case _: Throwable => unbuilder.readField[Long]("id").toString + case _: Throwable => { + val prefix = "\u2668" // Append prefix to show the original type was Number + prefix + unbuilder.readField[Long]("id").toString + } } val method = unbuilder.readField[String]("method") val params = unbuilder.lookupField("params") map { diff --git a/protocol/src/main/scala/sbt/internal/protocol/codec/JsonRpcResponseMessageFormats.scala b/protocol/src/main/scala/sbt/internal/protocol/codec/JsonRpcResponseMessageFormats.scala index d10164e67..c9d943296 100644 --- a/protocol/src/main/scala/sbt/internal/protocol/codec/JsonRpcResponseMessageFormats.scala +++ b/protocol/src/main/scala/sbt/internal/protocol/codec/JsonRpcResponseMessageFormats.scala @@ -7,8 +7,8 @@ package sbt.internal.protocol.codec -import _root_.sjsonnew.{ Unbuilder, Builder, JsonFormat, deserializationError } -import sjsonnew.shaded.scalajson.ast.unsafe.JValue +import _root_.sjsonnew.{ Builder, JsonFormat, Unbuilder, deserializationError } +import sjsonnew.shaded.scalajson.ast.unsafe._ trait JsonRpcResponseMessageFormats { self: sbt.internal.util.codec.JValueFormats @@ -45,10 +45,35 @@ trait JsonRpcResponseMessageFormats { } override def write[J](obj: sbt.internal.protocol.JsonRpcResponseMessage, builder: Builder[J]): Unit = { + // Parse given id to Long or String judging by prefix + def parseId(str: String): Either[Long, String] = { + if (str.startsWith("\u2668")) Left(str.substring(1).toLong) + else Right(str) + } + def parseResult(jValue: JValue): JValue = jValue match { + case JObject(jFields) => + val replaced = jFields map { + case field @ JField("execId", JString(str)) => + parseId(str) match { + case Right(strId) => field.copy(value = JString(strId)) + case Left(longId) => field.copy(value = JNumber(longId)) + } + case other => + other + } + JObject(replaced) + case other => + other + } builder.beginObject() builder.addField("jsonrpc", obj.jsonrpc) - builder.addField("id", obj.id) - builder.addField("result", obj.result) + obj.id foreach { id => + parseId(id) match { + case Right(strId) => builder.addField("id", strId) + case Left(longId) => builder.addField("id", longId) + } + } + builder.addField("result", obj.result map parseResult) builder.addField("error", obj.error) builder.endObject() } From e5d2588927e1513eab9eaf57a790fa1d8bc2833c Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Sun, 18 Mar 2018 02:11:23 +0900 Subject: [PATCH 12/19] Add test case for number id in JSON-RPC --- sbt/src/test/scala/sbt/ServerSpec.scala | 29 +++++++++++++++++++------ 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/sbt/src/test/scala/sbt/ServerSpec.scala b/sbt/src/test/scala/sbt/ServerSpec.scala index 7ad307fd8..a328c6dfe 100644 --- a/sbt/src/test/scala/sbt/ServerSpec.scala +++ b/sbt/src/test/scala/sbt/ServerSpec.scala @@ -9,6 +9,7 @@ package sbt import org.scalatest._ import scala.concurrent._ +import scala.annotation.tailrec import java.io.{ InputStream, OutputStream } import java.util.concurrent.atomic.AtomicInteger import java.util.concurrent.{ ThreadFactory, ThreadPoolExecutor } @@ -23,15 +24,22 @@ class ServerSpec extends AsyncFlatSpec with Matchers { """{ "jsonrpc": "2.0", "id": 3, "method": "sbt/setting", "params": { "setting": "root/name" } }""", out) Thread.sleep(100) - val l2 = contentLength(in) - println(l2) - readLine(in) - readLine(in) - val x2 = readContentLength(in, l2) - println(x2) - assert(1 == 1) + assert(waitFor(in, 10) { s => + s contains """"id":3""" + }) } } + + @tailrec + private[this] def waitFor(in: InputStream, num: Int)(f: String => Boolean): Boolean = { + if (num < 0) false + else + readFrame(in) match { + case Some(x) if f(x) => true + case _ => + waitFor(in, num - 1)(f) + } + } } object ServerSpec { @@ -90,6 +98,13 @@ object ServerSpec { writeLine(message, out) } + def readFrame(in: InputStream): Option[String] = { + val l = contentLength(in) + readLine(in) + readLine(in) + readContentLength(in, l) + } + def contentLength(in: InputStream): Int = { readLine(in) map { line => line.drop(16).toInt From 8eb2d7389d5367d6bea91df0975747aa942f15a1 Mon Sep 17 00:00:00 2001 From: Ethan Atkins Date: Wed, 21 Mar 2018 10:16:01 -0700 Subject: [PATCH 13/19] Add test for async utest TestSuites Sometimes when utest runs async tests (i.e. tests that return a future) the test suite will fail even when none of the individual tests do. This is due to a data race in sbt. Most, but not all, of the time, this test will induce that race. --- sbt/src/sbt-test/tests/fork-async/build.sbt | 8 +++++++ .../src/test/scala/ForkAsyncTest.scala | 21 +++++++++++++++++++ sbt/src/sbt-test/tests/fork-async/test | 1 + 3 files changed, 30 insertions(+) create mode 100644 sbt/src/sbt-test/tests/fork-async/build.sbt create mode 100644 sbt/src/sbt-test/tests/fork-async/src/test/scala/ForkAsyncTest.scala create mode 100644 sbt/src/sbt-test/tests/fork-async/test diff --git a/sbt/src/sbt-test/tests/fork-async/build.sbt b/sbt/src/sbt-test/tests/fork-async/build.sbt new file mode 100644 index 000000000..bb42b0c17 --- /dev/null +++ b/sbt/src/sbt-test/tests/fork-async/build.sbt @@ -0,0 +1,8 @@ +testFrameworks += new TestFramework("utest.runner.Framework") + +lazy val root = (project in file(".")). + settings( + scalaVersion := "2.12.4", + libraryDependencies += "com.lihaoyi" %% "utest" % "0.6.4" % Test, + fork in Test := true + ) diff --git a/sbt/src/sbt-test/tests/fork-async/src/test/scala/ForkAsyncTest.scala b/sbt/src/sbt-test/tests/fork-async/src/test/scala/ForkAsyncTest.scala new file mode 100644 index 000000000..a8bc4c0f2 --- /dev/null +++ b/sbt/src/sbt-test/tests/fork-async/src/test/scala/ForkAsyncTest.scala @@ -0,0 +1,21 @@ +import utest._ + +import utest._ +import utest.framework._ + +import scala.concurrent.{ ExecutionContext, Promise } +import scala.util.Success + +object ForkAsyncTest extends TestSuite { + val g = ExecutionContext.global + val n = 10 + val (testNames, promises) = (1 to n).map(i => Tree(s"$i") -> Promise[Unit]).unzip + val testTrees = promises.zipWithIndex.map { case (p, i) => + new TestCallTree(Left { + if (i == (n - 1)) promises.foreach(p => g.execute(() => p.tryComplete(Success(())))) + p.future + }) + } + val tests = + Tests(nameTree = Tree("async", testNames: _*), callTree = new TestCallTree(Right(testTrees))) +} diff --git a/sbt/src/sbt-test/tests/fork-async/test b/sbt/src/sbt-test/tests/fork-async/test new file mode 100644 index 000000000..dfffb838b --- /dev/null +++ b/sbt/src/sbt-test/tests/fork-async/test @@ -0,0 +1 @@ +> test From 9b24e9f9ebffadfa7d715b457b9fb1b8d51c3bdb Mon Sep 17 00:00:00 2001 From: Ethan Atkins Date: Tue, 20 Mar 2018 18:06:03 -0700 Subject: [PATCH 14/19] Use ConcurrentLinkedDeque for EventHandler ArrayList::add is not thread safe. I ran into cases where async tests using utests would fail even when all of the individual tests passed. This was because multiple threads called back into the handle method of the handler instance variable, which just delegated to eventList::add. When this happened, one of the events would get added to the list as a null reference, which would manifest as an NPE upstream on the master process. After this change, my tests stopped failing. --- testing/agent/src/main/java/sbt/ForkMain.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/testing/agent/src/main/java/sbt/ForkMain.java b/testing/agent/src/main/java/sbt/ForkMain.java index 24acaf52b..a92d02506 100644 --- a/testing/agent/src/main/java/sbt/ForkMain.java +++ b/testing/agent/src/main/java/sbt/ForkMain.java @@ -17,6 +17,7 @@ import java.net.Socket; import java.net.InetAddress; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collection; import java.util.List; import java.util.concurrent.*; @@ -294,7 +295,7 @@ final public class ForkMain { Task[] nestedTasks; final TaskDef taskDef = task.taskDef(); try { - final List eventList = new ArrayList(); + final Collection eventList = new ConcurrentLinkedDeque(); final EventHandler handler = new EventHandler() { public void handle(final Event e){ eventList.add(new ForkEvent(e)); } }; logDebug(os, " Running " + taskDef); nestedTasks = task.execute(handler, loggers); From 9d2d81645b28e90ab17c925ecf7c1b390e4e1ff0 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Sat, 24 Mar 2018 02:17:02 +0900 Subject: [PATCH 15/19] bump modules --- main/src/main/scala/sbt/Defaults.scala | 15 +++++++++------ project/Dependencies.scala | 10 +++++----- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/main/src/main/scala/sbt/Defaults.scala b/main/src/main/scala/sbt/Defaults.scala index b9ab939ef..3ae24adde 100755 --- a/main/src/main/scala/sbt/Defaults.scala +++ b/main/src/main/scala/sbt/Defaults.scala @@ -623,12 +623,15 @@ object Defaults extends BuildCommon { if (ScalaInstance.isDotty(scalaVersion.value)) file(ScalaArtifacts.dottyID(binVersion)) else file(ScalaArtifacts.CompilerID) - new ScalaInstance(scalaVersion.value, - makeClassLoader(state.value)(allJars.toList), - libraryJar, - compilerJar, - allJars.toArray, - None) + new ScalaInstance( + scalaVersion.value, + makeClassLoader(state.value)(allJars.toList), + makeClassLoader(state.value)(List(libraryJar)), + libraryJar, + compilerJar, + allJars.toArray, + None + ) } def scalaInstanceFromHome(dir: File): Initialize[Task[ScalaInstance]] = Def.task { ScalaInstance(dir)(makeClassLoader(state.value)) diff --git a/project/Dependencies.scala b/project/Dependencies.scala index aa50fc3e1..94a583ea8 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -9,9 +9,9 @@ object Dependencies { // sbt modules private val ioVersion = "1.1.4" - private val utilVersion = "1.1.2" - private val lmVersion = "1.1.3" - private val zincVersion = "1.1.1" + private val utilVersion = "1.1.3" + private val lmVersion = "1.1.4" + private val zincVersion = "1.1.3" private val sbtIO = "org.scala-sbt" %% "io" % ioVersion @@ -26,8 +26,8 @@ object Dependencies { private val libraryManagementCore = "org.scala-sbt" %% "librarymanagement-core" % lmVersion private val libraryManagementIvy = "org.scala-sbt" %% "librarymanagement-ivy" % lmVersion - val launcherInterface = "org.scala-sbt" % "launcher-interface" % "1.0.2" - val rawLauncher = "org.scala-sbt" % "launcher" % "1.0.2" + val launcherInterface = "org.scala-sbt" % "launcher-interface" % "1.0.3" + val rawLauncher = "org.scala-sbt" % "launcher" % "1.0.3" val testInterface = "org.scala-sbt" % "test-interface" % "1.0" val ipcSocket = "org.scala-sbt.ipcsocket" % "ipcsocket" % "1.0.0" From b111b05d5f0ab6fdfc5bbaf262c711932b9d77e5 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Sat, 24 Mar 2018 13:45:35 -0400 Subject: [PATCH 16/19] Fixes new command leaving target directory Fixes #2835 This fixes `new` command creating `target` directory by moving the `target` to a staging directory in the command itself. --- main/src/main/scala/sbt/TemplateCommand.scala | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/main/src/main/scala/sbt/TemplateCommand.scala b/main/src/main/scala/sbt/TemplateCommand.scala index 2da6dcb33..b30755c0c 100644 --- a/main/src/main/scala/sbt/TemplateCommand.scala +++ b/main/src/main/scala/sbt/TemplateCommand.scala @@ -26,12 +26,22 @@ private[sbt] object TemplateCommandUtil { private def templateCommandParser(state: State): Parser[Seq[String]] = (token(Space) ~> repsep(StringBasic, token(Space))) | (token(EOF) map (_ => Nil)) - private def runTemplate(state: State, inputArg: Seq[String]): State = { + private def runTemplate(s0: State, inputArg: Seq[String]): State = { + import BuildPaths._ + val extracted0 = (Project extract s0) + val globalBase = getGlobalBase(s0) + val stagingDirectory = getStagingDirectory(s0, globalBase).getCanonicalFile + val templateStage = stagingDirectory / "new" + // This moves the target directory to a staging directory + // https://github.com/sbt/sbt/issues/2835 + val state = extracted0.appendWithSession(Seq( + Keys.target := templateStage + ), + s0) val infos = (state get templateResolverInfos getOrElse Nil).toList val log = state.globalLogging.full val extracted = (Project extract state) val (s2, ivyConf) = extracted.runTask(Keys.ivyConfiguration, state) - val globalBase = BuildPaths.getGlobalBase(state) val scalaModuleInfo = extracted.get(Keys.scalaModuleInfo in Keys.updateSbtClassifiers) val arguments = inputArg.toList ++ (state.remainingCommands match { From 25ab94d96afa3ed20eac1e057aeb309ab7fe612b Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Sun, 25 Mar 2018 14:56:00 -0400 Subject: [PATCH 17/19] Fixes -error not suppressing startup logs Fixes #3849 This brings back the 0.13 logic: ```scala def setGlobalLogLevel(s: State, level: Level.Value): State = { s.globalLogging.full match { case a: AbstractLogger => a.setLevel(level) case _ => () } s.put(BasicKeys.explicitGlobalLogLevels, true).put(Keys.logLevel.key, level) } ``` --- main/src/main/scala/sbt/internal/LogManager.scala | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/main/src/main/scala/sbt/internal/LogManager.scala b/main/src/main/scala/sbt/internal/LogManager.scala index 9abec04c6..66aa49fce 100644 --- a/main/src/main/scala/sbt/internal/LogManager.scala +++ b/main/src/main/scala/sbt/internal/LogManager.scala @@ -229,8 +229,13 @@ object LogManager { // s // } - def setGlobalLogLevel(s: State, level: Level.Value): State = - s.put(BasicKeys.explicitGlobalLogLevels, true).put(Keys.logLevel.key, level) + def setGlobalLogLevel(s: State, level: Level.Value): State = { + val s1 = s.put(BasicKeys.explicitGlobalLogLevels, true).put(Keys.logLevel.key, level) + val gl = s1.globalLogging + LogExchange.unbindLoggerAppenders(gl.full.name) + LogExchange.bindLoggerAppenders(gl.full.name, (gl.backed -> level) :: Nil) + s1 + } // This is the default implementation for the relay appender val defaultRelay: Unit => Appender = _ => defaultRelayImpl From f607b6c73ffe2f6c4dbae0553a25ba1b66f56947 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Tue, 27 Mar 2018 06:52:32 -0400 Subject: [PATCH 18/19] sbt 1.1.2 --- project/build.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/build.properties b/project/build.properties index 31334bbd3..05313438a 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.1.1 +sbt.version=1.1.2 From 1b77b353334af641599592f77b8dadf8105d5d8f Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Tue, 27 Mar 2018 06:53:05 -0400 Subject: [PATCH 19/19] bump to 1.1.3-SNAPSHOT --- build.sbt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.sbt b/build.sbt index 5e50c04aa..d2b19aef3 100644 --- a/build.sbt +++ b/build.sbt @@ -9,7 +9,7 @@ def buildLevelSettings: Seq[Setting[_]] = inThisBuild( Seq( organization := "org.scala-sbt", - version := "1.1.2-SNAPSHOT", + version := "1.1.3-SNAPSHOT", description := "sbt is an interactive build tool", bintrayOrganization := Some("sbt"), bintrayRepository := { @@ -79,7 +79,7 @@ val mimaSettings = Def settings ( mimaPreviousArtifacts := { Seq( "1.0.0", "1.0.1", "1.0.2", "1.0.3", "1.0.4", - "1.1.0", "1.1.1", + "1.1.0", "1.1.1", "1.1.2", ).map { v => organization.value % moduleName.value % v cross (if (crossPaths.value) CrossVersion.binary else CrossVersion.disabled) }.toSet