KADABRA API

LARA API

LARA Common Language API

(.js)
laraImport("weaver.Selector");

(.lara)
import weaver.Selector;

Selector

Constructor

Selector

new Selector([$baseJp = undefined], [inclusive = false])

Selects join points according to their type and filter rules.

Parameters

$baseJp: $jp - starting join point for the search. (optional)
inclusive: boolean - if true, $baseJp is included in the search. (optional)

Instance Members

Symbol.iterator

Symbol.iterator

Generator function, allows Selector to be used in for..of statements.

Returns join points iteratively, as if .get() was called.


chain

chain()

Returns

any - an array of objects where each object maps the name of the join point to the corresponding join point that was searched, as well as creating mappings of the format <joinpoint_name>_<repetition>. For instance, if the search chain has the same name multiple times (e.g., search("loop").search("loop")), the chain object will have an attribute "loop" mapped to the last loop of the chain, an attribute "loop_0" mapped to the first loop of the chain and an attribute "loop_1" mapped to the second loop of the chain.

children

children(type, [filter = {}], name)

Search in the children of the previously selected nodes.

Parameters

type: String - type of the join point to search.
filter: Object|String|Function|Regex - filter rules for the search. (optional)
name: any

Returns

weaver.Selector - the results of the search.

first

first()

Returns

$jp - the first selected node

get

get()

Returns

any - an array with the join points of the last chain (e.g., search("function").search("call").get() returns an array of $call join points).

getFirst

getFirst()

Same as .first()

Returns

$jp - the first selected node

scope

scope(name, [filter = {}])

If previously select nodes have the concept of scope (e.g. if, loop), search the direct children of that scope.

Parameters

name: String - type of the join point to search.
filter: Object|String|Function|Regex - filter rules for the search. (optional)

Returns

weaver.Selector - the results of the search.

search

search(type, [filter = {}], [traversal = TraversalType.PREORDER], name)

Parameters

type: String - type of the join point to search.
filter: Object|String|Function|Regex - filter rules for the search. (optional)
traversal: String - AST traversal type, according to weaver.TraversalType (optional)
name: any

Returns

weaver.Selector - the results of the search.