mirror of
https://github.com/golang/go
synced 2024-11-19 01:14:39 -07:00
e713427fea
We're still leaving open the possibility of changing this API, but things have baked for a bit so I feel comfortable removing the build tag. Also add some documentation. Change-Id: I3beb666b58177553fc406dc9670d569d5928fedd Reviewed-on: https://go-review.googlesource.com/c/tools/+/189460 Run-TryBot: Michael Matloob <matloob@golang.org> Reviewed-by: Rebecca Stambler <rstambler@golang.org>
25 lines
580 B
Go
25 lines
580 B
Go
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
|
|
}
|