@@ -68,7 +68,7 @@ func (handler *InoHandler) FromStdio(ctx context.Context, conn *jsonrpc2.Conn, r
68
68
result , err = sendRequest (ctx , handler .ClangdConn , req .Method , params )
69
69
}
70
70
if err != nil {
71
- log .Println ("From stdio: Method:" , req .Method , "Params:" , params , " Error:" , err )
71
+ log .Println ("From stdio: Method:" , req .Method , "Error:" , err )
72
72
return nil , err
73
73
}
74
74
if enableLogging {
@@ -130,6 +130,14 @@ func (handler *InoHandler) transformClangdParams(method string, raw *json.RawMes
130
130
p := params .(* lsp.ReferenceParams )
131
131
uri = p .TextDocument .URI
132
132
err = handler .ino2cppTextDocumentPositionParams (& p .TextDocumentPositionParams )
133
+ case "textDocument/formatting" :
134
+ p := params .(* lsp.DocumentFormattingParams )
135
+ uri = p .TextDocument .URI
136
+ err = handler .ino2cppTextDocumentIdentifier (& p .TextDocument )
137
+ case "textDocument/rangeFormatting" :
138
+ // TODO
139
+ case "textDocument/onTypeFormatting" :
140
+ // TODO
133
141
}
134
142
return
135
143
}
@@ -286,6 +294,15 @@ func (handler *InoHandler) transformClangdResult(method string, uri lsp.Document
286
294
for index := range * r {
287
295
handler .cpp2inoDocumentHighlight (& (* r )[index ], uri )
288
296
}
297
+ case "textDocument/formatting" :
298
+ fallthrough
299
+ case "textDocument/rangeFormatting" :
300
+ fallthrough
301
+ case "textDocument/onTypeFormatting" :
302
+ r := result .(* []lsp.TextEdit )
303
+ for index := range * r {
304
+ handler .cpp2inoTextEdit (& (* r )[index ], uri )
305
+ }
289
306
}
290
307
return result
291
308
}
@@ -357,6 +374,13 @@ func (handler *InoHandler) cpp2inoDocumentHighlight(highlight *lsp.DocumentHighl
357
374
}
358
375
}
359
376
377
+ func (handler * InoHandler ) cpp2inoTextEdit (edit * lsp.TextEdit , uri lsp.DocumentURI ) {
378
+ if data , ok := handler .data [uri ]; ok {
379
+ edit .Range .Start .Line = data .sourceLineMap [edit .Range .Start .Line ]
380
+ edit .Range .End .Line = data .sourceLineMap [edit .Range .End .Line ]
381
+ }
382
+ }
383
+
360
384
// FromClangd handles a message received from clangd.
361
385
func (handler * InoHandler ) FromClangd (ctx context.Context , connection * jsonrpc2.Conn , req * jsonrpc2.Request ) (interface {}, error ) {
362
386
params , _ , err := handler .transformStdioParams (req .Method , req .Params )
@@ -371,7 +395,7 @@ func (handler *InoHandler) FromClangd(ctx context.Context, connection *jsonrpc2.
371
395
result , err = sendRequest (ctx , handler .StdioConn , req .Method , params )
372
396
}
373
397
if err != nil {
374
- log .Println ("From clangd: Method:" , req .Method , "Params:" , params , " Error:" , err )
398
+ log .Println ("From clangd: Method:" , req .Method , "Error:" , err )
375
399
return nil , err
376
400
}
377
401
if enableLogging {
0 commit comments