The underlying TSQuery
this(Language
language, string
queryString);
Create a new query from a string containing one or more S-expression
patterns.
The query is associated with a particular language, and can only be run
on syntax nodes parsed with that language. References to Queries can be
shared between multiple threads.
QueryIterator
exec
(Node
node);
Execute a query over an entire node.
The caller may iterate over the result to receive a series of
QueryMatch
results.
QueryIterator
exec
(Node
node, uint
min, uint
max);
Execute a query between given start and end byte offsets.
The caller may iterate over the result to receive a series of
QueryMatch
results.
QueryIterator
exec
(Node
node, Point
min, Point
max);
Execute a query between given start and end Points
.
The caller may iterate over the result to receive a series of
QueryMatch
results.
nothrow @nogc int
pattern_count
();
Get the number of patterns in the query.
nothrow @nogc int
capture_count
();
Get the number of captures in the query.
nothrow @nogc int
string_count
();
Get the number of string literals in the query.
nothrow @nogc int
start_byte_for_pattern
(uint
patternId);
Get the byte offset where the given pattern starts in the query's source.
This can be useful when combining queries by concatenating their source
code strings.
nothrow @nogc const(TSQueryPredicateStep)[]
predicates_for_pattern
(uint
patternId);
Get all of the predicates for the given pattern in the query.
The predicates are represented as a single array of steps. There are three
types of steps in this array, which correspond to the three legal values for
the
type
field:
TSQueryPredicateStepTypeCapture
- Steps with this type represent names
of captures. Their value_id
can be used with the
ts_query_capture_name_for_id
function to obtain the name of the capture.
TSQueryPredicateStepTypeString
- Steps with this type represent literal
strings. Their value_id
can be used with the
ts_query_string_value_for_id
function to obtain their string value.
TSQueryPredicateStepTypeDone
- Steps with this type are sentinels
that represent the end of an individual predicate. If a pattern has two
predicates, then there will be two steps with this type
in the array.
nothrow @nogc bool
is_pattern_guaranteed_at_step
(uint
byteOffset);
Check if a given step in a query is 'definite'.
A query step is 'definite' if its parent pattern will be guaranteed to match
successfully once it reaches the step.
nothrow @nogc bool
step_is_definite
(uint
byteOffset);
@deprecated. Use is_pattern_guaranteed_at_step
instead.
nothrow string
capture_name_for_id
(uint
captureId);
Get the name of one of the query's captures.
Each capture is associated with a numeric id based on the order that it
appeared in the query's source.
nothrow string
capture_name
(TSQueryCapture
capture);
Get the name of one of the query's captures, given a TSQueryCapture.
nothrow string
query_string_value_for_id
(uint
id);
Get the name of one of the query's string literals.
Each string is associated with a numeric id based on the order that it
appeared in the query's source.
void
disable_capture
(string
captureName);
Disable a certain capture within a query.
This prevents the capture from being returned in matches, and also avoids
any resource usage associated with recording the capture. Currently, there
is no way to undo this.
nothrow @nogc void
disable_pattern
(uint
patternId);
Disable a certain pattern within a query.
This prevents the pattern from matching and removes most of the overhead
associated with the pattern. Currently, there is no way to undo this.