TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/tree-sitter/tree-sitter/llms.txt
Use this file to discover all available pages before exploring further.
query command runs a query on a parser and views the results. It allows you to search through source code using Tree-sitter query syntax.
q
Query Path
The requiredQUERY_PATH argument specifies the path to a file containing Tree-sitter query patterns.
Source Paths
OptionalPATHS arguments specify the source files to query. If no paths are provided, input is read from stdin.
Options
Input Options
The path to a file that contains paths to source files in which the query will be executed.
The path to the directory containing the grammar. Implies
--rebuild.The path to the parser’s dynamic library. Used instead of the cached or automatically generated library.
If
--lib-path is used, the name of the language used to extract the library’s language function.The language scope to use for parsing and querying. Useful when the language is ambiguous.
Query the contents of a specific test.
Query Range Options
The range of byte offsets in which the query will be executed. Format:
start_byte:end_byte.The range of byte offsets in which the query will be executed. Only matches fully contained within the provided byte range will be returned.
The range of rows in which the query will be executed. Format:
start_row:end_row.The range of rows in which the query will be executed. Only matches fully contained within the provided row range will be returned.
Output Options
Order the query results by captures instead of matches.
Suppress main output.
Print the time taken to execute the query on the file.
Test Options
Whether to run query tests or not.
Build Options
Force a rebuild of the parser before executing the query.
The path to an alternative configuration (
config.json) file. See init-config.