irutil

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Code generated by the `ir/codegen` package. DO NOT EDIT.

Code generated by the `ir/codegen` package. DO NOT EDIT.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindClassMethodNode added in v0.4.0

func FindClassMethodNode(n ir.Node, name string) *ir.ClassMethodStmt

func FindPHPDoc added in v0.5.0

func FindPHPDoc(n ir.Node, withSuspicious bool) (doc string, found bool)

FindPHPDoc searches for phpdoc by traversing all subtree and all tokens.

func FindWithPredicate added in v0.4.0

func FindWithPredicate(what ir.Node, where ir.Node, pred findPredicate) bool

FindWithPredicate searches for a node in the passed subtree using a predicate.

If the predicate returns true, the search ends.

func FmtNode

func FmtNode(n ir.Node) string

FmtNode returns string representation of n.

func InLoop added in v0.4.0

func InLoop(path NodePath) bool

func Inspect

func Inspect(root ir.Node, visit func(ir.Node) bool)

func IsAssign

func IsAssign(n ir.Node) bool

func IsBoolAnd added in v0.5.0

func IsBoolAnd(n ir.Node) bool

func IsBoolOr added in v0.5.0

func IsBoolOr(n ir.Node) bool

func IsLoop added in v0.4.0

func IsLoop(n ir.Node) bool

func Keywords added in v0.4.0

func Keywords(n ir.Node) []*token.Token

Keywords returns one or two tokens that contain the keywords for the passed node.

func NodeClone

func NodeClone(x ir.Node) ir.Node

func NodeEqual

func NodeEqual(x, y ir.Node) bool

func NodeSliceClone

func NodeSliceClone(xs []ir.Node) []ir.Node

func NodeSliceEqual

func NodeSliceEqual(xs, ys []ir.Node) bool

func Unparen

func Unparen(e ir.Node) ir.Node

Unparen returns n with all parenthesis removed.

Types

type NodePath added in v0.4.0

type NodePath struct {
	// contains filtered or unexported fields
}

func NewNodePath added in v0.4.0

func NewNodePath() NodePath

func (NodePath) Conditional added in v0.4.0

func (p NodePath) Conditional() bool

func (NodePath) ConditionalUntil added in v0.4.0

func (p NodePath) ConditionalUntil(end ir.Node) bool

func (NodePath) Current added in v0.4.0

func (p NodePath) Current() ir.Node

func (NodePath) NthParent added in v0.4.0

func (p NodePath) NthParent(n int) ir.Node

func (NodePath) Parent added in v0.4.0

func (p NodePath) Parent() ir.Node

func (*NodePath) Pop added in v0.4.0

func (p *NodePath) Pop()

func (*NodePath) Push added in v0.4.0

func (p *NodePath) Push(n ir.Node)

func (NodePath) String added in v0.4.0

func (p NodePath) String() string

type NodeSet

type NodeSet struct {
	// contains filtered or unexported fields
}

NodeSet is a set of unique AST nodes.

It's possible to avoid allocations in most cases if node set is reused with Reset(). If this is not possible, use NewNodeSet() to create a set that can do fewer allocations than a zero value set.

NodeSet is not thread-safe, but since Root/Block walkers always operate in isolation, we can share on per RootWalker level.

func NewNodeSet

func NewNodeSet() NodeSet

NewNodeSet returns a node set with preallocated storage.

Intended to be used in places where reusing root node set is tricky or impossible (function is reentrant).

func (*NodeSet) Add

func (set *NodeSet) Add(x ir.Node) bool

Add attempts to insert x into the node set.

Returns true if element was inserted. If x is already in the set, false is returned and no insertion is performed.

func (*NodeSet) Len

func (set *NodeSet) Len() int

Len returns the number of unique node elements present in the set.

func (*NodeSet) Reset

func (set *NodeSet) Reset()

Reset clears the set state and prepares it for another round.

Jump to

Keyboard shortcuts

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