@@ -83,7 +83,10 @@ func NewInoHandler(stdio io.ReadWriteCloser, board lsp.Board) *InoHandler {
8383 handler .clangdStarted = sync .NewCond (& handler .dataMux )
8484 stdStream := jsonrpc2 .NewBufferedStream (stdio , jsonrpc2.VSCodeObjectCodec {})
8585 var stdHandler jsonrpc2.Handler = jsonrpc2 .HandlerWithError (handler .HandleMessageFromIDE )
86- handler .StdioConn = jsonrpc2 .NewConn (context .Background (), stdStream , stdHandler )
86+ handler .StdioConn = jsonrpc2 .NewConn (context .Background (), stdStream , stdHandler ,
87+ jsonrpc2 .OnRecv (streams .JSONRPCConnLogOnRecv ("IDE --> LS CL:" )),
88+ jsonrpc2 .OnSend (streams .JSONRPCConnLogOnSend ("IDE <-- LS CL:" )),
89+ )
8790
8891 handler .progressHandler = NewProgressProxy (handler .StdioConn )
8992
@@ -176,6 +179,8 @@ func (handler *InoHandler) HandleMessageFromIDE(ctx context.Context, conn *jsonr
176179 // method "initialize"
177180
178181 go func () {
182+ defer streams .CatchAndLogPanic ()
183+
179184 // Start clangd asynchronously
180185 log .Printf ("LS --- initializing workbench (queued)" )
181186 handler .dataMux .Lock ()
@@ -514,7 +519,9 @@ func (handler *InoHandler) initializeWorkbench(ctx context.Context, params *lsp.
514519
515520 clangdStream := jsonrpc2 .NewBufferedStream (clangdStdio , jsonrpc2.VSCodeObjectCodec {})
516521 clangdHandler := AsyncHandler {jsonrpc2 .HandlerWithError (handler .FromClangd )}
517- handler .ClangdConn = jsonrpc2 .NewConn (context .Background (), clangdStream , clangdHandler )
522+ handler .ClangdConn = jsonrpc2 .NewConn (context .Background (), clangdStream , clangdHandler ,
523+ jsonrpc2 .OnRecv (streams .JSONRPCConnLogOnRecv ("IDE LS <-- CL:" )),
524+ jsonrpc2 .OnSend (streams .JSONRPCConnLogOnSend ("IDE LS --> CL:" )))
518525
519526 // Send initialization command to clangd
520527 ctx , cancel := context .WithTimeout (context .Background (), time .Second )
@@ -1087,12 +1094,15 @@ func (handler *InoHandler) transformClangdResult(method string, inoURI, cppURI l
10871094
10881095 if r .DocumentSymbolArray != nil {
10891096 // Treat the input as []DocumentSymbol
1097+ log .Printf (" <-- documentSymbol(%d document symbols)" , len (* r .DocumentSymbolArray ))
10901098 return handler .cpp2inoDocumentSymbols (* r .DocumentSymbolArray , inoURI )
10911099 } else if r .SymbolInformationArray != nil {
10921100 // Treat the input as []SymbolInformation
1101+ log .Printf (" <-- documentSymbol(%d symbol information)" , len (* r .SymbolInformationArray ))
10931102 return handler .cpp2inoSymbolInformation (* r .SymbolInformationArray )
10941103 } else {
10951104 // Treat the input as null
1105+ log .Printf (" <-- null documentSymbol" )
10961106 }
10971107
10981108 case * []lsp.CommandOrCodeAction :
0 commit comments