-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
doc(query): add docs for queries, cursors, matches and captures
- Loading branch information
Showing
5 changed files
with
138 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--- | ||
-- A query that can be ran on `Node`s of a given `Language`. | ||
-- Analogous to `TSQuery`. | ||
-- @classmod Query | ||
-- @pragma nostrip | ||
|
||
--- | ||
-- Functions | ||
-- @section Functions | ||
|
||
|
||
--- | ||
-- Create a new query for a given `Language` from a source `string`. | ||
-- @tparam Language lang | ||
-- @tparam string source | ||
-- @treturn Query | ||
-- @raise Invalid pattern in the source. | ||
function Query.new(lang, source) end | ||
|
||
--- | ||
-- Methods | ||
-- @section Methods | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
--- | ||
-- A capture of a `Query`. | ||
-- Analogous to `TSQueryCapture`. | ||
-- @classmod QueryCapture | ||
-- @pragma nostrip | ||
|
||
--- | ||
-- Methods | ||
-- @section Methods | ||
|
||
--- | ||
-- Get the `Node` of the capture. | ||
-- @treturn Node | ||
function QueryCapture:node() end | ||
|
||
--- | ||
-- Get the index of the capture. | ||
-- @treturn integer | ||
function QueryCapture:index() end | ||
|
||
--- | ||
-- Get the `QueryMatch` the capture belongs to. | ||
-- @treturn QueryMatch | ||
function QueryCapture:match() end | ||
|
||
--- | ||
-- Get the `Query` the capture belongs to. | ||
-- @treturn Query | ||
function QueryCapture:query() end | ||
|
||
--- | ||
-- Get the name of the capture. | ||
-- @treturn Node | ||
function QueryCapture:name() end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
--- | ||
-- A cursor for executing a given `Query`. | ||
-- Analogous to `TSQueryCursor`. | ||
-- @classmod QueryCursor | ||
-- @pragma nostrip | ||
|
||
--- | ||
-- Functions | ||
-- @section Functions | ||
|
||
--- | ||
-- Create a new cursor for executing a given `Query` on a given `Node`. | ||
-- @tparam Query query | ||
-- @tparam Node node | ||
-- @treturn QueryCursor | ||
function QueryCursor.new(query, node) end | ||
|
||
--- | ||
-- Methods | ||
-- @section Methods | ||
|
||
--- | ||
-- Get the `Query` the cursor is executing. | ||
-- @treturn Query | ||
function QueryCursor:query() end | ||
|
||
--- | ||
-- Set the range of `Point`s in which the `Query` will be executed. | ||
-- @tparam Point start_point | ||
-- @tparam Point end_point | ||
function QueryCursor:set_point_range(start_point, end_point) end | ||
|
||
--- | ||
-- Advance to and get the next match. | ||
-- | ||
-- This method may return `nil` if there are no more matches. | ||
-- @treturn QueryMatch|nil | ||
function QueryCursor:next_match() end | ||
|
||
--- | ||
-- Advance to and get the next capture. | ||
-- | ||
-- This method may return `nil` if there are no more captures. | ||
-- @treturn QueryCapture|nil | ||
function QueryCursor:next_capture() end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
--- | ||
-- A match of a `Query`. | ||
-- Analogous to `TSQueryMatch`. | ||
-- @classmod QueryMatch | ||
-- @pragma nostrip | ||
|
||
--- | ||
-- Methods | ||
-- @section Methods | ||
|
||
--- | ||
-- Get the pattern index of the match. | ||
-- @treturn integer | ||
function QueryMatch:pattern_index() end | ||
|
||
--- | ||
-- Get the number of `QueryCapture`s in the match. | ||
-- @treturn integer | ||
function QueryMatch:capture_count() end | ||
|
||
--- | ||
-- Get the `QueryCapture` at a given index. | ||
-- @tparam integer index | ||
-- @treturn QueryCapture | ||
-- @raise Indexing a negative index. | ||
-- Indexing beyond last element. | ||
function QueryMatch:capture_at(index) end | ||
|
||
--- | ||
-- Get the `Query` to which the match belongs. | ||
-- @treturn Query | ||
function QueryMatch:query() end |