
Fix #324, relates #314 1. Update gocritic to the latest version 2. Use proper gocritic checkers repo, old repo was archived 3. Get enabled by default gocritic checks in sync with go-critic: don't enable performance, experimental and opinionated checks by default 4. Support of `enabled-tags` options for gocritic 5. Enable almost all gocritic checks for the project 6. Make rich debugging for gocritic 7. Meticulously validate gocritic checks config
33 lines
596 B
Go
33 lines
596 B
Go
package astwalk
|
|
|
|
import (
|
|
"go/ast"
|
|
)
|
|
|
|
type localCommentWalker struct {
|
|
visitor LocalCommentVisitor
|
|
}
|
|
|
|
func (w *localCommentWalker) WalkFile(f *ast.File) {
|
|
if !w.visitor.EnterFile(f) {
|
|
return
|
|
}
|
|
|
|
for _, decl := range f.Decls {
|
|
decl, ok := decl.(*ast.FuncDecl)
|
|
if !ok || !w.visitor.EnterFunc(decl) {
|
|
continue
|
|
}
|
|
|
|
for _, cg := range f.Comments {
|
|
// Not sure that decls/comments are sorted
|
|
// by positions, so do a naive full scan for now.
|
|
if cg.Pos() < decl.Pos() || cg.Pos() > decl.End() {
|
|
continue
|
|
}
|
|
|
|
visitCommentGroups(cg, w.visitor.VisitLocalComment)
|
|
}
|
|
}
|
|
}
|