These functions are helpful in mFQL query compositions.
The getByAddress function is used in applying the results of one query to another. For example, we might have a node of particular interest, and we want our query to return only nodes that join (in some way) to the specified node.
This sample builds a set containing the single node related to the address specified:
To create a set of more than one node, use several calls to the node function from within a union join. This sample creates a set of three specific nodes:
getByPosition(File: String, Offset: Number)
The getByPosition function is used to return the inner most node that covers a certain position in a file. This function is useful for locating a position in the AST based upon a file position.
The distinct function ensures that a set has no duplicate values. All duplicate values are excluded from the result set.
This function is required to handle a side effect of the move function; it can create a set that includes duplicate nodes. The move function operates in this manner by design – it should only remove nodes that fail the specified traversal, ensuring the resulting set is discrete is beyond its scope and (in some cases) undesirable behavior.