astp: github.com/go-toolsmith/astp Index | Examples | Files

package astp

import "github.com/go-toolsmith/astp"

Code:

if astp.IsIdent(strparse.Expr(`x`)) {
    fmt.Println("ident")
}
if astp.IsBlockStmt(strparse.Stmt(`{f()}`)) {
    fmt.Println("block stmt")
}
if astp.IsGenDecl(strparse.Decl(`var x int = 10`)) {
    fmt.Println("gen decl")
}

Output:

ident
block stmt
gen decl

Index

Examples

Package Files

decl.go expr.go stmt.go

func IsArrayType Uses

func IsArrayType(node ast.Node) bool

IsArrayType reports whether a given ast.Node is an array or slice type (*ast.IsArrayType).

func IsAssignStmt Uses

func IsAssignStmt(node ast.Node) bool

IsAssignStmt reports whether a given ast.Node is an assignment statement(*ast.AssignStmt)

func IsBadExpr Uses

func IsBadExpr(node ast.Node) bool

IsBadExpr reports whether a given ast.Node is a bad expression (*ast.IsBadExpr).

func IsBadStmt Uses

func IsBadStmt(node ast.Node) bool

IsBadStmt reports whether a given ast.Node is a bad statement(*ast.BadStmt)

func IsBasicLit Uses

func IsBasicLit(node ast.Node) bool

IsBasicLit reports whether a given ast.Node is a literal of basic type (*ast.IsBasicLit).

func IsBinaryExpr Uses

func IsBinaryExpr(node ast.Node) bool

IsBinaryExpr reports whether a given ast.Node is a binary expression (*ast.IsBinaryExpr).

func IsBlockStmt Uses

func IsBlockStmt(node ast.Node) bool

IsBlockStmt reports whether a given ast.Node is a block statement(*ast.BlockStmt)

func IsBranchStmt Uses

func IsBranchStmt(node ast.Node) bool

IsBranchStmt reports whether a given ast.Node is a branch(goto/continue/break/fallthrough)statement(*ast.BranchStmt)

func IsCallExpr Uses

func IsCallExpr(node ast.Node) bool

IsCallExpr reports whether a given ast.Node is an expression followed by an argument list (*ast.IsCallExpr).

func IsCaseClause Uses

func IsCaseClause(node ast.Node) bool

IsCaseClause reports whether a given ast.Node is a case statement(*ast.CaseClause)

func IsChanType Uses

func IsChanType(node ast.Node) bool

IsChanType reports whether a given ast.Node is a channel type (*ast.IsChanType).

func IsCommClause Uses

func IsCommClause(node ast.Node) bool

IsCommClause reports whether a given ast.Node is a select statement(*ast.CommClause)

func IsCompositeLit Uses

func IsCompositeLit(node ast.Node) bool

IsCompositeLit reports whether a given ast.Node is a composite literal (*ast.IsCompositeLit).

func IsDecl Uses

func IsDecl(node ast.Node) bool

IsDecl reports whether a node is a ast.Decl.

func IsDeclStmt Uses

func IsDeclStmt(node ast.Node) bool

IsDeclStmt reports whether a given ast.Node is a declaration statement(*ast.DeclStmt)

func IsDeferStmt Uses

func IsDeferStmt(node ast.Node) bool

IsDeferStmt reports whether a given ast.Node is a defer statement(*ast.DeferStmt)

func IsEllipsis Uses

func IsEllipsis(node ast.Node) bool

IsEllipsis reports whether a given ast.Node is an `...` (ellipsis) (*ast.IsEllipsis).

func IsEmptyStmt Uses

func IsEmptyStmt(node ast.Node) bool

IsEmptyStmt reports whether a given ast.Node is an empty statement(*ast.EmptyStmt)

func IsExpr Uses

func IsExpr(node ast.Node) bool

IsExpr reports whether a given ast.Node is an expression(ast.Expr).

func IsExprStmt Uses

func IsExprStmt(node ast.Node) bool

IsExprStmt reports whether a given ast.Node is an expression statement(*ast.ExprStmt)

func IsForStmt Uses

func IsForStmt(node ast.Node) bool

IsForStmt reports whether a given ast.Node is a for statement(*ast.ForStmt)

func IsFuncDecl Uses

func IsFuncDecl(node ast.Node) bool

IsFuncDecl reports whether a given ast.Node is a function declaration (*ast.FuncDecl).

func IsFuncLit Uses

func IsFuncLit(node ast.Node) bool

IsFuncLit reports whether a given ast.Node is a function literal (*ast.IsFuncLit).

func IsFuncType Uses

func IsFuncType(node ast.Node) bool

IsFuncType reports whether a given ast.Node is a function type (*ast.IsFuncType).

func IsGenDecl Uses

func IsGenDecl(node ast.Node) bool

IsGenDecl reports whether a given ast.Node is a generic declaration (*ast.GenDecl).

