From 36e079d12b6c83be81f6a09e7790d5960ae94f4b Mon Sep 17 00:00:00 2001 From: Alexey Alekhin Date: Thu, 2 Nov 2017 04:07:28 +0100 Subject: [PATCH] Added onNotification handler for the LSP CommandChannel --- .../sbt/internal/server/LanguageServerProtocol.scala | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/main/src/main/scala/sbt/internal/server/LanguageServerProtocol.scala b/main/src/main/scala/sbt/internal/server/LanguageServerProtocol.scala index 5c18b926b..47ac40aee 100644 --- a/main/src/main/scala/sbt/internal/server/LanguageServerProtocol.scala +++ b/main/src/main/scala/sbt/internal/server/LanguageServerProtocol.scala @@ -34,6 +34,15 @@ private[sbt] trait LanguageServerProtocol extends CommandChannel { protected def log: Logger protected def onSettingQuery(execId: Option[String], req: Q): Unit + protected def onNotification(notification: JsonRpcNotificationMessage): Unit = { + log.debug(s"onNotification: $notification") + notification.method match { + case "textDocument/didSave" => + append(Exec(";compile; collectAnalyses", None, Some(CommandSource(name)))) + case _ => () + } + } + protected def onRequestMessage(request: JsonRpcRequestMessage): Unit = { import sbt.internal.langserver.codec.JsonProtocol._ import internalJsonProtocol._ @@ -57,8 +66,6 @@ private[sbt] trait LanguageServerProtocol extends CommandChannel { setInitialized(true) append(Exec(s"collectAnalyses", Some(request.id), Some(CommandSource(name)))) langRespond(InitializeResult(serverCapabilities), Option(request.id)) - case "textDocument/didSave" => - append(Exec(";compile; collectAnalyses", Some(request.id), Some(CommandSource(name)))) case "textDocument/definition" => import scala.concurrent.ExecutionContext.Implicits.global Definition.lspDefinition(json, request.id, CommandSource(name), log)