Documentation
¶
Index ¶
- func SendNotification[Params any](t *testing.T, c *LSPClient, info lsproto.NotificationInfo[Params], ...)
- func SendRequest[Params, Resp any](t *testing.T, c *LSPClient, info lsproto.RequestInfo[Params, Resp], ...) (*lsproto.Message, Resp, bool)
- func SendRequestAsync[Params, Resp any](t *testing.T, c *LSPClient, info lsproto.RequestInfo[Params, Resp], ...) func() (*lsproto.Message, Resp, bool)
- type LSPClient
- func (c *LSPClient) MessageRouter(ctx context.Context) error
- func (c *LSPClient) NextID() int32
- func (c *LSPClient) SendRequestWorker(t *testing.T, req *lsproto.RequestMessage, reqID *jsonrpc.ID) (*lsproto.ResponseMessage, bool)
- func (c *LSPClient) SetCompilerOptionsForInferredProjects(options *core.CompilerOptions)
- func (c *LSPClient) WriteMsg(t *testing.T, msg *lsproto.Message)
- type LSPReader
- type LSPWriter
- type ServerNotificationHandler
- type ServerRequestHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SendNotification ¶
func SendNotification[Params any](t *testing.T, c *LSPClient, info lsproto.NotificationInfo[Params], params Params)
SendNotification sends a typed notification.
Types ¶
type LSPClient ¶
type LSPClient struct {
Server *lsp.Server
// OnServerNotification handles server-initiated notifications (e.g., $/progress).
// If nil, notifications are ignored.
OnServerNotification ServerNotificationHandler
// contains filtered or unexported fields
}
LSPClient provides infrastructure for communicating with an LSP server in tests.
func NewLSPClient ¶
func NewLSPClient(t *testing.T, serverOpts lsp.ServerOptions, onServerRequest ServerRequestHandler) (*LSPClient, func() error)
NewLSPClient creates an LSPClient wrapping the given server and pipes.
func (*LSPClient) MessageRouter ¶
MessageRouter runs in a goroutine and routes incoming messages from the server. It handles responses to client requests and server-initiated requests. It continues draining the output channel until it is closed (EOF), even after context cancellation, to prevent the server's writeLoop from blocking on a send.
func (*LSPClient) SendRequestWorker ¶
func (c *LSPClient) SendRequestWorker(t *testing.T, req *lsproto.RequestMessage, reqID *jsonrpc.ID) (*lsproto.ResponseMessage, bool)
This is an untyped version of SendRequest. Prefer to use SendRequest when possible.
func (*LSPClient) SetCompilerOptionsForInferredProjects ¶
func (c *LSPClient) SetCompilerOptionsForInferredProjects(options *core.CompilerOptions)
type LSPReader ¶
type LSPReader struct {
// contains filtered or unexported fields
}
LSPReader reads LSP messages from a channel.
type LSPWriter ¶
type LSPWriter struct {
// contains filtered or unexported fields
}
LSPWriter writes LSP messages to a channel.
type ServerNotificationHandler ¶
type ServerNotificationHandler func(ctx context.Context, req *lsproto.RequestMessage)
ServerNotificationHandler handles server-initiated notifications (e.g., $/progress).
type ServerRequestHandler ¶
type ServerRequestHandler func(ctx context.Context, req *lsproto.RequestMessage) *lsproto.ResponseMessage
ServerRequestHandler handles server-initiated requests and returns the response to send back.