github.com/blueinnovationsgroup/can-go@v0.0.0-20230518195432-d0567cda0028/pkg/dbc/analysis/passes/newsymbols/analyzer.go (about) 1 package newsymbols 2 3 import ( 4 "github.com/blueinnovationsgroup/can-go/pkg/dbc" 5 "github.com/blueinnovationsgroup/can-go/pkg/dbc/analysis" 6 ) 7 8 func Analyzer() *analysis.Analyzer { 9 return &analysis.Analyzer{ 10 Name: "newsymbols", 11 Doc: "check that the new symbols definition is empty", 12 Run: run, 13 } 14 } 15 16 func run(pass *analysis.Pass) error { 17 for _, def := range pass.File.Defs { 18 newSymbolsDef, ok := def.(*dbc.NewSymbolsDef) 19 if !ok { 20 continue // not a new symbols definition 21 } 22 if len(newSymbolsDef.Symbols) > 0 { 23 pass.Reportf(newSymbolsDef.Pos, "new symbols should be empty") 24 } 25 } 26 return nil 27 }