@@ -151,75 +151,60 @@ func (handler *InoHandler) transformParamsToClangd(ctx context.Context, method s
151151 defer handler .synchronizer .DataMux .RUnlock ()
152152 }
153153
154- switch method {
155- case "textDocument/didOpen" :
156- p := params .(* lsp.DidOpenTextDocumentParams )
154+ switch p := params .(type ) {
155+ case * lsp.DidOpenTextDocumentParams : // "textDocument/didOpen":
157156 uri = p .TextDocument .URI
158157 err = handler .ino2cppTextDocumentItem (ctx , & p .TextDocument )
159- case "textDocument/didChange" :
160- p := params .(* lsp.DidChangeTextDocumentParams )
158+ case * lsp.DidChangeTextDocumentParams : // "textDocument/didChange":
161159 uri = p .TextDocument .URI
162160 err = handler .ino2cppDidChangeTextDocumentParams (ctx , p )
163- case "textDocument/didSave" :
164- p := params .(* lsp.DidSaveTextDocumentParams )
161+ case * lsp.DidSaveTextDocumentParams : // "textDocument/didSave":
165162 uri = p .TextDocument .URI
166163 err = handler .ino2cppTextDocumentIdentifier (& p .TextDocument )
167- case "textDocument/didClose" :
168- p := params .(* lsp.DidCloseTextDocumentParams )
164+ case * lsp.DidCloseTextDocumentParams : // "textDocument/didClose":
169165 uri = p .TextDocument .URI
170166 err = handler .ino2cppTextDocumentIdentifier (& p .TextDocument )
171167 handler .deleteFileData (uri )
172- case "textDocument/completion" :
173- p := params .(* lsp.CompletionParams )
168+ case * lsp.CompletionParams : // "textDocument/completion":
174169 uri = p .TextDocument .URI
175170 err = handler .ino2cppTextDocumentPositionParams (& p .TextDocumentPositionParams )
176- case "textDocument/codeAction" :
177- p := params .(* lsp.CodeActionParams )
171+ case * lsp.CodeActionParams : // "textDocument/codeAction":
178172 uri = p .TextDocument .URI
179173 err = handler .ino2cppCodeActionParams (p )
180- case "textDocument/signatureHelp" :
181- fallthrough
182- case "textDocument/hover" :
183- fallthrough
184- case "textDocument/definition" :
185- fallthrough
186- case "textDocument/typeDefinition" :
187- fallthrough
188- case "textDocument/implementation" :
189- fallthrough
190- case "textDocument/documentHighlight" :
191- p := params .(* lsp.TextDocumentPositionParams )
174+ // case "textDocument/signatureHelp":
175+ // fallthrough
176+ // case "textDocument/hover":
177+ // fallthrough
178+ // case "textDocument/definition":
179+ // fallthrough
180+ // case "textDocument/typeDefinition":
181+ // fallthrough
182+ // case "textDocument/implementation":
183+ // fallthrough
184+ case * lsp.TextDocumentPositionParams : // "textDocument/documentHighlight":
192185 uri = p .TextDocument .URI
193186 err = handler .ino2cppTextDocumentPositionParams (p )
194- case "textDocument/references" :
195- p := params .(* lsp.ReferenceParams )
187+ case * lsp.ReferenceParams : // "textDocument/references":
196188 uri = p .TextDocument .URI
197189 err = handler .ino2cppTextDocumentPositionParams (& p .TextDocumentPositionParams )
198- case "textDocument/formatting" :
199- p := params .(* lsp.DocumentFormattingParams )
190+ case * lsp.DocumentFormattingParams : // "textDocument/formatting":
200191 uri = p .TextDocument .URI
201192 err = handler .ino2cppTextDocumentIdentifier (& p .TextDocument )
202- case "textDocument/rangeFormatting" :
203- p := params .(* lsp.DocumentRangeFormattingParams )
193+ case * lsp.DocumentRangeFormattingParams : // "textDocument/rangeFormatting":
204194 uri = p .TextDocument .URI
205195 err = handler .ino2cppDocumentRangeFormattingParams (p )
206- case "textDocument/onTypeFormatting" :
207- p := params .(* lsp.DocumentOnTypeFormattingParams )
196+ case * lsp.DocumentOnTypeFormattingParams : // "textDocument/onTypeFormatting":
208197 uri = p .TextDocument .URI
209198 err = handler .ino2cppDocumentOnTypeFormattingParams (p )
210- case "textDocument/documentSymbol" :
211- p := params .(* lsp.DocumentSymbolParams )
199+ case * lsp.DocumentSymbolParams : // "textDocument/documentSymbol":
212200 uri = p .TextDocument .URI
213201 err = handler .ino2cppTextDocumentIdentifier (& p .TextDocument )
214- case "textDocument/rename" :
215- p := params .(* lsp.RenameParams )
202+ case * lsp.RenameParams : // "textDocument/rename":
216203 uri = p .TextDocument .URI
217204 err = handler .ino2cppRenameParams (p )
218- case "workspace/didChangeWatchedFiles" :
219- p := params .(* lsp.DidChangeWatchedFilesParams )
205+ case * lsp.DidChangeWatchedFilesParams : // "workspace/didChangeWatchedFiles":
220206 err = handler .ino2cppDidChangeWatchedFilesParams (p )
221- case "workspace/executeCommand" :
222- p := params .(* lsp.ExecuteCommandParams )
207+ case * lsp.ExecuteCommandParams : // "workspace/executeCommand":
223208 err = handler .ino2cppExecuteCommand (p )
224209 }
225210 return
@@ -473,12 +458,10 @@ func (handler *InoHandler) transformClangdResult(method string, uri lsp.Document
473458 handler .synchronizer .DataMux .RLock ()
474459 defer handler .synchronizer .DataMux .RUnlock ()
475460
476- switch method {
477- case "textDocument/completion" :
478- r := result .(* lsp.CompletionList )
461+ switch r := result .(type ) {
462+ case * lsp.CompletionList : // "textDocument/completion":
479463 handler .cpp2inoCompletionList (r , uri )
480- case "textDocument/codeAction" :
481- r := result .(* []* commandOrCodeAction )
464+ case * []* commandOrCodeAction : // "textDocument/codeAction":
482465 for index := range * r {
483466 command := (* r )[index ].Command
484467 if command != nil {
@@ -489,41 +472,35 @@ func (handler *InoHandler) transformClangdResult(method string, uri lsp.Document
489472 handler .cpp2inoCodeAction (codeAction , uri )
490473 }
491474 }
492- case "textDocument/hover" :
493- r := result .(* Hover )
475+ case * Hover : // "textDocument/hover":
494476 if len (r .Contents .Value ) == 0 {
495477 return nil
496478 }
497479 handler .cpp2inoHover (r , uri )
498- case "textDocument/definition" :
499- fallthrough
500- case "textDocument/typeDefinition" :
501- fallthrough
502- case "textDocument/implementation" :
503- fallthrough
504- case "textDocument/references" :
505- r := result .(* []lsp.Location )
480+ // case "textDocument/definition":
481+ // fallthrough
482+ // case "textDocument/typeDefinition":
483+ // fallthrough
484+ // case "textDocument/implementation":
485+ // fallthrough
486+ case * []lsp.Location : // "textDocument/references":
506487 for index := range * r {
507488 handler .cpp2inoLocation (& (* r )[index ])
508489 }
509- case "textDocument/documentHighlight" :
510- r := result .(* []lsp.DocumentHighlight )
490+ case * []lsp.DocumentHighlight : // "textDocument/documentHighlight":
511491 for index := range * r {
512492 handler .cpp2inoDocumentHighlight (& (* r )[index ], uri )
513493 }
514- case "textDocument/formatting" :
515- fallthrough
516- case "textDocument/rangeFormatting" :
517- fallthrough
518- case "textDocument/onTypeFormatting" :
519- r := result .(* []lsp.TextEdit )
494+ // case "textDocument/formatting":
495+ // fallthrough
496+ // case "textDocument/rangeFormatting":
497+ // fallthrough
498+ case * []lsp.TextEdit : // "textDocument/onTypeFormatting":
520499 for index := range * r {
521500 handler .cpp2inoTextEdit (& (* r )[index ], uri )
522501 }
523- case "textDocument/documentSymbol" :
524- r , ok := result .(* []* documentSymbolOrSymbolInformation )
525-
526- if ! ok || len (* r ) == 0 {
502+ case * []* documentSymbolOrSymbolInformation : // "textDocument/documentSymbol":
503+ if len (* r ) == 0 {
527504 return result
528505 }
529506
@@ -544,11 +521,9 @@ func (handler *InoHandler) transformClangdResult(method string, uri lsp.Document
544521 }
545522 return handler .cpp2inoSymbolInformation (symbols )
546523 }
547- case "textDocument/rename" :
548- r := result .(* lsp.WorkspaceEdit )
524+ case * lsp.WorkspaceEdit : // "textDocument/rename":
549525 return handler .cpp2inoWorkspaceEdit (r )
550- case "workspace/symbol" :
551- r := result .(* []lsp.SymbolInformation )
526+ case * []lsp.SymbolInformation : // "workspace/symbol":
552527 for index := range * r {
553528 handler .cpp2inoLocation (& (* r )[index ].Location )
554529 }
0 commit comments