token.go 502 B

12345678910111213141516171819202122232425
  1. package facts
  2. import (
  3. "go/ast"
  4. "go/token"
  5. "reflect"
  6. "golang.org/x/tools/go/analysis"
  7. )
  8. var TokenFile = &analysis.Analyzer{
  9. Name: "tokenfileanalyzer",
  10. Doc: "creates a mapping of *token.File to *ast.File",
  11. Run: func(pass *analysis.Pass) (interface{}, error) {
  12. m := map[*token.File]*ast.File{}
  13. for _, af := range pass.Files {
  14. tf := pass.Fset.File(af.Pos())
  15. m[tf] = af
  16. }
  17. return m, nil
  18. },
  19. RunDespiteErrors: true,
  20. ResultType: reflect.TypeOf(map[*token.File]*ast.File{}),
  21. }