Documentation

Lean.Server.Requests

def Lean.FileMap.rangeContainsHoverPos (text : FileMap) (r : Syntax.Range) (hoverPos : String.Pos.Raw) (includeStop : Bool := false) :

Checks whether r contains hoverPos, taking into account EOF according to text.

Instances For
    def Lean.FileMap.rangeOverlapsRequestedRange (text : FileMap) (documentRange requestedRange : Syntax.Range) (includeDocumentRangeStop includeRequestedRangeStop : Bool := false) :
    Instances For
      def Lean.FileMap.rangeIncludesRequestedRange (text : FileMap) (documentRange requestedRange : Syntax.Range) (includeDocumentRangeStop includeRequestedRangeStop : Bool := false) :
      Instances For
        Instances For

          Finds the first (in pre-order) snapshot task in tree that contains hoverPos (including whitespace) and which contains an info tree, and then returns that info tree, waiting for any snapshot tasks on the way. Subtrees that do not contain the position are skipped without forcing their tasks. If the caller of this function needs the correct snapshot when the cursor is on whitespace, then this function is likely the wrong one to call, as it simply yields the first snapshot that contains hoverPos in its whitespace, which is not necessarily the correct one (e.g. it may be indentation-sensitive).

          Instances For
            def Lean.Language.SnapshotTree.foldInfosInRange {α : Type u_1} (tree : SnapshotTree) (requestedRange : Syntax.Range) (init : α) (f : Elab.ContextInfoElab.Infoαα) :
            Instances For
              Instances For
                def Lean.Server.parseRequestParams (paramType : Type) [FromJson paramType] (params : Json) :
                Instances For
                  Instances For
                    @[reducible, inline]
                    Instances For
                      @[reducible, inline]
                      abbrev Lean.Server.RequestTask (α : Type u_1) :
                      Type u_1
                      Instances For
                        @[reducible, inline]
                        abbrev Lean.Server.RequestT (m : TypeType u_1) (α : Type) :
                        Type u_1
                        Instances For
                          @[reducible, inline]

                          Workers execute request handlers in this monad.

                          Instances For
                            Instances For
                              @[reducible, inline]
                              abbrev Lean.Server.RequestTask.pure {α : Type u_1} (a : α) :
                              Instances For
                                Instances For
                                  Instances For
                                    def Lean.Server.RequestM.mapTaskCheap {α : Type u_1} {β : Type} (t : ServerTask α) (f : αRequestM β) :
                                    Instances For
                                      def Lean.Server.RequestM.mapTaskCostly {α : Type u_1} {β : Type} (t : ServerTask α) (f : αRequestM β) :
                                      Instances For
                                        def Lean.Server.RequestM.bindTaskCheap {α : Type u_1} {β : Type} (t : ServerTask α) (f : αRequestM (RequestTask β)) :
                                        Instances For
                                          def Lean.Server.RequestM.bindTaskCostly {α : Type u_1} {β : Type} (t : ServerTask α) (f : αRequestM (RequestTask β)) :
                                          Instances For
                                            def Lean.Server.RequestM.mapRequestTaskCheap {α : Type u_1} {β : Type} (t : RequestTask α) (f : αRequestM β) :
                                            Instances For
                                              def Lean.Server.RequestM.mapRequestTaskCostly {α : Type u_1} {β : Type} (t : RequestTask α) (f : αRequestM β) :
                                              Instances For
                                                Instances For
                                                  Instances For
                                                    def Lean.Server.RequestM.parseRequestParams (paramType : Type) [FromJson paramType] (params : Json) :
                                                    RequestM paramType
                                                    Instances For
                                                      def Lean.Server.RequestM.sendServerRequest (paramType : Type u_1) [ToJson paramType] (responseType : Type) [FromJson responseType] [Inhabited responseType] (method : String) (param : paramType) :
                                                      Instances For

                                                        Create a task which waits for the first snapshot matching p, handles various errors, and if a matching snapshot was found executes x with it. If not found, the task executes notFoundX.

                                                        Instances For

                                                          Create a task which waits for the snapshot containing lspPos and executes f with it. If no such snapshot exists, the request fails with an error.

                                                          Instances For

                                                            Finds the first CommandParsedSnapshot containing hoverPos, asynchronously.

                                                            Instances For

                                                              Finds the command syntax and info tree of the first snapshot task containing pos, asynchronously. The info tree may be from a nested snapshot, such as a single tactic.

                                                              See SnapshotTree.findInfoTreeAtPos for details on how the search is done.

                                                              Instances For

                                                                Finds the info tree of the first snapshot task containing pos, asynchronously. The info tree may be from a nested snapshot, such as a single tactic.

                                                                See SnapshotTree.findInfoTreeAtPos for details on how the search is done.

                                                                Instances For

                                                                  The global request handlers table #

                                                                  We maintain a global map of LSP request handlers. This allows user code such as plugins to register its own handlers, for example to support ITP functionality such as goal state visualization.

                                                                  For details of how to register one, see registerLspRequestHandler.

                                                                  • response : α
                                                                  • isComplete : Bool
                                                                  Instances For
                                                                    Instances For
                                                                      def Lean.Server.registerLspRequestHandler (method : String) (paramType : Type) [FromJson paramType] [Lsp.FileSource paramType] (respType : Type) [ToJson respType] (handler : paramTypeRequestM (RequestTask respType)) (serialize? : Option (respTypeString) := none) :

                                                                      NB: This method may only be called in initialize blocks (user or builtin).

                                                                      A registration consists of:

                                                                      • a type of JSON-parsable request data paramType
                                                                      • a FileSource instance for it so the system knows where to route requests
                                                                      • a type of JSON-serializable response data respType
                                                                      • an actual handler which runs in the RequestM monad and is expected to produce an asynchronous RequestTask which does any waiting/computation
                                                                      • an optional serialize function which can be used to serialize respType directly to a string for performance reasons, skipping Json

                                                                      A handler task may be cancelled at any time, so it should check the cancellation token when possible to handle this cooperatively. Any exceptions thrown in a request handler will be reported to the client as LSP error responses.

                                                                      Instances For
                                                                        def Lean.Server.chainLspRequestHandler (method : String) (paramType : Type) [FromJson paramType] (respType : Type) [FromJson respType] [ToJson respType] (handler : paramTypeRequestTask respTypeRequestM (RequestTask respType)) :

                                                                        NB: This method may only be called in initialize blocks (user or builtin).

                                                                        Register another handler to invoke after the last one registered for a method. At least one handler for the method must have already been registered to perform chaining.

                                                                        For more details on the registration of a handler, see registerLspRequestHandler.

                                                                        Instances For
                                                                          • complete : RequestHandlerCompleteness
                                                                          • partial (refreshMethod : String) (refreshIntervalMs : Nat) : RequestHandlerCompleteness

                                                                            A request handler is partial if the LSP spec states that the request method implemented by the handler should be responded to with the full state of the document, but our implementation of the handler only returns a partial result for the document (e.g. only for the processed regions of the document, to reduce latency after a didChange). A request handler can only be partial if LSP also specifies a corresponding refresh server-to-client request, e.g. workspace/inlayHint/refresh for textDocument/inlayHint. This is necessary because we use the refresh request to prompt the client to re-request the data for a partial request if we returned a partial response for that request in the past, so that the client eventually converges to a complete set of information for the full document.

                                                                          Instances For
                                                                            Instances For
                                                                              def Lean.Server.registerCompleteStatefulLspRequestHandler (method : String) (paramType : Type) [FromJson paramType] [Lsp.FileSource paramType] (respType : Type) [ToJson respType] (stateType : Type) [TypeName stateType] (initState : stateType) (handler : paramTypestateTypeRequestM (respType × stateType)) (onDidChange : Lsp.DidChangeTextDocumentParamsStateT stateType RequestM Unit) :
                                                                              Instances For
                                                                                def Lean.Server.registerPartialStatefulLspRequestHandler (method refreshMethod : String) (refreshIntervalMs : Nat) (paramType : Type) [FromJson paramType] [Lsp.FileSource paramType] (respType : Type) [ToJson respType] (stateType : Type) [TypeName stateType] (initState : stateType) (handler : paramTypestateTypeRequestM (LspResponse respType × stateType)) (onDidChange : Lsp.DidChangeTextDocumentParamsStateT stateType RequestM Unit) :
                                                                                Instances For
                                                                                  def Lean.Server.chainStatefulLspRequestHandler (method : String) (paramType : Type) [FromJson paramType] [ToJson paramType] [Lsp.FileSource paramType] (respType : Type) [FromJson respType] [ToJson respType] (stateType : Type) [TypeName stateType] (handler : paramTypeLspResponse respTypestateTypeRequestM (LspResponse respType × stateType)) (onDidChange : Lsp.DidChangeTextDocumentParamsStateT stateType RequestM Unit) :
                                                                                  Instances For