mirror of
https://github.com/golang/go
synced 2024-11-18 21:34:46 -07:00
ff9f140924
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>
27 lines
604 B
Go
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
|
|
}
|