1package protocol 2 3// Package protocol contains data types and code for LSP jsonrpcs 4// generated automatically from vscode-languageserver-node 5// commit: 901fd40345060d159f07d234bbc967966a929a34 6// last fetched Mon Oct 26 2020 09:10:42 GMT-0400 (Eastern Daylight Time) 7 8// Code generated (see typescript/README.md) DO NOT EDIT. 9 10import ( 11 "context" 12 "encoding/json" 13 14 "golang.org/x/tools/internal/jsonrpc2" 15 errors "golang.org/x/xerrors" 16) 17 18type Client interface { 19 ShowMessage(context.Context, *ShowMessageParams) error 20 LogMessage(context.Context, *LogMessageParams) error 21 Event(context.Context, *interface{}) error 22 PublishDiagnostics(context.Context, *PublishDiagnosticsParams) error 23 Progress(context.Context, *ProgressParams) error 24 WorkspaceFolders(context.Context) ([]WorkspaceFolder /*WorkspaceFolder[] | null*/, error) 25 Configuration(context.Context, *ParamConfiguration) ([]interface{}, error) 26 WorkDoneProgressCreate(context.Context, *WorkDoneProgressCreateParams) error 27 RegisterCapability(context.Context, *RegistrationParams) error 28 UnregisterCapability(context.Context, *UnregistrationParams) error 29 ShowMessageRequest(context.Context, *ShowMessageRequestParams) (*MessageActionItem /*MessageActionItem | null*/, error) 30 ApplyEdit(context.Context, *ApplyWorkspaceEditParams) (*ApplyWorkspaceEditResponse, error) 31} 32 33func clientDispatch(ctx context.Context, client Client, reply jsonrpc2.Replier, r jsonrpc2.Request) (bool, error) { 34 switch r.Method() { 35 case "window/showMessage": // notif 36 var params ShowMessageParams 37 if err := json.Unmarshal(r.Params(), ¶ms); err != nil { 38 return true, sendParseError(ctx, reply, err) 39 } 40 err := client.ShowMessage(ctx, ¶ms) 41 return true, reply(ctx, nil, err) 42 case "window/logMessage": // notif 43 var params LogMessageParams 44 if err := json.Unmarshal(r.Params(), ¶ms); err != nil { 45 return true, sendParseError(ctx, reply, err) 46 } 47 err := client.LogMessage(ctx, ¶ms) 48 return true, reply(ctx, nil, err) 49 case "telemetry/event": // notif 50 var params interface{} 51 if err := json.Unmarshal(r.Params(), ¶ms); err != nil { 52 return true, sendParseError(ctx, reply, err) 53 } 54 err := client.Event(ctx, ¶ms) 55 return true, reply(ctx, nil, err) 56 case "textDocument/publishDiagnostics": // notif 57 var params PublishDiagnosticsParams 58 if err := json.Unmarshal(r.Params(), ¶ms); err != nil { 59 return true, sendParseError(ctx, reply, err) 60 } 61 err := client.PublishDiagnostics(ctx, ¶ms) 62 return true, reply(ctx, nil, err) 63 case "$/progress": // notif 64 var params ProgressParams 65 if err := json.Unmarshal(r.Params(), ¶ms); err != nil { 66 return true, sendParseError(ctx, reply, err) 67 } 68 err := client.Progress(ctx, ¶ms) 69 return true, reply(ctx, nil, err) 70 case "workspace/workspaceFolders": // req 71 if len(r.Params()) > 0 { 72 return true, reply(ctx, nil, errors.Errorf("%w: expected no params", jsonrpc2.ErrInvalidParams)) 73 } 74 resp, err := client.WorkspaceFolders(ctx) 75 return true, reply(ctx, resp, err) 76 case "workspace/configuration": // req 77 var params ParamConfiguration 78 if err := json.Unmarshal(r.Params(), ¶ms); err != nil { 79 return true, sendParseError(ctx, reply, err) 80 } 81 resp, err := client.Configuration(ctx, ¶ms) 82 return true, reply(ctx, resp, err) 83 case "window/workDoneProgress/create": // req 84 var params WorkDoneProgressCreateParams 85 if err := json.Unmarshal(r.Params(), ¶ms); err != nil { 86 return true, sendParseError(ctx, reply, err) 87 } 88 err := client.WorkDoneProgressCreate(ctx, ¶ms) 89 return true, reply(ctx, nil, err) 90 case "client/registerCapability": // req 91 var params RegistrationParams 92 if err := json.Unmarshal(r.Params(), ¶ms); err != nil { 93 return true, sendParseError(ctx, reply, err) 94 } 95 err := client.RegisterCapability(ctx, ¶ms) 96 return true, reply(ctx, nil, err) 97 case "client/unregisterCapability": // req 98 var params UnregistrationParams 99 if err := json.Unmarshal(r.Params(), ¶ms); err != nil { 100 return true, sendParseError(ctx, reply, err) 101 } 102 err := client.UnregisterCapability(ctx, ¶ms) 103 return true, reply(ctx, nil, err) 104 case "window/showMessageRequest": // req 105 var params ShowMessageRequestParams 106 if err := json.Unmarshal(r.Params(), ¶ms); err != nil { 107 return true, sendParseError(ctx, reply, err) 108 } 109 resp, err := client.ShowMessageRequest(ctx, ¶ms) 110 return true, reply(ctx, resp, err) 111 case "workspace/applyEdit": // req 112 var params ApplyWorkspaceEditParams 113 if err := json.Unmarshal(r.Params(), ¶ms); err != nil { 114 return true, sendParseError(ctx, reply, err) 115 } 116 resp, err := client.ApplyEdit(ctx, ¶ms) 117 return true, reply(ctx, resp, err) 118 119 default: 120 return false, nil 121 } 122} 123 124func (s *clientDispatcher) ShowMessage(ctx context.Context, params *ShowMessageParams) error { 125 return s.Conn.Notify(ctx, "window/showMessage", params) 126} 127 128func (s *clientDispatcher) LogMessage(ctx context.Context, params *LogMessageParams) error { 129 return s.Conn.Notify(ctx, "window/logMessage", params) 130} 131 132func (s *clientDispatcher) Event(ctx context.Context, params *interface{}) error { 133 return s.Conn.Notify(ctx, "telemetry/event", params) 134} 135 136func (s *clientDispatcher) PublishDiagnostics(ctx context.Context, params *PublishDiagnosticsParams) error { 137 return s.Conn.Notify(ctx, "textDocument/publishDiagnostics", params) 138} 139 140func (s *clientDispatcher) Progress(ctx context.Context, params *ProgressParams) error { 141 return s.Conn.Notify(ctx, "$/progress", params) 142} 143func (s *clientDispatcher) WorkspaceFolders(ctx context.Context) ([]WorkspaceFolder /*WorkspaceFolder[] | null*/, error) { 144 var result []WorkspaceFolder /*WorkspaceFolder[] | null*/ 145 if err := Call(ctx, s.Conn, "workspace/workspaceFolders", nil, &result); err != nil { 146 return nil, err 147 } 148 return result, nil 149} 150 151func (s *clientDispatcher) Configuration(ctx context.Context, params *ParamConfiguration) ([]interface{}, error) { 152 var result []interface{} 153 if err := Call(ctx, s.Conn, "workspace/configuration", params, &result); err != nil { 154 return nil, err 155 } 156 return result, nil 157} 158 159func (s *clientDispatcher) WorkDoneProgressCreate(ctx context.Context, params *WorkDoneProgressCreateParams) error { 160 return Call(ctx, s.Conn, "window/workDoneProgress/create", params, nil) // Call, not Notify 161} 162 163func (s *clientDispatcher) RegisterCapability(ctx context.Context, params *RegistrationParams) error { 164 return Call(ctx, s.Conn, "client/registerCapability", params, nil) // Call, not Notify 165} 166 167func (s *clientDispatcher) UnregisterCapability(ctx context.Context, params *UnregistrationParams) error { 168 return Call(ctx, s.Conn, "client/unregisterCapability", params, nil) // Call, not Notify 169} 170 171func (s *clientDispatcher) ShowMessageRequest(ctx context.Context, params *ShowMessageRequestParams) (*MessageActionItem /*MessageActionItem | null*/, error) { 172 var result *MessageActionItem /*MessageActionItem | null*/ 173 if err := Call(ctx, s.Conn, "window/showMessageRequest", params, &result); err != nil { 174 return nil, err 175 } 176 return result, nil 177} 178 179func (s *clientDispatcher) ApplyEdit(ctx context.Context, params *ApplyWorkspaceEditParams) (*ApplyWorkspaceEditResponse, error) { 180 var result *ApplyWorkspaceEditResponse 181 if err := Call(ctx, s.Conn, "workspace/applyEdit", params, &result); err != nil { 182 return nil, err 183 } 184 return result, nil 185} 186