pub fn execute_query(
language: &str,
source: &str,
query: &str,
) -> Result<Vec<QueryCapture>, ParserError>Expand description
Execute a custom tree-sitter query against source code.
§Arguments
language- Language name (e.g., “rust”, “python”). Must be an enabled language feature.source- Source code to query.query- A tree-sitter query string (S-expression syntax).
§Returns
A vector of QueryCapture results, or a ParserError if the query is malformed
or the language is not supported.
§Security note
This function accepts user-controlled query strings. Pathological queries against
large source inputs may cause CPU exhaustion. Callers in untrusted environments
should bound the length of both source and query before calling this function.
Query::new() returns Err on malformed queries rather than panicking.