From 3e041465ccae5f99030696bb174c1f40dbd5213a Mon Sep 17 00:00:00 2001 From: Peter Weinbergr Date: Tue, 10 Mar 2020 11:47:56 -0400 Subject: [PATCH] internal/lsp: change the type of CompletionItem.TextEdit back The recent LPS protocol change made the definition of textEdit into a union type, so the generated code made TextEdit an interface{}, which broke govim. This CL reverts it to a *TextEdit. The code generator will be fixed in another CL. We can revisit this when gopls wants to start using the new InsertReplaceEdit type. Change-Id: I4d7a14b3746b747f34b0907f72ecbc3593706a05 Reviewed-on: https://go-review.googlesource.com/c/tools/+/222765 Reviewed-by: Rebecca Stambler --- internal/lsp/protocol/tsprotocol.go | 2 +- internal/lsp/tests/util.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/lsp/protocol/tsprotocol.go b/internal/lsp/protocol/tsprotocol.go index eb640ef944..7436a7d338 100644 --- a/internal/lsp/protocol/tsprotocol.go +++ b/internal/lsp/protocol/tsprotocol.go @@ -674,7 +674,7 @@ type CompletionItem struct { * * @since 3.16.0 additional type `InsertReplaceEdit` - Proposed state */ - TextEdit interface{}/*TextEdit | InsertReplaceEdit*/ `json:"textEdit,omitempty"` + TextEdit *TextEdit/*TextEdit | InsertReplaceEdit*/ `json:"textEdit,omitempty"` /** * An optional array of additional [text edits](#TextEdit) that are applied when * selecting this completion. Edits must not overlap (including the same insert position) diff --git a/internal/lsp/tests/util.go b/internal/lsp/tests/util.go index 965eadcebd..924fbd550b 100644 --- a/internal/lsp/tests/util.go +++ b/internal/lsp/tests/util.go @@ -428,14 +428,14 @@ func CheckCompletionOrder(want, got []protocol.CompletionItem, strictScores bool func DiffSnippets(want string, got *protocol.CompletionItem) string { if want == "" { if got != nil { - x := got.TextEdit.(*protocol.TextEdit) + x := got.TextEdit return fmt.Sprintf("expected no snippet but got %s", x.NewText) } } else { if got == nil { return fmt.Sprintf("couldn't find completion matching %q", want) } - x := got.TextEdit.(*protocol.TextEdit) + x := got.TextEdit if want != x.NewText { return fmt.Sprintf("expected snippet %q, got %q", want, x.NewText) }