Documentation ¶
Overview ¶
Package lsprpc implements a jsonrpc2.StreamServer that may be used to serve the LSP on a jsonrpc2 channel.
Index ¶
- Constants
- func ConnectToRemote(ctx context.Context, addr string, opts ...RemoteOption) (net.Conn, error)
- func ExecuteCommand(ctx context.Context, addr string, id string, request, result interface{}) error
- func ParseAddr(listen string) (network string, address string)
- type ClientBinder
- type ClientFunc
- type ClientSession
- type ForwardBinder
- type Forwarder
- type RemoteDebugAddress
- type RemoteListenTimeout
- type RemoteLogfile
- type RemoteOption
- type ServerBinder
- type ServerFunc
- type ServerState
- type StreamServer
Constants ¶
const AutoNetwork = "auto"
AutoNetwork is the pseudo network type used to signal that gopls should use automatic discovery to resolve a remote address.
Variables ¶
This section is empty.
Functions ¶
func ConnectToRemote ¶
func ExecuteCommand ¶
Types ¶
type ClientBinder ¶
type ClientBinder struct {
// contains filtered or unexported fields
}
func NewClientBinder ¶
func NewClientBinder(newClient ClientFunc) *ClientBinder
func (*ClientBinder) Bind ¶
func (b *ClientBinder) Bind(ctx context.Context, conn *jsonrpc2_v2.Connection) (jsonrpc2_v2.ConnectionOptions, error)
type ClientSession ¶
type ClientSession struct { SessionID string `json:"sessionID"` Logfile string `json:"logfile"` DebugAddr string `json:"debugAddr"` }
ClientSession identifies a current client LSP session on the server. Note that it looks similar to handshakeResposne, but in fact 'Logfile' and 'DebugAddr' now refer to the client.
type ForwardBinder ¶
type ForwardBinder struct {
// contains filtered or unexported fields
}
func NewForwardBinder ¶
func NewForwardBinder(dialer jsonrpc2_v2.Dialer) *ForwardBinder
func (*ForwardBinder) Bind ¶
func (b *ForwardBinder) Bind(ctx context.Context, conn *jsonrpc2_v2.Connection) (opts jsonrpc2_v2.ConnectionOptions, _ error)
type Forwarder ¶
type Forwarder struct {
// contains filtered or unexported fields
}
A Forwarder is a jsonrpc2.StreamServer that handles an LSP stream by forwarding it to a remote. This is used when the gopls process started by the editor is in the `-remote` mode, which means it finds and connects to a separate gopls daemon. In these cases, we still want the forwarder gopls to be instrumented with telemetry, and want to be able to in some cases hijack the jsonrpc2 connection with the daemon.
func NewForwarder ¶
func NewForwarder(network, addr string, opts ...RemoteOption) *Forwarder
NewForwarder creates a new Forwarder, ready to forward connections to the remote server specified by network and addr.
func (*Forwarder) Binder ¶
func (f *Forwarder) Binder() *ForwardBinder
type RemoteDebugAddress ¶
type RemoteDebugAddress string
RemoteDebugAddress configures the address used by the auto-started Gopls daemon for serving debug information.
type RemoteListenTimeout ¶
RemoteListenTimeout configures the amount of time the auto-started gopls daemon will wait with no client connections before shutting down.
type RemoteLogfile ¶
type RemoteLogfile string
RemoteLogfile configures the logfile location for the auto-started gopls daemon.
type RemoteOption ¶
type RemoteOption interface {
// contains filtered or unexported methods
}
A RemoteOption configures the behavior of the auto-started remote.
type ServerBinder ¶
type ServerBinder struct {
// contains filtered or unexported fields
}
ServerBinder binds incoming connections to a new server.
func NewServerBinder ¶
func NewServerBinder(newServer ServerFunc) *ServerBinder
func (*ServerBinder) Bind ¶
func (b *ServerBinder) Bind(ctx context.Context, conn *jsonrpc2_v2.Connection) (jsonrpc2_v2.ConnectionOptions, error)
type ServerFunc ¶
type ServerState ¶
type ServerState struct { Logfile string `json:"logfile"` DebugAddr string `json:"debugAddr"` GoplsPath string `json:"goplsPath"` CurrentClientID string `json:"currentClientID"` Clients []ClientSession `json:"clients"` }
ServerState holds information about the gopls daemon process, including its debug information and debug information of all of its current connected clients.
func QueryServerState ¶
func QueryServerState(ctx context.Context, addr string) (*ServerState, error)
QueryServerState queries the server state of the current server.
type StreamServer ¶
type StreamServer struct {
// contains filtered or unexported fields
}
The StreamServer type is a jsonrpc2.StreamServer that handles incoming streams as a new LSP session, using a shared cache.
func NewStreamServer ¶
func NewStreamServer(cache *cache.Cache, daemon bool) *StreamServer
NewStreamServer creates a StreamServer using the shared cache. If withTelemetry is true, each session is instrumented with telemetry that records RPC statistics.
func (*StreamServer) Binder ¶
func (s *StreamServer) Binder() *ServerBinder
func (*StreamServer) ServeStream ¶
ServeStream implements the jsonrpc2.StreamServer interface, by handling incoming streams using a new lsp server.