Function tree_sitter::ffi::ts_parser_set_included_ranges
source · pub unsafe extern "C" fn ts_parser_set_included_ranges(
self_: *mut TSParser,
ranges: *const TSRange,
count: u32
) -> bool
Expand description
Set the ranges of text that the parser should include when parsing.
By default, the parser will always include entire documents. This function allows you to parse only a portion of a document but still return a syntax tree whose ranges match up with the document as a whole. You can also pass multiple disjoint ranges.
The second and third parameters specify the location and length of an array of ranges. The parser does not take ownership of these ranges; it copies the data, so it doesn’t matter how these ranges are allocated.
If count
is zero, then the entire document will be parsed. Otherwise,
the given ranges must be ordered from earliest to latest in the document,
and they must not overlap. That is, the following must hold for all:
i < count - 1
: ranges[i].end_byte <= ranges[i + 1].start_byte
If this requirement is not satisfied, the operation will fail, the ranges
will not be assigned, and this function will return false
. On success,
this function returns true