lintutil

package
v0.3.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 3, 2019 License: MIT Imports: 7 Imported by: 0

Documentation

Index

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

func AsBinaryExprOp(x ast.Node, op token.Token) *ast.BinaryExpr

AsBinaryExprOp is like AsBinaryExpr, but also checks for op token.

func AsCallExpr

func AsCallExpr(x ast.Node) *ast.CallExpr

AsCallExpr coerces x into non-nil call expr.

func AsIdent

func AsIdent(x ast.Node) *ast.Ident

AsIdent coerces x into non-nil ident.

func AsParenExpr

func AsParenExpr(x ast.Node) *ast.ParenExpr

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

func AsUnaryExpr(x ast.Node) *ast.UnaryExpr

AsUnaryExpr coerces x into non-nil unary expr.

func AsUnaryExprOp

func AsUnaryExprOp(x ast.Node, op token.Token) *ast.UnaryExpr

AsUnaryExprOp is like AsUnaryExpr, but also checks for op token.

func ContainsNode

func ContainsNode(root ast.Node, pred func(ast.Node) bool) bool

ContainsNode reports whether `FindNode(root, pred)!=nil`.

func CouldBeMutated

func CouldBeMutated(info *types.Info, body ast.Node, dst ast.Expr) bool

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

func FindNode(root ast.Node, pred func(ast.Node) bool) ast.Node

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

func IsImmutable(info *types.Info, n ast.Expr) bool

IsImmutable reports whether n can be midified through any operation.

func IsNil

func IsNil(x ast.Node) bool

IsNil reports whether x is nil. Unlike simple nil check, also detects nil AST sentinels.

func IsTypeExpr

func IsTypeExpr(info *types.Info, x ast.Expr) bool

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.

func (*AstSet) Clear

func (s *AstSet) Clear()

Clear removes all element from set.

func (*AstSet) Contains

func (s *AstSet) Contains(x ast.Node) bool

Contains reports whether s contains x.

func (*AstSet) Insert

func (s *AstSet) Insert(x ast.Node) bool

Insert pushes x in s if it's not already there. Returns true if element was inserted.

func (*AstSet) Len

func (s *AstSet) Len() int

Len returns the number of elements contained inside s.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL