@@ -151,75 +151,60 @@ func (handler *InoHandler) transformParamsToClangd(ctx context.Context, method s
151
151
defer handler .synchronizer .DataMux .RUnlock ()
152
152
}
153
153
154
- switch method {
155
- case "textDocument/didOpen" :
156
- p := params .(* lsp.DidOpenTextDocumentParams )
154
+ switch p := params .(type ) {
155
+ case * lsp.DidOpenTextDocumentParams : // "textDocument/didOpen":
157
156
uri = p .TextDocument .URI
158
157
err = handler .ino2cppTextDocumentItem (ctx , & p .TextDocument )
159
- case "textDocument/didChange" :
160
- p := params .(* lsp.DidChangeTextDocumentParams )
158
+ case * lsp.DidChangeTextDocumentParams : // "textDocument/didChange":
161
159
uri = p .TextDocument .URI
162
160
err = handler .ino2cppDidChangeTextDocumentParams (ctx , p )
163
- case "textDocument/didSave" :
164
- p := params .(* lsp.DidSaveTextDocumentParams )
161
+ case * lsp.DidSaveTextDocumentParams : // "textDocument/didSave":
165
162
uri = p .TextDocument .URI
166
163
err = handler .ino2cppTextDocumentIdentifier (& p .TextDocument )
167
- case "textDocument/didClose" :
168
- p := params .(* lsp.DidCloseTextDocumentParams )
164
+ case * lsp.DidCloseTextDocumentParams : // "textDocument/didClose":
169
165
uri = p .TextDocument .URI
170
166
err = handler .ino2cppTextDocumentIdentifier (& p .TextDocument )
171
167
handler .deleteFileData (uri )
172
- case "textDocument/completion" :
173
- p := params .(* lsp.CompletionParams )
168
+ case * lsp.CompletionParams : // "textDocument/completion":
174
169
uri = p .TextDocument .URI
175
170
err = handler .ino2cppTextDocumentPositionParams (& p .TextDocumentPositionParams )
176
- case "textDocument/codeAction" :
177
- p := params .(* lsp.CodeActionParams )
171
+ case * lsp.CodeActionParams : // "textDocument/codeAction":
178
172
uri = p .TextDocument .URI
179
173
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":
192
185
uri = p .TextDocument .URI
193
186
err = handler .ino2cppTextDocumentPositionParams (p )
194
- case "textDocument/references" :
195
- p := params .(* lsp.ReferenceParams )
187
+ case * lsp.ReferenceParams : // "textDocument/references":
196
188
uri = p .TextDocument .URI
197
189
err = handler .ino2cppTextDocumentPositionParams (& p .TextDocumentPositionParams )
198
- case "textDocument/formatting" :
199
- p := params .(* lsp.DocumentFormattingParams )
190
+ case * lsp.DocumentFormattingParams : // "textDocument/formatting":
200
191
uri = p .TextDocument .URI
201
192
err = handler .ino2cppTextDocumentIdentifier (& p .TextDocument )
202
- case "textDocument/rangeFormatting" :
203
- p := params .(* lsp.DocumentRangeFormattingParams )
193
+ case * lsp.DocumentRangeFormattingParams : // "textDocument/rangeFormatting":
204
194
uri = p .TextDocument .URI
205
195
err = handler .ino2cppDocumentRangeFormattingParams (p )
206
- case "textDocument/onTypeFormatting" :
207
- p := params .(* lsp.DocumentOnTypeFormattingParams )
196
+ case * lsp.DocumentOnTypeFormattingParams : // "textDocument/onTypeFormatting":
208
197
uri = p .TextDocument .URI
209
198
err = handler .ino2cppDocumentOnTypeFormattingParams (p )
210
- case "textDocument/documentSymbol" :
211
- p := params .(* lsp.DocumentSymbolParams )
199
+ case * lsp.DocumentSymbolParams : // "textDocument/documentSymbol":
212
200
uri = p .TextDocument .URI
213
201
err = handler .ino2cppTextDocumentIdentifier (& p .TextDocument )
214
- case "textDocument/rename" :
215
- p := params .(* lsp.RenameParams )
202
+ case * lsp.RenameParams : // "textDocument/rename":
216
203
uri = p .TextDocument .URI
217
204
err = handler .ino2cppRenameParams (p )
218
- case "workspace/didChangeWatchedFiles" :
219
- p := params .(* lsp.DidChangeWatchedFilesParams )
205
+ case * lsp.DidChangeWatchedFilesParams : // "workspace/didChangeWatchedFiles":
220
206
err = handler .ino2cppDidChangeWatchedFilesParams (p )
221
- case "workspace/executeCommand" :
222
- p := params .(* lsp.ExecuteCommandParams )
207
+ case * lsp.ExecuteCommandParams : // "workspace/executeCommand":
223
208
err = handler .ino2cppExecuteCommand (p )
224
209
}
225
210
return
@@ -473,12 +458,10 @@ func (handler *InoHandler) transformClangdResult(method string, uri lsp.Document
473
458
handler .synchronizer .DataMux .RLock ()
474
459
defer handler .synchronizer .DataMux .RUnlock ()
475
460
476
- switch method {
477
- case "textDocument/completion" :
478
- r := result .(* lsp.CompletionList )
461
+ switch r := result .(type ) {
462
+ case * lsp.CompletionList : // "textDocument/completion":
479
463
handler .cpp2inoCompletionList (r , uri )
480
- case "textDocument/codeAction" :
481
- r := result .(* []* commandOrCodeAction )
464
+ case * []* commandOrCodeAction : // "textDocument/codeAction":
482
465
for index := range * r {
483
466
command := (* r )[index ].Command
484
467
if command != nil {
@@ -489,41 +472,35 @@ func (handler *InoHandler) transformClangdResult(method string, uri lsp.Document
489
472
handler .cpp2inoCodeAction (codeAction , uri )
490
473
}
491
474
}
492
- case "textDocument/hover" :
493
- r := result .(* Hover )
475
+ case * Hover : // "textDocument/hover":
494
476
if len (r .Contents .Value ) == 0 {
495
477
return nil
496
478
}
497
479
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":
506
487
for index := range * r {
507
488
handler .cpp2inoLocation (& (* r )[index ])
508
489
}
509
- case "textDocument/documentHighlight" :
510
- r := result .(* []lsp.DocumentHighlight )
490
+ case * []lsp.DocumentHighlight : // "textDocument/documentHighlight":
511
491
for index := range * r {
512
492
handler .cpp2inoDocumentHighlight (& (* r )[index ], uri )
513
493
}
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":
520
499
for index := range * r {
521
500
handler .cpp2inoTextEdit (& (* r )[index ], uri )
522
501
}
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 {
527
504
return result
528
505
}
529
506
@@ -544,11 +521,9 @@ func (handler *InoHandler) transformClangdResult(method string, uri lsp.Document
544
521
}
545
522
return handler .cpp2inoSymbolInformation (symbols )
546
523
}
547
- case "textDocument/rename" :
548
- r := result .(* lsp.WorkspaceEdit )
524
+ case * lsp.WorkspaceEdit : // "textDocument/rename":
549
525
return handler .cpp2inoWorkspaceEdit (r )
550
- case "workspace/symbol" :
551
- r := result .(* []lsp.SymbolInformation )
526
+ case * []lsp.SymbolInformation : // "workspace/symbol":
552
527
for index := range * r {
553
528
handler .cpp2inoLocation (& (* r )[index ].Location )
554
529
}
0 commit comments