src

Go monorepo.
git clone git://code.dwrz.net/src
Log | Files | Refs

token.go (498B)


      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) (any, 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.TypeFor[map[*token.File]*ast.File](),
     24 }