tools

package
v3.2.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2019 License: Apache-2.0 Imports: 4 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// PreOrder traversal
	PreOrder = query.PreOrder
	// PostOrder traversal
	PostOrder = query.PostOrder
	// LevelOrder (aka breadth-first) traversal
	LevelOrder = query.LevelOrder
	// PositionOrder by node position in the source file
	PositionOrder = query.PositionOrder
)

Variables

This section is empty.

Functions

func Filter

func Filter(node nodes.Node, query string) (query.Iterator, error)

Filter filters the tree and returns the iterator of nodes that satisfy the given query.

func FilterBool

func FilterBool(node nodes.Node, query string) (bool, error)

FilterNode evaluates a query and returns a results as a boolean value.

func FilterInt

func FilterInt(node nodes.Node, query string) (int, error)

FilterInt evaluates a query and returns a results as an int value.

func FilterNode

func FilterNode(node nodes.Node, query string) (nodes.Node, error)

FilterNode filters the tree and returns a single node that satisfy the given query.

func FilterNumber

func FilterNumber(node nodes.Node, query string) (float64, error)

FilterNumber evaluates a query and returns a results as a float64 value.

func FilterString

func FilterString(node nodes.Node, query string) (string, error)

FilterString evaluates a query and returns a results as a string value.

func FilterValue

func FilterValue(node nodes.Node, query string) (nodes.Value, error)

FilterValue evaluates a query and returns a results as a value.

func Iterate

func Iterate(it Iterator) <-chan nodes.Node

Iterate function is similar to Next() but returns the `Node`s in a channel. It's mean to be used with the `for node := range Iterate(myIter) {}` loop.

Types

type Context

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

func NewContext

func NewContext(root nodes.Node) *Context

NewContext creates a new query context.

func (*Context) Filter

func (c *Context) Filter(query string) (query.Iterator, error)

Filter filters the tree and returns the iterator of nodes that satisfy the given query.

func (*Context) FilterBool

func (c *Context) FilterBool(query string) (bool, error)

FilterNode evaluates a query and returns a results as a boolean value.

func (*Context) FilterInt

func (c *Context) FilterInt(query string) (int, error)

FilterInt evaluates a query and returns a results as an int value.

func (*Context) FilterNode

func (c *Context) FilterNode(query string) (nodes.Node, error)

FilterNode filters the tree and returns a single node that satisfy the given query.

func (*Context) FilterNumber

func (c *Context) FilterNumber(query string) (float64, error)

FilterNumber evaluates a query and returns a results as a float64 value.

func (*Context) FilterString

func (c *Context) FilterString(query string) (string, error)

FilterString evaluates a query and returns a results as a string value.

func (*Context) FilterValue

func (c *Context) FilterValue(query string) (nodes.Value, error)

FilterValue evaluates a query and returns a results as a value.

type ErrInvalidArgument

type ErrInvalidArgument struct {
	Message string
}

func (*ErrInvalidArgument) Error

func (e *ErrInvalidArgument) Error() string

type Iterator

type Iterator = query.Iterator

Iterator allows for traversal over a UAST tree.

func NewIterator

func NewIterator(node nodes.Node, order TreeOrder) Iterator

NewIterator constructs a new Iterator starting from the given `Node` and iterating with the traversal strategy given by the `order` parameter.

type TreeOrder

type TreeOrder = query.IterOrder

TreeOrder represents the traversal strategy for UAST trees

Jump to

Keyboard shortcuts

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