2018-09-24 15:24:58 -06:00
|
|
|
package protocol
|
|
|
|
|
2019-11-17 12:29:15 -07:00
|
|
|
// Package protocol contains data types and code for LSP jsonrpcs
|
|
|
|
// generated automatically from vscode-languageserver-node
|
2020-03-09 10:51:18 -06:00
|
|
|
// commit: 151b520c995ee3d76729b5c46258ab273d989726
|
2020-03-30 15:09:42 -06:00
|
|
|
// last fetched Mon Mar 30 2020 21:01:17 GMT-0400 (Eastern Daylight Time)
|
2019-11-17 12:29:15 -07:00
|
|
|
|
2019-05-13 10:27:26 -06:00
|
|
|
// Code generated (see typescript/README.md) DO NOT EDIT.
|
2019-04-23 08:05:23 -06:00
|
|
|
|
2018-09-24 15:24:58 -06:00
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"encoding/json"
|
2020-04-09 20:37:52 -06:00
|
|
|
"fmt"
|
2018-09-24 15:24:58 -06:00
|
|
|
|
|
|
|
"golang.org/x/tools/internal/jsonrpc2"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Client interface {
|
|
|
|
ShowMessage(context.Context, *ShowMessageParams) error
|
|
|
|
LogMessage(context.Context, *LogMessageParams) error
|
2019-04-23 08:05:23 -06:00
|
|
|
Event(context.Context, *interface{}) error
|
|
|
|
PublishDiagnostics(context.Context, *PublishDiagnosticsParams) error
|
2020-03-12 14:31:00 -06:00
|
|
|
Progress(context.Context, *ProgressParams) error
|
2019-11-17 12:29:15 -07:00
|
|
|
WorkspaceFolders(context.Context) ([]WorkspaceFolder /*WorkspaceFolder[] | null*/, error)
|
|
|
|
Configuration(context.Context, *ParamConfiguration) ([]interface{}, error)
|
2020-03-12 14:31:00 -06:00
|
|
|
WorkDoneProgressCreate(context.Context, *WorkDoneProgressCreateParams) error
|
2019-04-23 08:05:23 -06:00
|
|
|
RegisterCapability(context.Context, *RegistrationParams) error
|
|
|
|
UnregisterCapability(context.Context, *UnregistrationParams) error
|
2019-11-17 12:29:15 -07:00
|
|
|
ShowMessageRequest(context.Context, *ShowMessageRequestParams) (*MessageActionItem /*MessageActionItem | null*/, error)
|
2019-04-23 08:05:23 -06:00
|
|
|
ApplyEdit(context.Context, *ApplyWorkspaceEditParams) (*ApplyWorkspaceEditResponse, error)
|
2018-09-24 15:24:58 -06:00
|
|
|
}
|
|
|
|
|
2020-06-06 10:43:59 -06:00
|
|
|
func clientDispatch(ctx context.Context, client Client, reply jsonrpc2.Replier, r jsonrpc2.Request) (bool, error) {
|
|
|
|
switch r.Method() {
|
|
|
|
case "window/showMessage": // notif
|
|
|
|
var params ShowMessageParams
|
|
|
|
if err := json.Unmarshal(r.Params(), ¶ms); err != nil {
|
|
|
|
return true, sendParseError(ctx, reply, err)
|
2020-03-30 15:09:42 -06:00
|
|
|
}
|
2020-06-06 10:43:59 -06:00
|
|
|
err := client.ShowMessage(ctx, ¶ms)
|
|
|
|
return true, reply(ctx, nil, err)
|
|
|
|
case "window/logMessage": // notif
|
|
|
|
var params LogMessageParams
|
|
|
|
if err := json.Unmarshal(r.Params(), ¶ms); err != nil {
|
|
|
|
return true, sendParseError(ctx, reply, err)
|
2020-03-30 15:09:42 -06:00
|
|
|
}
|
2020-06-06 10:43:59 -06:00
|
|
|
err := client.LogMessage(ctx, ¶ms)
|
|
|
|
return true, reply(ctx, nil, err)
|
|
|
|
case "telemetry/event": // notif
|
|
|
|
var params interface{}
|
|
|
|
if err := json.Unmarshal(r.Params(), ¶ms); err != nil {
|
|
|
|
return true, sendParseError(ctx, reply, err)
|
|
|
|
}
|
|
|
|
err := client.Event(ctx, ¶ms)
|
|
|
|
return true, reply(ctx, nil, err)
|
|
|
|
case "textDocument/publishDiagnostics": // notif
|
|
|
|
var params PublishDiagnosticsParams
|
|
|
|
if err := json.Unmarshal(r.Params(), ¶ms); err != nil {
|
|
|
|
return true, sendParseError(ctx, reply, err)
|
|
|
|
}
|
|
|
|
err := client.PublishDiagnostics(ctx, ¶ms)
|
|
|
|
return true, reply(ctx, nil, err)
|
|
|
|
case "$/progress": // notif
|
|
|
|
var params ProgressParams
|
|
|
|
if err := json.Unmarshal(r.Params(), ¶ms); err != nil {
|
|
|
|
return true, sendParseError(ctx, reply, err)
|
|
|
|
}
|
|
|
|
err := client.Progress(ctx, ¶ms)
|
|
|
|
return true, reply(ctx, nil, err)
|
|
|
|
case "workspace/workspaceFolders": // req
|
|
|
|
if len(r.Params()) > 0 {
|
|
|
|
return true, reply(ctx, nil, fmt.Errorf("%w: expected no params", jsonrpc2.ErrInvalidParams))
|
|
|
|
}
|
|
|
|
resp, err := client.WorkspaceFolders(ctx)
|
|
|
|
return true, reply(ctx, resp, err)
|
|
|
|
case "workspace/configuration": // req
|
|
|
|
var params ParamConfiguration
|
|
|
|
if err := json.Unmarshal(r.Params(), ¶ms); err != nil {
|
|
|
|
return true, sendParseError(ctx, reply, err)
|
|
|
|
}
|
|
|
|
resp, err := client.Configuration(ctx, ¶ms)
|
|
|
|
return true, reply(ctx, resp, err)
|
|
|
|
case "window/workDoneProgress/create": // req
|
|
|
|
var params WorkDoneProgressCreateParams
|
|
|
|
if err := json.Unmarshal(r.Params(), ¶ms); err != nil {
|
|
|
|
return true, sendParseError(ctx, reply, err)
|
|
|
|
}
|
|
|
|
err := client.WorkDoneProgressCreate(ctx, ¶ms)
|
|
|
|
return true, reply(ctx, nil, err)
|
|
|
|
case "client/registerCapability": // req
|
|
|
|
var params RegistrationParams
|
|
|
|
if err := json.Unmarshal(r.Params(), ¶ms); err != nil {
|
|
|
|
return true, sendParseError(ctx, reply, err)
|
|
|
|
}
|
|
|
|
err := client.RegisterCapability(ctx, ¶ms)
|
|
|
|
return true, reply(ctx, nil, err)
|
|
|
|
case "client/unregisterCapability": // req
|
|
|
|
var params UnregistrationParams
|
|
|
|
if err := json.Unmarshal(r.Params(), ¶ms); err != nil {
|
|
|
|
return true, sendParseError(ctx, reply, err)
|
|
|
|
}
|
|
|
|
err := client.UnregisterCapability(ctx, ¶ms)
|
|
|
|
return true, reply(ctx, nil, err)
|
|
|
|
case "window/showMessageRequest": // req
|
|
|
|
var params ShowMessageRequestParams
|
|
|
|
if err := json.Unmarshal(r.Params(), ¶ms); err != nil {
|
|
|
|
return true, sendParseError(ctx, reply, err)
|
|
|
|
}
|
|
|
|
resp, err := client.ShowMessageRequest(ctx, ¶ms)
|
|
|
|
return true, reply(ctx, resp, err)
|
|
|
|
case "workspace/applyEdit": // req
|
|
|
|
var params ApplyWorkspaceEditParams
|
|
|
|
if err := json.Unmarshal(r.Params(), ¶ms); err != nil {
|
|
|
|
return true, sendParseError(ctx, reply, err)
|
|
|
|
}
|
|
|
|
resp, err := client.ApplyEdit(ctx, ¶ms)
|
|
|
|
return true, reply(ctx, resp, err)
|
2018-09-24 15:24:58 -06:00
|
|
|
|
2020-06-06 10:43:59 -06:00
|
|
|
default:
|
|
|
|
return false, nil
|
|
|
|
}
|
2018-09-24 15:24:58 -06:00
|
|
|
}
|
|
|
|
|
2019-04-23 08:05:23 -06:00
|
|
|
func (s *clientDispatcher) ShowMessage(ctx context.Context, params *ShowMessageParams) error {
|
|
|
|
return s.Conn.Notify(ctx, "window/showMessage", params)
|
2018-09-24 15:24:58 -06:00
|
|
|
}
|
|
|
|
|
2019-04-23 08:05:23 -06:00
|
|
|
func (s *clientDispatcher) LogMessage(ctx context.Context, params *LogMessageParams) error {
|
|
|
|
return s.Conn.Notify(ctx, "window/logMessage", params)
|
2018-09-24 15:24:58 -06:00
|
|
|
}
|
|
|
|
|
2019-04-23 08:05:23 -06:00
|
|
|
func (s *clientDispatcher) Event(ctx context.Context, params *interface{}) error {
|
|
|
|
return s.Conn.Notify(ctx, "telemetry/event", params)
|
2018-09-24 15:24:58 -06:00
|
|
|
}
|
|
|
|
|
2019-04-23 08:05:23 -06:00
|
|
|
func (s *clientDispatcher) PublishDiagnostics(ctx context.Context, params *PublishDiagnosticsParams) error {
|
|
|
|
return s.Conn.Notify(ctx, "textDocument/publishDiagnostics", params)
|
2018-09-24 15:24:58 -06:00
|
|
|
}
|
2020-03-12 14:31:00 -06:00
|
|
|
|
|
|
|
func (s *clientDispatcher) Progress(ctx context.Context, params *ProgressParams) error {
|
|
|
|
return s.Conn.Notify(ctx, "$/progress", params)
|
|
|
|
}
|
2019-11-17 12:29:15 -07:00
|
|
|
func (s *clientDispatcher) WorkspaceFolders(ctx context.Context) ([]WorkspaceFolder /*WorkspaceFolder[] | null*/, error) {
|
|
|
|
var result []WorkspaceFolder /*WorkspaceFolder[] | null*/
|
2020-04-07 19:35:47 -06:00
|
|
|
if err := Call(ctx, s.Conn, "workspace/workspaceFolders", nil, &result); err != nil {
|
2018-09-24 15:24:58 -06:00
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return result, nil
|
|
|
|
}
|
|
|
|
|
2019-11-17 12:29:15 -07:00
|
|
|
func (s *clientDispatcher) Configuration(ctx context.Context, params *ParamConfiguration) ([]interface{}, error) {
|
2018-09-24 15:24:58 -06:00
|
|
|
var result []interface{}
|
2020-04-07 19:35:47 -06:00
|
|
|
if err := Call(ctx, s.Conn, "workspace/configuration", params, &result); err != nil {
|
2018-09-24 15:24:58 -06:00
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return result, nil
|
|
|
|
}
|
|
|
|
|
2020-03-12 14:31:00 -06:00
|
|
|
func (s *clientDispatcher) WorkDoneProgressCreate(ctx context.Context, params *WorkDoneProgressCreateParams) error {
|
2020-04-07 19:35:47 -06:00
|
|
|
return Call(ctx, s.Conn, "window/workDoneProgress/create", params, nil) // Call, not Notify
|
2020-03-12 14:31:00 -06:00
|
|
|
}
|
|
|
|
|
2019-04-23 08:05:23 -06:00
|
|
|
func (s *clientDispatcher) RegisterCapability(ctx context.Context, params *RegistrationParams) error {
|
2020-04-07 19:35:47 -06:00
|
|
|
return Call(ctx, s.Conn, "client/registerCapability", params, nil) // Call, not Notify
|
2019-04-23 08:05:23 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s *clientDispatcher) UnregisterCapability(ctx context.Context, params *UnregistrationParams) error {
|
2020-04-07 19:35:47 -06:00
|
|
|
return Call(ctx, s.Conn, "client/unregisterCapability", params, nil) // Call, not Notify
|
2019-04-23 08:05:23 -06:00
|
|
|
}
|
|
|
|
|
2019-11-17 12:29:15 -07:00
|
|
|
func (s *clientDispatcher) ShowMessageRequest(ctx context.Context, params *ShowMessageRequestParams) (*MessageActionItem /*MessageActionItem | null*/, error) {
|
2020-03-04 11:29:23 -07:00
|
|
|
var result *MessageActionItem /*MessageActionItem | null*/
|
2020-04-07 19:35:47 -06:00
|
|
|
if err := Call(ctx, s.Conn, "window/showMessageRequest", params, &result); err != nil {
|
2019-04-23 08:05:23 -06:00
|
|
|
return nil, err
|
2018-09-24 15:24:58 -06:00
|
|
|
}
|
2020-03-04 11:29:23 -07:00
|
|
|
return result, nil
|
2018-09-24 15:24:58 -06:00
|
|
|
}
|
|
|
|
|
2019-04-23 08:05:23 -06:00
|
|
|
func (s *clientDispatcher) ApplyEdit(ctx context.Context, params *ApplyWorkspaceEditParams) (*ApplyWorkspaceEditResponse, error) {
|
2020-03-04 11:29:23 -07:00
|
|
|
var result *ApplyWorkspaceEditResponse
|
2020-04-07 19:35:47 -06:00
|
|
|
if err := Call(ctx, s.Conn, "workspace/applyEdit", params, &result); err != nil {
|
2019-04-23 08:05:23 -06:00
|
|
|
return nil, err
|
|
|
|
}
|
2020-03-04 11:29:23 -07:00
|
|
|
return result, nil
|
2018-09-24 15:24:58 -06:00
|
|
|
}
|