github.com/amarpal/go-tools@v0.0.0-20240422043104-40142f59f616/analysis/facts/tokenfile/token.go (about)

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