tree_sitter::ffi

Function ts_query_predicates_for_pattern

source
pub unsafe extern "C" fn ts_query_predicates_for_pattern(
    self_: *const TSQuery,
    pattern_index: u32,
    step_count: *mut u32,
) -> *const TSQueryPredicateStep
Expand description

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.