src/Tools/VSCode/src/lsp.scala
author Thomas Lindae <thomas.lindae@in.tum.de>
Thu, 16 May 2024 11:59:33 +0200
changeset 81042 f1e0ca5aaa6b
parent 81039 9c5a4ba4ced6
child 81043 2174ec5f0d0c
permissions -rw-r--r--
lsp: added decorations to state updates;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
72761
4519eeefe3b5 avoid conflicting base names;
wenzelm
parents: 71774
diff changeset
     1
/*  Title:      Tools/VSCode/src/lsp.scala
64605
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
     2
    Author:     Makarius
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
     3
75201
8f6b8a46f54c clarified modules: more uniform .scala vs. ts (amending 4519eeefe3b5);
wenzelm
parents: 75199
diff changeset
     4
Message formats for Language Server Protocol, with adhoc PIDE extensions.
8f6b8a46f54c clarified modules: more uniform .scala vs. ts (amending 4519eeefe3b5);
wenzelm
parents: 75199
diff changeset
     5
See https://github.com/Microsoft/language-server-protocol/blob/master/protocol.md
64605
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
     6
*/
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
     7
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
     8
package isabelle.vscode
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
     9
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
    10
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
    11
import isabelle._
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
    12
64777
ca09695eb43c clarified Document.Node.Name (again): canonical platform file;
wenzelm
parents: 64767
diff changeset
    13
import java.io.{File => JFile}
ca09695eb43c clarified Document.Node.Name (again): canonical platform file;
wenzelm
parents: 64767
diff changeset
    14
ca09695eb43c clarified Document.Node.Name (again): canonical platform file;
wenzelm
parents: 64767
diff changeset
    15
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 75263
diff changeset
    16
