src/lsp/server.bend checks
raw source on the hub · import bolt@1.25.0.0/src/lsp/server.bend as Server
lsp/server: the loop. The transport the messages ride on, the files behind imports and Base, and the checker behind the diagnostics are passed in (transport/, files/, checker/answer.bend's Checker; checker/bend.bend's service is the real checker). The open documents are the loop's state. The checker runs on open and save, against the file on disk; the linter on every open, change and save, on the text the editor shows.
20 imports
import Base import 0xa81e161008ecc2f297c0a3065cb9b188/main.bend as Ezjson import 0xa81e161008ecc2f297c0a3065cb9b188/src/value.bend as J import ./proto.bend as Proto import ./docs.bend as Docs import ./nav.bend as Nav import ./semantic.bend as Semantic import ../rules.bend as Lint import ../finding.bend as Finding import ../config.bend as Config import ../lint/plan.bend as Plan import ../noqa.bend as Noqa import ./transport/service.bend as T import ./checker/answer.bend as C import ./files/service.bend as F import ./report.bend as Rep import ./enc.bend as Enc import ../syntax/outline.bend as Outline import ../syntax/lex.bend as Lex import ../syntax/word.bend as Word
Types
type Method source · line 29 · raw
Data
the methods the server answers; MOther is anything else
MInitializeMethod
MShutdownMethod
MExitMethod
MOpenMethod
MChangeMethod
MSaveMethod
MCloseMethod
MHoverMethod
MDefinitionMethod
MSymbolsMethod
MCompletionMethod
MReferencesMethod
MRenameMethod
MSemanticMethod
MOtherMethod
type Reply source · line 48 · raw
Data
a message the server sends: a notification, already printed, or the response to a request, its result or its error
RNote@body:String -> Reply
RResult@id:0xa81e161008ecc2f297c0a3065cb9b188/src/value.Json -> @result:0xa81e161008ecc2f297c0a3065cb9b188/src/value.Json -> Reply
RError@id:0xa81e161008ecc2f297c0a3065cb9b188/src/value.Json -> @code:String -> @message:String -> Reply
type Answer source · line 54 · raw
Data
what a request is answered with: a result, or an error's code and message
Answer@result:0xa81e161008ecc2f297c0a3065cb9b188/src/value.Json -> Answer
Refusal@code:String -> @message:String -> Answer
type Work source · line 60 · raw
Data
what the work behind a method gave: the notifications it sends, the answer (read for a request only), the documents after it. It never sees the id
Work@notes:List<&2, String> -> @answer:Answer -> @docs:List<&2, 0x9783a6a2a487c8baa062899ad235618e/src/lsp/docs.Doc> -> Work
type Out source · line 64 · raw
Data
what one message leads to: the replies to send, whether to stop, the documents
Out@replies:List<&2, Reply> -> @quit:Bool -> @docs:List<&2, 0x9783a6a2a487c8baa062899ad235618e/src/lsp/docs.Doc> -> Out
type Role source · line 69 · raw
Data
how the server treats a method: a request owed one response, a notification, exit, or a method it does not know
RRequestRole
RNoticeRole
RExitRole
RUnknownRole
Definitions
def method source · line 76 · raw
@+name:String -> Method
a method by its name
def role source · line 94 · raw
@mm:Method -> Role
a method's role
def name_of source · line 128 · raw
@msg:0xa81e161008ecc2f297c0a3065cb9b188/src/value.Json -> String
a message's method name, empty when it has none
def id_of source · line 132 · raw
@msg:0xa81e161008ecc2f297c0a3065cb9b188/src/value.Json -> 0xa81e161008ecc2f297c0a3065cb9b188/src/value.Json
a message's id: null for a notification
def uri_of source · line 136 · raw
@params:0xa81e161008ecc2f297c0a3065cb9b188/src/value.Json -> String
the document a request is about
def line_of source · line 140 · raw
@params:0xa81e161008ecc2f297c0a3065cb9b188/src/value.Json -> U32
the line of a request's position
def col_of source · line 144 · raw
@params:0xa81e161008ecc2f297c0a3065cb9b188/src/value.Json -> U32
the character of a request's position
def text source · line 148 · raw
@rr:Reply -> String
a reply as the text sent
def notices source · line 158 · raw
@ns:List<&2, String> -> List<&2, Reply>
notifications as replies
def respond source · line 166 · raw
@id:0xa81e161008ecc2f297c0a3065cb9b188/src/value.Json -> @aa:Answer -> Reply
the response to the request with this id
def unknown source · line 174 · raw
@id:0xa81e161008ecc2f297c0a3065cb9b188/src/value.Json -> List<&2, Reply>
a request the server does not know is refused; a notification is ignored
def answered source · line 182 · raw
@result:0xa81e161008ecc2f297c0a3065cb9b188/src/value.Json -> @docs:List<&2, 0x9783a6a2a487c8baa062899ad235618e/src/lsp/docs.Doc> -> Work
the work of a request: its result, no notifications
def noted source · line 186 · raw
@notes:List<&2, String> -> @docs:List<&2, 0x9783a6a2a487c8baa062899ad235618e/src/lsp/docs.Doc> -> Work
the work of a notification: what it sends, and no answer
def step.go source · line 189 · raw
@rr:Role -> @id:0xa81e161008ecc2f297c0a3065cb9b188/src/value.Json -> @ww:Work -> Out
def step source · line 207 · raw
@mm:Method -> @id:0xa81e161008ecc2f297c0a3065cb9b188/src/value.Json -> @ww:Work -> Out
the dispatcher's decision for one message, whatever its method's work gave: a request gets one response with its id, a notification its notices, exit stops, and a method it does not know is refused or ignored
def pub.note source · line 218 · raw
@cc:0x9783a6a2a487c8baa062899ad235618e/src/lsp/enc.Cols -> @uri:String -> @ds:List<&2, 0x9783a6a2a487c8baa062899ad235618e/src/lsp/report.Diag> -> @gs:List<&2, 0x9783a6a2a487c8baa062899ad235618e/src/finding.Graded> -> String
a document's diagnostics, as the notification sent: the checker's errors, then the linter's findings
def pub.cands source · line 223 · raw
@cwd:String -> @path:String -> List<&2, String>
the bolt.bend candidates of a document's path, nearest first: the ones the CLI reads for a file at that path, run from the same directory
def pub.lint source · line 231 · raw
@+path:String -> @+text:String -> @rs:List<&2, Maybe<&2, String>> -> List<&2, 0x9783a6a2a487c8baa062899ad235618e/src/finding.Graded>
the linter's findings on the text the editor shows, at the levels the
nearest bolt.bend read gives them, less what the text's noqa comments
silence, then the noqa rule's, which judges no project rule's code (the
editor runs none); none for a bolt.bend, which is bolt's configuration,
not source
def pub.checked source · line 239 · raw
@ee:0x9783a6a2a487c8baa062899ad235618e/src/lsp/enc.Enc -> @+uri:String -> @+text:String -> @+ds:List<&2, 0x9783a6a2a487c8baa062899ad235618e/src/lsp/report.Diag> -> @rs:List<&2, Maybe<&2, String>> -> @+docs:List<&2, 0x9783a6a2a487c8baa062899ad235618e/src/lsp/docs.Doc> -> Work
open or save: the checker's errors with the lint of the text, the errors kept for the changes after
def pub.open source · line 250 · raw
@ee:0x9783a6a2a487c8baa062899ad235618e/src/lsp/enc.Enc -> @+uri:String -> @+text:String -> @ds:List<&2, 0x9783a6a2a487c8baa062899ad235618e/src/lsp/report.Diag> -> @rs:List<&2, Maybe<&2, String>> -> @+docs:List<&2, 0x9783a6a2a487c8baa062899ad235618e/src/lsp/docs.Doc> -> Work
open: the document's text kept, then published with the checker's errors
def pub.save source · line 261 · raw
@ee:0x9783a6a2a487c8baa062899ad235618e/src/lsp/enc.Enc -> @+uri:String -> @ds:List<&2, 0x9783a6a2a487c8baa062899ad235618e/src/lsp/report.Diag> -> @rs:List<&2, Maybe<&2, String>> -> @+docs:List<&2, 0x9783a6a2a487c8baa062899ad235618e/src/lsp/docs.Doc> -> Work
save: the text the editor shows published with the checker's new errors
def pub.change source · line 272 · raw
@ee:0x9783a6a2a487c8baa062899ad235618e/src/lsp/enc.Enc -> @+uri:String -> @+text:String -> @rs:List<&2, Maybe<&2, String>> -> @+docs:List<&2, 0x9783a6a2a487c8baa062899ad235618e/src/lsp/docs.Doc> -> Work
change: the new text kept, and its lint published with the checker's last errors
def pub.close source · line 283 · raw
@ee:0x9783a6a2a487c8baa062899ad235618e/src/lsp/enc.Enc -> @+uri:String -> @docs:List<&2, 0x9783a6a2a487c8baa062899ad235618e/src/lsp/docs.Doc> -> Work
close: the document forgotten, and an empty list published
def hover.of source · line 319 · raw
@mm:Maybe<&2, 0x9783a6a2a487c8baa062899ad235618e/src/lsp/nav.Found> -> 0xa81e161008ecc2f297c0a3065cb9b188/src/value.Json
def definition.of source · line 328 · raw
@cc:0x9783a6a2a487c8baa062899ad235618e/src/lsp/enc.Cols -> @mm:Maybe<&2, 0x9783a6a2a487c8baa062899ad235618e/src/lsp/nav.Found> -> 0xa81e161008ecc2f297c0a3065cb9b188/src/value.Json
def col_in source · line 339 · raw
@cc:0x9783a6a2a487c8baa062899ad235618e/src/lsp/enc.Cols -> @+params:0xa81e161008ecc2f297c0a3065cb9b188/src/value.Json -> U32
the column a request's position names, read in the negotiated encoding of the document's text
def references.of source · line 397 · raw
@cc:0x9783a6a2a487c8baa062899ad235618e/src/lsp/enc.Cols -> @ss:0x9783a6a2a487c8baa062899ad235618e/src/lsp/nav.Sites -> @uri:String -> @name:String -> 0xa81e161008ecc2f297c0a3065cb9b188/src/value.Json
def rename.of source · line 402 · raw
@cc:0x9783a6a2a487c8baa062899ad235618e/src/lsp/enc.Cols -> @ss:0x9783a6a2a487c8baa062899ad235618e/src/lsp/nav.Sites -> @uri:String -> @name:String -> @new:String -> Answer
only a name bound in the document renames; the editor shows the refusal
def encoding source · line 504 · raw
@mm:Method -> @params:0xa81e161008ecc2f297c0a3065cb9b188/src/value.Json -> @ee:0x9783a6a2a487c8baa062899ad235618e/src/lsp/enc.Enc -> 0x9783a6a2a487c8baa062899ad235618e/src/lsp/enc.Enc
the encoding after a message: initialize settles it (enc.bend's negotiate); every other message keeps it
def decoded source · line 525 · raw
@mm:Maybe<&2, 0xa81e161008ecc2f297c0a3065cb9b188/src/value.Json> -> 0xa81e161008ecc2f297c0a3065cb9b188/src/value.Json
a parsed message, or null when it did not parse
def next source · line 539 · raw
@-H:Type -> @quit:Bool -> @h3:H -> @ee:0x9783a6a2a487c8baa062899ad235618e/src/lsp/enc.Enc -> @docs:List<&2, 0x9783a6a2a487c8baa062899ad235618e/src/lsp/docs.Doc> -> @rest:(@_:H -> @_:0x9783a6a2a487c8baa062899ad235618e/src/lsp/enc.Enc -> @_:List<&2, 0x9783a6a2a487c8baa062899ad235618e/src/lsp/docs.Doc> -> IO(Unit)) -> IO(Unit)
the loop goes on with the documents, unless the message said to quit
Templates
template pub.configs source · line 287 · raw
@-fs:0x9783a6a2a487c8baa062899ad235618e/src/lsp/files/service.Files -> @+uri:String -> IO(List<&2, Maybe<&2, String>>)
the texts of a document's bolt.bend candidates, as the files hold them
template pub.opened source · line 293 · raw
@-fs:0x9783a6a2a487c8baa062899ad235618e/src/lsp/files/service.Files -> @-ck:0x9783a6a2a487c8baa062899ad235618e/src/lsp/checker/answer.Checker -> @ee:0x9783a6a2a487c8baa062899ad235618e/src/lsp/enc.Enc -> @+uri:String -> @text:String -> @docs:List<&2, 0x9783a6a2a487c8baa062899ad235618e/src/lsp/docs.Doc> -> IO(Work)
open, on the checker's run on the file on disk
template pub.saved source · line 307 · raw
@-fs:0x9783a6a2a487c8baa062899ad235618e/src/lsp/files/service.Files -> @-ck:0x9783a6a2a487c8baa062899ad235618e/src/lsp/checker/answer.Checker -> @ee:0x9783a6a2a487c8baa062899ad235618e/src/lsp/enc.Enc -> @+uri:String -> @docs:List<&2, 0x9783a6a2a487c8baa062899ad235618e/src/lsp/docs.Doc> -> IO(Work)
save, on the checker's run on the file on disk
template pub.changed source · line 314 · raw
@-fs:0x9783a6a2a487c8baa062899ad235618e/src/lsp/files/service.Files -> @ee:0x9783a6a2a487c8baa062899ad235618e/src/lsp/enc.Enc -> @+uri:String -> @text:String -> @docs:List<&2, 0x9783a6a2a487c8baa062899ad235618e/src/lsp/docs.Doc> -> IO(Work)
change: the linter only
template hovered source · line 343 · raw
@-fs:0x9783a6a2a487c8baa062899ad235618e/src/lsp/files/service.Files -> @ee:0x9783a6a2a487c8baa062899ad235618e/src/lsp/enc.Enc -> @+docs:List<&2, 0x9783a6a2a487c8baa062899ad235618e/src/lsp/docs.Doc> -> @+uri:String -> @+params:0xa81e161008ecc2f297c0a3065cb9b188/src/value.Json -> IO(Work)
hover at a request's position
template defined source · line 356 · raw
@-fs:0x9783a6a2a487c8baa062899ad235618e/src/lsp/files/service.Files -> @ee:0x9783a6a2a487c8baa062899ad235618e/src/lsp/enc.Enc -> @+docs:List<&2, 0x9783a6a2a487c8baa062899ad235618e/src/lsp/docs.Doc> -> @+uri:String -> @+params:0xa81e161008ecc2f297c0a3065cb9b188/src/value.Json -> IO(Work)
definition at a request's position
template complete.with source · line 369 · raw
@-fs:0x9783a6a2a487c8baa062899ad235618e/src/lsp/files/service.Files -> @cc:0x9783a6a2a487c8baa062899ad235618e/src/lsp/enc.Cols -> @+prefix:String -> @+docs:List<&2, 0x9783a6a2a487c8baa062899ad235618e/src/lsp/docs.Doc> -> @uri:String -> @+line:U32 -> @+col:U32 -> IO(Work)
template complete source · line 383 · raw
@-fs:0x9783a6a2a487c8baa062899ad235618e/src/lsp/files/service.Files -> @ee:0x9783a6a2a487c8baa062899ad235618e/src/lsp/enc.Enc -> @+docs:List<&2, 0x9783a6a2a487c8baa062899ad235618e/src/lsp/docs.Doc> -> @+uri:String -> @+params:0xa81e161008ecc2f297c0a3065cb9b188/src/value.Json -> IO(Work)
the candidates for the name being typed at a position
template references source · line 411 · raw
@-fs:0x9783a6a2a487c8baa062899ad235618e/src/lsp/files/service.Files -> @ee:0x9783a6a2a487c8baa062899ad235618e/src/lsp/enc.Enc -> @+docs:List<&2, 0x9783a6a2a487c8baa062899ad235618e/src/lsp/docs.Doc> -> @+uri:String -> @+params:0xa81e161008ecc2f297c0a3065cb9b188/src/value.Json -> IO(Work)
every position of the name at a position
template renamed source · line 427 · raw
@-fs:0x9783a6a2a487c8baa062899ad235618e/src/lsp/files/service.Files -> @ee:0x9783a6a2a487c8baa062899ad235618e/src/lsp/enc.Enc -> @+docs:List<&2, 0x9783a6a2a487c8baa062899ad235618e/src/lsp/docs.Doc> -> @+uri:String -> @+params:0xa81e161008ecc2f297c0a3065cb9b188/src/value.Json -> IO(Work)
the edit renaming the name at a position, or a refusal
template semantic source · line 446 · raw
@-fs:0x9783a6a2a487c8baa062899ad235618e/src/lsp/files/service.Files -> @ee:0x9783a6a2a487c8baa062899ad235618e/src/lsp/enc.Enc -> @+docs:List<&2, 0x9783a6a2a487c8baa062899ad235618e/src/lsp/docs.Doc> -> @uri:String -> IO(Work)
the document's semantic tokens
template symbols source · line 452 · raw
@-fs:0x9783a6a2a487c8baa062899ad235618e/src/lsp/files/service.Files -> @ee:0x9783a6a2a487c8baa062899ad235618e/src/lsp/enc.Enc -> @+docs:List<&2, 0x9783a6a2a487c8baa062899ad235618e/src/lsp/docs.Doc> -> @+uri:String -> IO(Work)
the document's symbols
template work source · line 460 · raw
@-fs:0x9783a6a2a487c8baa062899ad235618e/src/lsp/files/service.Files -> @-ck:0x9783a6a2a487c8baa062899ad235618e/src/lsp/checker/answer.Checker -> @ee:0x9783a6a2a487c8baa062899ad235618e/src/lsp/enc.Enc -> @mm:Method -> @+params:0xa81e161008ecc2f297c0a3065cb9b188/src/value.Json -> @+docs:List<&2, 0x9783a6a2a487c8baa062899ad235618e/src/lsp/docs.Doc> -> IO(Work)
the work behind a method: what the checker, the files and the documents give it. It does not see the message's id: step alone puts that on a reply
template handle source · line 512 · raw
@-fs:0x9783a6a2a487c8baa062899ad235618e/src/lsp/files/service.Files -> @-ck:0x9783a6a2a487c8baa062899ad235618e/src/lsp/checker/answer.Checker -> @ee:0x9783a6a2a487c8baa062899ad235618e/src/lsp/enc.Enc -> @+msg:0xa81e161008ecc2f297c0a3065cb9b188/src/value.Json -> @docs:List<&2, 0x9783a6a2a487c8baa062899ad235618e/src/lsp/docs.Doc> -> IO(Out)
one message: its method's work, then step's decision on it
template send_all source · line 529 · raw
@-H:Type -> @-tr:0x9783a6a2a487c8baa062899ad235618e/src/lsp/transport/service.Transport<H> -> @replies:List<&2, Reply> -> @h3:H -> IO(H)
every reply sent, in order
template answer source · line 554 · raw
@-H:Type -> @-tr:0x9783a6a2a487c8baa062899ad235618e/src/lsp/transport/service.Transport<H> -> @out:Out -> @h3:H -> @ee:0x9783a6a2a487c8baa062899ad235618e/src/lsp/enc.Enc -> @rest:(@_:H -> @_:0x9783a6a2a487c8baa062899ad235618e/src/lsp/enc.Enc -> @_:List<&2, 0x9783a6a2a487c8baa062899ad235618e/src/lsp/docs.Doc> -> IO(Unit)) -> IO(Unit)
the replies sent, then the loop goes on
template turn.msg source · line 568 · raw
@-H:Type -> @-tr:0x9783a6a2a487c8baa062899ad235618e/src/lsp/transport/service.Transport<H> -> @-fs:0x9783a6a2a487c8baa062899ad235618e/src/lsp/files/service.Files -> @-ck:0x9783a6a2a487c8baa062899ad235618e/src/lsp/checker/answer.Checker -> @+msg:0xa81e161008ecc2f297c0a3065cb9b188/src/value.Json -> @h3:H -> @ee:0x9783a6a2a487c8baa062899ad235618e/src/lsp/enc.Enc -> @docs:List<&2, 0x9783a6a2a487c8baa062899ad235618e/src/lsp/docs.Doc> -> @rest:(@_:H -> @_:0x9783a6a2a487c8baa062899ad235618e/src/lsp/enc.Enc -> @_:List<&2, 0x9783a6a2a487c8baa062899ad235618e/src/lsp/docs.Doc> -> IO(Unit)) -> IO(Unit)
a message handled under the encoding it leaves, and answered
template turn source · line 585 · raw
@-H:Type -> @-tr:0x9783a6a2a487c8baa062899ad235618e/src/lsp/transport/service.Transport<H> -> @-fs:0x9783a6a2a487c8baa062899ad235618e/src/lsp/files/service.Files -> @-ck:0x9783a6a2a487c8baa062899ad235618e/src/lsp/checker/answer.Checker -> @mm:Maybe<&2, String> -> @h3:H -> @ee:0x9783a6a2a487c8baa062899ad235618e/src/lsp/enc.Enc -> @docs:List<&2, 0x9783a6a2a487c8baa062899ad235618e/src/lsp/docs.Doc> -> @rest:(@_:H -> @_:0x9783a6a2a487c8baa062899ad235618e/src/lsp/enc.Enc -> @_:List<&2, 0x9783a6a2a487c8baa062899ad235618e/src/lsp/docs.Doc> -> IO(Unit)) -> IO(Unit)
one message body handled and answered; none means the peer is gone
template got source · line 603 · raw
@-H:Type -> @-tr:0x9783a6a2a487c8baa062899ad235618e/src/lsp/transport/service.Transport<H> -> @-fs:0x9783a6a2a487c8baa062899ad235618e/src/lsp/files/service.Files -> @-ck:0x9783a6a2a487c8baa062899ad235618e/src/lsp/checker/answer.Checker -> @rr:Pair(H, Maybe<&2, String>) -> @ee:0x9783a6a2a487c8baa062899ad235618e/src/lsp/enc.Enc -> @docs:List<&2, 0x9783a6a2a487c8baa062899ad235618e/src/lsp/docs.Doc> -> @rest:(@_:H -> @_:0x9783a6a2a487c8baa062899ad235618e/src/lsp/enc.Enc -> @_:List<&2, 0x9783a6a2a487c8baa062899ad235618e/src/lsp/docs.Doc> -> IO(Unit)) -> IO(Unit)
what recv gave: the handle and maybe a body
template serve.go source · line 616 · raw
@-H:Type -> @-tr:0x9783a6a2a487c8baa062899ad235618e/src/lsp/transport/service.Transport<H> -> @-fs:0x9783a6a2a487c8baa062899ad235618e/src/lsp/files/service.Files -> @-ck:0x9783a6a2a487c8baa062899ad235618e/src/lsp/checker/answer.Checker -> @fuel:Nat -> @h3:H -> @ee:0x9783a6a2a487c8baa062899ad235618e/src/lsp/enc.Enc -> @docs:List<&2, 0x9783a6a2a487c8baa062899ad235618e/src/lsp/docs.Doc> -> IO(Unit)
template serve source · line 636 · raw
@-H:Type -> @-tr:0x9783a6a2a487c8baa062899ad235618e/src/lsp/transport/service.Transport<H> -> @-fs:0x9783a6a2a487c8baa062899ad235618e/src/lsp/files/service.Files -> @-ck:0x9783a6a2a487c8baa062899ad235618e/src/lsp/checker/answer.Checker -> @fuel:Nat -> @h3:H -> @docs:List<&2, 0x9783a6a2a487c8baa062899ad235618e/src/lsp/docs.Doc> -> IO(Unit)
serves until exit, the peer's end, or the fuel's (a message each), in UTF-16 until initialize negotiates