class
QueryCursorStores the state needed to execute a query and iteratively search for matches.
Contents
You first have to call QueryCursor::
You can iterate over the result matches by calling QueryCursor::
You can also iterate over the captures if you don't care which patterns matched.
At any point you can call QueryCursor::
Can't be copied because the underlying TSQueryCursor
can't be copied.
Features not included (because we currently don't use them):
- setting byte/point range to search in:
ts_query_cursor_set_byte_range
ts_query_cursor_set_point_range
Constructors, destructors, conversion operators
- QueryCursor(const Tree&) explicit noexcept
- Create a QueryCursor for a Tree.
- QueryCursor(QueryCursor&&) defaulted
- Move constructor.
Public functions
- auto operator=(QueryCursor&&) -> QueryCursor& defaulted
- Move assignment operator.
- auto raw() const -> const TSQueryCursor*
- Returns the raw Tree-Sitter query.
- auto raw() -> TSQueryCursor*
- Returns the raw Tree-Sitter query.
- void exec(const Query&, Node)
- Start running a given query on a given node.
- void exec(const Query&)
- Start running a given query on the root of the tree.
- auto next_match() -> std::optional<Match>
- Advance to the next match of the currently running query if possible.
- auto next_capture() -> std::optional<Capture>
- Advance to the next capture of the currently running query if possible.
- auto matches() -> std::vector<Match>
- Get all matches.
Function documentation
const TSQueryCursor* ts:: QueryCursor:: raw() const
Returns the raw Tree-Sitter query.
TSQueryCursor* ts:: QueryCursor:: raw()
Returns the raw Tree-Sitter query.
std::vector<Match> ts:: QueryCursor:: matches()
Get all matches.
This needs to internally advance over the matches so you can only call this once. Subsequent calls will return an empty vector.
This will also omit matches that were already retrieved by calling QueryCursor::