1fd4e5da5Sopenharmony_ci// Copyright 2019 The Go Authors.
2fd4e5da5Sopenharmony_ci//
3fd4e5da5Sopenharmony_ci// Licensed under the Apache License, Version 2.0 (the "License");
4fd4e5da5Sopenharmony_ci// you may not use this file except in compliance with the License.
5fd4e5da5Sopenharmony_ci// You may obtain a copy of the License at
6fd4e5da5Sopenharmony_ci//
7fd4e5da5Sopenharmony_ci//     http://www.apache.org/licenses/LICENSE-2.0
8fd4e5da5Sopenharmony_ci//
9fd4e5da5Sopenharmony_ci// Unless required by applicable law or agreed to in writing, software
10fd4e5da5Sopenharmony_ci// distributed under the License is distributed on an "AS IS" BASIS,
11fd4e5da5Sopenharmony_ci// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12fd4e5da5Sopenharmony_ci// See the License for the specific language governing permissions and
13fd4e5da5Sopenharmony_ci// limitations under the License.
14fd4e5da5Sopenharmony_ci
15fd4e5da5Sopenharmony_cipackage protocol
16fd4e5da5Sopenharmony_ci
17fd4e5da5Sopenharmony_ciimport (
18fd4e5da5Sopenharmony_ci	"context"
19fd4e5da5Sopenharmony_ci	"encoding/json"
20fd4e5da5Sopenharmony_ci	"log"
21fd4e5da5Sopenharmony_ci
22fd4e5da5Sopenharmony_ci	"github.com/KhronosGroup/SPIRV-Tools/utils/vscode/src/lsp/jsonrpc2"
23fd4e5da5Sopenharmony_ci)
24fd4e5da5Sopenharmony_ci
25fd4e5da5Sopenharmony_citype Server interface {
26fd4e5da5Sopenharmony_ci	DidChangeWorkspaceFolders(context.Context, *DidChangeWorkspaceFoldersParams) error
27fd4e5da5Sopenharmony_ci	Initialized(context.Context, *InitializedParams) error
28fd4e5da5Sopenharmony_ci	Exit(context.Context) error
29fd4e5da5Sopenharmony_ci	DidChangeConfiguration(context.Context, *DidChangeConfigurationParams) error
30fd4e5da5Sopenharmony_ci	DidOpen(context.Context, *DidOpenTextDocumentParams) error
31fd4e5da5Sopenharmony_ci	DidChange(context.Context, *DidChangeTextDocumentParams) error
32fd4e5da5Sopenharmony_ci	DidClose(context.Context, *DidCloseTextDocumentParams) error
33fd4e5da5Sopenharmony_ci	DidSave(context.Context, *DidSaveTextDocumentParams) error
34fd4e5da5Sopenharmony_ci	WillSave(context.Context, *WillSaveTextDocumentParams) error
35fd4e5da5Sopenharmony_ci	DidChangeWatchedFiles(context.Context, *DidChangeWatchedFilesParams) error
36fd4e5da5Sopenharmony_ci	Progress(context.Context, *ProgressParams) error
37fd4e5da5Sopenharmony_ci	SetTraceNotification(context.Context, *SetTraceParams) error
38fd4e5da5Sopenharmony_ci	LogTraceNotification(context.Context, *LogTraceParams) error
39fd4e5da5Sopenharmony_ci	Implementation(context.Context, *ImplementationParams) ([]Location, error)
40fd4e5da5Sopenharmony_ci	TypeDefinition(context.Context, *TypeDefinitionParams) ([]Location, error)
41fd4e5da5Sopenharmony_ci	DocumentColor(context.Context, *DocumentColorParams) ([]ColorInformation, error)
42fd4e5da5Sopenharmony_ci	ColorPresentation(context.Context, *ColorPresentationParams) ([]ColorPresentation, error)
43fd4e5da5Sopenharmony_ci	FoldingRange(context.Context, *FoldingRangeParams) ([]FoldingRange, error)
44fd4e5da5Sopenharmony_ci	Declaration(context.Context, *DeclarationParams) ([]DeclarationLink, error)
45fd4e5da5Sopenharmony_ci	SelectionRange(context.Context, *SelectionRangeParams) ([]SelectionRange, error)
46fd4e5da5Sopenharmony_ci	Initialize(context.Context, *ParamInitia) (*InitializeResult, error)
47fd4e5da5Sopenharmony_ci	Shutdown(context.Context) error
48fd4e5da5Sopenharmony_ci	WillSaveWaitUntil(context.Context, *WillSaveTextDocumentParams) ([]TextEdit, error)
49fd4e5da5Sopenharmony_ci	Completion(context.Context, *CompletionParams) (*CompletionList, error)
50fd4e5da5Sopenharmony_ci	Resolve(context.Context, *CompletionItem) (*CompletionItem, error)
51fd4e5da5Sopenharmony_ci	Hover(context.Context, *HoverParams) (*Hover, error)
52fd4e5da5Sopenharmony_ci	SignatureHelp(context.Context, *SignatureHelpParams) (*SignatureHelp, error)
53fd4e5da5Sopenharmony_ci	Definition(context.Context, *DefinitionParams) ([]Location, error)
54fd4e5da5Sopenharmony_ci	References(context.Context, *ReferenceParams) ([]Location, error)
55fd4e5da5Sopenharmony_ci	DocumentHighlight(context.Context, *DocumentHighlightParams) ([]DocumentHighlight, error)
56fd4e5da5Sopenharmony_ci	DocumentSymbol(context.Context, *DocumentSymbolParams) ([]DocumentSymbol, error)
57fd4e5da5Sopenharmony_ci	CodeAction(context.Context, *CodeActionParams) ([]CodeAction, error)
58fd4e5da5Sopenharmony_ci	Symbol(context.Context, *WorkspaceSymbolParams) ([]SymbolInformation, error)
59fd4e5da5Sopenharmony_ci	CodeLens(context.Context, *CodeLensParams) ([]CodeLens, error)
60fd4e5da5Sopenharmony_ci	ResolveCodeLens(context.Context, *CodeLens) (*CodeLens, error)
61fd4e5da5Sopenharmony_ci	DocumentLink(context.Context, *DocumentLinkParams) ([]DocumentLink, error)
62fd4e5da5Sopenharmony_ci	ResolveDocumentLink(context.Context, *DocumentLink) (*DocumentLink, error)
63fd4e5da5Sopenharmony_ci	Formatting(context.Context, *DocumentFormattingParams) ([]TextEdit, error)
64fd4e5da5Sopenharmony_ci	RangeFormatting(context.Context, *DocumentRangeFormattingParams) ([]TextEdit, error)
65fd4e5da5Sopenharmony_ci	OnTypeFormatting(context.Context, *DocumentOnTypeFormattingParams) ([]TextEdit, error)
66fd4e5da5Sopenharmony_ci	Rename(context.Context, *RenameParams) (*WorkspaceEdit, error)
67fd4e5da5Sopenharmony_ci	PrepareRename(context.Context, *PrepareRenameParams) (*Range, error)
68fd4e5da5Sopenharmony_ci	ExecuteCommand(context.Context, *ExecuteCommandParams) (interface{}, error)
69fd4e5da5Sopenharmony_ci}
70fd4e5da5Sopenharmony_ci
71fd4e5da5Sopenharmony_cifunc (h serverHandler) Deliver(ctx context.Context, r *jsonrpc2.Request, delivered bool) bool {
72fd4e5da5Sopenharmony_ci	if delivered {
73fd4e5da5Sopenharmony_ci		return false
74fd4e5da5Sopenharmony_ci	}
75fd4e5da5Sopenharmony_ci	if ctx.Err() != nil {
76fd4e5da5Sopenharmony_ci		r.Reply(ctx, nil, jsonrpc2.NewErrorf(RequestCancelledError, ""))
77fd4e5da5Sopenharmony_ci		return true
78fd4e5da5Sopenharmony_ci	}
79fd4e5da5Sopenharmony_ci	switch r.Method {
80fd4e5da5Sopenharmony_ci	case "workspace/didChangeWorkspaceFolders": // notif
81fd4e5da5Sopenharmony_ci		var params DidChangeWorkspaceFoldersParams
82fd4e5da5Sopenharmony_ci		if err := json.Unmarshal(*r.Params, &params); err != nil {
83fd4e5da5Sopenharmony_ci			sendParseError(ctx, r, err)
84fd4e5da5Sopenharmony_ci			return true
85fd4e5da5Sopenharmony_ci		}
86fd4e5da5Sopenharmony_ci		if err := h.server.DidChangeWorkspaceFolders(ctx, &params); err != nil {
87fd4e5da5Sopenharmony_ci			log.Printf("%v", err)
88fd4e5da5Sopenharmony_ci		}
89fd4e5da5Sopenharmony_ci		return true
90fd4e5da5Sopenharmony_ci	case "initialized": // notif
91fd4e5da5Sopenharmony_ci		var params InitializedParams
92fd4e5da5Sopenharmony_ci		if err := json.Unmarshal(*r.Params, &params); err != nil {
93fd4e5da5Sopenharmony_ci			sendParseError(ctx, r, err)
94fd4e5da5Sopenharmony_ci			return true
95fd4e5da5Sopenharmony_ci		}
96fd4e5da5Sopenharmony_ci		if err := h.server.Initialized(ctx, &params); err != nil {
97fd4e5da5Sopenharmony_ci			log.Printf("%v", err)
98fd4e5da5Sopenharmony_ci		}
99fd4e5da5Sopenharmony_ci		return true
100fd4e5da5Sopenharmony_ci	case "exit": // notif
101fd4e5da5Sopenharmony_ci		if err := h.server.Exit(ctx); err != nil {
102fd4e5da5Sopenharmony_ci			log.Printf("%v", err)
103fd4e5da5Sopenharmony_ci		}
104fd4e5da5Sopenharmony_ci		return true
105fd4e5da5Sopenharmony_ci	case "workspace/didChangeConfiguration": // notif
106fd4e5da5Sopenharmony_ci		var params DidChangeConfigurationParams
107fd4e5da5Sopenharmony_ci		if err := json.Unmarshal(*r.Params, &params); err != nil {
108fd4e5da5Sopenharmony_ci			sendParseError(ctx, r, err)
109fd4e5da5Sopenharmony_ci			return true
110fd4e5da5Sopenharmony_ci		}
111fd4e5da5Sopenharmony_ci		if err := h.server.DidChangeConfiguration(ctx, &params); err != nil {
112fd4e5da5Sopenharmony_ci			log.Printf("%v", err)
113fd4e5da5Sopenharmony_ci		}
114fd4e5da5Sopenharmony_ci		return true
115fd4e5da5Sopenharmony_ci	case "textDocument/didOpen": // notif
116fd4e5da5Sopenharmony_ci		var params DidOpenTextDocumentParams
117fd4e5da5Sopenharmony_ci		if err := json.Unmarshal(*r.Params, &params); err != nil {
118fd4e5da5Sopenharmony_ci			sendParseError(ctx, r, err)
119fd4e5da5Sopenharmony_ci			return true
120fd4e5da5Sopenharmony_ci		}
121fd4e5da5Sopenharmony_ci		if err := h.server.DidOpen(ctx, &params); err != nil {
122fd4e5da5Sopenharmony_ci			log.Printf("%v", err)
123fd4e5da5Sopenharmony_ci		}
124fd4e5da5Sopenharmony_ci		return true
125fd4e5da5Sopenharmony_ci	case "textDocument/didChange": // notif
126fd4e5da5Sopenharmony_ci		var params DidChangeTextDocumentParams
127fd4e5da5Sopenharmony_ci		if err := json.Unmarshal(*r.Params, &params); err != nil {
128fd4e5da5Sopenharmony_ci			sendParseError(ctx, r, err)
129fd4e5da5Sopenharmony_ci			return true
130fd4e5da5Sopenharmony_ci		}
131fd4e5da5Sopenharmony_ci		if err := h.server.DidChange(ctx, &params); err != nil {
132fd4e5da5Sopenharmony_ci			log.Printf("%v", err)
133fd4e5da5Sopenharmony_ci		}
134fd4e5da5Sopenharmony_ci		return true
135fd4e5da5Sopenharmony_ci	case "textDocument/didClose": // notif
136fd4e5da5Sopenharmony_ci		var params DidCloseTextDocumentParams
137fd4e5da5Sopenharmony_ci		if err := json.Unmarshal(*r.Params, &params); err != nil {
138fd4e5da5Sopenharmony_ci			sendParseError(ctx, r, err)
139fd4e5da5Sopenharmony_ci			return true
140fd4e5da5Sopenharmony_ci		}
141fd4e5da5Sopenharmony_ci		if err := h.server.DidClose(ctx, &params); err != nil {
142fd4e5da5Sopenharmony_ci			log.Printf("%v", err)
143fd4e5da5Sopenharmony_ci		}
144fd4e5da5Sopenharmony_ci		return true
145fd4e5da5Sopenharmony_ci	case "textDocument/didSave": // notif
146fd4e5da5Sopenharmony_ci		var params DidSaveTextDocumentParams
147fd4e5da5Sopenharmony_ci		if err := json.Unmarshal(*r.Params, &params); err != nil {
148fd4e5da5Sopenharmony_ci			sendParseError(ctx, r, err)
149fd4e5da5Sopenharmony_ci			return true
150fd4e5da5Sopenharmony_ci		}
151fd4e5da5Sopenharmony_ci		if err := h.server.DidSave(ctx, &params); err != nil {
152fd4e5da5Sopenharmony_ci			log.Printf("%v", err)
153fd4e5da5Sopenharmony_ci		}
154fd4e5da5Sopenharmony_ci		return true
155fd4e5da5Sopenharmony_ci	case "textDocument/willSave": // notif
156fd4e5da5Sopenharmony_ci		var params WillSaveTextDocumentParams
157fd4e5da5Sopenharmony_ci		if err := json.Unmarshal(*r.Params, &params); err != nil {
158fd4e5da5Sopenharmony_ci			sendParseError(ctx, r, err)
159fd4e5da5Sopenharmony_ci			return true
160fd4e5da5Sopenharmony_ci		}
161fd4e5da5Sopenharmony_ci		if err := h.server.WillSave(ctx, &params); err != nil {
162fd4e5da5Sopenharmony_ci			log.Printf("%v", err)
163fd4e5da5Sopenharmony_ci		}
164fd4e5da5Sopenharmony_ci		return true
165fd4e5da5Sopenharmony_ci	case "workspace/didChangeWatchedFiles": // notif
166fd4e5da5Sopenharmony_ci		var params DidChangeWatchedFilesParams
167fd4e5da5Sopenharmony_ci		if err := json.Unmarshal(*r.Params, &params); err != nil {
168fd4e5da5Sopenharmony_ci			sendParseError(ctx, r, err)
169fd4e5da5Sopenharmony_ci			return true
170fd4e5da5Sopenharmony_ci		}
171fd4e5da5Sopenharmony_ci		if err := h.server.DidChangeWatchedFiles(ctx, &params); err != nil {
172fd4e5da5Sopenharmony_ci			log.Printf("%v", err)
173fd4e5da5Sopenharmony_ci		}
174fd4e5da5Sopenharmony_ci		return true
175fd4e5da5Sopenharmony_ci	case "$/progress": // notif
176fd4e5da5Sopenharmony_ci		var params ProgressParams
177fd4e5da5Sopenharmony_ci		if err := json.Unmarshal(*r.Params, &params); err != nil {
178fd4e5da5Sopenharmony_ci			sendParseError(ctx, r, err)
179fd4e5da5Sopenharmony_ci			return true
180fd4e5da5Sopenharmony_ci		}
181fd4e5da5Sopenharmony_ci		if err := h.server.Progress(ctx, &params); err != nil {
182fd4e5da5Sopenharmony_ci			log.Printf("%v", err)
183fd4e5da5Sopenharmony_ci		}
184fd4e5da5Sopenharmony_ci		return true
185fd4e5da5Sopenharmony_ci	case "$/setTraceNotification": // notif
186fd4e5da5Sopenharmony_ci		var params SetTraceParams
187fd4e5da5Sopenharmony_ci		if err := json.Unmarshal(*r.Params, &params); err != nil {
188fd4e5da5Sopenharmony_ci			sendParseError(ctx, r, err)
189fd4e5da5Sopenharmony_ci			return true
190fd4e5da5Sopenharmony_ci		}
191fd4e5da5Sopenharmony_ci		if err := h.server.SetTraceNotification(ctx, &params); err != nil {
192fd4e5da5Sopenharmony_ci			log.Printf("%v", err)
193fd4e5da5Sopenharmony_ci		}
194fd4e5da5Sopenharmony_ci		return true
195fd4e5da5Sopenharmony_ci	case "$/logTraceNotification": // notif
196fd4e5da5Sopenharmony_ci		var params LogTraceParams
197fd4e5da5Sopenharmony_ci		if err := json.Unmarshal(*r.Params, &params); err != nil {
198fd4e5da5Sopenharmony_ci			sendParseError(ctx, r, err)
199fd4e5da5Sopenharmony_ci			return true
200fd4e5da5Sopenharmony_ci		}
201fd4e5da5Sopenharmony_ci		if err := h.server.LogTraceNotification(ctx, &params); err != nil {
202fd4e5da5Sopenharmony_ci			log.Printf("%v", err)
203fd4e5da5Sopenharmony_ci		}
204fd4e5da5Sopenharmony_ci		return true
205fd4e5da5Sopenharmony_ci	case "textDocument/implementation": // req
206fd4e5da5Sopenharmony_ci		var params ImplementationParams
207fd4e5da5Sopenharmony_ci		if err := json.Unmarshal(*r.Params, &params); err != nil {
208fd4e5da5Sopenharmony_ci			sendParseError(ctx, r, err)
209fd4e5da5Sopenharmony_ci			return true
210fd4e5da5Sopenharmony_ci		}
211fd4e5da5Sopenharmony_ci		resp, err := h.server.Implementation(ctx, &params)
212fd4e5da5Sopenharmony_ci		if err := r.Reply(ctx, resp, err); err != nil {
213fd4e5da5Sopenharmony_ci			log.Printf("%v", err)
214fd4e5da5Sopenharmony_ci		}
215fd4e5da5Sopenharmony_ci		return true
216fd4e5da5Sopenharmony_ci	case "textDocument/typeDefinition": // req
217fd4e5da5Sopenharmony_ci		var params TypeDefinitionParams
218fd4e5da5Sopenharmony_ci		if err := json.Unmarshal(*r.Params, &params); err != nil {
219fd4e5da5Sopenharmony_ci			sendParseError(ctx, r, err)
220fd4e5da5Sopenharmony_ci			return true
221fd4e5da5Sopenharmony_ci		}
222fd4e5da5Sopenharmony_ci		resp, err := h.server.TypeDefinition(ctx, &params)
223fd4e5da5Sopenharmony_ci		if err := r.Reply(ctx, resp, err); err != nil {
224fd4e5da5Sopenharmony_ci			log.Printf("%v", err)
225fd4e5da5Sopenharmony_ci		}
226fd4e5da5Sopenharmony_ci		return true
227fd4e5da5Sopenharmony_ci	case "textDocument/documentColor": // req
228fd4e5da5Sopenharmony_ci		var params DocumentColorParams
229fd4e5da5Sopenharmony_ci		if err := json.Unmarshal(*r.Params, &params); err != nil {
230fd4e5da5Sopenharmony_ci			sendParseError(ctx, r, err)
231fd4e5da5Sopenharmony_ci			return true
232fd4e5da5Sopenharmony_ci		}
233fd4e5da5Sopenharmony_ci		resp, err := h.server.DocumentColor(ctx, &params)
234fd4e5da5Sopenharmony_ci		if err := r.Reply(ctx, resp, err); err != nil {
235fd4e5da5Sopenharmony_ci			log.Printf("%v", err)
236fd4e5da5Sopenharmony_ci		}
237fd4e5da5Sopenharmony_ci		return true
238fd4e5da5Sopenharmony_ci	case "textDocument/colorPresentation": // req
239fd4e5da5Sopenharmony_ci		var params ColorPresentationParams
240fd4e5da5Sopenharmony_ci		if err := json.Unmarshal(*r.Params, &params); err != nil {
241fd4e5da5Sopenharmony_ci			sendParseError(ctx, r, err)
242fd4e5da5Sopenharmony_ci			return true
243fd4e5da5Sopenharmony_ci		}
244fd4e5da5Sopenharmony_ci		resp, err := h.server.ColorPresentation(ctx, &params)
245fd4e5da5Sopenharmony_ci		if err := r.Reply(ctx, resp, err); err != nil {
246fd4e5da5Sopenharmony_ci			log.Printf("%v", err)
247fd4e5da5Sopenharmony_ci		}
248fd4e5da5Sopenharmony_ci		return true
249fd4e5da5Sopenharmony_ci	case "textDocument/foldingRange": // req
250fd4e5da5Sopenharmony_ci		var params FoldingRangeParams
251fd4e5da5Sopenharmony_ci		if err := json.Unmarshal(*r.Params, &params); err != nil {
252fd4e5da5Sopenharmony_ci			sendParseError(ctx, r, err)
253fd4e5da5Sopenharmony_ci			return true
254fd4e5da5Sopenharmony_ci		}
255fd4e5da5Sopenharmony_ci		resp, err := h.server.FoldingRange(ctx, &params)
256fd4e5da5Sopenharmony_ci		if err := r.Reply(ctx, resp, err); err != nil {
257fd4e5da5Sopenharmony_ci			log.Printf("%v", err)
258fd4e5da5Sopenharmony_ci		}
259fd4e5da5Sopenharmony_ci		return true
260fd4e5da5Sopenharmony_ci	case "textDocument/declaration": // req
261fd4e5da5Sopenharmony_ci		var params DeclarationParams
262fd4e5da5Sopenharmony_ci		if err := json.Unmarshal(*r.Params, &params); err != nil {
263fd4e5da5Sopenharmony_ci			sendParseError(ctx, r, err)
264fd4e5da5Sopenharmony_ci			return true
265fd4e5da5Sopenharmony_ci		}
266fd4e5da5Sopenharmony_ci		resp, err := h.server.Declaration(ctx, &params)
267fd4e5da5Sopenharmony_ci		if err := r.Reply(ctx, resp, err); err != nil {
268fd4e5da5Sopenharmony_ci			log.Printf("%v", err)
269fd4e5da5Sopenharmony_ci		}
270fd4e5da5Sopenharmony_ci		return true
271fd4e5da5Sopenharmony_ci	case "textDocument/selectionRange": // req
272fd4e5da5Sopenharmony_ci		var params SelectionRangeParams
273fd4e5da5Sopenharmony_ci		if err := json.Unmarshal(*r.Params, &params); err != nil {
274fd4e5da5Sopenharmony_ci			sendParseError(ctx, r, err)
275fd4e5da5Sopenharmony_ci			return true
276fd4e5da5Sopenharmony_ci		}
277fd4e5da5Sopenharmony_ci		resp, err := h.server.SelectionRange(ctx, &params)
278fd4e5da5Sopenharmony_ci		if err := r.Reply(ctx, resp, err); err != nil {
279fd4e5da5Sopenharmony_ci			log.Printf("%v", err)
280fd4e5da5Sopenharmony_ci		}
281fd4e5da5Sopenharmony_ci		return true
282fd4e5da5Sopenharmony_ci	case "initialize": // req
283fd4e5da5Sopenharmony_ci		var params ParamInitia
284fd4e5da5Sopenharmony_ci		if err := json.Unmarshal(*r.Params, &params); err != nil {
285fd4e5da5Sopenharmony_ci			sendParseError(ctx, r, err)
286fd4e5da5Sopenharmony_ci			return true
287fd4e5da5Sopenharmony_ci		}
288fd4e5da5Sopenharmony_ci		resp, err := h.server.Initialize(ctx, &params)
289fd4e5da5Sopenharmony_ci		if err := r.Reply(ctx, resp, err); err != nil {
290fd4e5da5Sopenharmony_ci			log.Printf("%v", err)
291fd4e5da5Sopenharmony_ci		}
292fd4e5da5Sopenharmony_ci		return true
293fd4e5da5Sopenharmony_ci	case "shutdown": // req
294fd4e5da5Sopenharmony_ci		if r.Params != nil {
295fd4e5da5Sopenharmony_ci			r.Reply(ctx, nil, jsonrpc2.NewErrorf(jsonrpc2.CodeInvalidParams, "Expected no params"))
296fd4e5da5Sopenharmony_ci			return true
297fd4e5da5Sopenharmony_ci		}
298fd4e5da5Sopenharmony_ci		err := h.server.Shutdown(ctx)
299fd4e5da5Sopenharmony_ci		if err := r.Reply(ctx, nil, err); err != nil {
300fd4e5da5Sopenharmony_ci			log.Printf("%v", err)
301fd4e5da5Sopenharmony_ci		}
302fd4e5da5Sopenharmony_ci		return true
303fd4e5da5Sopenharmony_ci	case "textDocument/willSaveWaitUntil": // req
304fd4e5da5Sopenharmony_ci		var params WillSaveTextDocumentParams
305fd4e5da5Sopenharmony_ci		if err := json.Unmarshal(*r.Params, &params); err != nil {
306fd4e5da5Sopenharmony_ci			sendParseError(ctx, r, err)
307fd4e5da5Sopenharmony_ci			return true
308fd4e5da5Sopenharmony_ci		}
309fd4e5da5Sopenharmony_ci		resp, err := h.server.WillSaveWaitUntil(ctx, &params)
310fd4e5da5Sopenharmony_ci		if err := r.Reply(ctx, resp, err); err != nil {
311fd4e5da5Sopenharmony_ci			log.Printf("%v", err)
312fd4e5da5Sopenharmony_ci		}
313fd4e5da5Sopenharmony_ci		return true
314fd4e5da5Sopenharmony_ci	case "textDocument/completion": // req
315fd4e5da5Sopenharmony_ci		var params CompletionParams
316fd4e5da5Sopenharmony_ci		if err := json.Unmarshal(*r.Params, &params); err != nil {
317fd4e5da5Sopenharmony_ci			sendParseError(ctx, r, err)
318fd4e5da5Sopenharmony_ci			return true
319fd4e5da5Sopenharmony_ci		}
320fd4e5da5Sopenharmony_ci		resp, err := h.server.Completion(ctx, &params)
321fd4e5da5Sopenharmony_ci		if err := r.Reply(ctx, resp, err); err != nil {
322fd4e5da5Sopenharmony_ci			log.Printf("%v", err)
323fd4e5da5Sopenharmony_ci		}
324fd4e5da5Sopenharmony_ci		return true
325fd4e5da5Sopenharmony_ci	case "completionItem/resolve": // req
326fd4e5da5Sopenharmony_ci		var params CompletionItem
327fd4e5da5Sopenharmony_ci		if err := json.Unmarshal(*r.Params, &params); err != nil {
328fd4e5da5Sopenharmony_ci			sendParseError(ctx, r, err)
329fd4e5da5Sopenharmony_ci			return true
330fd4e5da5Sopenharmony_ci		}
331fd4e5da5Sopenharmony_ci		resp, err := h.server.Resolve(ctx, &params)
332fd4e5da5Sopenharmony_ci		if err := r.Reply(ctx, resp, err); err != nil {
333fd4e5da5Sopenharmony_ci			log.Printf("%v", err)
334fd4e5da5Sopenharmony_ci		}
335fd4e5da5Sopenharmony_ci		return true
336fd4e5da5Sopenharmony_ci	case "textDocument/hover": // req
337fd4e5da5Sopenharmony_ci		var params HoverParams
338fd4e5da5Sopenharmony_ci		if err := json.Unmarshal(*r.Params, &params); err != nil {
339fd4e5da5Sopenharmony_ci			sendParseError(ctx, r, err)
340fd4e5da5Sopenharmony_ci			return true
341fd4e5da5Sopenharmony_ci		}
342fd4e5da5Sopenharmony_ci		resp, err := h.server.Hover(ctx, &params)
343fd4e5da5Sopenharmony_ci		if err := r.Reply(ctx, resp, err); err != nil {
344fd4e5da5Sopenharmony_ci			log.Printf("%v", err)
345fd4e5da5Sopenharmony_ci		}
346fd4e5da5Sopenharmony_ci		return true
347fd4e5da5Sopenharmony_ci	case "textDocument/signatureHelp": // req
348fd4e5da5Sopenharmony_ci		var params SignatureHelpParams
349fd4e5da5Sopenharmony_ci		if err := json.Unmarshal(*r.Params, &params); err != nil {
350fd4e5da5Sopenharmony_ci			sendParseError(ctx, r, err)
351fd4e5da5Sopenharmony_ci			return true
352fd4e5da5Sopenharmony_ci		}
353fd4e5da5Sopenharmony_ci		resp, err := h.server.SignatureHelp(ctx, &params)
354fd4e5da5Sopenharmony_ci		if err := r.Reply(ctx, resp, err); err != nil {
355fd4e5da5Sopenharmony_ci			log.Printf("%v", err)
356fd4e5da5Sopenharmony_ci		}
357fd4e5da5Sopenharmony_ci		return true
358fd4e5da5Sopenharmony_ci	case "textDocument/definition": // req
359fd4e5da5Sopenharmony_ci		var params DefinitionParams
360fd4e5da5Sopenharmony_ci		if err := json.Unmarshal(*r.Params, &params); err != nil {
361fd4e5da5Sopenharmony_ci			sendParseError(ctx, r, err)
362fd4e5da5Sopenharmony_ci			return true
363fd4e5da5Sopenharmony_ci		}
364fd4e5da5Sopenharmony_ci		resp, err := h.server.Definition(ctx, &params)
365fd4e5da5Sopenharmony_ci		if err := r.Reply(ctx, resp, err); err != nil {
366fd4e5da5Sopenharmony_ci			log.Printf("%v", err)
367fd4e5da5Sopenharmony_ci		}
368fd4e5da5Sopenharmony_ci		return true
369fd4e5da5Sopenharmony_ci	case "textDocument/references": // req
370fd4e5da5Sopenharmony_ci		var params ReferenceParams
371fd4e5da5Sopenharmony_ci		if err := json.Unmarshal(*r.Params, &params); err != nil {
372fd4e5da5Sopenharmony_ci			sendParseError(ctx, r, err)
373fd4e5da5Sopenharmony_ci			return true
374fd4e5da5Sopenharmony_ci		}
375fd4e5da5Sopenharmony_ci		resp, err := h.server.References(ctx, &params)
376fd4e5da5Sopenharmony_ci		if err := r.Reply(ctx, resp, err); err != nil {
377fd4e5da5Sopenharmony_ci			log.Printf("%v", err)
378fd4e5da5Sopenharmony_ci		}
379fd4e5da5Sopenharmony_ci		return true
380fd4e5da5Sopenharmony_ci	case "textDocument/documentHighlight": // req
381fd4e5da5Sopenharmony_ci		var params DocumentHighlightParams
382fd4e5da5Sopenharmony_ci		if err := json.Unmarshal(*r.Params, &params); err != nil {
383fd4e5da5Sopenharmony_ci			sendParseError(ctx, r, err)
384fd4e5da5Sopenharmony_ci			return true
385fd4e5da5Sopenharmony_ci		}
386fd4e5da5Sopenharmony_ci		resp, err := h.server.DocumentHighlight(ctx, &params)
387fd4e5da5Sopenharmony_ci		if err := r.Reply(ctx, resp, err); err != nil {
388fd4e5da5Sopenharmony_ci			log.Printf("%v", err)
389fd4e5da5Sopenharmony_ci		}
390fd4e5da5Sopenharmony_ci		return true
391fd4e5da5Sopenharmony_ci	case "textDocument/documentSymbol": // req
392fd4e5da5Sopenharmony_ci		var params DocumentSymbolParams
393fd4e5da5Sopenharmony_ci		if err := json.Unmarshal(*r.Params, &params); err != nil {
394fd4e5da5Sopenharmony_ci			sendParseError(ctx, r, err)
395fd4e5da5Sopenharmony_ci			return true
396fd4e5da5Sopenharmony_ci		}
397fd4e5da5Sopenharmony_ci		resp, err := h.server.DocumentSymbol(ctx, &params)
398fd4e5da5Sopenharmony_ci		if err := r.Reply(ctx, resp, err); err != nil {
399fd4e5da5Sopenharmony_ci			log.Printf("%v", err)
400fd4e5da5Sopenharmony_ci		}
401fd4e5da5Sopenharmony_ci		return true
402fd4e5da5Sopenharmony_ci	case "textDocument/codeAction": // req
403fd4e5da5Sopenharmony_ci		var params CodeActionParams
404fd4e5da5Sopenharmony_ci		if err := json.Unmarshal(*r.Params, &params); err != nil {
405fd4e5da5Sopenharmony_ci			sendParseError(ctx, r, err)
406fd4e5da5Sopenharmony_ci			return true
407fd4e5da5Sopenharmony_ci		}
408fd4e5da5Sopenharmony_ci		resp, err := h.server.CodeAction(ctx, &params)
409fd4e5da5Sopenharmony_ci		if err := r.Reply(ctx, resp, err); err != nil {
410fd4e5da5Sopenharmony_ci			log.Printf("%v", err)
411fd4e5da5Sopenharmony_ci		}
412fd4e5da5Sopenharmony_ci		return true
413fd4e5da5Sopenharmony_ci	case "workspace/symbol": // req
414fd4e5da5Sopenharmony_ci		var params WorkspaceSymbolParams
415fd4e5da5Sopenharmony_ci		if err := json.Unmarshal(*r.Params, &params); err != nil {
416fd4e5da5Sopenharmony_ci			sendParseError(ctx, r, err)
417fd4e5da5Sopenharmony_ci			return true
418fd4e5da5Sopenharmony_ci		}
419fd4e5da5Sopenharmony_ci		resp, err := h.server.Symbol(ctx, &params)
420fd4e5da5Sopenharmony_ci		if err := r.Reply(ctx, resp, err); err != nil {
421fd4e5da5Sopenharmony_ci			log.Printf("%v", err)
422fd4e5da5Sopenharmony_ci		}
423fd4e5da5Sopenharmony_ci		return true
424fd4e5da5Sopenharmony_ci	case "textDocument/codeLens": // req
425fd4e5da5Sopenharmony_ci		var params CodeLensParams
426fd4e5da5Sopenharmony_ci		if err := json.Unmarshal(*r.Params, &params); err != nil {
427fd4e5da5Sopenharmony_ci			sendParseError(ctx, r, err)
428fd4e5da5Sopenharmony_ci			return true
429fd4e5da5Sopenharmony_ci		}
430fd4e5da5Sopenharmony_ci		resp, err := h.server.CodeLens(ctx, &params)
431fd4e5da5Sopenharmony_ci		if err := r.Reply(ctx, resp, err); err != nil {
432fd4e5da5Sopenharmony_ci			log.Printf("%v", err)
433fd4e5da5Sopenharmony_ci		}
434fd4e5da5Sopenharmony_ci		return true
435fd4e5da5Sopenharmony_ci	case "codeLens/resolve": // req
436fd4e5da5Sopenharmony_ci		var params CodeLens
437fd4e5da5Sopenharmony_ci		if err := json.Unmarshal(*r.Params, &params); err != nil {
438fd4e5da5Sopenharmony_ci			sendParseError(ctx, r, err)
439fd4e5da5Sopenharmony_ci			return true
440fd4e5da5Sopenharmony_ci		}
441fd4e5da5Sopenharmony_ci		resp, err := h.server.ResolveCodeLens(ctx, &params)
442fd4e5da5Sopenharmony_ci		if err := r.Reply(ctx, resp, err); err != nil {
443fd4e5da5Sopenharmony_ci			log.Printf("%v", err)
444fd4e5da5Sopenharmony_ci		}
445fd4e5da5Sopenharmony_ci		return true
446fd4e5da5Sopenharmony_ci	case "textDocument/documentLink": // req
447fd4e5da5Sopenharmony_ci		var params DocumentLinkParams
448fd4e5da5Sopenharmony_ci		if err := json.Unmarshal(*r.Params, &params); err != nil {
449fd4e5da5Sopenharmony_ci			sendParseError(ctx, r, err)
450fd4e5da5Sopenharmony_ci			return true
451fd4e5da5Sopenharmony_ci		}
452fd4e5da5Sopenharmony_ci		resp, err := h.server.DocumentLink(ctx, &params)
453fd4e5da5Sopenharmony_ci		if err := r.Reply(ctx, resp, err); err != nil {
454fd4e5da5Sopenharmony_ci			log.Printf("%v", err)
455fd4e5da5Sopenharmony_ci		}
456fd4e5da5Sopenharmony_ci		return true
457fd4e5da5Sopenharmony_ci	case "documentLink/resolve": // req
458fd4e5da5Sopenharmony_ci		var params DocumentLink
459fd4e5da5Sopenharmony_ci		if err := json.Unmarshal(*r.Params, &params); err != nil {
460fd4e5da5Sopenharmony_ci			sendParseError(ctx, r, err)
461fd4e5da5Sopenharmony_ci			return true
462fd4e5da5Sopenharmony_ci		}
463fd4e5da5Sopenharmony_ci		resp, err := h.server.ResolveDocumentLink(ctx, &params)
464fd4e5da5Sopenharmony_ci		if err := r.Reply(ctx, resp, err); err != nil {
465fd4e5da5Sopenharmony_ci			log.Printf("%v", err)
466fd4e5da5Sopenharmony_ci		}
467fd4e5da5Sopenharmony_ci		return true
468fd4e5da5Sopenharmony_ci	case "textDocument/formatting": // req
469fd4e5da5Sopenharmony_ci		var params DocumentFormattingParams
470fd4e5da5Sopenharmony_ci		if err := json.Unmarshal(*r.Params, &params); err != nil {
471fd4e5da5Sopenharmony_ci			sendParseError(ctx, r, err)
472fd4e5da5Sopenharmony_ci			return true
473fd4e5da5Sopenharmony_ci		}
474fd4e5da5Sopenharmony_ci		resp, err := h.server.Formatting(ctx, &params)
475fd4e5da5Sopenharmony_ci		if err := r.Reply(ctx, resp, err); err != nil {
476fd4e5da5Sopenharmony_ci			log.Printf("%v", err)
477fd4e5da5Sopenharmony_ci		}
478fd4e5da5Sopenharmony_ci		return true
479fd4e5da5Sopenharmony_ci	case "textDocument/rangeFormatting": // req
480fd4e5da5Sopenharmony_ci		var params DocumentRangeFormattingParams
481fd4e5da5Sopenharmony_ci		if err := json.Unmarshal(*r.Params, &params); err != nil {
482fd4e5da5Sopenharmony_ci			sendParseError(ctx, r, err)
483fd4e5da5Sopenharmony_ci			return true
484fd4e5da5Sopenharmony_ci		}
485fd4e5da5Sopenharmony_ci		resp, err := h.server.RangeFormatting(ctx, &params)
486fd4e5da5Sopenharmony_ci		if err := r.Reply(ctx, resp, err); err != nil {
487fd4e5da5Sopenharmony_ci			log.Printf("%v", err)
488fd4e5da5Sopenharmony_ci		}
489fd4e5da5Sopenharmony_ci		return true
490fd4e5da5Sopenharmony_ci	case "textDocument/onTypeFormatting": // req
491fd4e5da5Sopenharmony_ci		var params DocumentOnTypeFormattingParams
492fd4e5da5Sopenharmony_ci		if err := json.Unmarshal(*r.Params, &params); err != nil {
493fd4e5da5Sopenharmony_ci			sendParseError(ctx, r, err)
494fd4e5da5Sopenharmony_ci			return true
495fd4e5da5Sopenharmony_ci		}
496fd4e5da5Sopenharmony_ci		resp, err := h.server.OnTypeFormatting(ctx, &params)
497fd4e5da5Sopenharmony_ci		if err := r.Reply(ctx, resp, err); err != nil {
498fd4e5da5Sopenharmony_ci			log.Printf("%v", err)
499fd4e5da5Sopenharmony_ci		}
500fd4e5da5Sopenharmony_ci		return true
501fd4e5da5Sopenharmony_ci	case "textDocument/rename": // req
502fd4e5da5Sopenharmony_ci		var params RenameParams
503fd4e5da5Sopenharmony_ci		if err := json.Unmarshal(*r.Params, &params); err != nil {
504fd4e5da5Sopenharmony_ci			sendParseError(ctx, r, err)
505fd4e5da5Sopenharmony_ci			return true
506fd4e5da5Sopenharmony_ci		}
507fd4e5da5Sopenharmony_ci		resp, err := h.server.Rename(ctx, &params)
508fd4e5da5Sopenharmony_ci		if err := r.Reply(ctx, resp, err); err != nil {
509fd4e5da5Sopenharmony_ci			log.Printf("%v", err)
510fd4e5da5Sopenharmony_ci		}
511fd4e5da5Sopenharmony_ci		return true
512fd4e5da5Sopenharmony_ci	case "textDocument/prepareRename": // req
513fd4e5da5Sopenharmony_ci		var params PrepareRenameParams
514fd4e5da5Sopenharmony_ci		if err := json.Unmarshal(*r.Params, &params); err != nil {
515fd4e5da5Sopenharmony_ci			sendParseError(ctx, r, err)
516fd4e5da5Sopenharmony_ci			return true
517fd4e5da5Sopenharmony_ci		}
518fd4e5da5Sopenharmony_ci		resp, err := h.server.PrepareRename(ctx, &params)
519fd4e5da5Sopenharmony_ci		if err := r.Reply(ctx, resp, err); err != nil {
520fd4e5da5Sopenharmony_ci			log.Printf("%v", err)
521fd4e5da5Sopenharmony_ci		}
522fd4e5da5Sopenharmony_ci		return true
523fd4e5da5Sopenharmony_ci	case "workspace/executeCommand": // req
524fd4e5da5Sopenharmony_ci		var params ExecuteCommandParams
525fd4e5da5Sopenharmony_ci		if err := json.Unmarshal(*r.Params, &params); err != nil {
526fd4e5da5Sopenharmony_ci			sendParseError(ctx, r, err)
527fd4e5da5Sopenharmony_ci			return true
528fd4e5da5Sopenharmony_ci		}
529fd4e5da5Sopenharmony_ci		resp, err := h.server.ExecuteCommand(ctx, &params)
530fd4e5da5Sopenharmony_ci		if err := r.Reply(ctx, resp, err); err != nil {
531fd4e5da5Sopenharmony_ci			log.Printf("%v", err)
532fd4e5da5Sopenharmony_ci		}
533fd4e5da5Sopenharmony_ci		return true
534fd4e5da5Sopenharmony_ci
535fd4e5da5Sopenharmony_ci	default:
536fd4e5da5Sopenharmony_ci		return false
537fd4e5da5Sopenharmony_ci	}
538fd4e5da5Sopenharmony_ci}
539fd4e5da5Sopenharmony_ci
540fd4e5da5Sopenharmony_citype serverDispatcher struct {
541fd4e5da5Sopenharmony_ci	*jsonrpc2.Conn
542fd4e5da5Sopenharmony_ci}
543fd4e5da5Sopenharmony_ci
544fd4e5da5Sopenharmony_cifunc (s *serverDispatcher) DidChangeWorkspaceFolders(ctx context.Context, params *DidChangeWorkspaceFoldersParams) error {
545fd4e5da5Sopenharmony_ci	return s.Conn.Notify(ctx, "workspace/didChangeWorkspaceFolders", params)
546fd4e5da5Sopenharmony_ci}
547fd4e5da5Sopenharmony_ci
548fd4e5da5Sopenharmony_cifunc (s *serverDispatcher) Initialized(ctx context.Context, params *InitializedParams) error {
549fd4e5da5Sopenharmony_ci	return s.Conn.Notify(ctx, "initialized", params)
550fd4e5da5Sopenharmony_ci}
551fd4e5da5Sopenharmony_ci
552fd4e5da5Sopenharmony_cifunc (s *serverDispatcher) Exit(ctx context.Context) error {
553fd4e5da5Sopenharmony_ci	return s.Conn.Notify(ctx, "exit", nil)
554fd4e5da5Sopenharmony_ci}
555fd4e5da5Sopenharmony_ci
556fd4e5da5Sopenharmony_cifunc (s *serverDispatcher) DidChangeConfiguration(ctx context.Context, params *DidChangeConfigurationParams) error {
557fd4e5da5Sopenharmony_ci	return s.Conn.Notify(ctx, "workspace/didChangeConfiguration", params)
558fd4e5da5Sopenharmony_ci}
559fd4e5da5Sopenharmony_ci
560fd4e5da5Sopenharmony_cifunc (s *serverDispatcher) DidOpen(ctx context.Context, params *DidOpenTextDocumentParams) error {
561fd4e5da5Sopenharmony_ci	return s.Conn.Notify(ctx, "textDocument/didOpen", params)
562fd4e5da5Sopenharmony_ci}
563fd4e5da5Sopenharmony_ci
564fd4e5da5Sopenharmony_cifunc (s *serverDispatcher) DidChange(ctx context.Context, params *DidChangeTextDocumentParams) error {
565fd4e5da5Sopenharmony_ci	return s.Conn.Notify(ctx, "textDocument/didChange", params)
566fd4e5da5Sopenharmony_ci}
567fd4e5da5Sopenharmony_ci
568fd4e5da5Sopenharmony_cifunc (s *serverDispatcher) DidClose(ctx context.Context, params *DidCloseTextDocumentParams) error {
569fd4e5da5Sopenharmony_ci	return s.Conn.Notify(ctx, "textDocument/didClose", params)
570fd4e5da5Sopenharmony_ci}
571fd4e5da5Sopenharmony_ci
572fd4e5da5Sopenharmony_cifunc (s *serverDispatcher) DidSave(ctx context.Context, params *DidSaveTextDocumentParams) error {
573fd4e5da5Sopenharmony_ci	return s.Conn.Notify(ctx, "textDocument/didSave", params)
574fd4e5da5Sopenharmony_ci}
575fd4e5da5Sopenharmony_ci
576fd4e5da5Sopenharmony_cifunc (s *serverDispatcher) WillSave(ctx context.Context, params *WillSaveTextDocumentParams) error {
577fd4e5da5Sopenharmony_ci	return s.Conn.Notify(ctx, "textDocument/willSave", params)
578fd4e5da5Sopenharmony_ci}
579fd4e5da5Sopenharmony_ci
580fd4e5da5Sopenharmony_cifunc (s *serverDispatcher) DidChangeWatchedFiles(ctx context.Context, params *DidChangeWatchedFilesParams) error {
581fd4e5da5Sopenharmony_ci	return s.Conn.Notify(ctx, "workspace/didChangeWatchedFiles", params)
582fd4e5da5Sopenharmony_ci}
583fd4e5da5Sopenharmony_ci
584fd4e5da5Sopenharmony_cifunc (s *serverDispatcher) Progress(ctx context.Context, params *ProgressParams) error {
585fd4e5da5Sopenharmony_ci	return s.Conn.Notify(ctx, "$/progress", params)
586fd4e5da5Sopenharmony_ci}
587fd4e5da5Sopenharmony_ci
588fd4e5da5Sopenharmony_cifunc (s *serverDispatcher) SetTraceNotification(ctx context.Context, params *SetTraceParams) error {
589fd4e5da5Sopenharmony_ci	return s.Conn.Notify(ctx, "$/setTraceNotification", params)
590fd4e5da5Sopenharmony_ci}
591fd4e5da5Sopenharmony_ci
592fd4e5da5Sopenharmony_cifunc (s *serverDispatcher) LogTraceNotification(ctx context.Context, params *LogTraceParams) error {
593fd4e5da5Sopenharmony_ci	return s.Conn.Notify(ctx, "$/logTraceNotification", params)
594fd4e5da5Sopenharmony_ci}
595fd4e5da5Sopenharmony_cifunc (s *serverDispatcher) Implementation(ctx context.Context, params *ImplementationParams) ([]Location, error) {
596fd4e5da5Sopenharmony_ci	var result []Location
597fd4e5da5Sopenharmony_ci	if err := s.Conn.Call(ctx, "textDocument/implementation", params, &result); err != nil {
598fd4e5da5Sopenharmony_ci		return nil, err
599fd4e5da5Sopenharmony_ci	}
600fd4e5da5Sopenharmony_ci	return result, nil
601fd4e5da5Sopenharmony_ci}
602fd4e5da5Sopenharmony_ci
603fd4e5da5Sopenharmony_cifunc (s *serverDispatcher) TypeDefinition(ctx context.Context, params *TypeDefinitionParams) ([]Location, error) {
604fd4e5da5Sopenharmony_ci	var result []Location
605fd4e5da5Sopenharmony_ci	if err := s.Conn.Call(ctx, "textDocument/typeDefinition", params, &result); err != nil {
606fd4e5da5Sopenharmony_ci		return nil, err
607fd4e5da5Sopenharmony_ci	}
608fd4e5da5Sopenharmony_ci	return result, nil
609fd4e5da5Sopenharmony_ci}
610fd4e5da5Sopenharmony_ci
611fd4e5da5Sopenharmony_cifunc (s *serverDispatcher) DocumentColor(ctx context.Context, params *DocumentColorParams) ([]ColorInformation, error) {
612fd4e5da5Sopenharmony_ci	var result []ColorInformation
613fd4e5da5Sopenharmony_ci	if err := s.Conn.Call(ctx, "textDocument/documentColor", params, &result); err != nil {
614fd4e5da5Sopenharmony_ci		return nil, err
615fd4e5da5Sopenharmony_ci	}
616fd4e5da5Sopenharmony_ci	return result, nil
617fd4e5da5Sopenharmony_ci}
618fd4e5da5Sopenharmony_ci
619fd4e5da5Sopenharmony_cifunc (s *serverDispatcher) ColorPresentation(ctx context.Context, params *ColorPresentationParams) ([]ColorPresentation, error) {
620fd4e5da5Sopenharmony_ci	var result []ColorPresentation
621fd4e5da5Sopenharmony_ci	if err := s.Conn.Call(ctx, "textDocument/colorPresentation", params, &result); err != nil {
622fd4e5da5Sopenharmony_ci		return nil, err
623fd4e5da5Sopenharmony_ci	}
624fd4e5da5Sopenharmony_ci	return result, nil
625fd4e5da5Sopenharmony_ci}
626fd4e5da5Sopenharmony_ci
627fd4e5da5Sopenharmony_cifunc (s *serverDispatcher) FoldingRange(ctx context.Context, params *FoldingRangeParams) ([]FoldingRange, error) {
628fd4e5da5Sopenharmony_ci	var result []FoldingRange
629fd4e5da5Sopenharmony_ci	if err := s.Conn.Call(ctx, "textDocument/foldingRange", params, &result); err != nil {
630fd4e5da5Sopenharmony_ci		return nil, err
631fd4e5da5Sopenharmony_ci	}
632fd4e5da5Sopenharmony_ci	return result, nil
633fd4e5da5Sopenharmony_ci}
634fd4e5da5Sopenharmony_ci
635fd4e5da5Sopenharmony_cifunc (s *serverDispatcher) Declaration(ctx context.Context, params *DeclarationParams) ([]DeclarationLink, error) {
636fd4e5da5Sopenharmony_ci	var result []DeclarationLink
637fd4e5da5Sopenharmony_ci	if err := s.Conn.Call(ctx, "textDocument/declaration", params, &result); err != nil {
638fd4e5da5Sopenharmony_ci		return nil, err
639fd4e5da5Sopenharmony_ci	}
640fd4e5da5Sopenharmony_ci	return result, nil
641fd4e5da5Sopenharmony_ci}
642fd4e5da5Sopenharmony_ci
643fd4e5da5Sopenharmony_cifunc (s *serverDispatcher) SelectionRange(ctx context.Context, params *SelectionRangeParams) ([]SelectionRange, error) {
644fd4e5da5Sopenharmony_ci	var result []SelectionRange
645fd4e5da5Sopenharmony_ci	if err := s.Conn.Call(ctx, "textDocument/selectionRange", params, &result); err != nil {
646fd4e5da5Sopenharmony_ci		return nil, err
647fd4e5da5Sopenharmony_ci	}
648fd4e5da5Sopenharmony_ci	return result, nil
649fd4e5da5Sopenharmony_ci}
650fd4e5da5Sopenharmony_ci
651fd4e5da5Sopenharmony_cifunc (s *serverDispatcher) Initialize(ctx context.Context, params *ParamInitia) (*InitializeResult, error) {
652fd4e5da5Sopenharmony_ci	var result InitializeResult
653fd4e5da5Sopenharmony_ci	if err := s.Conn.Call(ctx, "initialize", params, &result); err != nil {
654fd4e5da5Sopenharmony_ci		return nil, err
655fd4e5da5Sopenharmony_ci	}
656fd4e5da5Sopenharmony_ci	return &result, nil
657fd4e5da5Sopenharmony_ci}
658fd4e5da5Sopenharmony_ci
659fd4e5da5Sopenharmony_cifunc (s *serverDispatcher) Shutdown(ctx context.Context) error {
660fd4e5da5Sopenharmony_ci	return s.Conn.Call(ctx, "shutdown", nil, nil)
661fd4e5da5Sopenharmony_ci}
662fd4e5da5Sopenharmony_ci
663fd4e5da5Sopenharmony_cifunc (s *serverDispatcher) WillSaveWaitUntil(ctx context.Context, params *WillSaveTextDocumentParams) ([]TextEdit, error) {
664fd4e5da5Sopenharmony_ci	var result []TextEdit
665fd4e5da5Sopenharmony_ci	if err := s.Conn.Call(ctx, "textDocument/willSaveWaitUntil", params, &result); err != nil {
666fd4e5da5Sopenharmony_ci		return nil, err
667fd4e5da5Sopenharmony_ci	}
668fd4e5da5Sopenharmony_ci	return result, nil
669fd4e5da5Sopenharmony_ci}
670fd4e5da5Sopenharmony_ci
671fd4e5da5Sopenharmony_cifunc (s *serverDispatcher) Completion(ctx context.Context, params *CompletionParams) (*CompletionList, error) {
672fd4e5da5Sopenharmony_ci	var result CompletionList
673fd4e5da5Sopenharmony_ci	if err := s.Conn.Call(ctx, "textDocument/completion", params, &result); err != nil {
674fd4e5da5Sopenharmony_ci		return nil, err
675fd4e5da5Sopenharmony_ci	}
676fd4e5da5Sopenharmony_ci	return &result, nil
677fd4e5da5Sopenharmony_ci}
678fd4e5da5Sopenharmony_ci
679fd4e5da5Sopenharmony_cifunc (s *serverDispatcher) Resolve(ctx context.Context, params *CompletionItem) (*CompletionItem, error) {
680fd4e5da5Sopenharmony_ci	var result CompletionItem
681fd4e5da5Sopenharmony_ci	if err := s.Conn.Call(ctx, "completionItem/resolve", params, &result); err != nil {
682fd4e5da5Sopenharmony_ci		return nil, err
683fd4e5da5Sopenharmony_ci	}
684fd4e5da5Sopenharmony_ci	return &result, nil
685fd4e5da5Sopenharmony_ci}
686fd4e5da5Sopenharmony_ci
687fd4e5da5Sopenharmony_cifunc (s *serverDispatcher) Hover(ctx context.Context, params *HoverParams) (*Hover, error) {
688fd4e5da5Sopenharmony_ci	var result Hover
689fd4e5da5Sopenharmony_ci	if err := s.Conn.Call(ctx, "textDocument/hover", params, &result); err != nil {
690fd4e5da5Sopenharmony_ci		return nil, err
691fd4e5da5Sopenharmony_ci	}
692fd4e5da5Sopenharmony_ci	return &result, nil
693fd4e5da5Sopenharmony_ci}
694fd4e5da5Sopenharmony_ci
695fd4e5da5Sopenharmony_cifunc (s *serverDispatcher) SignatureHelp(ctx context.Context, params *SignatureHelpParams) (*SignatureHelp, error) {
696fd4e5da5Sopenharmony_ci	var result SignatureHelp
697fd4e5da5Sopenharmony_ci	if err := s.Conn.Call(ctx, "textDocument/signatureHelp", params, &result); err != nil {
698fd4e5da5Sopenharmony_ci		return nil, err
699fd4e5da5Sopenharmony_ci	}
700fd4e5da5Sopenharmony_ci	return &result, nil
701fd4e5da5Sopenharmony_ci}
702fd4e5da5Sopenharmony_ci
703fd4e5da5Sopenharmony_cifunc (s *serverDispatcher) Definition(ctx context.Context, params *DefinitionParams) ([]Location, error) {
704fd4e5da5Sopenharmony_ci	var result []Location
705fd4e5da5Sopenharmony_ci	if err := s.Conn.Call(ctx, "textDocument/definition", params, &result); err != nil {
706fd4e5da5Sopenharmony_ci		return nil, err
707fd4e5da5Sopenharmony_ci	}
708fd4e5da5Sopenharmony_ci	return result, nil
709fd4e5da5Sopenharmony_ci}
710fd4e5da5Sopenharmony_ci
711fd4e5da5Sopenharmony_cifunc (s *serverDispatcher) References(ctx context.Context, params *ReferenceParams) ([]Location, error) {
712fd4e5da5Sopenharmony_ci	var result []Location
713fd4e5da5Sopenharmony_ci	if err := s.Conn.Call(ctx, "textDocument/references", params, &result); err != nil {
714fd4e5da5Sopenharmony_ci		return nil, err
715fd4e5da5Sopenharmony_ci	}
716fd4e5da5Sopenharmony_ci	return result, nil
717fd4e5da5Sopenharmony_ci}
718fd4e5da5Sopenharmony_ci
719fd4e5da5Sopenharmony_cifunc (s *serverDispatcher) DocumentHighlight(ctx context.Context, params *DocumentHighlightParams) ([]DocumentHighlight, error) {
720fd4e5da5Sopenharmony_ci	var result []DocumentHighlight
721fd4e5da5Sopenharmony_ci	if err := s.Conn.Call(ctx, "textDocument/documentHighlight", params, &result); err != nil {
722fd4e5da5Sopenharmony_ci		return nil, err
723fd4e5da5Sopenharmony_ci	}
724fd4e5da5Sopenharmony_ci	return result, nil
725fd4e5da5Sopenharmony_ci}
726fd4e5da5Sopenharmony_ci
727fd4e5da5Sopenharmony_cifunc (s *serverDispatcher) DocumentSymbol(ctx context.Context, params *DocumentSymbolParams) ([]DocumentSymbol, error) {
728fd4e5da5Sopenharmony_ci	var result []DocumentSymbol
729fd4e5da5Sopenharmony_ci	if err := s.Conn.Call(ctx, "textDocument/documentSymbol", params, &result); err != nil {
730fd4e5da5Sopenharmony_ci		return nil, err
731fd4e5da5Sopenharmony_ci	}
732fd4e5da5Sopenharmony_ci	return result, nil
733fd4e5da5Sopenharmony_ci}
734fd4e5da5Sopenharmony_ci
735fd4e5da5Sopenharmony_cifunc (s *serverDispatcher) CodeAction(ctx context.Context, params *CodeActionParams) ([]CodeAction, error) {
736fd4e5da5Sopenharmony_ci	var result []CodeAction
737fd4e5da5Sopenharmony_ci	if err := s.Conn.Call(ctx, "textDocument/codeAction", params, &result); err != nil {
738fd4e5da5Sopenharmony_ci		return nil, err
739fd4e5da5Sopenharmony_ci	}
740fd4e5da5Sopenharmony_ci	return result, nil
741fd4e5da5Sopenharmony_ci}
742fd4e5da5Sopenharmony_ci
743fd4e5da5Sopenharmony_cifunc (s *serverDispatcher) Symbol(ctx context.Context, params *WorkspaceSymbolParams) ([]SymbolInformation, error) {
744fd4e5da5Sopenharmony_ci	var result []SymbolInformation
745fd4e5da5Sopenharmony_ci	if err := s.Conn.Call(ctx, "workspace/symbol", params, &result); err != nil {
746fd4e5da5Sopenharmony_ci		return nil, err
747fd4e5da5Sopenharmony_ci	}
748fd4e5da5Sopenharmony_ci	return result, nil
749fd4e5da5Sopenharmony_ci}
750fd4e5da5Sopenharmony_ci
751fd4e5da5Sopenharmony_cifunc (s *serverDispatcher) CodeLens(ctx context.Context, params *CodeLensParams) ([]CodeLens, error) {
752fd4e5da5Sopenharmony_ci	var result []CodeLens
753fd4e5da5Sopenharmony_ci	if err := s.Conn.Call(ctx, "textDocument/codeLens", params, &result); err != nil {
754fd4e5da5Sopenharmony_ci		return nil, err
755fd4e5da5Sopenharmony_ci	}
756fd4e5da5Sopenharmony_ci	return result, nil
757fd4e5da5Sopenharmony_ci}
758fd4e5da5Sopenharmony_ci
759fd4e5da5Sopenharmony_cifunc (s *serverDispatcher) ResolveCodeLens(ctx context.Context, params *CodeLens) (*CodeLens, error) {
760fd4e5da5Sopenharmony_ci	var result CodeLens
761fd4e5da5Sopenharmony_ci	if err := s.Conn.Call(ctx, "codeLens/resolve", params, &result); err != nil {
762fd4e5da5Sopenharmony_ci		return nil, err
763fd4e5da5Sopenharmony_ci	}
764fd4e5da5Sopenharmony_ci	return &result, nil
765fd4e5da5Sopenharmony_ci}
766fd4e5da5Sopenharmony_ci
767fd4e5da5Sopenharmony_cifunc (s *serverDispatcher) DocumentLink(ctx context.Context, params *DocumentLinkParams) ([]DocumentLink, error) {
768fd4e5da5Sopenharmony_ci	var result []DocumentLink
769fd4e5da5Sopenharmony_ci	if err := s.Conn.Call(ctx, "textDocument/documentLink", params, &result); err != nil {
770fd4e5da5Sopenharmony_ci		return nil, err
771fd4e5da5Sopenharmony_ci	}
772fd4e5da5Sopenharmony_ci	return result, nil
773fd4e5da5Sopenharmony_ci}
774fd4e5da5Sopenharmony_ci
775fd4e5da5Sopenharmony_cifunc (s *serverDispatcher) ResolveDocumentLink(ctx context.Context, params *DocumentLink) (*DocumentLink, error) {
776fd4e5da5Sopenharmony_ci	var result DocumentLink
777fd4e5da5Sopenharmony_ci	if err := s.Conn.Call(ctx, "documentLink/resolve", params, &result); err != nil {
778fd4e5da5Sopenharmony_ci		return nil, err
779fd4e5da5Sopenharmony_ci	}
780fd4e5da5Sopenharmony_ci	return &result, nil
781fd4e5da5Sopenharmony_ci}
782fd4e5da5Sopenharmony_ci
783fd4e5da5Sopenharmony_cifunc (s *serverDispatcher) Formatting(ctx context.Context, params *DocumentFormattingParams) ([]TextEdit, error) {
784fd4e5da5Sopenharmony_ci	var result []TextEdit
785fd4e5da5Sopenharmony_ci	if err := s.Conn.Call(ctx, "textDocument/formatting", params, &result); err != nil {
786fd4e5da5Sopenharmony_ci		return nil, err
787fd4e5da5Sopenharmony_ci	}
788fd4e5da5Sopenharmony_ci	return result, nil
789fd4e5da5Sopenharmony_ci}
790fd4e5da5Sopenharmony_ci
791fd4e5da5Sopenharmony_cifunc (s *serverDispatcher) RangeFormatting(ctx context.Context, params *DocumentRangeFormattingParams) ([]TextEdit, error) {
792fd4e5da5Sopenharmony_ci	var result []TextEdit
793fd4e5da5Sopenharmony_ci	if err := s.Conn.Call(ctx, "textDocument/rangeFormatting", params, &result); err != nil {
794fd4e5da5Sopenharmony_ci		return nil, err
795fd4e5da5Sopenharmony_ci	}
796fd4e5da5Sopenharmony_ci	return result, nil
797fd4e5da5Sopenharmony_ci}
798fd4e5da5Sopenharmony_ci
799fd4e5da5Sopenharmony_cifunc (s *serverDispatcher) OnTypeFormatting(ctx context.Context, params *DocumentOnTypeFormattingParams) ([]TextEdit, error) {
800fd4e5da5Sopenharmony_ci	var result []TextEdit
801fd4e5da5Sopenharmony_ci	if err := s.Conn.Call(ctx, "textDocument/onTypeFormatting", params, &result); err != nil {
802fd4e5da5Sopenharmony_ci		return nil, err
803fd4e5da5Sopenharmony_ci	}
804fd4e5da5Sopenharmony_ci	return result, nil
805fd4e5da5Sopenharmony_ci}
806fd4e5da5Sopenharmony_ci
807fd4e5da5Sopenharmony_cifunc (s *serverDispatcher) Rename(ctx context.Context, params *RenameParams) (*WorkspaceEdit, error) {
808fd4e5da5Sopenharmony_ci	var result WorkspaceEdit
809fd4e5da5Sopenharmony_ci	if err := s.Conn.Call(ctx, "textDocument/rename", params, &result); err != nil {
810fd4e5da5Sopenharmony_ci		return nil, err
811fd4e5da5Sopenharmony_ci	}
812fd4e5da5Sopenharmony_ci	return &result, nil
813fd4e5da5Sopenharmony_ci}
814fd4e5da5Sopenharmony_ci
815fd4e5da5Sopenharmony_cifunc (s *serverDispatcher) PrepareRename(ctx context.Context, params *PrepareRenameParams) (*Range, error) {
816fd4e5da5Sopenharmony_ci	var result Range
817fd4e5da5Sopenharmony_ci	if err := s.Conn.Call(ctx, "textDocument/prepareRename", params, &result); err != nil {
818fd4e5da5Sopenharmony_ci		return nil, err
819fd4e5da5Sopenharmony_ci	}
820fd4e5da5Sopenharmony_ci	return &result, nil
821fd4e5da5Sopenharmony_ci}
822fd4e5da5Sopenharmony_ci
823fd4e5da5Sopenharmony_cifunc (s *serverDispatcher) ExecuteCommand(ctx context.Context, params *ExecuteCommandParams) (interface{}, error) {
824fd4e5da5Sopenharmony_ci	var result interface{}
825fd4e5da5Sopenharmony_ci	if err := s.Conn.Call(ctx, "workspace/executeCommand", params, &result); err != nil {
826fd4e5da5Sopenharmony_ci		return nil, err
827fd4e5da5Sopenharmony_ci	}
828fd4e5da5Sopenharmony_ci	return result, nil
829fd4e5da5Sopenharmony_ci}
830fd4e5da5Sopenharmony_ci
831fd4e5da5Sopenharmony_citype CancelParams struct {
832fd4e5da5Sopenharmony_ci	/**
833fd4e5da5Sopenharmony_ci	 * The request id to cancel.
834fd4e5da5Sopenharmony_ci	 */
835fd4e5da5Sopenharmony_ci	ID jsonrpc2.ID `json:"id"`
836fd4e5da5Sopenharmony_ci}
837fd4e5da5Sopenharmony_ci
838fd4e5da5Sopenharmony_ci// Types constructed to avoid structs as formal argument types
839fd4e5da5Sopenharmony_citype ParamInitia struct {
840fd4e5da5Sopenharmony_ci	InitializeParams
841fd4e5da5Sopenharmony_ci	WorkDoneProgressParams
842fd4e5da5Sopenharmony_ci}
843