object LSP {
64605
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
    17
  /* abstract message */
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
    18
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 75263
diff changeset
    19
  object Message {
67850
3e9fe7a84b5d tuned signature;
wenzelm
parents: 67843
diff changeset
    20
    val empty: JSON.Object.T = JSON.Object("jsonrpc" -> "2.0")
65922
d2f19f05c0e9 clarified message logging;
wenzelm
parents: 65229
diff changeset
    21
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 75263
diff changeset
    22
    def log(prefix: String, json: JSON.T, logger: Logger, verbose: Boolean): Unit = {
67851
wenzelm
parents: 67850
diff changeset
    23
      val header =
65922
d2f19f05c0e9 clarified message logging;
wenzelm
parents: 65229
diff changeset
    24
        json match {
67851
wenzelm
parents: 67850
diff changeset
    25
          case JSON.Object(obj) => obj -- (obj.keySet - "method" - "id")
67850
3e9fe7a84b5d tuned signature;
wenzelm
parents: 67843
diff changeset
    26
          case _ => JSON.Object.empty
65922
d2f19f05c0e9 clarified message logging;
wenzelm
parents: 65229
diff changeset
    27
        }
d2f19f05c0e9 clarified message logging;
wenzelm
parents: 65229
diff changeset
    28
      if (verbose || header.isEmpty) logger(prefix + "\n" + JSON.Format(json))
d2f19f05c0e9 clarified message logging;
wenzelm
parents: 65229
diff changeset
    29
      else logger(prefix + " " + JSON.Format(header))
d2f19f05c0e9 clarified message logging;
wenzelm
parents: 65229
diff changeset
    30
    }
64605
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
    31
  }
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
    32
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
    33
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
    34
  /* notification */
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
    35
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 75263
diff changeset
    36
  object Notification {
64605
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
    37
    def apply(method: String, params: JSON.T): JSON.T =
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
    38
      Message.empty + ("method" -> method) + ("params" -> params)
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
    39
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
    40
    def unapply(json: JSON.T): Option[(String, Option[JSON.T])] =
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
    41
      for {
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
    42
        method <- JSON.string(json, "method")
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
    43
        params = JSON.value(json, "params")
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
    44
      } yield (method, params)
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
    45
  }
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
    46
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 75263
diff changeset
    47
  class Notification0(name: String) {
64605
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
    48
    def unapply(json: JSON.T): Option[Unit] =
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
    49
      json match {
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
    50
        case Notification(method, _) if method == name => Some(())
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
    51
        case _ => None
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
    52
      }
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
    53
  }
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
    54
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
    55
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
    56
  /* request message */
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
    57
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 75263
diff changeset
    58
  object Id {
66675
6f4613dbfef6 support for workspace edits;
wenzelm
parents: 66235
diff changeset
    59
    def empty: Id = Id("")
6f4613dbfef6 support for workspace edits;
wenzelm
parents: 66235
diff changeset
    60
  }
6f4613dbfef6 support for workspace edits;
wenzelm
parents: 66235
diff changeset
    61
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 75263
diff changeset
    62
  sealed case class Id(id: Any) {
64605
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
    63
    require(
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
    64
      id.isInstanceOf[Int] ||
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
    65
      id.isInstanceOf[Long] ||
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
    66
      id.isInstanceOf[Double] ||
73120
c3589f2dff31 more informative errors: simplify diagnosis of spurious failures reported by users;
wenzelm
parents: 72761
diff changeset
    67
      id.isInstanceOf[String], "bad id type")
64605
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
    68
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
    69
    override def toString: String = id.toString
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
    70
  }
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
    71
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 75263
diff changeset
    72
  object RequestMessage {
64605
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
    73
    def apply(id: Id, method: String, params: JSON.T): JSON.T =
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
    74
      Message.empty + ("id" -> id.id) + ("method" -> method) + ("params" -> params)
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
    75
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
    76
    def unapply(json: JSON.T): Option[(Id, String, Option[JSON.T])] =
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
    77
      for {
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
    78
        id <- JSON.long(json, "id") orElse JSON.double(json, "id") orElse JSON.string(json, "id")
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
    79
        method <- JSON.string(json, "method")
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
    80
        params = JSON.value(json, "params")
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
    81
      } yield (Id(id), method, params)
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
    82
  }
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
    83
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 75263
diff changeset
    84
  class Request0(name: String) {
64605
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
    85
    def unapply(json: JSON.T): Option[Id] =
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
    86
      json match {
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
    87
        case RequestMessage(id, method, _) if method == name => Some(id)
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
    88
        case _ => None
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
    89
      }
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
    90
  }
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
    91
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 75263
diff changeset
    92
  class RequestTextDocumentPosition(name: String) {
64651
ea5620f7b0d8 clarified signature;
wenzelm
parents: 64649
diff changeset
    93
    def unapply(json: JSON.T): Option[(Id, Line.Node_Position)] =
64648
5d7f741aaccb basic support for hyperlinks / Goto Definition Request;
wenzelm
parents: 64605
diff changeset
    94
      json match {
64651
ea5620f7b0d8 clarified signature;
wenzelm
parents: 64649
diff changeset
    95
        case RequestMessage(id, method, Some(TextDocumentPosition(node_pos))) if method == name =>
ea5620f7b0d8 clarified signature;
wenzelm
parents: 64649
diff changeset
    96
          Some((id, node_pos))
64648
5d7f741aaccb basic support for hyperlinks / Goto Definition Request;
wenzelm
parents: 64605
diff changeset
    97
        case _ => None
5d7f741aaccb basic support for hyperlinks / Goto Definition Request;
wenzelm
parents: 64605
diff changeset
    98
      }
5d7f741aaccb basic support for hyperlinks / Goto Definition Request;
wenzelm
parents: 64605
diff changeset
    99
  }
5d7f741aaccb basic support for hyperlinks / Goto Definition Request;
wenzelm
parents: 64605
diff changeset
   100
64605
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   101
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   102
  /* response message */
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   103
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 75263
diff changeset
   104
  object ResponseMessage {
64605
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   105
    def apply(id: Id, result: Option[JSON.T] = None, error: Option[ResponseError] = None): JSON.T =
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   106
      Message.empty + ("id" -> id.id) ++
64878
wenzelm
parents: 64877
diff changeset
   107
        JSON.optional("result" -> result) ++
wenzelm
parents: 64877
diff changeset
   108
        JSON.optional("error" -> error.map(_.json))
64605
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   109
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   110
    def strict(id: Id, result: Option[JSON.T] = None, error: String = ""): JSON.T =
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   111
      if (error == "") apply(id, result = result)
81026
c4bc259393f6 lsp: updated ErrorCodes;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81021
diff changeset
   112
      else apply(id, error = Some(ResponseError(code = ErrorCodes.jsonrpcReservedErrorRangeEnd, message = error)))
66675
6f4613dbfef6 support for workspace edits;
wenzelm
parents: 66235
diff changeset
   113
6f4613dbfef6 support for workspace edits;
wenzelm
parents: 66235
diff changeset
   114
    def is_empty(json: JSON.T): Boolean =
6f4613dbfef6 support for workspace edits;
wenzelm
parents: 66235
diff changeset
   115
      JSON.string(json, "id") == Some("") && JSON.value(json, "result").isDefined
64605
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   116
  }
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   117
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 75263
diff changeset
   118
  sealed case class ResponseError(code: Int, message: String, data: Option[JSON.T] = None) {
64605
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   119
    def json: JSON.T =
67850
3e9fe7a84b5d tuned signature;
wenzelm
parents: 67843
diff changeset
   120
      JSON.Object("code" -> code, "message" -> message) ++ JSON.optional("data" -> data)
64605
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   121
  }
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   122
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 75263
diff changeset
   123
  object ErrorCodes {
64605
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   124
    val ParseError = -32700
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   125
    val InvalidRequest = -32600
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   126
    val MethodNotFound = -32601
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   127
    val InvalidParams = -32602
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   128
    val InternalError = -32603
81026
c4bc259393f6 lsp: updated ErrorCodes;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81021
diff changeset
   129
c4bc259393f6 lsp: updated ErrorCodes;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81021
diff changeset
   130
    val jsonrpcReservedErrorRangeStart = -32099
c4bc259393f6 lsp: updated ErrorCodes;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81021
diff changeset
   131
    val ServerNotInitialized = -32002
c4bc259393f6 lsp: updated ErrorCodes;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81021
diff changeset
   132
    val UnknownErrorCode = -32001
c4bc259393f6 lsp: updated ErrorCodes;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81021
diff changeset
   133
    val jsonrpcReservedErrorRangeEnd = -32000
c4bc259393f6 lsp: updated ErrorCodes;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81021
diff changeset
   134
c4bc259393f6 lsp: updated ErrorCodes;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81021
diff changeset
   135
    val lspReservedErrorRangeStart = -32899
c4bc259393f6 lsp: updated ErrorCodes;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81021
diff changeset
   136
    val RequestFailed = -32803
c4bc259393f6 lsp: updated ErrorCodes;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81021
diff changeset
   137
    val ServerCancelled = -32802
c4bc259393f6 lsp: updated ErrorCodes;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81021
diff changeset
   138
    val ContentModified = -32801
c4bc259393f6 lsp: updated ErrorCodes;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81021
diff changeset
   139
    val RequestCancelled = -32800
c4bc259393f6 lsp: updated ErrorCodes;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81021
diff changeset
   140
    val lspReservedErrorRangeEnd = -32800
64605
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   141
  }
81026
c4bc259393f6 lsp: updated ErrorCodes;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81021
diff changeset
   142
  
64605
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   143
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   144
  /* init and exit */
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   145
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 75263
diff changeset
   146
  object Initialize extends Request0("initialize") {
64605
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   147
    def reply(id: Id, error: String): JSON.T =
67850
3e9fe7a84b5d tuned signature;
wenzelm
parents: 67843
diff changeset
   148
      ResponseMessage.strict(
3e9fe7a84b5d tuned signature;
wenzelm
parents: 67843
diff changeset
   149
        id, Some(JSON.Object("capabilities" -> ServerCapabilities.json)), error)
64605
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   150
  }
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   151
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 75263
diff changeset
   152
  object ServerCapabilities {
64605
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   153
    val json: JSON.T =
67850
3e9fe7a84b5d tuned signature;
wenzelm
parents: 67843
diff changeset
   154
      JSON.Object(
65160
6e042537555d incremental document changes;
wenzelm
parents: 65106
diff changeset
   155
        "textDocumentSync" -> 2,
75126
da1108a6d249 various improvements to Isabelle/VSCode (by Denis Paluca and Fabian Huch);
wenzelm
parents: 73541
diff changeset
   156
        "completionProvider" -> JSON.Object(
da1108a6d249 various improvements to Isabelle/VSCode (by Denis Paluca and Fabian Huch);
wenzelm
parents: 73541
diff changeset
   157
          "resolveProvider" -> false,
da1108a6d249 various improvements to Isabelle/VSCode (by Denis Paluca and Fabian Huch);
wenzelm
parents: 73541
diff changeset
   158
          "triggerCharacters" ->
75199
1ced8ee860e2 clarified signature;
wenzelm
parents: 75197
diff changeset
   159
            Symbol.symbols.entries.flatMap(_.abbrevs).flatMap(_.toList).map(_.toString).distinct
75126
da1108a6d249 various improvements to Isabelle/VSCode (by Denis Paluca and Fabian Huch);
wenzelm
parents: 73541
diff changeset
   160
        ),
64648
5d7f741aaccb basic support for hyperlinks / Goto Definition Request;
wenzelm
parents: 64605
diff changeset
   161
        "hoverProvider" -> true,
64767
f5c4ffdb1124 support VSCode DocumentHighlights;
wenzelm
parents: 64762
diff changeset
   162
        "definitionProvider" -> true,
f5c4ffdb1124 support VSCode DocumentHighlights;
wenzelm
parents: 64762
diff changeset
   163
        "documentHighlightProvider" -> true)
64605
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   164
  }
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   165
65229
cc96b8c3b8cb explicitly ignore "initialized" message;
wenzelm
parents: 65201
diff changeset
   166
  object Initialized extends Notification0("initialized")
cc96b8c3b8cb explicitly ignore "initialized" message;
wenzelm
parents: 65201
diff changeset
   167
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 75263
diff changeset
   168
  object Shutdown extends Request0("shutdown") {
64605
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   169
    def reply(id: Id, error: String): JSON.T =
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   170
      ResponseMessage.strict(id, Some("OK"), error)
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   171
  }
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   172
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   173
  object Exit extends Notification0("exit")
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   174
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   175
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   176
  /* document positions */
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   177
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 75263
diff changeset
   178
  object Position {
64605
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   179
    def apply(pos: Line.Position): JSON.T =
67850
3e9fe7a84b5d tuned signature;
wenzelm
parents: 67843
diff changeset
   180
      JSON.Object("line" -> pos.line, "character" -> pos.column)
64605
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   181
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   182
    def unapply(json: JSON.T): Option[Line.Position] =
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   183
      for {
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   184
        line <- JSON.int(json, "line")
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   185
        column <- JSON.int(json, "character")
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   186
      } yield Line.Position(line, column)
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   187
  }
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   188
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 75263
diff changeset
   189
  object Range {
65173
3700be571a01 more compact protocol message;
wenzelm
parents: 65165
diff changeset
   190
    def compact(range: Line.Range): List[Int] =
3700be571a01 more compact protocol message;
wenzelm
parents: 65165
diff changeset
   191
      List(range.start.line, range.start.column, range.stop.line, range.stop.column)
3700be571a01 more compact protocol message;
wenzelm
parents: 65165
diff changeset
   192
64605
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   193
    def apply(range: Line.Range): JSON.T =
67850
3e9fe7a84b5d tuned signature;
wenzelm
parents: 67843
diff changeset
   194
      JSON.Object("start" -> Position(range.start), "end" -> Position(range.stop))
64605
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   195
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   196
    def unapply(json: JSON.T): Option[Line.Range] =
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   197
      (JSON.value(json, "start"), JSON.value(json, "end")) match {
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   198
        case (Some(Position(start)), Some(Position(stop))) => Some(Line.Range(start, stop))
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   199
        case _ => None
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   200
      }
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   201
  }
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   202
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 75263
diff changeset
   203
  object Location {
64651
ea5620f7b0d8 clarified signature;
wenzelm
parents: 64649
diff changeset
   204
    def apply(loc: Line.Node_Range): JSON.T =
67850
3e9fe7a84b5d tuned signature;
wenzelm
parents: 67843
diff changeset
   205
      JSON.Object("uri" -> Url.print_file_name(loc.name), "range" -> Range(loc.range))
64605
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   206
64651
ea5620f7b0d8 clarified signature;
wenzelm
parents: 64649
diff changeset
   207
    def unapply(json: JSON.T): Option[Line.Node_Range] =
64605
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   208
      for {
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   209
        uri <- JSON.string(json, "uri")
75126
da1108a6d249 various improvements to Isabelle/VSCode (by Denis Paluca and Fabian Huch);
wenzelm
parents: 73541
diff changeset
   210
        if Url.is_wellformed_file(uri)
64605
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   211
        range_json <- JSON.value(json, "range")
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   212
        range <- Range.unapply(range_json)
66235
d4fa51e7c4ff retain symlinks in file names from VSCode: relevant for proper file locations in decorations etc.;
wenzelm
parents: 66216
diff changeset
   213
      } yield Line.Node_Range(Url.absolute_file_name(uri), range)
64605
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   214
  }
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   215
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 75263
diff changeset
   216
  object TextDocumentPosition {
64651
ea5620f7b0d8 clarified signature;
wenzelm
parents: 64649
diff changeset
   217
    def unapply(json: JSON.T): Option[Line.Node_Position] =
64605
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   218
      for {
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   219
        doc <- JSON.value(json, "textDocument")
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   220
        uri <- JSON.string(doc, "uri")
75126
da1108a6d249 various improvements to Isabelle/VSCode (by Denis Paluca and Fabian Huch);
wenzelm
parents: 73541
diff changeset
   221
        if Url.is_wellformed_file(uri)
64605
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   222
        pos_json <- JSON.value(json, "position")
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   223
        pos <- Position.unapply(pos_json)
66235
d4fa51e7c4ff retain symlinks in file names from VSCode: relevant for proper file locations in decorations etc.;
wenzelm
parents: 66216
diff changeset
   224
      } yield Line.Node_Position(Url.absolute_file_name(uri), pos)
64605
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   225
  }
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   226
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   227
65103
0bf1836ce4b1 tight protocol messages;
wenzelm
parents: 65095
diff changeset
   228
  /* marked strings */
65093
5f08197206ce clarified signature;
wenzelm
parents: 64878
diff changeset
   229
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 75263
diff changeset
   230
  sealed case class MarkedString(text: String, language: String = "plaintext") {
67850
3e9fe7a84b5d tuned signature;
wenzelm
parents: 67843
diff changeset
   231
    def json: JSON.T = JSON.Object("language" -> language, "value" -> text)
65093
5f08197206ce clarified signature;
wenzelm
parents: 64878
diff changeset
   232
  }
5f08197206ce clarified signature;
wenzelm
parents: 64878
diff changeset
   233
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 75263
diff changeset
   234
  object MarkedStrings {
65103
0bf1836ce4b1 tight protocol messages;
wenzelm
parents: 65095
diff changeset
   235
    def json(msgs: List[MarkedString]): Option[JSON.T] =
0bf1836ce4b1 tight protocol messages;
wenzelm
parents: 65095
diff changeset
   236
      msgs match {
0bf1836ce4b1 tight protocol messages;
wenzelm
parents: 65095
diff changeset
   237
        case Nil => None
0bf1836ce4b1 tight protocol messages;
wenzelm
parents: 65095
diff changeset
   238
        case List(msg) => Some(msg.json)
0bf1836ce4b1 tight protocol messages;
wenzelm
parents: 65095
diff changeset
   239
        case _ => Some(msgs.map(_.json))
0bf1836ce4b1 tight protocol messages;
wenzelm
parents: 65095
diff changeset
   240
      }
0bf1836ce4b1 tight protocol messages;
wenzelm
parents: 65095
diff changeset
   241
  }
0bf1836ce4b1 tight protocol messages;
wenzelm
parents: 65095
diff changeset
   242
65093
5f08197206ce clarified signature;
wenzelm
parents: 64878
diff changeset
   243
64605
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   244
  /* diagnostic messages */
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   245
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 75263
diff changeset
   246
  object MessageType {
64605
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   247
    val Error = 1
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   248
    val Warning = 2
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   249
    val Info = 3
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   250
    val Log = 4
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   251
  }
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   252
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 75263
diff changeset
   253
  object DisplayMessage {
73541
1240abf2e3f5 tuned signature;
wenzelm
parents: 73340
diff changeset
   254
    def apply(message_type: Int, message: String, show: Boolean): JSON.T =
64605
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   255
      Notification(if (show) "window/showMessage" else "window/logMessage",
67850
3e9fe7a84b5d tuned signature;
wenzelm
parents: 67843
diff changeset
   256
        JSON.Object("type" -> message_type, "message" -> message))
64605
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   257
  }
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   258
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   259
66138
f7ef4c50b747 added commands for spell-checker dictionary;
wenzelm
parents: 66096
diff changeset
   260
  /* commands */
f7ef4c50b747 added commands for spell-checker dictionary;
wenzelm
parents: 66096
diff changeset
   261
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 75263
diff changeset
   262
  sealed case class Command(title: String, command: String, arguments: List[JSON.T] = Nil) {
66138
f7ef4c50b747 added commands for spell-checker dictionary;
wenzelm
parents: 66096
diff changeset
   263
    def json: JSON.T =
67850
3e9fe7a84b5d tuned signature;
wenzelm
parents: 67843
diff changeset
   264
      JSON.Object("title" -> title, "command" -> command, "arguments" -> arguments)
66138
f7ef4c50b747 added commands for spell-checker dictionary;
wenzelm
parents: 66096
diff changeset
   265
  }
f7ef4c50b747 added commands for spell-checker dictionary;
wenzelm
parents: 66096
diff changeset
   266
f7ef4c50b747 added commands for spell-checker dictionary;
wenzelm
parents: 66096
diff changeset
   267
64605
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   268
  /* document edits */
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   269
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 75263
diff changeset
   270
  object DidOpenTextDocument {
64777
ca09695eb43c clarified Document.Node.Name (again): canonical platform file;
wenzelm
parents: 64767
diff changeset
   271
    def unapply(json: JSON.T): Option[(JFile, String, Long, String)] =
64605
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   272
      json match {
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   273
        case Notification("textDocument/didOpen", Some(params)) =>
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   274
          for {
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   275
            doc <- JSON.value(params, "textDocument")
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   276
            uri <- JSON.string(doc, "uri")
75126
da1108a6d249 various improvements to Isabelle/VSCode (by Denis Paluca and Fabian Huch);
wenzelm
parents: 73541
diff changeset
   277
            if Url.is_wellformed_file(uri)
64605
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   278
            lang <- JSON.string(doc, "languageId")
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   279
            version <- JSON.long(doc, "version")
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   280
            text <- JSON.string(doc, "text")
66235
d4fa51e7c4ff retain symlinks in file names from VSCode: relevant for proper file locations in decorations etc.;
wenzelm
parents: 66216
diff changeset
   281
          } yield (Url.absolute_file(uri), lang, version, text)
64605
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   282
        case _ => None
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   283
      }
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   284
  }
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   285
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   286
65160
6e042537555d incremental document changes;
wenzelm
parents: 65106
diff changeset
   287
  sealed case class TextDocumentChange(range: Option[Line.Range], text: String)
64605
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   288
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 75263
diff changeset
   289
  object DidChangeTextDocument {
65160
6e042537555d incremental document changes;
wenzelm
parents: 65106
diff changeset
   290
    def unapply_change(json: JSON.T): Option[TextDocumentChange] =
6e042537555d incremental document changes;
wenzelm
parents: 65106
diff changeset
   291
      for { text <- JSON.string(json, "text") }
75204
b0910e6c1320 tuned, based on suggestions by IntelliJ IDEA;
wenzelm
parents: 75201
diff changeset
   292
      yield TextDocumentChange(JSON.value(json, "range", Range.unapply), text)
65160
6e042537555d incremental document changes;
wenzelm
parents: 65106
diff changeset
   293
6e042537555d incremental document changes;
wenzelm
parents: 65106
diff changeset
   294
    def unapply(json: JSON.T): Option[(JFile, Long, List[TextDocumentChange])] =
64605
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   295
      json match {
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   296
        case Notification("textDocument/didChange", Some(params)) =>
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   297
          for {
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   298
            doc <- JSON.value(params, "textDocument")
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   299
            uri <- JSON.string(doc, "uri")
75126
da1108a6d249 various improvements to Isabelle/VSCode (by Denis Paluca and Fabian Huch);
wenzelm
parents: 73541
diff changeset
   300
            if Url.is_wellformed_file(uri)
64605
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   301
            version <- JSON.long(doc, "version")
75204
b0910e6c1320 tuned, based on suggestions by IntelliJ IDEA;
wenzelm
parents: 75201
diff changeset
   302
            changes <- JSON.list(params, "contentChanges", unapply_change)
66235
d4fa51e7c4ff retain symlinks in file names from VSCode: relevant for proper file locations in decorations etc.;
wenzelm
parents: 66216
diff changeset
   303
          } yield (Url.absolute_file(uri), version, changes)
64605
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   304
        case _ => None
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   305
      }
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   306
  }
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   307
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 75263
diff changeset
   308
  class TextDocumentNotification(name: String) {
64777
ca09695eb43c clarified Document.Node.Name (again): canonical platform file;
wenzelm
parents: 64767
diff changeset
   309
    def unapply(json: JSON.T): Option[JFile] =
64605
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   310
      json match {
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   311
        case Notification(method, Some(params)) if method == name =>
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   312
          for {
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   313
            doc <- JSON.value(params, "textDocument")
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   314
            uri <- JSON.string(doc, "uri")
75126
da1108a6d249 various improvements to Isabelle/VSCode (by Denis Paluca and Fabian Huch);
wenzelm
parents: 73541
diff changeset
   315
            if Url.is_wellformed_file(uri)
66235
d4fa51e7c4ff retain symlinks in file names from VSCode: relevant for proper file locations in decorations etc.;
wenzelm
parents: 66216
diff changeset
   316
          } yield Url.absolute_file(uri)
64605
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   317
        case _ => None
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   318
      }
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   319
  }
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   320
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   321
  object DidCloseTextDocument extends TextDocumentNotification("textDocument/didClose")
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   322
  object DidSaveTextDocument extends TextDocumentNotification("textDocument/didSave")
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   323
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   324
66675
6f4613dbfef6 support for workspace edits;
wenzelm
parents: 66235
diff changeset
   325
  /* workspace edits */
6f4613dbfef6 support for workspace edits;
wenzelm
parents: 66235
diff changeset
   326
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 75263
diff changeset
   327
  sealed case class TextEdit(range: Line.Range, new_text: String) {
67850
3e9fe7a84b5d tuned signature;
wenzelm
parents: 67843
diff changeset
   328
    def json: JSON.T = JSON.Object("range" -> Range(range), "newText" -> new_text)
66675
6f4613dbfef6 support for workspace edits;
wenzelm
parents: 66235
diff changeset
   329
  }
6f4613dbfef6 support for workspace edits;
wenzelm
parents: 66235
diff changeset
   330
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 75263
diff changeset
   331
  sealed case class TextDocumentEdit(file: JFile, version: Long, edits: List[TextEdit]) {
66675
6f4613dbfef6 support for workspace edits;
wenzelm
parents: 66235
diff changeset
   332
    def json: JSON.T =
67850
3e9fe7a84b5d tuned signature;
wenzelm
parents: 67843
diff changeset
   333
      JSON.Object(
3e9fe7a84b5d tuned signature;
wenzelm
parents: 67843
diff changeset
   334
        "textDocument" -> JSON.Object("uri" -> Url.print_file(file), "version" -> version),
66675
6f4613dbfef6 support for workspace edits;
wenzelm
parents: 66235
diff changeset
   335
        "edits" -> edits.map(_.json))
6f4613dbfef6 support for workspace edits;
wenzelm
parents: 66235
diff changeset
   336
  }
6f4613dbfef6 support for workspace edits;
wenzelm
parents: 66235
diff changeset
   337
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 75263
diff changeset
   338
  object WorkspaceEdit {
66675
6f4613dbfef6 support for workspace edits;
wenzelm
parents: 66235
diff changeset
   339
    def apply(edits: List[TextDocumentEdit]): JSON.T =
6f4613dbfef6 support for workspace edits;
wenzelm
parents: 66235
diff changeset
   340
      RequestMessage(Id.empty, "workspace/applyEdit",
67850
3e9fe7a84b5d tuned signature;
wenzelm
parents: 67843
diff changeset
   341
        JSON.Object("edit" -> JSON.Object("documentChanges" -> edits.map(_.json))))
66675
6f4613dbfef6 support for workspace edits;
wenzelm
parents: 66235
diff changeset
   342
  }
6f4613dbfef6 support for workspace edits;
wenzelm
parents: 66235
diff changeset
   343
6f4613dbfef6 support for workspace edits;
wenzelm
parents: 66235
diff changeset
   344
64877
31e9920a0dc1 support for semantic completion;
wenzelm
parents: 64777
diff changeset
   345
  /* completion */
31e9920a0dc1 support for semantic completion;
wenzelm
parents: 64777
diff changeset
   346
31e9920a0dc1 support for semantic completion;
wenzelm
parents: 64777
diff changeset
   347
  sealed case class CompletionItem(
31e9920a0dc1 support for semantic completion;
wenzelm
parents: 64777
diff changeset
   348
    label: String,
31e9920a0dc1 support for semantic completion;
wenzelm
parents: 64777
diff changeset
   349
    kind: Option[Int] = None,
31e9920a0dc1 support for semantic completion;
wenzelm
parents: 64777
diff changeset
   350
    detail: Option[String] = None,
31e9920a0dc1 support for semantic completion;
wenzelm
parents: 64777
diff changeset
   351
    documentation: Option[String] = None,
66140
cdb6c10122b6 tuned signature;
wenzelm
parents: 66139
diff changeset
   352
    text: Option[String] = None,
66138
f7ef4c50b747 added commands for spell-checker dictionary;
wenzelm
parents: 66096
diff changeset
   353
    range: Option[Line.Range] = None,
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 75263
diff changeset
   354
    command: Option[Command] = None
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 75263
diff changeset
   355
  ) {
64877
31e9920a0dc1 support for semantic completion;
wenzelm
parents: 64777
diff changeset
   356
    def json: JSON.T =
67850
3e9fe7a84b5d tuned signature;
wenzelm
parents: 67843
diff changeset
   357
      JSON.Object("label" -> label) ++
66061
wenzelm
parents: 66052
diff changeset
   358
      JSON.optional("kind" -> kind) ++
wenzelm
parents: 66052
diff changeset
   359
      JSON.optional("detail" -> detail) ++
wenzelm
parents: 66052
diff changeset
   360
      JSON.optional("documentation" -> documentation) ++
66140
cdb6c10122b6 tuned signature;
wenzelm
parents: 66139
diff changeset
   361
      JSON.optional("insertText" -> text) ++
66062
175772371cd0 use old-style "textEdit" for the sake of the external protocol (see also vscode-languageserver-node/issues/188);
wenzelm
parents: 66061
diff changeset
   362
      JSON.optional("range" -> range.map(Range(_))) ++
66675
6f4613dbfef6 support for workspace edits;
wenzelm
parents: 66235
diff changeset
   363
      JSON.optional("textEdit" -> range.map(r => TextEdit(r, text.getOrElse(label)).json)) ++
66138
f7ef4c50b747 added commands for spell-checker dictionary;
wenzelm
parents: 66096
diff changeset
   364
      JSON.optional("command" -> command.map(_.json))
64877
31e9920a0dc1 support for semantic completion;
wenzelm
parents: 64777
diff changeset
   365
  }
31e9920a0dc1 support for semantic completion;
wenzelm
parents: 64777
diff changeset
   366
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 75263
diff changeset
   367
  object Completion extends RequestTextDocumentPosition("textDocument/completion") {
64877
31e9920a0dc1 support for semantic completion;
wenzelm
parents: 64777
diff changeset
   368
    def reply(id: Id, result: List[CompletionItem]): JSON.T =
31e9920a0dc1 support for semantic completion;
wenzelm
parents: 64777
diff changeset
   369
      ResponseMessage(id, Some(result.map(_.json)))
31e9920a0dc1 support for semantic completion;
wenzelm
parents: 64777
diff changeset
   370
  }
31e9920a0dc1 support for semantic completion;
wenzelm
parents: 64777
diff changeset
   371
31e9920a0dc1 support for semantic completion;
wenzelm
parents: 64777
diff changeset
   372
66138
f7ef4c50b747 added commands for spell-checker dictionary;
wenzelm
parents: 66096
diff changeset
   373
  /* spell checker */
f7ef4c50b747 added commands for spell-checker dictionary;
wenzelm
parents: 66096
diff changeset
   374
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 75263
diff changeset
   375
  object Include_Word extends Notification0("PIDE/include_word") {
66139
6a8f8be2741c provide spell-checker menu via completion commands;
wenzelm
parents: 66138
diff changeset
   376
    val command = Command("Include word", "isabelle.include-word")
6a8f8be2741c provide spell-checker menu via completion commands;
wenzelm
parents: 66138
diff changeset
   377
  }
6a8f8be2741c provide spell-checker menu via completion commands;
wenzelm
parents: 66138
diff changeset
   378
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 75263
diff changeset
   379
  object Include_Word_Permanently extends Notification0("PIDE/include_word_permanently") {
66139
6a8f8be2741c provide spell-checker menu via completion commands;
wenzelm
parents: 66138
diff changeset
   380
    val command = Command("Include word permanently", "isabelle.include-word-permanently")
6a8f8be2741c provide spell-checker menu via completion commands;
wenzelm
parents: 66138
diff changeset
   381
  }
6a8f8be2741c provide spell-checker menu via completion commands;
wenzelm
parents: 66138
diff changeset
   382
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 75263
diff changeset
   383
  object Exclude_Word extends Notification0("PIDE/exclude_word") {
66139
6a8f8be2741c provide spell-checker menu via completion commands;
wenzelm
parents: 66138
diff changeset
   384
    val command = Command("Exclude word", "isabelle.exclude-word")
6a8f8be2741c provide spell-checker menu via completion commands;
wenzelm
parents: 66138
diff changeset
   385
  }
6a8f8be2741c provide spell-checker menu via completion commands;
wenzelm
parents: 66138
diff changeset
   386
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 75263
diff changeset
   387
  object Exclude_Word_Permanently extends Notification0("PIDE/exclude_word_permanently") {
66139
6a8f8be2741c provide spell-checker menu via completion commands;
wenzelm
parents: 66138
diff changeset
   388
    val command = Command("Exclude word permanently", "isabelle.exclude-word-permanently")
6a8f8be2741c provide spell-checker menu via completion commands;
wenzelm
parents: 66138
diff changeset
   389
  }
6a8f8be2741c provide spell-checker menu via completion commands;
wenzelm
parents: 66138
diff changeset
   390
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 75263
diff changeset
   391
  object Reset_Words extends Notification0("PIDE/reset_words") {
66139
6a8f8be2741c provide spell-checker menu via completion commands;
wenzelm
parents: 66138
diff changeset
   392
    val command = Command("Reset non-permanent words", "isabelle.reset-words")
6a8f8be2741c provide spell-checker menu via completion commands;
wenzelm
parents: 66138
diff changeset
   393
  }
66138
f7ef4c50b747 added commands for spell-checker dictionary;
wenzelm
parents: 66096
diff changeset
   394
f7ef4c50b747 added commands for spell-checker dictionary;
wenzelm
parents: 66096
diff changeset
   395
64605
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   396
  /* hover request */
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   397
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 75263
diff changeset
   398
  object Hover extends RequestTextDocumentPosition("textDocument/hover") {
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 75263
diff changeset
   399
    def reply(id: Id, result: Option[(Line.Range, List[MarkedString])]): JSON.T = {
64605
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   400
      val res =
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   401
        result match {
64747
54afac94f52b proper content format;
wenzelm
parents: 64693
diff changeset
   402
          case Some((range, contents)) =>
67850
3e9fe7a84b5d tuned signature;
wenzelm
parents: 67843
diff changeset
   403
            JSON.Object(
3e9fe7a84b5d tuned signature;
wenzelm
parents: 67843
diff changeset
   404
              "contents" -> MarkedStrings.json(contents).getOrElse(Nil),
3e9fe7a84b5d tuned signature;
wenzelm
parents: 67843
diff changeset
   405
              "range" -> Range(range))
3e9fe7a84b5d tuned signature;
wenzelm
parents: 67843
diff changeset
   406
          case None => JSON.Object("contents" -> Nil)
64605
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   407
        }
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   408
      ResponseMessage(id, Some(res))
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   409
    }
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   410
  }
64648
5d7f741aaccb basic support for hyperlinks / Goto Definition Request;
wenzelm
parents: 64605
diff changeset
   411
5d7f741aaccb basic support for hyperlinks / Goto Definition Request;
wenzelm
parents: 64605
diff changeset
   412
5d7f741aaccb basic support for hyperlinks / Goto Definition Request;
wenzelm
parents: 64605
diff changeset
   413
  /* goto definition request */
5d7f741aaccb basic support for hyperlinks / Goto Definition Request;
wenzelm
parents: 64605
diff changeset
   414
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 75263
diff changeset
   415
  object GotoDefinition extends RequestTextDocumentPosition("textDocument/definition") {
64651
ea5620f7b0d8 clarified signature;
wenzelm
parents: 64649
diff changeset
   416
    def reply(id: Id, result: List[Line.Node_Range]): JSON.T =
75204
b0910e6c1320 tuned, based on suggestions by IntelliJ IDEA;
wenzelm
parents: 75201
diff changeset
   417
      ResponseMessage(id, Some(result.map(Location.apply)))
64648
5d7f741aaccb basic support for hyperlinks / Goto Definition Request;
wenzelm
parents: 64605
diff changeset
   418
  }
64675
c557279d93f2 support for diagnostics;
wenzelm
parents: 64651
diff changeset
   419
c557279d93f2 support for diagnostics;
wenzelm
parents: 64651
diff changeset
   420
64767
f5c4ffdb1124 support VSCode DocumentHighlights;
wenzelm
parents: 64762
diff changeset
   421
  /* document highlights request */
f5c4ffdb1124 support VSCode DocumentHighlights;
wenzelm
parents: 64762
diff changeset
   422
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 75263
diff changeset
   423
  object DocumentHighlight {
64767
f5c4ffdb1124 support VSCode DocumentHighlights;
wenzelm
parents: 64762
diff changeset
   424
    def text(range: Line.Range): DocumentHighlight = DocumentHighlight(range, Some(1))
f5c4ffdb1124 support VSCode DocumentHighlights;
wenzelm
parents: 64762
diff changeset
   425
    def read(range: Line.Range): DocumentHighlight = DocumentHighlight(range, Some(2))
f5c4ffdb1124 support VSCode DocumentHighlights;
wenzelm
parents: 64762
diff changeset
   426
    def write(range: Line.Range): DocumentHighlight = DocumentHighlight(range, Some(3))
f5c4ffdb1124 support VSCode DocumentHighlights;
wenzelm
parents: 64762
diff changeset
   427
  }
f5c4ffdb1124 support VSCode DocumentHighlights;
wenzelm
parents: 64762
diff changeset
   428
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 75263
diff changeset
   429
  sealed case class DocumentHighlight(range: Line.Range, kind: Option[Int] = None) {
64767
f5c4ffdb1124 support VSCode DocumentHighlights;
wenzelm
parents: 64762
diff changeset
   430
    def json: JSON.T =
f5c4ffdb1124 support VSCode DocumentHighlights;
wenzelm
parents: 64762
diff changeset
   431
      kind match {
67850
3e9fe7a84b5d tuned signature;
wenzelm
parents: 67843
diff changeset
   432
        case None => JSON.Object("range" -> Range(range))
3e9fe7a84b5d tuned signature;
wenzelm
parents: 67843
diff changeset
   433
        case Some(k) => JSON.Object("range" -> Range(range), "kind" -> k)
64767
f5c4ffdb1124 support VSCode DocumentHighlights;
wenzelm
parents: 64762
diff changeset
   434
      }
f5c4ffdb1124 support VSCode DocumentHighlights;
wenzelm
parents: 64762
diff changeset
   435
  }
f5c4ffdb1124 support VSCode DocumentHighlights;
wenzelm
parents: 64762
diff changeset
   436
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 75263
diff changeset
   437
  object DocumentHighlights extends RequestTextDocumentPosition("textDocument/documentHighlight") {
64767
f5c4ffdb1124 support VSCode DocumentHighlights;
wenzelm
parents: 64762
diff changeset
   438
    def reply(id: Id, result: List[DocumentHighlight]): JSON.T =
f5c4ffdb1124 support VSCode DocumentHighlights;
wenzelm
parents: 64762
diff changeset
   439
      ResponseMessage(id, Some(result.map(_.json)))
f5c4ffdb1124 support VSCode DocumentHighlights;
wenzelm
parents: 64762
diff changeset
   440
  }
f5c4ffdb1124 support VSCode DocumentHighlights;
wenzelm
parents: 64762
diff changeset
   441
f5c4ffdb1124 support VSCode DocumentHighlights;
wenzelm
parents: 64762
diff changeset
   442
64675
c557279d93f2 support for diagnostics;
wenzelm
parents: 64651
diff changeset
   443
  /* diagnostics */
c557279d93f2 support for diagnostics;
wenzelm
parents: 64651
diff changeset
   444
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 75263
diff changeset
   445
  sealed case class Diagnostic(
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 75263
diff changeset
   446
    range: Line.Range,
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 75263
diff changeset
   447
    message: String,
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 75263
diff changeset
   448
    severity: Option[Int] = None,
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 75263
diff changeset
   449
    code: Option[Int] = None,
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 75263
diff changeset
   450
    source: Option[String] = None
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 75263
diff changeset
   451
  ) {
64675
c557279d93f2 support for diagnostics;
wenzelm
parents: 64651
diff changeset
   452
    def json: JSON.T =
c557279d93f2 support for diagnostics;
wenzelm
parents: 64651
diff changeset
   453
      Message.empty + ("range" -> Range(range)) + ("message" -> message) ++
64878
wenzelm
parents: 64877
diff changeset
   454
      JSON.optional("severity" -> severity) ++
wenzelm
parents: 64877
diff changeset
   455
      JSON.optional("code" -> code) ++
wenzelm
parents: 64877
diff changeset
   456
      JSON.optional("source" -> source)
64675
c557279d93f2 support for diagnostics;
wenzelm
parents: 64651
diff changeset
   457
  }
c557279d93f2 support for diagnostics;
wenzelm
parents: 64651
diff changeset
   458
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 75263
diff changeset
   459
  object DiagnosticSeverity {
64762
cd545bec3fd0 clarified message severity, based on empirical observation of VSCode 1.8.1;
wenzelm
parents: 64747
diff changeset
   460
    val Error = 1
cd545bec3fd0 clarified message severity, based on empirical observation of VSCode 1.8.1;
wenzelm
parents: 64747
diff changeset
   461
    val Warning = 2
cd545bec3fd0 clarified message severity, based on empirical observation of VSCode 1.8.1;
wenzelm
parents: 64747
diff changeset
   462
    val Information = 3
cd545bec3fd0 clarified message severity, based on empirical observation of VSCode 1.8.1;
wenzelm
parents: 64747
diff changeset
   463
    val Hint = 4
64675
c557279d93f2 support for diagnostics;
wenzelm
parents: 64651
diff changeset
   464
  }
c557279d93f2 support for diagnostics;
wenzelm
parents: 64651
diff changeset
   465
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 75263
diff changeset
   466
  object PublishDiagnostics {
64777
ca09695eb43c clarified Document.Node.Name (again): canonical platform file;
wenzelm
parents: 64767
diff changeset
   467
    def apply(file: JFile, diagnostics: List[Diagnostic]): JSON.T =
64675
c557279d93f2 support for diagnostics;
wenzelm
parents: 64651
diff changeset
   468
      Notification("textDocument/publishDiagnostics",
67850
3e9fe7a84b5d tuned signature;
wenzelm
parents: 67843
diff changeset
   469
        JSON.Object("uri" -> Url.print_file(file), "diagnostics" -> diagnostics.map(_.json)))
64675
c557279d93f2 support for diagnostics;
wenzelm
parents: 64651
diff changeset
   470
  }
65094
386d9d487f62 support for decorations;
wenzelm
parents: 65093
diff changeset
   471
386d9d487f62 support for decorations;
wenzelm
parents: 65093
diff changeset
   472
386d9d487f62 support for decorations;
wenzelm
parents: 65093
diff changeset
   473
  /* decorations */
386d9d487f62 support for decorations;
wenzelm
parents: 65093
diff changeset
   474
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 75263
diff changeset
   475
  sealed case class Decoration_Options(range: Line.Range, hover_message: List[MarkedString]) {
65094
386d9d487f62 support for decorations;
wenzelm
parents: 65093
diff changeset
   476
    def json: JSON.T =
67850
3e9fe7a84b5d tuned signature;
wenzelm
parents: 67843
diff changeset
   477
      JSON.Object("range" -> Range.compact(range)) ++
65173
3700be571a01 more compact protocol message;
wenzelm
parents: 65165
diff changeset
   478
      JSON.optional("hover_message" -> MarkedStrings.json(hover_message))
65094
386d9d487f62 support for decorations;
wenzelm
parents: 65093
diff changeset
   479
  }
386d9d487f62 support for decorations;
wenzelm
parents: 65093
diff changeset
   480
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 75263
diff changeset
   481
  sealed case class Decoration(decorations: List[(String, List[Decoration_Options])]) {
65095
eb21a4f70b0e publish decorations like diagnostics;
wenzelm
parents: 65094
diff changeset
   482
    def json(file: JFile): JSON.T =
65094
386d9d487f62 support for decorations;
wenzelm
parents: 65093
diff changeset
   483
      Notification("PIDE/decoration",
75126
da1108a6d249 various improvements to Isabelle/VSCode (by Denis Paluca and Fabian Huch);
wenzelm
parents: 73541
diff changeset
   484
        JSON.Object(
da1108a6d249 various improvements to Isabelle/VSCode (by Denis Paluca and Fabian Huch);
wenzelm
parents: 73541
diff changeset
   485
          "uri" -> Url.print_file(file),
da1108a6d249 various improvements to Isabelle/VSCode (by Denis Paluca and Fabian Huch);
wenzelm
parents: 73541
diff changeset
   486
          "entries" -> decorations.map(decoration => JSON.Object(
da1108a6d249 various improvements to Isabelle/VSCode (by Denis Paluca and Fabian Huch);
wenzelm
parents: 73541
diff changeset
   487
            "type" -> decoration._1,
da1108a6d249 various improvements to Isabelle/VSCode (by Denis Paluca and Fabian Huch);
wenzelm
parents: 73541
diff changeset
   488
            "content" -> decoration._2.map(_.json))
da1108a6d249 various improvements to Isabelle/VSCode (by Denis Paluca and Fabian Huch);
wenzelm
parents: 73541
diff changeset
   489
          ))
da1108a6d249 various improvements to Isabelle/VSCode (by Denis Paluca and Fabian Huch);
wenzelm
parents: 73541
diff changeset
   490
      )
65094
386d9d487f62 support for decorations;
wenzelm
parents: 65093
diff changeset
   491
  }
65189
41d2452845fc support for caret handling and dynamic output;
wenzelm
parents: 65173
diff changeset
   492
41d2452845fc support for caret handling and dynamic output;
wenzelm
parents: 65173
diff changeset
   493
66215
9a8b6b86350c proper hyperlink_command, notably for locate_query;
wenzelm
parents: 66211
diff changeset
   494
  /* caret update: bidirectional */
65189
41d2452845fc support for caret handling and dynamic output;
wenzelm
parents: 65173
diff changeset
   495
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 75263
diff changeset
   496
  object Caret_Update {
66216
d4949bae0bad clarified editor focus;
wenzelm
parents: 66215
diff changeset
   497
    def apply(node_pos: Line.Node_Position, focus: Boolean): JSON.T =
66215
9a8b6b86350c proper hyperlink_command, notably for locate_query;
wenzelm
parents: 66211
diff changeset
   498
      Notification("PIDE/caret_update",
67850
3e9fe7a84b5d tuned signature;
wenzelm
parents: 67843
diff changeset
   499
        JSON.Object(
3e9fe7a84b5d tuned signature;
wenzelm
parents: 67843
diff changeset
   500
          "uri" -> Url.print_file_name(node_pos.name),
66215
9a8b6b86350c proper hyperlink_command, notably for locate_query;
wenzelm
parents: 66211
diff changeset
   501
          "line" -> node_pos.pos.line,
66216
d4949bae0bad clarified editor focus;
wenzelm
parents: 66215
diff changeset
   502
          "character" -> node_pos.pos.column,
d4949bae0bad clarified editor focus;
wenzelm
parents: 66215
diff changeset
   503
          "focus" -> focus))
66215
9a8b6b86350c proper hyperlink_command, notably for locate_query;
wenzelm
parents: 66211
diff changeset
   504
65189
41d2452845fc support for caret handling and dynamic output;
wenzelm
parents: 65173
diff changeset
   505
    def unapply(json: JSON.T): Option[Option[(JFile, Line.Position)]] =
41d2452845fc support for caret handling and dynamic output;
wenzelm
parents: 65173
diff changeset
   506
      json match {
41d2452845fc support for caret handling and dynamic output;
wenzelm
parents: 65173
diff changeset
   507
        case Notification("PIDE/caret_update", Some(params)) =>
41d2452845fc support for caret handling and dynamic output;
wenzelm
parents: 65173
diff changeset
   508
          val caret =
41d2452845fc support for caret handling and dynamic output;
wenzelm
parents: 65173
diff changeset
   509
            for {
41d2452845fc support for caret handling and dynamic output;
wenzelm
parents: 65173
diff changeset
   510
              uri <- JSON.string(params, "uri")
41d2452845fc support for caret handling and dynamic output;
wenzelm
parents: 65173
diff changeset
   511
              if Url.is_wellformed_file(uri)
41d2452845fc support for caret handling and dynamic output;
wenzelm
parents: 65173
diff changeset
   512
              pos <- Position.unapply(params)
66235
d4fa51e7c4ff retain symlinks in file names from VSCode: relevant for proper file locations in decorations etc.;
wenzelm
parents: 66216
diff changeset
   513
            } yield (Url.absolute_file(uri), pos)
65189
41d2452845fc support for caret handling and dynamic output;
wenzelm
parents: 65173
diff changeset
   514
          Some(caret)
41d2452845fc support for caret handling and dynamic output;
wenzelm
parents: 65173
diff changeset
   515
        case _ => None
41d2452845fc support for caret handling and dynamic output;
wenzelm
parents: 65173
diff changeset
   516
      }
41d2452845fc support for caret handling and dynamic output;
wenzelm
parents: 65173
diff changeset
   517
  }
41d2452845fc support for caret handling and dynamic output;
wenzelm
parents: 65173
diff changeset
   518
65201
2d01b30e6ac6 clarified modules;
wenzelm
parents: 65200
diff changeset
   519
2d01b30e6ac6 clarified modules;
wenzelm
parents: 65200
diff changeset
   520
  /* dynamic output */
2d01b30e6ac6 clarified modules;
wenzelm
parents: 65200
diff changeset
   521
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 75263
diff changeset
   522
  object Dynamic_Output {
81039
9c5a4ba4ced6 lsp: unified PIDE/decorations and dynamic output decorations format;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81037
diff changeset
   523
    def apply(content: String, decorations: Option[List[(String, List[Decoration_Options])]] = None): JSON.T =
81037
f1aef7110329 lsp: added decorations to dynamic output;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81032
diff changeset
   524
      Notification("PIDE/dynamic_output",
f1aef7110329 lsp: added decorations to dynamic output;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81032
diff changeset
   525
        JSON.Object("content" -> content) ++
f1aef7110329 lsp: added decorations to dynamic output;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81032
diff changeset
   526
        JSON.optional(
f1aef7110329 lsp: added decorations to dynamic output;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81032
diff changeset
   527
          "decorations" -> decorations.map(decorations =>
f1aef7110329 lsp: added decorations to dynamic output;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81032
diff changeset
   528
            decorations.map(decoration => JSON.Object(
81039
9c5a4ba4ced6 lsp: unified PIDE/decorations and dynamic output decorations format;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81037
diff changeset
   529
              "type" -> decoration._1,
9c5a4ba4ced6 lsp: unified PIDE/decorations and dynamic output decorations format;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81037
diff changeset
   530
              "content" -> decoration._2.map(_.json))
81037
f1aef7110329 lsp: added decorations to dynamic output;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81032
diff changeset
   531
            ))
f1aef7110329 lsp: added decorations to dynamic output;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81032
diff changeset
   532
        ))
65189
41d2452845fc support for caret handling and dynamic output;
wenzelm
parents: 65173
diff changeset
   533
  }
65977
c51b74be23b6 provide preview content on Scala side (similar to output);
wenzelm
parents: 65924
diff changeset
   534
81029
f4cb1e35c63e lsp: added Output_Set_Margin and State_Set_Margin Notifications;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81028
diff changeset
   535
  object Output_Set_Margin {
f4cb1e35c63e lsp: added Output_Set_Margin and State_Set_Margin Notifications;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81028
diff changeset
   536
    def unapply(json: JSON.T): Option[Double] =
f4cb1e35c63e lsp: added Output_Set_Margin and State_Set_Margin Notifications;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81028
diff changeset
   537
      json match {
f4cb1e35c63e lsp: added Output_Set_Margin and State_Set_Margin Notifications;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81028
diff changeset
   538
        case Notification("PIDE/output_set_margin", Some(params)) =>
81032
de94fcfbc3ce lsp: tuned;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81030
diff changeset
   539
          JSON.double(params, "margin")
81029
f4cb1e35c63e lsp: added Output_Set_Margin and State_Set_Margin Notifications;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81028
diff changeset
   540
        case _ => None
f4cb1e35c63e lsp: added Output_Set_Margin and State_Set_Margin Notifications;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81028
diff changeset
   541
      }
f4cb1e35c63e lsp: added Output_Set_Margin and State_Set_Margin Notifications;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81028
diff changeset
   542
  }
f4cb1e35c63e lsp: added Output_Set_Margin and State_Set_Margin Notifications;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81028
diff changeset
   543
65977
c51b74be23b6 provide preview content on Scala side (similar to output);
wenzelm
parents: 65924
diff changeset
   544
66096
6187612e83c1 support for separate proof state output;
wenzelm
parents: 66090
diff changeset
   545
  /* state output */
6187612e83c1 support for separate proof state output;
wenzelm
parents: 66090
diff changeset
   546
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 75263
diff changeset
   547
  object State_Output {
81042
f1e0ca5aaa6b lsp: added decorations to state updates;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81039
diff changeset
   548
    def apply(
f1e0ca5aaa6b lsp: added decorations to state updates;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81039
diff changeset
   549
       id: Counter.ID,
f1e0ca5aaa6b lsp: added decorations to state updates;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81039
diff changeset
   550
       content: String,
f1e0ca5aaa6b lsp: added decorations to state updates;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81039
diff changeset
   551
       auto_update: Boolean,
f1e0ca5aaa6b lsp: added decorations to state updates;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81039
diff changeset
   552
       decorations: Option[List[(String, List[Decoration_Options])]] = None
f1e0ca5aaa6b lsp: added decorations to state updates;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81039
diff changeset
   553
    ): JSON.T =
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 75263
diff changeset
   554
      Notification("PIDE/state_output",
81042
f1e0ca5aaa6b lsp: added decorations to state updates;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81039
diff changeset
   555
        JSON.Object("id" -> id, "content" -> content, "auto_update" -> auto_update) ++
f1e0ca5aaa6b lsp: added decorations to state updates;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81039
diff changeset
   556
        JSON.optional(
f1e0ca5aaa6b lsp: added decorations to state updates;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81039
diff changeset
   557
          "decorations" -> decorations.map(decorations =>
f1e0ca5aaa6b lsp: added decorations to state updates;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81039
diff changeset
   558
            decorations.map(decoration => JSON.Object(
f1e0ca5aaa6b lsp: added decorations to state updates;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81039
diff changeset
   559
              "type" -> decoration._1,
f1e0ca5aaa6b lsp: added decorations to state updates;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81039
diff changeset
   560
              "content" -> decoration._2.map(_.json))
f1e0ca5aaa6b lsp: added decorations to state updates;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81039
diff changeset
   561
            ))
f1e0ca5aaa6b lsp: added decorations to state updates;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81039
diff changeset
   562
        ))
66096
6187612e83c1 support for separate proof state output;
wenzelm
parents: 66090
diff changeset
   563
  }
6187612e83c1 support for separate proof state output;
wenzelm
parents: 66090
diff changeset
   564
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 75263
diff changeset
   565
  class State_Id_Notification(name: String) {
66096
6187612e83c1 support for separate proof state output;
wenzelm
parents: 66090
diff changeset
   566
    def unapply(json: JSON.T): Option[Counter.ID] =
6187612e83c1 support for separate proof state output;
wenzelm
parents: 66090
diff changeset
   567
      json match {
6187612e83c1 support for separate proof state output;
wenzelm
parents: 66090
diff changeset
   568
        case Notification(method, Some(params)) if method == name => JSON.long(params, "id")
6187612e83c1 support for separate proof state output;
wenzelm
parents: 66090
diff changeset
   569
        case _ => None
6187612e83c1 support for separate proof state output;
wenzelm
parents: 66090
diff changeset
   570
      }
6187612e83c1 support for separate proof state output;
wenzelm
parents: 66090
diff changeset
   571
  }
6187612e83c1 support for separate proof state output;
wenzelm
parents: 66090
diff changeset
   572
81028
84f6f17274d0 lsp: changed State_Init notification into a request and removed State_Init_Response;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81026
diff changeset
   573
  object State_Init extends Request0("PIDE/state_init") {
84f6f17274d0 lsp: changed State_Init notification into a request and removed State_Init_Response;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81026
diff changeset
   574
    def reply(id: Id, state_id: Counter.ID): JSON.T =
84f6f17274d0 lsp: changed State_Init notification into a request and removed State_Init_Response;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81026
diff changeset
   575
      ResponseMessage(id, Some(JSON.Object("state_id" -> state_id)))
84f6f17274d0 lsp: changed State_Init notification into a request and removed State_Init_Response;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81026
diff changeset
   576
  }
84f6f17274d0 lsp: changed State_Init notification into a request and removed State_Init_Response;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81026
diff changeset
   577
66096
6187612e83c1 support for separate proof state output;
wenzelm
parents: 66090
diff changeset
   578
  object State_Exit extends State_Id_Notification("PIDE/state_exit")
6187612e83c1 support for separate proof state output;
wenzelm
parents: 66090
diff changeset
   579
  object State_Locate extends State_Id_Notification("PIDE/state_locate")
6187612e83c1 support for separate proof state output;
wenzelm
parents: 66090
diff changeset
   580
  object State_Update extends State_Id_Notification("PIDE/state_update")
6187612e83c1 support for separate proof state output;
wenzelm
parents: 66090
diff changeset
   581
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 75263
diff changeset
   582
  object State_Auto_Update {
66211
100c9c997e2b HTML GUI actions via JavaScript;
wenzelm
parents: 66140
diff changeset
   583
    def unapply(json: JSON.T): Option[(Counter.ID, Boolean)] =
100c9c997e2b HTML GUI actions via JavaScript;
wenzelm
parents: 66140
diff changeset
   584
      json match {
100c9c997e2b HTML GUI actions via JavaScript;
wenzelm
parents: 66140
diff changeset
   585
        case Notification("PIDE/state_auto_update", Some(params)) =>
100c9c997e2b HTML GUI actions via JavaScript;
wenzelm
parents: 66140
diff changeset
   586
          for {
100c9c997e2b HTML GUI actions via JavaScript;
wenzelm
parents: 66140
diff changeset
   587
            id <- JSON.long(params, "id")
100c9c997e2b HTML GUI actions via JavaScript;
wenzelm
parents: 66140
diff changeset
   588
            enabled <- JSON.bool(params, "enabled")
100c9c997e2b HTML GUI actions via JavaScript;
wenzelm
parents: 66140
diff changeset
   589
          } yield (id, enabled)
100c9c997e2b HTML GUI actions via JavaScript;
wenzelm
parents: 66140
diff changeset
   590
        case _ => None
100c9c997e2b HTML GUI actions via JavaScript;
wenzelm
parents: 66140
diff changeset
   591
      }
100c9c997e2b HTML GUI actions via JavaScript;
wenzelm
parents: 66140
diff changeset
   592
  }
100c9c997e2b HTML GUI actions via JavaScript;
wenzelm
parents: 66140
diff changeset
   593
81029
f4cb1e35c63e lsp: added Output_Set_Margin and State_Set_Margin Notifications;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81028
diff changeset
   594
  object State_Set_Margin {
f4cb1e35c63e lsp: added Output_Set_Margin and State_Set_Margin Notifications;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81028
diff changeset
   595
    def unapply(json: JSON.T): Option[(Counter.ID, Double)] =
f4cb1e35c63e lsp: added Output_Set_Margin and State_Set_Margin Notifications;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81028
diff changeset
   596
      json match {
f4cb1e35c63e lsp: added Output_Set_Margin and State_Set_Margin Notifications;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81028
diff changeset
   597
        case Notification("PIDE/state_set_margin", Some(params)) =>
f4cb1e35c63e lsp: added Output_Set_Margin and State_Set_Margin Notifications;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81028
diff changeset
   598
          for {
f4cb1e35c63e lsp: added Output_Set_Margin and State_Set_Margin Notifications;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81028
diff changeset
   599
            id <- JSON.long(params, "id")
f4cb1e35c63e lsp: added Output_Set_Margin and State_Set_Margin Notifications;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81028
diff changeset
   600
            margin <- JSON.double(params, "margin")
f4cb1e35c63e lsp: added Output_Set_Margin and State_Set_Margin Notifications;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81028
diff changeset
   601
          } yield (id, margin)
f4cb1e35c63e lsp: added Output_Set_Margin and State_Set_Margin Notifications;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81028
diff changeset
   602
        case _ => None
f4cb1e35c63e lsp: added Output_Set_Margin and State_Set_Margin Notifications;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81028
diff changeset
   603
      }
f4cb1e35c63e lsp: added Output_Set_Margin and State_Set_Margin Notifications;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81028
diff changeset
   604
  }
f4cb1e35c63e lsp: added Output_Set_Margin and State_Set_Margin Notifications;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81028
diff changeset
   605
66096
6187612e83c1 support for separate proof state output;
wenzelm
parents: 66090
diff changeset
   606
81030
88879ff1cef5 lsp: added Symbols_Request;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81029
diff changeset
   607
  /* symbols */
88879ff1cef5 lsp: added Symbols_Request;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81029
diff changeset
   608
88879ff1cef5 lsp: added Symbols_Request;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81029
diff changeset
   609
  object Symbols_Request extends Request0("PIDE/symbols_request") {
88879ff1cef5 lsp: added Symbols_Request;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81029
diff changeset
   610
    def reply(id: Id, symbols: Symbol.Symbols): JSON.T = {
88879ff1cef5 lsp: added Symbols_Request;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81029
diff changeset
   611
      def json(symbol: Symbol.Entry): JSON.T =
88879ff1cef5 lsp: added Symbols_Request;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81029
diff changeset
   612
        JSON.Object(
88879ff1cef5 lsp: added Symbols_Request;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81029
diff changeset
   613
          "symbol" -> symbol.symbol,
88879ff1cef5 lsp: added Symbols_Request;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81029
diff changeset
   614
          "name" -> symbol.name,
88879ff1cef5 lsp: added Symbols_Request;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81029
diff changeset
   615
          "argument" -> symbol.argument.toString,
88879ff1cef5 lsp: added Symbols_Request;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81029
diff changeset
   616
        ) ++
88879ff1cef5 lsp: added Symbols_Request;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81029
diff changeset
   617
          JSON.optional("code", symbol.code) ++
88879ff1cef5 lsp: added Symbols_Request;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81029
diff changeset
   618
          JSON.optional("font", symbol.font) ++
88879ff1cef5 lsp: added Symbols_Request;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81029
diff changeset
   619
          JSON.Object(
88879ff1cef5 lsp: added Symbols_Request;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81029
diff changeset
   620
            "groups" -> symbol.groups,
88879ff1cef5 lsp: added Symbols_Request;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81029
diff changeset
   621
            "abbrevs" -> symbol.abbrevs,
88879ff1cef5 lsp: added Symbols_Request;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81029
diff changeset
   622
          )
88879ff1cef5 lsp: added Symbols_Request;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81029
diff changeset
   623
88879ff1cef5 lsp: added Symbols_Request;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81029
diff changeset
   624
      ResponseMessage(id, Some(symbols.entries.map(s => json(s))))
88879ff1cef5 lsp: added Symbols_Request;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81029
diff changeset
   625
    }
88879ff1cef5 lsp: added Symbols_Request;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81029
diff changeset
   626
88879ff1cef5 lsp: added Symbols_Request;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81029
diff changeset
   627
  }
88879ff1cef5 lsp: added Symbols_Request;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81029
diff changeset
   628
88879ff1cef5 lsp: added Symbols_Request;
Thomas Lindae <thomas.lindae@in.tum.de>
parents: 81029
diff changeset
   629
65983
d8c5603c1732 explicit preview request/response;
wenzelm
parents: 65979
diff changeset
   630
  /* preview */
65977
c51b74be23b6 provide preview content on Scala side (similar to output);
wenzelm
parents: 65924
diff changeset
   631
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 75263
diff changeset
   632
  object Preview_Request {
65983
d8c5603c1732 explicit preview request/response;
wenzelm
parents: 65979
diff changeset
   633
    def unapply(json: JSON.T): Option[(JFile, Int)] =
d8c5603c1732 explicit preview request/response;
wenzelm
parents: 65979
diff changeset
   634
      json match {
d8c5603c1732 explicit preview request/response;
wenzelm
parents: 65979
diff changeset
   635
        case Notification("PIDE/preview_request", Some(params)) =>
d8c5603c1732 explicit preview request/response;
wenzelm
parents: 65979
diff changeset
   636
          for {
d8c5603c1732 explicit preview request/response;
wenzelm
parents: 65979
diff changeset
   637
            uri <- JSON.string(params, "uri")
d8c5603c1732 explicit preview request/response;
wenzelm
parents: 65979
diff changeset
   638
            if Url.is_wellformed_file(uri)
d8c5603c1732 explicit preview request/response;
wenzelm
parents: 65979
diff changeset
   639
            column <- JSON.int(params, "column")
66235
d4fa51e7c4ff retain symlinks in file names from VSCode: relevant for proper file locations in decorations etc.;
wenzelm
parents: 66216
diff changeset
   640
          } yield (Url.absolute_file(uri), column)
65983
d8c5603c1732 explicit preview request/response;
wenzelm
parents: 65979
diff changeset
   641
        case _ => None
d8c5603c1732 explicit preview request/response;
wenzelm
parents: 65979
diff changeset
   642
      }
d8c5603c1732 explicit preview request/response;
wenzelm
parents: 65979
diff changeset
   643
  }
d8c5603c1732 explicit preview request/response;
wenzelm
parents: 65979
diff changeset
   644
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 75263
diff changeset
   645
  object Preview_Response {
65983
d8c5603c1732 explicit preview request/response;
wenzelm
parents: 65979
diff changeset
   646
    def apply(file: JFile, column: Int, label: String, content: String): JSON.T =
d8c5603c1732 explicit preview request/response;
wenzelm
parents: 65979
diff changeset
   647
      Notification("PIDE/preview_response",
67850
3e9fe7a84b5d tuned signature;
wenzelm
parents: 67843
diff changeset
   648
        JSON.Object(
65983
d8c5603c1732 explicit preview request/response;
wenzelm
parents: 65979
diff changeset
   649
          "uri" -> Url.print_file(file),
d8c5603c1732 explicit preview request/response;
wenzelm
parents: 65979
diff changeset
   650
          "column" -> column,
d8c5603c1732 explicit preview request/response;
wenzelm
parents: 65979
diff changeset
   651
          "label" -> label,
d8c5603c1732 explicit preview request/response;
wenzelm
parents: 65979
diff changeset
   652
          "content" -> content))
65977
c51b74be23b6 provide preview content on Scala side (similar to output);
wenzelm
parents: 65924
diff changeset
   653
  }
64605
9c1173a7e4cb basic support for VSCode Language Server protocol;
wenzelm
parents:
diff changeset
   654
}