@@ -180,6 +180,23 @@ func (handler *InoHandler) HandleMessageFromIDE(ctx context.Context, conn *jsonr
180180 err = handler .ino2cppTextDocumentPositionParams (& p .TextDocumentPositionParams )
181181 log .Printf (" --> completion(%s:%d:%d)\n " , p .TextDocument .URI , p .Position .Line , p .Position .Character )
182182
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+
183200 case * lsp.HoverParams :
184201 // method: "textDocument/hover"
185202 uri = p .TextDocument .URI
@@ -200,11 +217,6 @@ func (handler *InoHandler) HandleMessageFromIDE(ctx context.Context, conn *jsonr
200217 uri = p .TextDocument .URI
201218 err = handler .sketchToBuildPathTextDocumentIdentifier (& p .TextDocument )
202219 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 )
208220 // case "textDocument/signatureHelp":
209221 // fallthrough
210222 // case "textDocument/definition":
@@ -607,20 +619,6 @@ func (handler *InoHandler) ino2cppTextDocumentPositionParams(params *lsp.TextDoc
607619 return nil
608620}
609621
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-
624622func (handler * InoHandler ) ino2cppDocumentRangeFormattingParams (params * lsp.DocumentRangeFormattingParams ) error {
625623 panic ("not implemented" )
626624 // handler.sketchToBuildPathTextDocumentIdentifier(¶ms.TextDocument)
@@ -727,7 +725,12 @@ func (handler *InoHandler) transformClangdResult(method string, uri lsp.Document
727725 log .Printf ("<-- completion(%d items)" , len (r .Items ))
728726 return r
729727
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
731734 for index := range * r {
732735 command := (* r )[index ].Command
733736 if command != nil {
@@ -738,6 +741,7 @@ func (handler *InoHandler) transformClangdResult(method string, uri lsp.Document
738741 handler .cpp2inoCodeAction (codeAction , uri )
739742 }
740743 }
744+
741745 // case "textDocument/definition":
742746 // fallthrough
743747 // case "textDocument/typeDefinition":
0 commit comments