Documentation ¶
Index ¶
- func WalkerForComment(v CommentVisitor) lintpack.FileWalker
- func WalkerForDocComment(v DocCommentVisitor) lintpack.FileWalker
- func WalkerForExpr(v ExprVisitor) lintpack.FileWalker
- func WalkerForFuncDecl(v FuncDeclVisitor) lintpack.FileWalker
- func WalkerForLocalComment(v LocalCommentVisitor) lintpack.FileWalker
- func WalkerForLocalDef(v LocalDefVisitor, info *types.Info) lintpack.FileWalker
- func WalkerForLocalExpr(v LocalExprVisitor) lintpack.FileWalker
- func WalkerForStmt(v StmtVisitor) lintpack.FileWalker
- func WalkerForStmtList(v StmtListVisitor) lintpack.FileWalker
- func WalkerForTypeExpr(v TypeExprVisitor, info *types.Info) lintpack.FileWalker
- type CommentVisitor
- type DocCommentVisitor
- type ExprVisitor
- type FuncDeclVisitor
- type LocalCommentVisitor
- type LocalDefVisitor
- type LocalExprVisitor
- type Name
- type NameKind
- type StmtListVisitor
- type StmtVisitor
- type TypeExprVisitor
- type WalkHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WalkerForComment ¶ added in v0.5.2
func WalkerForComment(v CommentVisitor) lintpack.FileWalker
WalkerForComment returns file walker implementation for CommentVisitor.
func WalkerForDocComment ¶
func WalkerForDocComment(v DocCommentVisitor) lintpack.FileWalker
WalkerForDocComment returns file walker implementation for DocCommentVisitor.
func WalkerForExpr ¶
func WalkerForExpr(v ExprVisitor) lintpack.FileWalker
WalkerForExpr returns file walker implementation for ExprVisitor.
func WalkerForFuncDecl ¶
func WalkerForFuncDecl(v FuncDeclVisitor) lintpack.FileWalker
WalkerForFuncDecl returns file walker implementation for FuncDeclVisitor.
func WalkerForLocalComment ¶
func WalkerForLocalComment(v LocalCommentVisitor) lintpack.FileWalker
WalkerForLocalComment returns file walker implementation for LocalCommentVisitor.
func WalkerForLocalDef ¶
func WalkerForLocalDef(v LocalDefVisitor, info *types.Info) lintpack.FileWalker
WalkerForLocalDef returns file walker implementation for LocalDefVisitor.
func WalkerForLocalExpr ¶
func WalkerForLocalExpr(v LocalExprVisitor) lintpack.FileWalker
WalkerForLocalExpr returns file walker implementation for LocalExprVisitor.
func WalkerForStmt ¶
func WalkerForStmt(v StmtVisitor) lintpack.FileWalker
WalkerForStmt returns file walker implementation for StmtVisitor.
func WalkerForStmtList ¶
func WalkerForStmtList(v StmtListVisitor) lintpack.FileWalker
WalkerForStmtList returns file walker implementation for StmtListVisitor.
func WalkerForTypeExpr ¶
func WalkerForTypeExpr(v TypeExprVisitor, info *types.Info) lintpack.FileWalker
WalkerForTypeExpr returns file walker implementation for TypeExprVisitor.
Types ¶
type CommentVisitor ¶ added in v0.5.2
type CommentVisitor interface { VisitComment(*ast.CommentGroup) // contains filtered or unexported methods }
CommentVisitor visits every comment.
type DocCommentVisitor ¶
type DocCommentVisitor interface {
VisitDocComment(*ast.CommentGroup)
}
DocCommentVisitor visits every doc-comment. Does not visit doc-comments for function-local definitions (types, etc). Also does not visit package doc-comment (file-level doc-comments).
type ExprVisitor ¶
ExprVisitor visits every expression inside AST file.
type FuncDeclVisitor ¶
type FuncDeclVisitor interface { VisitFuncDecl(*ast.FuncDecl) // contains filtered or unexported methods }
FuncDeclVisitor visits every top-level function declaration.
type LocalCommentVisitor ¶
type LocalCommentVisitor interface { VisitLocalComment(*ast.CommentGroup) // contains filtered or unexported methods }
LocalCommentVisitor visits every comment inside function body.
type LocalDefVisitor ¶
type LocalDefVisitor interface { VisitLocalDef(Name, ast.Expr) // contains filtered or unexported methods }
LocalDefVisitor visits every name definitions inside a function.
Next elements are considered as name definitions:
- Function parameters (input, output, receiver)
- Every LHS of ":=" assignment that defines a new name
- Every local var/const declaration.
NOTE: this visitor is experimental. This is also why it lives in a separate file.
type LocalExprVisitor ¶
type LocalExprVisitor interface { VisitLocalExpr(ast.Expr) // contains filtered or unexported methods }
LocalExprVisitor visits every expression inside function body.
type Name ¶
type Name struct { ID *ast.Ident Kind NameKind // Index is NameVar-specific field that is used to // specify nth tuple element being assigned to the name. Index int }
Name holds ver/const/param definition symbol info.
type NameKind ¶
type NameKind int
NameKind describes what kind of name Name object holds.
const ( // NameParam is function/method receiver/input/output name. // Initializing expression is always nil. NameParam NameKind = iota // NameVar is var or ":=" declared name. // Initizlizing expression may be nil for var-declared names // without explicit initializing expression. NameVar // NameConst is const-declared name. // Initializing expression is never nil. NameConst )
NOTE: set of name kinds is not stable and may change over time.
TODO(quasilyte): is NameRecv/NameParam/NameResult granularity desired? TODO(quasilyte): is NameVar/NameBind (var vs :=) granularity desired?
type StmtListVisitor ¶
type StmtListVisitor interface { VisitStmtList([]ast.Stmt) // contains filtered or unexported methods }
StmtListVisitor visits every statement list inside function body. This includes block statement bodies as well as implicit blocks introduced by case clauses and alike.
type StmtVisitor ¶
StmtVisitor visits every statement inside function body.
type TypeExprVisitor ¶
type TypeExprVisitor interface { VisitTypeExpr(ast.Expr) // contains filtered or unexported methods }
TypeExprVisitor visits every type describing expression. It also traverses struct types and interface types to run checker over their fields/method signatures.
type WalkHandler ¶
type WalkHandler struct { // SkipChilds controls whether currently analyzed // node childs should be traversed. // // Value is reset after each visitor invocation, // so there is no need to set value back to false. SkipChilds bool }
WalkHandler is a type to be embedded into every checker that uses astwalk walkers.