Documentation ¶
Index ¶
- func AsAssignStmt(x ast.Node) *ast.AssignStmt
- func AsBinaryExpr(x ast.Node) *ast.BinaryExpr
- func AsBinaryExprOp(x ast.Node, op token.Token) *ast.BinaryExpr
- func AsCallExpr(x ast.Node) *ast.CallExpr
- func AsIdent(x ast.Node) *ast.Ident
- func AsParenExpr(x ast.Node) *ast.ParenExpr
- func AsSelectorExpr(x ast.Node) *ast.SelectorExpr
- func AsUnaryExpr(x ast.Node) *ast.UnaryExpr
- func AsUnaryExprOp(x ast.Node, op token.Token) *ast.UnaryExpr
- func ContainsNode(root ast.Node, pred func(ast.Node) bool) bool
- func CouldBeMutated(info *types.Info, body ast.Node, dst ast.Expr) bool
- func FindNode(root ast.Node, pred func(ast.Node) bool) ast.Node
- func IsImmutable(info *types.Info, n ast.Expr) bool
- func IsNil(x ast.Node) bool
- func IsTypeExpr(info *types.Info, x ast.Expr) bool
- type AstSet
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AsAssignStmt ¶
func AsAssignStmt(x ast.Node) *ast.AssignStmt
AsAssignStmt coerces x into non-nil assign stmt.
func AsBinaryExpr ¶
func AsBinaryExpr(x ast.Node) *ast.BinaryExpr
AsBinaryExpr coerces x into non-nil binary expr.
func AsBinaryExprOp ¶
AsBinaryExprOp is like AsBinaryExpr, but also checks for op token.
func AsCallExpr ¶
AsCallExpr coerces x into non-nil call expr.
func AsParenExpr ¶
AsParenExpr coerces x into non-nil paren expr.
func AsSelectorExpr ¶
func AsSelectorExpr(x ast.Node) *ast.SelectorExpr
AsSelectorExpr coerces x into non-nil selector expr.
func AsUnaryExpr ¶
AsUnaryExpr coerces x into non-nil unary expr.
func AsUnaryExprOp ¶
AsUnaryExprOp is like AsUnaryExpr, but also checks for op token.
func ContainsNode ¶
ContainsNode reports whether `FindNode(root, pred)!=nil`.
func CouldBeMutated ¶
CouldBeMutated reports whether dst can be modified inside body.
Note that it does not take already existing pointers to dst. An example of safe and correct usage is checking of something that was just defined, so the dst is a result of that definition.
func FindNode ¶
FindNode applies pred for root and all it's childs until it returns true. Matched node is returned. If none of the nodes matched predicate, nil is returned.
func IsImmutable ¶
IsImmutable reports whether n can be midified through any operation.
func IsNil ¶
IsNil reports whether x is nil. Unlike simple nil check, also detects nil AST sentinels.
func IsTypeExpr ¶
IsTypeExpr reports whether x represents type expression.
Type expression does not evaluate to any run time value, but rather describes type that is used inside Go expression. For example, (*T)(v) is a CallExpr that "calls" (*T). (*T) is a type expression that tells Go compiler type v should be converted to.
Types ¶
type AstSet ¶
type AstSet struct {
// contains filtered or unexported fields
}
AstSet is a simple ast.Node set. Zero value is ready to use set. Can be reused after Clear call.