mirror of https://github.com/sunface/rust-course
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
502 B
25 lines
502 B
package facts
|
|
|
|
import (
|
|
"go/ast"
|
|
"go/token"
|
|
"reflect"
|
|
|
|
"golang.org/x/tools/go/analysis"
|
|
)
|
|
|
|
var TokenFile = &analysis.Analyzer{
|
|
Name: "tokenfileanalyzer",
|
|
Doc: "creates a mapping of *token.File to *ast.File",
|
|
Run: func(pass *analysis.Pass) (interface{}, error) {
|
|
m := map[*token.File]*ast.File{}
|
|
for _, af := range pass.Files {
|
|
tf := pass.Fset.File(af.Pos())
|
|
m[tf] = af
|
|
}
|
|
return m, nil
|
|
},
|
|
RunDespiteErrors: true,
|
|
ResultType: reflect.TypeOf(map[*token.File]*ast.File{}),
|
|
}
|