 6a979fb40d
			
		
	
	
		6a979fb40d
		
			
		
	
	
	
	
		
			
			* update staticcheck Don't fork staticcheck: use the upstream version. Remove unneeded SSA loading. * Cache go/analysis facts Don't load unneeded packages for go/analysis. Repeated run of go/analysis linters now 10x faster (2s vs 20s on this repo) than before.
		
			
				
	
	
		
			25 lines
		
	
	
		
			502 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			25 lines
		
	
	
		
			502 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| 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{}),
 | |
| }
 |