Skip to content

Commit be08b32

Browse files
committed
Handled events 'shutdown' and 'exit'
1 parent 6cceaac commit be08b32

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

Diff for: ls/ls.go

+12
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,14 @@ func (handler *INOLanguageServer) InitializeReqFromIDE(ctx context.Context, logg
308308
return resp, nil
309309
}
310310

311+
func (ls *INOLanguageServer) ShutdownReqFromIDE(ctx context.Context, logger jsonrpc.FunctionLogger) *jsonrpc.ResponseError {
312+
logger.Logf("Sending shutdown notification to clangd...")
313+
ls.Clangd.conn.Shutdown(context.Background())
314+
logger.Logf("Arduino Language Server is shutting down.")
315+
ls.Close()
316+
return nil
317+
}
318+
311319
func (ls *INOLanguageServer) TextDocumentCompletionReqFromIDE(ctx context.Context, logger jsonrpc.FunctionLogger, inoParams *lsp.CompletionParams) (*lsp.CompletionList, *jsonrpc.ResponseError) {
312320
ls.readLock(logger, true)
313321
defer ls.readUnlock(logger)
@@ -815,6 +823,10 @@ func (ls *INOLanguageServer) InitializedNotifFromIDE(logger jsonrpc.FunctionLogg
815823
logger.Logf("Notification is not propagated to clangd")
816824
}
817825

826+
func (ls *INOLanguageServer) ExitNotifFromIDE(logger jsonrpc.FunctionLogger) {
827+
logger.Logf("Notification is not propagated to clangd")
828+
}
829+
818830
func (ls *INOLanguageServer) TextDocumentDidOpenNotifFromIDE(logger jsonrpc.FunctionLogger, inoParam *lsp.DidOpenTextDocumentParams) {
819831
ls.writeLock(logger, true)
820832
defer ls.writeUnlock(logger)

Diff for: ls/lsp_client_clangd.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ func (client *ClangdLSPClient) Run() {
7373
}
7474

7575
func (client *ClangdLSPClient) Close() {
76-
panic("unimplemented")
76+
client.conn.Exit() // send "exit" notification to Clangd
77+
// TODO: kill client.conn
7778
}
7879

7980
// The following are events incoming from Clangd

Diff for: ls/lsp_server_ide.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func (server *IDELSPServer) Initialize(ctx context.Context, logger jsonrpc.Funct
3232
}
3333

3434
func (server *IDELSPServer) Shutdown(ctx context.Context, logger jsonrpc.FunctionLogger) *jsonrpc.ResponseError {
35-
panic("unimplemented")
35+
return server.ls.ShutdownReqFromIDE(ctx, logger)
3636
}
3737

3838
func (server *IDELSPServer) WorkspaceSymbol(ctx context.Context, logger jsonrpc.FunctionLogger, params *lsp.WorkspaceSymbolParams) ([]lsp.SymbolInformation, *jsonrpc.ResponseError) {
@@ -206,7 +206,7 @@ func (server *IDELSPServer) Initialized(logger jsonrpc.FunctionLogger, params *l
206206
}
207207

208208
func (server *IDELSPServer) Exit(logger jsonrpc.FunctionLogger) {
209-
panic("unimplemented")
209+
server.ls.ExitNotifFromIDE(logger)
210210
}
211211

212212
func (server *IDELSPServer) SetTrace(logger jsonrpc.FunctionLogger, params *lsp.SetTraceParams) {

0 commit comments

Comments
 (0)