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 <rstambler@golang.org>
This commit is contained in:
Peter Weinbergr 2020-03-10 11:47:56 -04:00 committed by Peter Weinberger
parent b84001dd64
commit 3e041465cc
2 changed files with 3 additions and 3 deletions

View File

@ -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)

View File

@ -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)
}