Conversation
| enabled: bool = True, | ||
| initialization_options: DottedDict | None = None, | ||
| settings: DottedDict | None = None, | ||
| env: dict[str, str | list[str]] | None = None, |
There was a problem hiding this comment.
Don't quite see why we've allowed a list of strings for the dict value. I don't see this documented in https://lsp.sublimetext.io/client_configuration/ and also I don't see any package using that format so I think it's fine to drop it.
EDIT: After looking at relevant test I see now that it was used to construct strings joined with platform-specific PATH separator but since nothing used that, I still think it's fine to remove.
There was a problem hiding this comment.
Don't quite see why we've allowed a list of strings for the dict value. I don't see this documented in...
These comments are relevant for this #1811 (comment)
There was a problem hiding this comment.
Great digging.
Not sure how I feel about it. Whether should remove or keep and document maybe.
|
This is a quite large diff to review, and I'm not really familiar with this code, so I guess if it's just a refactoring and if CI passes feel free to merge. |
|
I agree, not easy to review. Probably the most important part of that code is the old |
Refactor transports implementation.
This is based on refactoring in #2015 but with quite notable changes:
ClientConfigtransport options - everything is controlled with the same settings as beforeSessionor plugin which transport is used. InsteadTransportWrapperis just an opaque controller for the transport thatSessionsees. Everything is now properly typed - previously we had issues with subprocess types and what not.More detailed description of the changes (AI generated):
plugin/core/transports.py(major rewrite)Transport[T],TransportCallbacks[T_contra],AbstractProcessor[T]are gone. Everything now operates directly onJSONRPCMessage(a concrete type alias).TransportConfigmoved in — previously lived intypes.py; now an abstract base class (ABC) intransports.py, with three concrete subclasses:StdioTransportConfig— stdio-based subprocess transportTcpClientTransportConfig— text editor acts as TCP clientTcpServerTransportConfig— text editor acts as TCP server/listenerProcessTransport→TransportWrapper** — renamed and simplified; no longer generic, drops thesocket/stderrfields, now holds aTransportinstance and anErrorReader.Transportrefactored — now a plain class withread(),write(),close()methods, with two concrete subclasses:FileObjectTransportandSocketTransport.ErrorReaderextracted — stderr/stdout log reading was previously inline inProcessTransport; now a separate class.LaunchConfigadded — small helper encapsulatingcommand+env+ subprocess launch.JsonRpcProcessorremoved — encode/decode promoted to module-levelencode_json/decode_jsonfunctions.create_transport()removed — replaced by the polymorphicTransportConfig.start()dispatch.plugin/core/types.pyTransportConfigandTCP_CONNECT_TIMEOUTremoved (moved totransports.py).plugin/core/sessions.pySessionno longer parameterized:TransportCallbacks['dict[str, Any]']→TransportCallbacks.self.transporttype changed fromTransporttoTransportWrapper._response_handlerskey type widened frominttostr | int(JSON IDs can be strings).deduce_payload/on_payload/response_handlerupdated to useJSONRPCMessageinstead ofdict[str, Any].exit()cleaned up: replaced try/except AttributeError hack with a properif self.transport:guard.plugin/core/windows.py/plugin/tooling.pyTransportConfig.start()API instead of the oldcreate_transport()function.tests/test_protocol.py