@@ -180,6 +180,23 @@ func (handler *InoHandler) HandleMessageFromIDE(ctx context.Context, conn *jsonr
180
180
err = handler .ino2cppTextDocumentPositionParams (& p .TextDocumentPositionParams )
181
181
log .Printf (" --> completion(%s:%d:%d)\n " , p .TextDocument .URI , p .Position .Line , p .Position .Character )
182
182
183
+ case * lsp.CodeActionParams :
184
+ // method "textDocument/codeAction"
185
+ uri = p .TextDocument .URI
186
+ log .Printf ("--> codeAction(%s:%s)" , p .TextDocument .URI , p .Range .Start )
187
+
188
+ if err := handler .sketchToBuildPathTextDocumentIdentifier (& p .TextDocument ); err != nil {
189
+ break
190
+ }
191
+ if p .TextDocument .URI .AsPath ().EquivalentTo (handler .buildSketchCpp ) {
192
+ p .Range = handler .sketchMapper .InoToCppLSPRange (uri , p .Range )
193
+ for index := range p .Context .Diagnostics {
194
+ r := & p .Context .Diagnostics [index ].Range
195
+ * r = handler .sketchMapper .InoToCppLSPRange (uri , * r )
196
+ }
197
+ }
198
+ log .Printf (" --> codeAction(%s:%s)" , p .TextDocument .URI , p .Range .Start )
199
+
183
200
case * lsp.HoverParams :
184
201
// method: "textDocument/hover"
185
202
uri = p .TextDocument .URI
@@ -200,11 +217,6 @@ func (handler *InoHandler) HandleMessageFromIDE(ctx context.Context, conn *jsonr
200
217
uri = p .TextDocument .URI
201
218
err = handler .sketchToBuildPathTextDocumentIdentifier (& p .TextDocument )
202
219
handler .deleteFileData (uri )
203
- case * lsp.CodeActionParams : // "textDocument/codeAction":
204
- log .Printf ("--X " + req .Method )
205
- return nil , nil
206
- uri = p .TextDocument .URI
207
- err = handler .ino2cppCodeActionParams (p )
208
220
// case "textDocument/signatureHelp":
209
221
// fallthrough
210
222
// case "textDocument/definition":
@@ -607,20 +619,6 @@ func (handler *InoHandler) ino2cppTextDocumentPositionParams(params *lsp.TextDoc
607
619
return nil
608
620
}
609
621
610
- func (handler * InoHandler ) ino2cppCodeActionParams (params * lsp.CodeActionParams ) error {
611
- panic ("not implemented" )
612
- // handler.sketchToBuildPathTextDocumentIdentifier(¶ms.TextDocument)
613
- // if data, ok := handler.data[params.TextDocument.URI]; ok {
614
- // params.Range = data.sourceMap.InoToCppLSPRange(data.sourceURI, params.Range)
615
- // for index := range params.Context.Diagnostics {
616
- // r := ¶ms.Context.Diagnostics[index].Range
617
- // *r = data.sourceMap.InoToCppLSPRange(data.sourceURI, *r)
618
- // }
619
- // return nil
620
- // }
621
- return unknownURI (params .TextDocument .URI )
622
- }
623
-
624
622
func (handler * InoHandler ) ino2cppDocumentRangeFormattingParams (params * lsp.DocumentRangeFormattingParams ) error {
625
623
panic ("not implemented" )
626
624
// handler.sketchToBuildPathTextDocumentIdentifier(¶ms.TextDocument)
@@ -727,7 +725,12 @@ func (handler *InoHandler) transformClangdResult(method string, uri lsp.Document
727
725
log .Printf ("<-- completion(%d items)" , len (r .Items ))
728
726
return r
729
727
730
- case * []* lsp.CommandOrCodeAction : // "textDocument/codeAction":
728
+ case * []* lsp.CommandOrCodeAction :
729
+ // method "textDocument/codeAction"
730
+ // TODO: implement response
731
+ r = & []* lsp.CommandOrCodeAction {}
732
+ log .Printf ("<-- codeAction(empty)" )
733
+ break
731
734
for index := range * r {
732
735
command := (* r )[index ].Command
733
736
if command != nil {
@@ -738,6 +741,7 @@ func (handler *InoHandler) transformClangdResult(method string, uri lsp.Document
738
741
handler .cpp2inoCodeAction (codeAction , uri )
739
742
}
740
743
}
744
+
741
745
// case "textDocument/definition":
742
746
// fallthrough
743
747
// case "textDocument/typeDefinition":
0 commit comments