diff --git a/internal/lsp/cmd/imports.go b/internal/lsp/cmd/imports.go index 2b8b13e947..2127e25ab8 100644 --- a/internal/lsp/cmd/imports.go +++ b/internal/lsp/cmd/imports.go @@ -69,11 +69,7 @@ func (t *imports) Run(ctx context.Context, args ...string) error { return errors.Errorf("%v: %v", from, err) } var edits []protocol.TextEdit - v, ok := actions.([]protocol.CodeAction) - if !ok { - return errors.Errorf("expected CodeAction, got %T", actions) - } - for _, a := range v { + for _, a := range actions { if a.Title != "Organize Imports" { continue } diff --git a/internal/lsp/cmd/suggested_fix.go b/internal/lsp/cmd/suggested_fix.go index 2687821f08..15c6bc9983 100644 --- a/internal/lsp/cmd/suggested_fix.go +++ b/internal/lsp/cmd/suggested_fix.go @@ -87,11 +87,7 @@ func (s *suggestedfix) Run(ctx context.Context, args ...string) error { return errors.Errorf("%v: %v", from, err) } var edits []protocol.TextEdit - v, ok := actions.([]protocol.CodeAction) - if !ok { - return errors.Errorf("expected CodeAction, got %T", actions) - } - for _, a := range v { + for _, a := range actions { if !a.IsPreferred && !s.All { continue } diff --git a/internal/lsp/lsp_test.go b/internal/lsp/lsp_test.go index 4ddc5abd4b..23d3927d47 100644 --- a/internal/lsp/lsp_test.go +++ b/internal/lsp/lsp_test.go @@ -314,9 +314,8 @@ func (r *runner) Import(t *testing.T, spn span.Span) { t.Fatal(err) } got := string(m.Content) - xact := actions.([]protocol.CodeAction) - if len(xact) > 0 { - res, err := applyWorkspaceEdits(r, xact[0].Edit) + if len(actions) > 0 { + res, err := applyWorkspaceEdits(r, actions[0].Edit) if err != nil { t.Fatal(err) } @@ -355,11 +354,10 @@ func (r *runner) SuggestedFix(t *testing.T, spn span.Span) { t.Fatal(err) } // TODO: This test should probably be able to handle multiple code actions. - xact := actions.([]protocol.CodeAction) - if len(xact) > 1 { + if len(actions) > 1 { t.Fatal("expected only 1 code action") } - res, err := applyWorkspaceEdits(r, xact[0].Edit) + res, err := applyWorkspaceEdits(r, actions[0].Edit) if err != nil { t.Fatal(err) } diff --git a/internal/lsp/protocol/tsserver.go b/internal/lsp/protocol/tsserver.go index f6593cbf64..8850d99c60 100644 --- a/internal/lsp/protocol/tsserver.go +++ b/internal/lsp/protocol/tsserver.go @@ -3,7 +3,7 @@ package protocol // Package protocol contains data types and code for LSP jsonrpcs // generated automatically from vscode-languageserver-node // commit: 635ab1fe6f8c57ce9402e573d007f24d6d290fd3 -// last fetched Sun Oct 13 2019 10:14:32 GMT-0400 (Eastern Daylight Time) +// last fetched Mon Oct 14 2019 09:09:30 GMT-0400 (Eastern Daylight Time) // Code generated (see typescript/README.md) DO NOT EDIT. @@ -27,7 +27,6 @@ type Server interface { DidSave(context.Context, *DidSaveTextDocumentParams) error WillSave(context.Context, *WillSaveTextDocumentParams) error DidChangeWatchedFiles(context.Context, *DidChangeWatchedFilesParams) error - CancelRequest(context.Context, *CancelParams) error Progress(context.Context, *ProgressParams) error SetTraceNotification(context.Context, *SetTraceParams) error LogTraceNotification(context.Context, *LogTraceParams) error @@ -49,7 +48,7 @@ type Server interface { References(context.Context, *ReferenceParams) ([]Location /*Location[] | null*/, error) DocumentHighlight(context.Context, *DocumentHighlightParams) ([]DocumentHighlight /*DocumentHighlight[] | null*/, error) DocumentSymbol(context.Context, *DocumentSymbolParams) ([]DocumentSymbol /*SymbolInformation[] | DocumentSymbol[] | null*/, error) - CodeAction(context.Context, *CodeActionParams) (interface{} /*Command | CodeAction*/ /*(Command | CodeAction)[] | null*/, error) + CodeAction(context.Context, *CodeActionParams) ([]CodeAction /*(Command | CodeAction)[] | null*/, error) Symbol(context.Context, *WorkspaceSymbolParams) ([]SymbolInformation /*SymbolInformation[] | null*/, error) CodeLens(context.Context, *CodeLensParams) ([]CodeLens /*CodeLens[] | null*/, error) ResolveCodeLens(context.Context, *CodeLens) (*CodeLens, error) @@ -168,16 +167,6 @@ func (h serverHandler) Deliver(ctx context.Context, r *jsonrpc2.Request, deliver log.Error(ctx, "", err) } return true - case "$/cancelRequest": // notif - var params CancelParams - if err := json.Unmarshal(*r.Params, ¶ms); err != nil { - sendParseError(ctx, r, err) - return true - } - if err := h.server.CancelRequest(ctx, ¶ms); err != nil { - log.Error(ctx, "", err) - } - return true case "$/progress": // notif var params ProgressParams if err := json.Unmarshal(*r.Params, ¶ms); err != nil { @@ -587,10 +576,6 @@ func (s *serverDispatcher) DidChangeWatchedFiles(ctx context.Context, params *Di return s.Conn.Notify(ctx, "workspace/didChangeWatchedFiles", params) } -func (s *serverDispatcher) CancelRequest(ctx context.Context, params *CancelParams) error { - return s.Conn.Notify(ctx, "$/cancelRequest", params) -} - func (s *serverDispatcher) Progress(ctx context.Context, params *ProgressParams) error { return s.Conn.Notify(ctx, "$/progress", params) } @@ -742,8 +727,8 @@ func (s *serverDispatcher) DocumentSymbol(ctx context.Context, params *DocumentS return result, nil } -func (s *serverDispatcher) CodeAction(ctx context.Context, params *CodeActionParams) (interface{} /*Command | CodeAction*/ /*(Command | CodeAction)[] | null*/, error) { - var result interface{} /*Command | CodeAction*/ /*(Command | CodeAction)[] | null*/ +func (s *serverDispatcher) CodeAction(ctx context.Context, params *CodeActionParams) ([]CodeAction /*(Command | CodeAction)[] | null*/, error) { + var result []CodeAction /*(Command | CodeAction)[] | null*/ if err := s.Conn.Call(ctx, "textDocument/codeAction", params, &result); err != nil { return nil, err } diff --git a/internal/lsp/server.go b/internal/lsp/server.go index c779adaddb..c13047c5ba 100644 --- a/internal/lsp/server.go +++ b/internal/lsp/server.go @@ -201,7 +201,7 @@ func (s *Server) DocumentSymbol(ctx context.Context, params *protocol.DocumentSy return s.documentSymbol(ctx, params) } -func (s *Server) CodeAction(ctx context.Context, params *protocol.CodeActionParams) (interface{}, error) { +func (s *Server) CodeAction(ctx context.Context, params *protocol.CodeActionParams) ([]protocol.CodeAction, error) { return s.codeAction(ctx, params) }