func IsGoStmt Uses

func IsGoStmt(node ast.Node) bool

IsGoStmt reports whether a given ast.Node is a go statement(*ast.GoStmt)

func IsIdent Uses

func IsIdent(node ast.Node) bool

IsIdent reports whether a given ast.Node is an identifier (*ast.IsIdent).

func IsIfStmt Uses

func IsIfStmt(node ast.Node) bool

IsIfStmt reports whether a given ast.Node is an if statement(*ast.IfStmt)

func IsImportSpec Uses

func IsImportSpec(node ast.Node) bool

IsImportSpec reports whether a given ast.Node is an import declaration (*ast.ImportSpec).

func IsIncDecStmt Uses

func IsIncDecStmt(node ast.Node) bool

IsIncDecStmt reports whether a given ast.Node is a increment/decrement statement(*ast.IncDecStmt)

func IsIndexExpr Uses

func IsIndexExpr(node ast.Node) bool

IsIndexExpr reports whether a given ast.Node is an index expression (*ast.IsIndexExpr).

func IsInterfaceType Uses

func IsInterfaceType(node ast.Node) bool

IsInterfaceType reports whether a given ast.Node is an interface type (*ast.IsInterfaceType).

func IsKeyValueExpr Uses

func IsKeyValueExpr(node ast.Node) bool

IsKeyValueExpr reports whether a given ast.Node is a (key:value) pair (*ast.IsKeyValueExpr).

func IsLabeledStmt Uses

func IsLabeledStmt(node ast.Node) bool

IsLabeledStmt reports whether a given ast.Node is a label statement(*ast.LabeledStmt)

func IsMapType Uses

func IsMapType(node ast.Node) bool

IsMapType reports whether a given ast.Node is a map type (*ast.IsMapType).

func IsParenExpr Uses

func IsParenExpr(node ast.Node) bool

IsParenExpr reports whether a given ast.Node is a parenthesized expression (*ast.IsParenExpr).

func IsRangeStmt Uses

func IsRangeStmt(node ast.Node) bool

IsRangeStmt reports whether a given ast.Node is a range statement(*ast.RangeStmt)

func IsReturnStmt Uses

func IsReturnStmt(node ast.Node) bool

IsReturnStmt reports whether a given ast.Node is a return statement(*ast.ReturnStmt)

func IsSelectStmt Uses

func IsSelectStmt(node ast.Node) bool

IsSelectStmt reports whether a given ast.Node is a selection statement(*ast.SelectStmt)

func IsSelectorExpr Uses

func IsSelectorExpr(node ast.Node) bool

IsSelectorExpr reports whether a given ast.Node is a selector expression (*ast.IsSelectorExpr).

func IsSendStmt Uses

func IsSendStmt(node ast.Node) bool

IsSendStmt reports whether a given ast.Node is a send to chan statement(*ast.SendStmt)

func IsSliceExpr Uses

func IsSliceExpr(node ast.Node) bool

IsSliceExpr reports whether a given ast.Node is a slice expression (*ast.IsSliceExpr).

func IsStarExpr Uses

func IsStarExpr(node ast.Node) bool

IsStarExpr reports whether a given ast.Node is a star expression(unary "*" or apointer) (*ast.IsStarExpr)

func IsStmt Uses

func IsStmt(node ast.Node) bool

IsStmt reports whether a given ast.Node is a statement(ast.Stmt).

func IsStructType Uses

func IsStructType(node ast.Node) bool

IsStructType reports whether a given ast.Node is a struct type (*ast.IsStructType).

func IsSwitchStmt Uses

func IsSwitchStmt(node ast.Node) bool

IsSwitchStmt reports whether a given ast.Node is a switch statement(*ast.SwitchStmt)

func IsTypeAssertExpr Uses

func IsTypeAssertExpr(node ast.Node) bool

IsTypeAssertExpr reports whether a given ast.Node is a type assert expression (*ast.IsTypeAssertExpr).

func IsTypeSpec Uses

func IsTypeSpec(node ast.Node) bool

IsTypeSpec reports whether a given ast.Node is a type declaration (*ast.TypeSpec).

func IsTypeSwitchStmt Uses

func IsTypeSwitchStmt(node ast.Node) bool

IsTypeSwitchStmt reports whether a given ast.Node is a type switch statement(*ast.TypeSwitchStmt)

func IsUnaryExpr Uses

func IsUnaryExpr(node ast.Node) bool

IsUnaryExpr reports whether a given ast.Node is a unary expression (*ast.IsUnaryExpr).

func IsValueSpec Uses

func IsValueSpec(node ast.Node) bool

IsValueSpec reports whether a given ast.Node is a value declaration (*ast.ValueSpec).

Package astp imports 1 packages (graph) and is imported by 4 packages. Updated 2018-09-12. Refresh now. Tools for package owners.