Documentation

Lean.Data.JsonRpc

Implementation of JSON-RPC 2.0 (https://www.jsonrpc.org/specification) for use in the LSP server.

In JSON-RPC, each request from the client editor to the language server comes with a request id so that the corresponding response can be identified or cancelled.

Instances For

    Error codes defined by JSON-RPC and LSP.

    • parseError : ErrorCode

      Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text.

    • invalidRequest : ErrorCode

      The JSON sent is not a valid Request object.

    • methodNotFound : ErrorCode

      The method does not exist / is not available.

    • invalidParams : ErrorCode

      Invalid method parameter(s).

    • internalError : ErrorCode

      Internal JSON-RPC error.

    • serverNotInitialized : ErrorCode

      Error code indicating that a server received a notification or request before the server has received the initialize request.

    • unknownErrorCode : ErrorCode
    • contentModified : ErrorCode

      The server detected that the content of a document got modified outside normal conditions. A server should NOT send this error code if it detects a content change in it unprocessed messages. The result even computed on an older state might still be useful for the client.

      If a client decides that a result is not of any use anymore the client should cancel the request.

    • requestCancelled : ErrorCode

      The client has canceled a request and a server as detected the cancel.

    • rpcNeedsReconnect : ErrorCode
    • workerExited : ErrorCode
    • workerCrashed : ErrorCode
    Instances For

      A JSON-RPC message.

      Uses separate constructors for notifications and errors because client and server behavior is expected to be wildly different for both.

      Instances For
        Equations
          Instances For
            structure Lean.JsonRpc.Request (α : Type u) :

            Generic version of Message.request.

            A request message to describe a request between the client and the server. Every processed request must send a response back to the sender of the request.

            Instances For
              Equations
                Instances For
                  Equations
                    instance Lean.JsonRpc.instBEqRequest {α✝ : Type u_1} [BEq α✝] :
                    BEq (Request α✝)
                    Equations
                      def Lean.JsonRpc.instBEqRequest.beq {α✝ : Type u_1} [BEq α✝] :
                      Request α✝Request α✝Bool
                      Equations
                        Instances For
                          structure Lean.JsonRpc.Notification (α : Type u) :

                          Generic version of Message.notification.

                          A notification message. A processed notification message must not send a response back. They work like events.

                          Instances For
                            Equations
                              Instances For
                                def Lean.JsonRpc.instBEqNotification.beq {α✝ : Type u_1} [BEq α✝] :
                                Notification α✝Notification α✝Bool
                                Equations
                                  Instances For
                                    instance Lean.JsonRpc.instBEqNotification {α✝ : Type u_1} [BEq α✝] :
                                    Equations
                                      structure Lean.JsonRpc.Response (α : Type u) :

                                      Generic version of Message.response.

                                      A Response Message sent as a result of a request. If a request doesn’t provide a result value the receiver of a request still needs to return a response message to conform to the JSON-RPC specification. The result property of the ResponseMessage should be set to null in this case to signal a successful request.

                                      References:

                                      Instances For
                                        Equations
                                          Equations
                                            Instances For
                                              instance Lean.JsonRpc.instBEqResponse {α✝ : Type u_1} [BEq α✝] :
                                              BEq (Response α✝)
                                              Equations
                                                def Lean.JsonRpc.instBEqResponse.beq {α✝ : Type u_1} [BEq α✝] :
                                                Response α✝Response α✝Bool
                                                Equations
                                                  Instances For
                                                    structure Lean.JsonRpc.ResponseError (α : Type u) :

                                                    Generic version of Message.responseError.

                                                    References:

                                                    • code : ErrorCode
                                                    • message : String

                                                      A string providing a short description of the error.

                                                    • data? : Option α

                                                      A primitive or structured value that contains additional information about the error. Can be omitted.

                                                    Instances For
                                                      Equations
                                                        Instances For
                                                          instance Lean.JsonRpc.instBEqResponseError {α✝ : Type u_1} [BEq α✝] :
                                                          Equations
                                                            def Lean.JsonRpc.instBEqResponseError.beq {α✝ : Type u_1} [BEq α✝] :
                                                            ResponseError α✝ResponseError α✝Bool
                                                            Equations
                                                              Instances For
                                                                Equations
                                                                  Instances For

                                                                    A variant of Message that has been parsed partially, without the payload. This is useful when we want to process the metadata of a Message without parsing and converting the whole thing.

                                                                    Instances For

                                                                      Danger: For performance reasons, this function makes a number of fragile assumptions about input. Namely:

                                                                      • input is the output of (toJson (v : Message)).compress
                                                                      • compress yields a lexicographic ordering of JSON object keys
                                                                      Equations
                                                                        Instances For
                                                                          Instances For
                                                                            Instances For
                                                                              Equations
                                                                                Instances For
                                                                                  def IO.FS.Stream.readRequestAs (h : Stream) (nBytes : Nat) (expectedMethod : String) (α : Type) [Lean.FromJson α] :
                                                                                  Equations
                                                                                    Instances For
                                                                                      def IO.FS.Stream.readNotificationAs (h : Stream) (nBytes : Nat) (expectedMethod : String) (α : Type) [Lean.FromJson α] :
                                                                                      Equations
                                                                                        Instances For
                                                                                          Equations
                                                                                            Instances For
                                                                                              Equations
                                                                                                Instances For
                                                                                                  Equations
                                                                                                    Instances For
                                                                                                      Equations
                                                                                                        Instances For
                                                                                                          Equations
                                                                                                            Instances For