Class Query.Cursor
A cursor for executing a given Query.
Analogous to TSQueryCursor
.
Functions
Cursor.new (query, node) | Create a new cursor for executing a given Query on a given Node. |
Methods
Cursor:query () | Get the Query the cursor is executing. |
Cursor:node () | Get the Node the cursor is executing on. |
Cursor:did_exceed_match_limit () | Check whether the match limit of the cursor has been exceeded. |
Cursor:match_limit () | Get the maximum number of in-progress matches of a cursor. |
Cursor:set_match_limit (limit) | Set the maximum number of in-progress matches of a cursor. |
Cursor:set_byte_range (start_byte, end_byte) | Set the range of bytes in which the Query will be executed. |
Cursor:set_point_range (start_point, end_point) | Set the range of Points in which the Query will be executed. |
Cursor:next_match () | Advance to and get the next match. |
Cursor:next_capture () | Advance to and get the next capture. |
Functions
- Cursor.new (query, node)
-
Create a new cursor for executing a given Query on a given Node.
Parameters:
Returns:
Methods
- Cursor:query ()
-
Get the Query the cursor is executing.
Returns:
- Cursor:node ()
-
Get the Node the cursor is executing on.
Returns:
- Cursor:did_exceed_match_limit ()
-
Check whether the match limit of the cursor has been exceeded.
Returns:
-
boolean
- Cursor:match_limit ()
-
Get the maximum number of in-progress matches of a cursor.
If the maximum number is reached, the earliest match is silently dropped.
By default, there is no maximum.
Returns:
-
integer
- Cursor:set_match_limit (limit)
-
Set the maximum number of in-progress matches of a cursor.
Parameters:
- limit integer
- Cursor:set_byte_range (start_byte, end_byte)
-
Set the range of bytes in which the Query will be executed.
Parameters:
- start_byte integer
- end_byte integer
- Cursor:set_point_range (start_point, end_point)
-
Set the range of Points in which the Query will be executed.
Parameters:
- Cursor:next_match ()
-
Advance to and get the next match.
This method may return
nil
if there are no more matches.Returns:
-
Match or nil
- Cursor:next_capture ()
-
Advance to and get the next capture.
This method may return
nil
if there are no more captures.Returns:
-
Capture or nil