From c5b43a5f5a3d94521f797231eca80ac13353961f Mon Sep 17 00:00:00 2001 From: Joe Kralicky Date: Tue, 11 Jul 2023 23:14:16 -0400 Subject: [PATCH] Add command to restart language server --- editors/vscode/client/src/extension.ts | 6 ++++++ editors/vscode/package.json | 6 ++++++ protols/resolver.go | 6 +++--- protols/server.go | 2 +- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/editors/vscode/client/src/extension.ts b/editors/vscode/client/src/extension.ts index 15de149..4de23db 100644 --- a/editors/vscode/client/src/extension.ts +++ b/editors/vscode/client/src/extension.ts @@ -86,6 +86,12 @@ export function activate(context: ExtensionContext) { workspace.registerTextDocumentContentProvider('proto', client); // Start the client. This will also launch the server client.start(); + + context.subscriptions.push( + vscode.commands.registerCommand('protols.restart', async () => { + await client.restart(); + } + )); } export function deactivate(): Thenable | undefined { diff --git a/editors/vscode/package.json b/editors/vscode/package.json index ddd37a3..924565a 100644 --- a/editors/vscode/package.json +++ b/editors/vscode/package.json @@ -37,6 +37,12 @@ "path": "./syntaxes/protobuf.tmLanguage.json" } ], + "commands": [ + { + "command": "protols.restart", + "title": "Protols: Restart Language Server" + } + ], "configuration": { "type": "object", "title": "Example configuration", diff --git a/protols/resolver.go b/protols/resolver.go index 9d37357..f28c377 100644 --- a/protols/resolver.go +++ b/protols/resolver.go @@ -194,9 +194,9 @@ func (r *Resolver) checkWellKnownImportPath(path string) (protocompile.SearchRes } func (r *Resolver) checkFS(path string) (protocompile.SearchResult, error) { - uri, err := r.PathToURI(path) - if err != nil { - return protocompile.SearchResult{}, err + uri, ok := r.fileURIsByPath[path] + if !ok { + return protocompile.SearchResult{}, os.ErrNotExist } if fh, err := r.ReadFile(context.TODO(), uri); err == nil { content, err := fh.Content() diff --git a/protols/server.go b/protols/server.go index b65ed81..7641cf8 100644 --- a/protols/server.go +++ b/protols/server.go @@ -668,7 +668,7 @@ func (*Server) SetTrace(context.Context, *protocol.SetTraceParams) error { // Shutdown implements protocol.Server. func (*Server) Shutdown(context.Context) error { - return jsonrpc2.ErrMethodNotFound + return nil } // SignatureHelp implements protocol.Server.