Documentation
¶
Index ¶
- type Connection
- func (c *Connection) Call(ctx context.Context, method string, params any, result any) error
- func (c *Connection) Close() error
- func (c *Connection) IsConnected() bool
- func (c *Connection) Notify(ctx context.Context, method string, params any) error
- func (c *Connection) RegisterHandler(method string, handler Handler)
- func (c *Connection) RegisterNotificationHandler(method string, handler NotificationHandler)
- type Handler
- type Message
- type MessageType
- type NotificationHandler
- type Router
- type StreamTransport
- type Transport
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
Connection represents a managed connection to a language server.
func NewConnection ¶
func NewConnection(ctx context.Context, stream io.ReadWriteCloser, logger *slog.Logger) (*Connection, error)
NewConnection creates a new managed connection.
func (*Connection) IsConnected ¶
func (c *Connection) IsConnected() bool
IsConnected returns true if the connection is still active.
func (*Connection) RegisterHandler ¶
func (c *Connection) RegisterHandler(method string, handler Handler)
RegisterHandler registers a handler for a specific method.
func (*Connection) RegisterNotificationHandler ¶
func (c *Connection) RegisterNotificationHandler(method string, handler NotificationHandler)
RegisterNotificationHandler registers a notification handler.
type Message ¶
type Message struct {
JSONRPC string `json:"jsonrpc"`
ID *jsonrpc2.ID `json:"id,omitempty"`
Method string `json:"method,omitempty"`
Params json.RawMessage `json:"params,omitempty"`
Result json.RawMessage `json:"result,omitempty"`
Error *jsonrpc2.Error `json:"error,omitempty"`
}
Message represents a JSON-RPC message.
type MessageType ¶
type MessageType int
MessageType represents the type of a JSON-RPC message.
const ( // RequestMessage is a request that expects a response. RequestMessage MessageType = iota // NotificationMessage is a notification that doesn't expect a response. NotificationMessage // ResponseMessage is a response to a request. ResponseMessage // ErrorMessage is an error response. ErrorMessage )
func ParseMessageType ¶
func ParseMessageType(msg *Message) MessageType
ParseMessageType determines the type of a JSON-RPC message.
type NotificationHandler ¶
type NotificationHandler func(ctx context.Context, method string, params json.RawMessage)
NotificationHandler is a function that handles incoming notifications.
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
Router routes incoming messages to appropriate handlers.
func (*Router) HandleNotification ¶
func (r *Router) HandleNotification(method string, handler NotificationHandler)
HandleNotification registers a notification handler for a specific method.
func (*Router) SetDefaultHandler ¶
SetDefaultHandler sets the default handler for unregistered methods.
type StreamTransport ¶
type StreamTransport struct {
// contains filtered or unexported fields
}
StreamTransport provides a bidirectional stream for JSON-RPC communication.
func NewStreamTransport ¶
NewStreamTransport creates a new stream transport.
func (*StreamTransport) ObjectStream ¶
func (s *StreamTransport) ObjectStream() jsonrpc2.ObjectStream
ObjectStream creates a jsonrpc2.ObjectStream from the transport.
type Transport ¶
type Transport struct {
// contains filtered or unexported fields
}
Transport handles the low-level communication with the language server.
func NewWithConn ¶
NewWithConn creates a new transport with an existing JSON-RPC connection.