pro_lsp 0.3.0
pro_lsp: ^0.3.0 copied to clipboard
Unified LSP 3.18 Dart bindings and client/server API implementation
Changelog #
0.3.0 #
- Upgraded the generated bindings to LSP 3.18. Models are now generated from
the LSP 3.18 meta-model. Highlights:
- New requests — dynamic text document content
(
workspace/textDocumentContentandworkspace/textDocumentContent/refresh). - New enumerations —
LanguageKind(typed language identifiers, includingdandpascal),TraceValue,CodeActionTag,ApplyKind. - New structures —
SnippetTextEdit,WorkspaceEditMetadata,CodeActionKindDocumentation,CompletionItemApplyKinds, theTextDocumentContent*family, structuredTextDocumentFilter*/NotebookDocumentFilter*(relative-pattern support), and namedClient*/Server*capability options promoted from inline literals (ClientInfo,ServerInfo, …). - New properties —
Command.tooltip,CompletionList.applyKind,CodeAction.tags,CodeLensClientCapabilities.resolveSupport,WorkspaceEditClientCapabilities.{metadataSupport,snippetEditSupport},ApplyWorkspaceEditParams.metadata,DiagnosticClientCapabilities.markupMessageSupport,WorkspaceClientCapabilities.textDocumentContent, and more.
- New requests — dynamic text document content
(
- Breaking (3.18 API shape changes consumers must adopt):
InitializeResult.serverInfo/InitializeParams.clientInfo(andLspClient.start(clientInfo:)) now take the namedServerInfo/ClientInfostructures instead of anonymous records.TextDocumentItem.languageIdis nowLanguageKindinstead ofString.Diagnostic.messageis now theDiagnosticMessageunion (string or markup) to supportmarkupMessageSupport.SignatureHelp.activeParameter/SignatureInformation.activeParameterare now nullable.- Union accessors renamed where the underlying members became named structures
(e.g.
TextDocumentContentChangeEventandWorkspaceSymbolLocation).
- Breaking (middleware API): unified the request context.
LspMiddlewarenow receives the sameLspRequestthat handlers do, gainingresolve<T>()/tryResolve<T>(),cancellationToken,connection, andisNotification. The separateLspIncomingRequesttype (passed to middleware since 0.1.0) is removed, and itsrequestIdfield is nowid. Rewrite params by mutatingrequest.paramsbefore callingnext(); the request is sealed read-only once the handler runs. Migration: changecall(LspIncomingRequest request, LspNext next)tocall(LspRequest request, LspNext next),request.requestIdtorequest.id, and any params rewrite from constructing a new request object to mutatingrequest.params. - Fuller
@sincehistory — structures with a multi-versionsinceTagshistory (e.g.ServerInfo,ClientInfo) now document every version (@since 3.15.0and@since 3.18.0 …) instead of only the latest. - Generator hygiene — doc-comment formatting regexes are compiled once; an
unrecognized LSP base type now warns instead of silently passing through;
union nullability is derived from a single
containsNullsource of truth on the type IR; the client/server API generators share one configurable implementation; and union-shape analysis and property flattening are split into focused, unit-tested helpers.
0.2.1 #
- Fixed: nullable-union request results crashed on a
nullresponse. Typed senders for results whose union includesnull(e.g.textDocument/definition,completion,implementation,typeDefinition,declaration,documentSymbol,inlineCompletion,semanticTokens/full/delta,workspace/symbol) cast the raw payload as non-nullObjectbeforefromJson. When the server legitimately returnednull(e.g. nothing resolves under the cursor) this threwtype 'Null' is not a subtype of type 'Object'. The code generator now castsraw as Object?for unions whose representation is nullable, so anullresponse decodes to the union's null variant. Non-nullable union results (textDocument/diagnostic,prepareRename) are unchanged. Generated code only — no API change.
0.2.0 #
- Fixed (behavior change):
LspClientnow receives server→client messages. Previously the connection's lifecycle state advanced only on an incominginitializerequest (the server role). A client drives the handshake by sendinginitialize, so its state stayeduninitializedand every incoming server→client message (textDocument/publishDiagnostics,window/*,$/progress,workspace/configuration,window/showMessageRequest,client/registerCapability, …) was rejected by the state machine and silently dropped — handlers were never invoked.LspClient.start()now advances its own state after the handshake, so these handlers fire as expected. If you relied on the previous (broken) behavior of these notifications never arriving, this is a behavior change. - Added:
LspConnection.markInitialized()— marks a connectioninitializedfrom the client side (the state machine only auto-advances on an incominginitialize, which a client never receives). Called automatically byLspClient.start(); exposed for callers that drive the handshake manually via the low-levellisten(). - Added:
LspClient.telemetrynamespace getter (ClientTelemetryHandlers), completing the set of incoming server→client handler namespaces on the client. Previouslytelemetry/eventcould only be handled by reaching intoconnectiondirectly. - Documentation restructured:
README.mdis now a concise overview (pitch, quick start, install) that links into a newdoc/tree — task-oriented guides plus a per-method reference covering every LSP request and notification with "what / when / example". Examples are distilled from the package's end-to-end tests, so they track the current API. - Generated model files that contain LSP-mandated
@Deprecatedmembers again carryignore_for_file: remove_deprecations_in_breaking_versions. The 0.1.2 removal was premature — that lint only fires on a breaking version bump, which this release is; the deprecations come from the LSP meta-model and cannot be dropped. The generator now emits the ignore only for the model files that actually contain a deprecated member. Generated code only; no API change.
0.1.2 #
LspServernow provides spec-compliant defaultshutdownandexithandlers when you don't register your own —shutdownsucceeds andexitcloses the connection. Registergeneral.onShutdown/general.onExitbeforelisten()to override.- Rewrote the README around a task-oriented structure (Quick start, Core
concepts, Building a server/client, Testing, Models, Errors, Cancellation)
and fixed several non-compiling examples (
Hover/union construction,completionProvider, custom transports). - Outgoing requests can now be cancelled and time-bounded: every request sender
(e.g.
client.server.textDocument.definition(...)) accepts optionaltoken(CancellationToken) andtimeout(Duration) arguments. On cancel/timeout a$/cancelRequestnotification is sent to the peer automatically. - Peer error responses are now surfaced as a typed
LspException(carrying the JSON-RPCcode,message, anddata) instead of the transport'sRpcException. - Breaking (low-level):
LspConnection.sendRequest'sparamsargument is now a required positional parameter, and the method gained namedtoken/timeoutparameters. The generated typed senders are the recommended API and are unaffected. - Removed a stale
ignore_for_file: remove_deprecations_in_breaking_versionsfrom the generated model files (it suppressed a lint that never fired). Generated code only; no API or behavior change. - Breaking:
LspClient.startno longer takes an untypedclientInfoMap. Pass a typedclientInfo: (name: ..., version: ...)record and the newprocessIdargument separately (previouslyprocessIdwas smuggled inside the map). This removes a runtime cast that could throw on a malformed map. - Custom (non-spec) protocol methods are now supported via
LspConnection.registerCustomRequestHandler/registerCustomNotificationHandlerandsendCustomRequest/sendCustomNotification. The typed enum-based handlers remain the recommended path for spec methods. - Feature-disposal errors with no
onErrorconfigured are now written tostderrinstead ofstdout— printing tostdoutcorrupts the JSON-RPC stream on the stdio transport. - Documentation fixes: corrected the
onErrordescription (errors are not logged to stdout), theLspFeatureexample (removed a non-compiling custom-method snippet), and clarified thatLspClient.startandlistenare mutually exclusive entry points.
0.1.1 #
Update README.md
0.1.0 #
- Initial release of
pro_lsp. - Complete LSP 3.17 specification bindings generated from the Microsoft LSP meta-model.
- Pluggable feature modularization architecture (
LspFeature) with automated register and dispose lifecycles. - Symmetrical client/server API with namespace-grouped handlers (
general,textDocument,workspace,window, etc.). - Connection lifecycle state machine tracking to enforce protocol-compliance.
- Custom middleware support (
LspMiddleware) for request/notification interception. - Built-in service container (dependency injection) registry inside connection contexts.
- Stream framing transport implementation (
LspByteStreamChannel) supporting stdio, TCP sockets, and custom streams.