1
0
mirror of https://github.com/golang/go synced 2024-11-19 02:14:43 -07:00
go/internal/lsp/source/suggested_fix_experimental.go
Michael Matloob ff9f140924 internal/lsp/source: fix renaming of SuggestedFixes in experimental file
Change-Id: I4a20ef09c565da39ed49f25d85133cd388c2bf05
Reviewed-on: https://go-review.googlesource.com/c/tools/+/187820
Run-TryBot: Michael Matloob <matloob@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-07-29 09:26:21 +00:00

27 lines
604 B
Go

// +build experimental
package source
import (
"go/token"
"golang.org/x/tools/go/analysis"
"golang.org/x/tools/internal/span"
)
func getCodeActions(fset *token.FileSet, diag analysis.Diagnostic) ([]SuggestedFixes, error) {
var cas []SuggestedFixes
for _, fix := range diag.SuggestedFixes {
var ca SuggestedFixes
ca.Title = fix.Message
for _, te := range fix.TextEdits {
span, err := span.NewRange(fset, te.Pos, te.End).Span()
if err != nil {
return nil, err
}
ca.Edits = append(ca.Edits, TextEdit{span, string(te.NewText)})
}
cas = append(cas, ca)
}
return cas, nil
}