Documentation ¶
Index ¶
- func Filter(node *uast.Node, xpath string) ([]*uast.Node, error)deprecated
- func FilterBool(node *uast.Node, xpath string) (bool, error)deprecated
- func FilterNumber(node *uast.Node, xpath string) (float64, error)deprecated
- func FilterString(node *uast.Node, xpath string) (string, error)deprecated
- func FilterXPath(node nodes.External, query string) (query.Iterator, error)
- type Context
- func (c *Context) Close() error
- func (c *Context) Filter(node *uast.Node, xpath string) (out []*uast.Node, err error)
- func (c *Context) FilterBool(node *uast.Node, xpath string) (out bool, err error)
- func (c *Context) FilterNumber(node *uast.Node, xpath string) (out float64, err error)
- func (c *Context) FilterString(node *uast.Node, xpath string) (out string, err error)
- func (c *Context) FilterXPath(node nodes.External, query string) (query.Iterator, error)
- func (c *Context) NewIterator(node *uast.Node, order TreeOrder) (*Iterator, error)
- type ErrInvalidArgument
- type Iterator
- type TreeOrder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Filter
deprecated
func FilterBool
deprecated
added in
v2.3.0
FilterBool takes a `*uast.Node` and a xpath query with a boolean return type (e.g. when using XPath functions returning a boolean type). FilterBool is thread-safe but not concurrent by an internal global lock.
Deprecated: use Context.FilterBool
func FilterNumber
deprecated
added in
v2.3.0
FilterNumber takes a `*uast.Node` and a xpath query with a float return type (e.g. when using XPath functions returning a float type). FilterNumber is thread-safe but not concurrent by an internal global lock.
Deprecated: use Context.FilterNumber
func FilterString
deprecated
added in
v2.3.0
FilterString takes a `*uast.Node` and a xpath query with a string return type (e.g. when using XPath functions returning a string type). FilterString is thread-safe but not concurrent by an internal global lock.
Deprecated: use Context.FilterString
Types ¶
type Context ¶ added in v2.8.0
type Context struct {
// contains filtered or unexported fields
}
func NewContext ¶ added in v2.8.0
func NewContext() *Context
NewContext creates a new query context. Caller should close the context to release resources.
func (*Context) Filter ¶ added in v2.8.0
Filter takes a `*uast.Node` and a xpath query and filters the tree, returning the list of nodes that satisfy the given query. Filter is thread-safe but not concurrent by an internal global lock.
func (*Context) FilterBool ¶ added in v2.8.0
FilterBool takes a `*uast.Node` and a xpath query with a boolean return type (e.g. when using XPath functions returning a boolean type). FilterBool is thread-safe but not concurrent by an internal global lock.
func (*Context) FilterNumber ¶ added in v2.8.0
FilterNumber takes a `*uast.Node` and a xpath query with a float return type (e.g. when using XPath functions returning a float type). FilterNumber is thread-safe but not concurrent by an internal global lock.
func (*Context) FilterString ¶ added in v2.8.0
FilterString takes a `*uast.Node` and a xpath query with a string return type (e.g. when using XPath functions returning a string type). FilterString is thread-safe but not concurrent by an internal global lock.
func (*Context) FilterXPath ¶ added in v2.8.7
FilterXPath takes a `Node` as returned by UAST() call and an xpath query and filters the tree, returning the iterator of nodes that satisfy the given query.
func (*Context) NewIterator ¶ added in v2.8.0
NewIterator constructs a new Iterator starting from the given `Node` and iterating with the traversal strategy given by the `order` parameter. Once the iteration have finished or you don't need the iterator anymore you must dispose it with the Dispose() method (or call it with `defer`).
type ErrInvalidArgument ¶ added in v2.6.1
type ErrInvalidArgument struct {
Message string
}
func (*ErrInvalidArgument) Error ¶ added in v2.6.1
func (e *ErrInvalidArgument) Error() string
type Iterator ¶ added in v2.2.0
type Iterator struct {
// contains filtered or unexported fields
}
Iterator allows for traversal over a UAST tree.
func NewIterator ¶ added in v2.2.0
NewIterator constructs a new Iterator starting from the given `Node` and iterating with the traversal strategy given by the `order` parameter. Once the iteration have finished or you don't need the iterator anymore you must dispose it with the Dispose() method (or call it with `defer`).
func (*Iterator) Close ¶ added in v2.8.0
Close must be called once you've finished using the iterator or preventively with `defer` to free the iterator resources. Failing to do so would produce a memory leak.
func (*Iterator) Iterate ¶ added in v2.2.0
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 myIter.Iterate() {}` loop.