1pub type TSSymbol = u16;
4pub type TSFieldId = u16;
5#[repr(C)]
6#[derive(Debug, Copy, Clone)]
7pub struct TSLanguage {
8 _unused: [u8; 0],
9}
10#[repr(C)]
11#[derive(Debug, Copy, Clone)]
12pub struct TSParser {
13 _unused: [u8; 0],
14}
15#[repr(C)]
16#[derive(Debug, Copy, Clone)]
17pub struct TSTree {
18 _unused: [u8; 0],
19}
20#[repr(C)]
21#[derive(Debug, Copy, Clone)]
22pub struct TSQuery {
23 _unused: [u8; 0],
24}
25#[repr(C)]
26#[derive(Debug, Copy, Clone)]
27pub struct TSQueryCursor {
28 _unused: [u8; 0],
29}
30pub const TSInputEncoding_TSInputEncodingUTF8: TSInputEncoding = 0;
31pub const TSInputEncoding_TSInputEncodingUTF16: TSInputEncoding = 1;
32pub type TSInputEncoding = ::std::os::raw::c_uint;
33pub const TSSymbolType_TSSymbolTypeRegular: TSSymbolType = 0;
34pub const TSSymbolType_TSSymbolTypeAnonymous: TSSymbolType = 1;
35pub const TSSymbolType_TSSymbolTypeAuxiliary: TSSymbolType = 2;
36pub type TSSymbolType = ::std::os::raw::c_uint;
37#[repr(C)]
38#[derive(Debug, Copy, Clone)]
39pub struct TSPoint {
40 pub row: u32,
41 pub column: u32,
42}
43#[repr(C)]
44#[derive(Debug, Copy, Clone)]
45pub struct TSRange {
46 pub start_point: TSPoint,
47 pub end_point: TSPoint,
48 pub start_byte: u32,
49 pub end_byte: u32,
50}
51#[repr(C)]
52#[derive(Debug, Copy, Clone)]
53pub struct TSInput {
54 pub payload: *mut ::std::os::raw::c_void,
55 pub read: ::std::option::Option<
56 unsafe extern "C" fn(
57 payload: *mut ::std::os::raw::c_void,
58 byte_index: u32,
59 position: TSPoint,
60 bytes_read: *mut u32,
61 ) -> *const ::std::os::raw::c_char,
62 >,
63 pub encoding: TSInputEncoding,
64}
65pub const TSLogType_TSLogTypeParse: TSLogType = 0;
66pub const TSLogType_TSLogTypeLex: TSLogType = 1;
67pub type TSLogType = ::std::os::raw::c_uint;
68#[repr(C)]
69#[derive(Debug, Copy, Clone)]
70pub struct TSLogger {
71 pub payload: *mut ::std::os::raw::c_void,
72 pub log: ::std::option::Option<
73 unsafe extern "C" fn(
74 payload: *mut ::std::os::raw::c_void,
75 arg1: TSLogType,
76 arg2: *const ::std::os::raw::c_char,
77 ),
78 >,
79}
80#[repr(C)]
81#[derive(Debug, Copy, Clone)]
82pub struct TSInputEdit {
83 pub start_byte: u32,
84 pub old_end_byte: u32,
85 pub new_end_byte: u32,
86 pub start_point: TSPoint,
87 pub old_end_point: TSPoint,
88 pub new_end_point: TSPoint,
89}
90#[repr(C)]
91#[derive(Debug, Copy, Clone)]
92pub struct TSNode {
93 pub context: [u32; 4usize],
94 pub id: *const ::std::os::raw::c_void,
95 pub tree: *const TSTree,
96}
97#[repr(C)]
98#[derive(Debug, Copy, Clone)]
99pub struct TSTreeCursor {
100 pub tree: *const ::std::os::raw::c_void,
101 pub id: *const ::std::os::raw::c_void,
102 pub context: [u32; 2usize],
103}
104#[repr(C)]
105#[derive(Debug, Copy, Clone)]
106pub struct TSQueryCapture {
107 pub node: TSNode,
108 pub index: u32,
109}
110pub const TSQuantifier_TSQuantifierZero: TSQuantifier = 0;
111pub const TSQuantifier_TSQuantifierZeroOrOne: TSQuantifier = 1;
112pub const TSQuantifier_TSQuantifierZeroOrMore: TSQuantifier = 2;
113pub const TSQuantifier_TSQuantifierOne: TSQuantifier = 3;
114pub const TSQuantifier_TSQuantifierOneOrMore: TSQuantifier = 4;
115pub type TSQuantifier = ::std::os::raw::c_uint;
116#[repr(C)]
117#[derive(Debug, Copy, Clone)]
118pub struct TSQueryMatch {
119 pub id: u32,
120 pub pattern_index: u16,
121 pub capture_count: u16,
122 pub captures: *const TSQueryCapture,
123}
124pub const TSQueryPredicateStepType_TSQueryPredicateStepTypeDone: TSQueryPredicateStepType = 0;
125pub const TSQueryPredicateStepType_TSQueryPredicateStepTypeCapture: TSQueryPredicateStepType = 1;
126pub const TSQueryPredicateStepType_TSQueryPredicateStepTypeString: TSQueryPredicateStepType = 2;
127pub type TSQueryPredicateStepType = ::std::os::raw::c_uint;
128#[repr(C)]
129#[derive(Debug, Copy, Clone)]
130pub struct TSQueryPredicateStep {
131 pub type_: TSQueryPredicateStepType,
132 pub value_id: u32,
133}
134pub const TSQueryError_TSQueryErrorNone: TSQueryError = 0;
135pub const TSQueryError_TSQueryErrorSyntax: TSQueryError = 1;
136pub const TSQueryError_TSQueryErrorNodeType: TSQueryError = 2;
137pub const TSQueryError_TSQueryErrorField: TSQueryError = 3;
138pub const TSQueryError_TSQueryErrorCapture: TSQueryError = 4;
139pub const TSQueryError_TSQueryErrorStructure: TSQueryError = 5;
140pub const TSQueryError_TSQueryErrorLanguage: TSQueryError = 6;
141pub type TSQueryError = ::std::os::raw::c_uint;
142extern "C" {
143 #[doc = " Create a new parser."]
144 pub fn ts_parser_new() -> *mut TSParser;
145}
146extern "C" {
147 #[doc = " Delete the parser, freeing all of the memory that it used."]
148 pub fn ts_parser_delete(parser: *mut TSParser);
149}
150extern "C" {
151 #[doc = " Set the language that the parser should use for parsing.\n\n Returns a boolean indicating whether or not the language was successfully\n assigned. True means assignment succeeded. False means there was a version\n mismatch: the language was generated with an incompatible version of the\n Tree-sitter CLI. Check the language's version using `ts_language_version`\n and compare it to this library's `TREE_SITTER_LANGUAGE_VERSION` and\n `TREE_SITTER_MIN_COMPATIBLE_LANGUAGE_VERSION` constants."]
152 pub fn ts_parser_set_language(self_: *mut TSParser, language: *const TSLanguage) -> bool;
153}
154extern "C" {
155 #[doc = " Get the parser's current language."]
156 pub fn ts_parser_language(self_: *const TSParser) -> *const TSLanguage;
157}
158extern "C" {
159 #[doc = " Set the ranges of text that the parser should include when parsing.\n\n By default, the parser will always include entire documents. This function\n allows you to parse only a *portion* of a document but still return a syntax\n tree whose ranges match up with the document as a whole. You can also pass\n multiple disjoint ranges.\n\n The second and third parameters specify the location and length of an array\n of ranges. The parser does *not* take ownership of these ranges; it copies\n the data, so it doesn't matter how these ranges are allocated.\n\n If `length` is zero, then the entire document will be parsed. Otherwise,\n the given ranges must be ordered from earliest to latest in the document,\n and they must not overlap. That is, the following must hold for all\n `i` < `length - 1`: ranges[i].end_byte <= ranges[i + 1].start_byte\n\n If this requirement is not satisfied, the operation will fail, the ranges\n will not be assigned, and this function will return `false`. On success,\n this function returns `true`"]
160 pub fn ts_parser_set_included_ranges(
161 self_: *mut TSParser,
162 ranges: *const TSRange,
163 length: u32,
164 ) -> bool;
165}
166extern "C" {
167 #[doc = " Get the ranges of text that the parser will include when parsing.\n\n The returned pointer is owned by the parser. The caller should not free it\n or write to it. The length of the array will be written to the given\n `length` pointer."]
168 pub fn ts_parser_included_ranges(self_: *const TSParser, length: *mut u32) -> *const TSRange;
169}
170extern "C" {
171 #[doc = " Use the parser to parse some source code and create a syntax tree.\n\n If you are parsing this document for the first time, pass `NULL` for the\n `old_tree` parameter. Otherwise, if you have already parsed an earlier\n version of this document and the document has since been edited, pass the\n previous syntax tree so that the unchanged parts of it can be reused.\n This will save time and memory. For this to work correctly, you must have\n already edited the old syntax tree using the `ts_tree_edit` function in a\n way that exactly matches the source code changes.\n\n The `TSInput` parameter lets you specify how to read the text. It has the\n following three fields:\n 1. `read`: A function to retrieve a chunk of text at a given byte offset\n and (row, column) position. The function should return a pointer to the\n text and write its length to the `bytes_read` pointer. The parser does\n not take ownership of this buffer; it just borrows it until it has\n finished reading it. The function should write a zero value to the\n `bytes_read` pointer to indicate the end of the document.\n 2. `payload`: An arbitrary pointer that will be passed to each invocation\n of the `read` function.\n 3. `encoding`: An indication of how the text is encoded. Either\n `TSInputEncodingUTF8` or `TSInputEncodingUTF16`.\n\n This function returns a syntax tree on success, and `NULL` on failure. There\n are three possible reasons for failure:\n 1. The parser does not have a language assigned. Check for this using the\n`ts_parser_language` function.\n 2. Parsing was cancelled due to a timeout that was set by an earlier call to\n the `ts_parser_set_timeout_micros` function. You can resume parsing from\n where the parser left out by calling `ts_parser_parse` again with the\n same arguments. Or you can start parsing from scratch by first calling\n `ts_parser_reset`.\n 3. Parsing was cancelled using a cancellation flag that was set by an\n earlier call to `ts_parser_set_cancellation_flag`. You can resume parsing\n from where the parser left out by calling `ts_parser_parse` again with\n the same arguments."]
172 pub fn ts_parser_parse(
173 self_: *mut TSParser,
174 old_tree: *const TSTree,
175 input: TSInput,
176 ) -> *mut TSTree;
177}
178extern "C" {
179 #[doc = " Use the parser to parse some source code stored in one contiguous buffer.\n The first two parameters are the same as in the `ts_parser_parse` function\n above. The second two parameters indicate the location of the buffer and its\n length in bytes."]
180 pub fn ts_parser_parse_string(
181 self_: *mut TSParser,
182 old_tree: *const TSTree,
183 string: *const ::std::os::raw::c_char,
184 length: u32,
185 ) -> *mut TSTree;
186}
187extern "C" {
188 #[doc = " Use the parser to parse some source code stored in one contiguous buffer with\n a given encoding. The first four parameters work the same as in the\n `ts_parser_parse_string` method above. The final parameter indicates whether\n the text is encoded as UTF8 or UTF16."]
189 pub fn ts_parser_parse_string_encoding(
190 self_: *mut TSParser,
191 old_tree: *const TSTree,
192 string: *const ::std::os::raw::c_char,
193 length: u32,
194 encoding: TSInputEncoding,
195 ) -> *mut TSTree;
196}
197extern "C" {
198 #[doc = " Instruct the parser to start the next parse from the beginning.\n\n If the parser previously failed because of a timeout or a cancellation, then\n by default, it will resume where it left off on the next call to\n `ts_parser_parse` or other parsing functions. If you don't want to resume,\n and instead intend to use this parser to parse some other document, you must\n call `ts_parser_reset` first."]
199 pub fn ts_parser_reset(self_: *mut TSParser);
200}
201extern "C" {
202 #[doc = " Set the maximum duration in microseconds that parsing should be allowed to\n take before halting.\n\n If parsing takes longer than this, it will halt early, returning NULL.\n See `ts_parser_parse` for more information."]
203 pub fn ts_parser_set_timeout_micros(self_: *mut TSParser, timeout: u64);
204}
205extern "C" {
206 #[doc = " Get the duration in microseconds that parsing is allowed to take."]
207 pub fn ts_parser_timeout_micros(self_: *const TSParser) -> u64;
208}
209extern "C" {
210 #[doc = " Set the parser's current cancellation flag pointer.\n\n If a non-null pointer is assigned, then the parser will periodically read\n from this pointer during parsing. If it reads a non-zero value, it will\n halt early, returning NULL. See `ts_parser_parse` for more information."]
211 pub fn ts_parser_set_cancellation_flag(self_: *mut TSParser, flag: *const usize);
212}
213extern "C" {
214 #[doc = " Get the parser's current cancellation flag pointer."]
215 pub fn ts_parser_cancellation_flag(self_: *const TSParser) -> *const usize;
216}
217extern "C" {
218 #[doc = " Set the logger that a parser should use during parsing.\n\n The parser does not take ownership over the logger payload. If a logger was\n previously assigned, the caller is responsible for releasing any memory\n owned by the previous logger."]
219 pub fn ts_parser_set_logger(self_: *mut TSParser, logger: TSLogger);
220}
221extern "C" {
222 #[doc = " Get the parser's current logger."]
223 pub fn ts_parser_logger(self_: *const TSParser) -> TSLogger;
224}
225extern "C" {
226 #[doc = " Set the file descriptor to which the parser should write debugging graphs\n during parsing. The graphs are formatted in the DOT language. You may want\n to pipe these graphs directly to a `dot(1)` process in order to generate\n SVG output. You can turn off this logging by passing a negative number."]
227 pub fn ts_parser_print_dot_graphs(self_: *mut TSParser, file: ::std::os::raw::c_int);
228}
229extern "C" {
230 #[doc = " Create a shallow copy of the syntax tree. This is very fast.\n\n You need to copy a syntax tree in order to use it on more than one thread at\n a time, as syntax trees are not thread safe."]
231 pub fn ts_tree_copy(self_: *const TSTree) -> *mut TSTree;
232}
233extern "C" {
234 #[doc = " Delete the syntax tree, freeing all of the memory that it used."]
235 pub fn ts_tree_delete(self_: *mut TSTree);
236}
237extern "C" {
238 #[doc = " Get the root node of the syntax tree."]
239 pub fn ts_tree_root_node(self_: *const TSTree) -> TSNode;
240}
241extern "C" {
242 #[doc = " Get the root node of the syntax tree, but with its position\n shifted forward by the given offset."]
243 pub fn ts_tree_root_node_with_offset(
244 self_: *const TSTree,
245 offset_bytes: u32,
246 offset_point: TSPoint,
247 ) -> TSNode;
248}
249extern "C" {
250 #[doc = " Get the language that was used to parse the syntax tree."]
251 pub fn ts_tree_language(arg1: *const TSTree) -> *const TSLanguage;
252}
253extern "C" {
254 #[doc = " Get the array of included ranges that was used to parse the syntax tree.\n\n The returned pointer must be freed by the caller."]
255 pub fn ts_tree_included_ranges(arg1: *const TSTree, length: *mut u32) -> *mut TSRange;
256}
257extern "C" {
258 #[doc = " Edit the syntax tree to keep it in sync with source code that has been\n edited.\n\n You must describe the edit both in terms of byte offsets and in terms of\n (row, column) coordinates."]
259 pub fn ts_tree_edit(self_: *mut TSTree, edit: *const TSInputEdit);
260}
261extern "C" {
262 #[doc = " Compare an old edited syntax tree to a new syntax tree representing the same\n document, returning an array of ranges whose syntactic structure has changed.\n\n For this to work correctly, the old syntax tree must have been edited such\n that its ranges match up to the new tree. Generally, you'll want to call\n this function right after calling one of the `ts_parser_parse` functions.\n You need to pass the old tree that was passed to parse, as well as the new\n tree that was returned from that function.\n\n The returned array is allocated using `malloc` and the caller is responsible\n for freeing it using `free`. The length of the array will be written to the\n given `length` pointer."]
263 pub fn ts_tree_get_changed_ranges(
264 old_tree: *const TSTree,
265 new_tree: *const TSTree,
266 length: *mut u32,
267 ) -> *mut TSRange;
268}
269extern "C" {
270 #[doc = " Write a DOT graph describing the syntax tree to the given file."]
271 pub fn ts_tree_print_dot_graph(arg1: *const TSTree, file_descriptor: ::std::os::raw::c_int);
272}
273extern "C" {
274 #[doc = " Get the node's type as a null-terminated string."]
275 pub fn ts_node_type(arg1: TSNode) -> *const ::std::os::raw::c_char;
276}
277extern "C" {
278 #[doc = " Get the node's type as a numerical id."]
279 pub fn ts_node_symbol(arg1: TSNode) -> TSSymbol;
280}
281extern "C" {
282 #[doc = " Get the node's start byte."]
283 pub fn ts_node_start_byte(arg1: TSNode) -> u32;
284}
285extern "C" {
286 #[doc = " Get the node's start position in terms of rows and columns."]
287 pub fn ts_node_start_point(arg1: TSNode) -> TSPoint;
288}
289extern "C" {
290 #[doc = " Get the node's end byte."]
291 pub fn ts_node_end_byte(arg1: TSNode) -> u32;
292}
293extern "C" {
294 #[doc = " Get the node's end position in terms of rows and columns."]
295 pub fn ts_node_end_point(arg1: TSNode) -> TSPoint;
296}
297extern "C" {
298 #[doc = " Get an S-expression representing the node as a string.\n\n This string is allocated with `malloc` and the caller is responsible for\n freeing it using `free`."]
299 pub fn ts_node_string(arg1: TSNode) -> *mut ::std::os::raw::c_char;
300}
301extern "C" {
302 #[doc = " Check if the node is null. Functions like `ts_node_child` and\n `ts_node_next_sibling` will return a null node to indicate that no such node\n was found."]
303 pub fn ts_node_is_null(arg1: TSNode) -> bool;
304}
305extern "C" {
306 #[doc = " Check if the node is *named*. Named nodes correspond to named rules in the\n grammar, whereas *anonymous* nodes correspond to string literals in the\n grammar."]
307 pub fn ts_node_is_named(arg1: TSNode) -> bool;
308}
309extern "C" {
310 #[doc = " Check if the node is *missing*. Missing nodes are inserted by the parser in\n order to recover from certain kinds of syntax errors."]
311 pub fn ts_node_is_missing(arg1: TSNode) -> bool;
312}
313extern "C" {
314 #[doc = " Check if the node is *extra*. Extra nodes represent things like comments,\n which are not required the grammar, but can appear anywhere."]
315 pub fn ts_node_is_extra(arg1: TSNode) -> bool;
316}
317extern "C" {
318 #[doc = " Check if a syntax node has been edited."]
319 pub fn ts_node_has_changes(arg1: TSNode) -> bool;
320}
321extern "C" {
322 #[doc = " Check if the node is a syntax error or contains any syntax errors."]
323 pub fn ts_node_has_error(arg1: TSNode) -> bool;
324}
325extern "C" {
326 #[doc = " Get the node's immediate parent."]
327 pub fn ts_node_parent(arg1: TSNode) -> TSNode;
328}
329extern "C" {
330 #[doc = " Get the node's child at the given index, where zero represents the first\n child."]
331 pub fn ts_node_child(arg1: TSNode, arg2: u32) -> TSNode;
332}
333extern "C" {
334 #[doc = " Get the field name for node's child at the given index, where zero represents\n the first child. Returns NULL, if no field is found."]
335 pub fn ts_node_field_name_for_child(arg1: TSNode, arg2: u32) -> *const ::std::os::raw::c_char;
336}
337extern "C" {
338 #[doc = " Get the node's number of children."]
339 pub fn ts_node_child_count(arg1: TSNode) -> u32;
340}
341extern "C" {
342 #[doc = " Get the node's *named* child at the given index.\n\n See also `ts_node_is_named`."]
343 pub fn ts_node_named_child(arg1: TSNode, arg2: u32) -> TSNode;
344}
345extern "C" {
346 #[doc = " Get the node's number of *named* children.\n\n See also `ts_node_is_named`."]
347 pub fn ts_node_named_child_count(arg1: TSNode) -> u32;
348}
349extern "C" {
350 #[doc = " Get the node's child with the given field name."]
351 pub fn ts_node_child_by_field_name(
352 self_: TSNode,
353 field_name: *const ::std::os::raw::c_char,
354 field_name_length: u32,
355 ) -> TSNode;
356}
357extern "C" {
358 #[doc = " Get the node's child with the given numerical field id.\n\n You can convert a field name to an id using the\n `ts_language_field_id_for_name` function."]
359 pub fn ts_node_child_by_field_id(arg1: TSNode, arg2: TSFieldId) -> TSNode;
360}
361extern "C" {
362 #[doc = " Get the node's next / previous sibling."]
363 pub fn ts_node_next_sibling(arg1: TSNode) -> TSNode;
364}
365extern "C" {
366 pub fn ts_node_prev_sibling(arg1: TSNode) -> TSNode;
367}
368extern "C" {
369 #[doc = " Get the node's next / previous *named* sibling."]
370 pub fn ts_node_next_named_sibling(arg1: TSNode) -> TSNode;
371}
372extern "C" {
373 pub fn ts_node_prev_named_sibling(arg1: TSNode) -> TSNode;
374}
375extern "C" {
376 #[doc = " Get the node's first child that extends beyond the given byte offset."]
377 pub fn ts_node_first_child_for_byte(arg1: TSNode, arg2: u32) -> TSNode;
378}
379extern "C" {
380 #[doc = " Get the node's first named child that extends beyond the given byte offset."]
381 pub fn ts_node_first_named_child_for_byte(arg1: TSNode, arg2: u32) -> TSNode;
382}
383extern "C" {
384 #[doc = " Get the smallest node within this node that spans the given range of bytes\n or (row, column) positions."]
385 pub fn ts_node_descendant_for_byte_range(arg1: TSNode, arg2: u32, arg3: u32) -> TSNode;
386}
387extern "C" {
388 pub fn ts_node_descendant_for_point_range(arg1: TSNode, arg2: TSPoint, arg3: TSPoint)
389 -> TSNode;
390}
391extern "C" {
392 #[doc = " Get the smallest named node within this node that spans the given range of\n bytes or (row, column) positions."]
393 pub fn ts_node_named_descendant_for_byte_range(arg1: TSNode, arg2: u32, arg3: u32) -> TSNode;
394}
395extern "C" {
396 pub fn ts_node_named_descendant_for_point_range(
397 arg1: TSNode,
398 arg2: TSPoint,
399 arg3: TSPoint,
400 ) -> TSNode;
401}
402extern "C" {
403 #[doc = " Edit the node to keep it in-sync with source code that has been edited.\n\n This function is only rarely needed. When you edit a syntax tree with the\n `ts_tree_edit` function, all of the nodes that you retrieve from the tree\n afterward will already reflect the edit. You only need to use `ts_node_edit`\n when you have a `TSNode` instance that you want to keep and continue to use\n after an edit."]
404 pub fn ts_node_edit(arg1: *mut TSNode, arg2: *const TSInputEdit);
405}
406extern "C" {
407 #[doc = " Check if two nodes are identical."]
408 pub fn ts_node_eq(arg1: TSNode, arg2: TSNode) -> bool;
409}
410extern "C" {
411 #[doc = " Create a new tree cursor starting from the given node.\n\n A tree cursor allows you to walk a syntax tree more efficiently than is\n possible using the `TSNode` functions. It is a mutable object that is always\n on a certain syntax node, and can be moved imperatively to different nodes."]
412 pub fn ts_tree_cursor_new(arg1: TSNode) -> TSTreeCursor;
413}
414extern "C" {
415 #[doc = " Delete a tree cursor, freeing all of the memory that it used."]
416 pub fn ts_tree_cursor_delete(arg1: *mut TSTreeCursor);
417}
418extern "C" {
419 #[doc = " Re-initialize a tree cursor to start at a different node."]
420 pub fn ts_tree_cursor_reset(arg1: *mut TSTreeCursor, arg2: TSNode);
421}
422extern "C" {
423 #[doc = " Get the tree cursor's current node."]
424 pub fn ts_tree_cursor_current_node(arg1: *const TSTreeCursor) -> TSNode;
425}
426extern "C" {
427 #[doc = " Get the field name of the tree cursor's current node.\n\n This returns `NULL` if the current node doesn't have a field.\n See also `ts_node_child_by_field_name`."]
428 pub fn ts_tree_cursor_current_field_name(
429 arg1: *const TSTreeCursor,
430 ) -> *const ::std::os::raw::c_char;
431}
432extern "C" {
433 #[doc = " Get the field id of the tree cursor's current node.\n\n This returns zero if the current node doesn't have a field.\n See also `ts_node_child_by_field_id`, `ts_language_field_id_for_name`."]
434 pub fn ts_tree_cursor_current_field_id(arg1: *const TSTreeCursor) -> TSFieldId;
435}
436extern "C" {
437 #[doc = " Move the cursor to the parent of its current node.\n\n This returns `true` if the cursor successfully moved, and returns `false`\n if there was no parent node (the cursor was already on the root node)."]
438 pub fn ts_tree_cursor_goto_parent(arg1: *mut TSTreeCursor) -> bool;
439}
440extern "C" {
441 #[doc = " Move the cursor to the next sibling of its current node.\n\n This returns `true` if the cursor successfully moved, and returns `false`\n if there was no next sibling node."]
442 pub fn ts_tree_cursor_goto_next_sibling(arg1: *mut TSTreeCursor) -> bool;
443}
444extern "C" {
445 #[doc = " Move the cursor to the first child of its current node.\n\n This returns `true` if the cursor successfully moved, and returns `false`\n if there were no children."]
446 pub fn ts_tree_cursor_goto_first_child(arg1: *mut TSTreeCursor) -> bool;
447}
448extern "C" {
449 #[doc = " Move the cursor to the first child of its current node that extends beyond\n the given byte offset or point.\n\n This returns the index of the child node if one was found, and returns -1\n if no such child was found."]
450 pub fn ts_tree_cursor_goto_first_child_for_byte(arg1: *mut TSTreeCursor, arg2: u32) -> i64;
451}
452extern "C" {
453 pub fn ts_tree_cursor_goto_first_child_for_point(arg1: *mut TSTreeCursor, arg2: TSPoint)
454 -> i64;
455}
456extern "C" {
457 pub fn ts_tree_cursor_copy(arg1: *const TSTreeCursor) -> TSTreeCursor;
458}
459extern "C" {
460 #[doc = " Create a new query from a string containing one or more S-expression\n patterns. The query is associated with a particular language, and can\n only be run on syntax nodes parsed with that language.\n\n If all of the given patterns are valid, this returns a `TSQuery`.\n If a pattern is invalid, this returns `NULL`, and provides two pieces\n of information about the problem:\n 1. The byte offset of the error is written to the `error_offset` parameter.\n 2. The type of error is written to the `error_type` parameter."]
461 pub fn ts_query_new(
462 language: *const TSLanguage,
463 source: *const ::std::os::raw::c_char,
464 source_len: u32,
465 error_offset: *mut u32,
466 error_type: *mut TSQueryError,
467 ) -> *mut TSQuery;
468}
469extern "C" {
470 #[doc = " Delete a query, freeing all of the memory that it used."]
471 pub fn ts_query_delete(arg1: *mut TSQuery);
472}
473extern "C" {
474 #[doc = " Get the number of patterns, captures, or string literals in the query."]
475 pub fn ts_query_pattern_count(arg1: *const TSQuery) -> u32;
476}
477extern "C" {
478 pub fn ts_query_capture_count(arg1: *const TSQuery) -> u32;
479}
480extern "C" {
481 pub fn ts_query_string_count(arg1: *const TSQuery) -> u32;
482}
483extern "C" {
484 #[doc = " Get the byte offset where the given pattern starts in the query's source.\n\n This can be useful when combining queries by concatenating their source\n code strings."]
485 pub fn ts_query_start_byte_for_pattern(arg1: *const TSQuery, arg2: u32) -> u32;
486}
487extern "C" {
488 #[doc = " Get all of the predicates for the given pattern in the query.\n\n The predicates are represented as a single array of steps. There are three\n types of steps in this array, which correspond to the three legal values for\n the `type` field:\n - `TSQueryPredicateStepTypeCapture` - Steps with this type represent names\n of captures. Their `value_id` can be used with the\n `ts_query_capture_name_for_id` function to obtain the name of the capture.\n - `TSQueryPredicateStepTypeString` - Steps with this type represent literal\n strings. Their `value_id` can be used with the\n `ts_query_string_value_for_id` function to obtain their string value.\n - `TSQueryPredicateStepTypeDone` - Steps with this type are *sentinels*\n that represent the end of an individual predicate. If a pattern has two\n predicates, then there will be two steps with this `type` in the array."]
489 pub fn ts_query_predicates_for_pattern(
490 self_: *const TSQuery,
491 pattern_index: u32,
492 length: *mut u32,
493 ) -> *const TSQueryPredicateStep;
494}
495extern "C" {
496 pub fn ts_query_is_pattern_rooted(self_: *const TSQuery, pattern_index: u32) -> bool;
497}
498extern "C" {
499 pub fn ts_query_is_pattern_non_local(self_: *const TSQuery, pattern_index: u32) -> bool;
500}
501extern "C" {
502 pub fn ts_query_is_pattern_guaranteed_at_step(self_: *const TSQuery, byte_offset: u32) -> bool;
503}
504extern "C" {
505 #[doc = " Get the name and length of one of the query's captures, or one of the\n query's string literals. Each capture and string is associated with a\n numeric id based on the order that it appeared in the query's source."]
506 pub fn ts_query_capture_name_for_id(
507 arg1: *const TSQuery,
508 id: u32,
509 length: *mut u32,
510 ) -> *const ::std::os::raw::c_char;
511}
512extern "C" {
513 #[doc = " Get the quantifier of the query's captures. Each capture is * associated\n with a numeric id based on the order that it appeared in the query's source."]
514 pub fn ts_query_capture_quantifier_for_id(
515 arg1: *const TSQuery,
516 pattern_id: u32,
517 capture_id: u32,
518 ) -> TSQuantifier;
519}
520extern "C" {
521 pub fn ts_query_string_value_for_id(
522 arg1: *const TSQuery,
523 id: u32,
524 length: *mut u32,
525 ) -> *const ::std::os::raw::c_char;
526}
527extern "C" {
528 #[doc = " Disable a certain capture within a query.\n\n This prevents the capture from being returned in matches, and also avoids\n any resource usage associated with recording the capture. Currently, there\n is no way to undo this."]
529 pub fn ts_query_disable_capture(
530 arg1: *mut TSQuery,
531 arg2: *const ::std::os::raw::c_char,
532 arg3: u32,
533 );
534}
535extern "C" {
536 #[doc = " Disable a certain pattern within a query.\n\n This prevents the pattern from matching and removes most of the overhead\n associated with the pattern. Currently, there is no way to undo this."]
537 pub fn ts_query_disable_pattern(arg1: *mut TSQuery, arg2: u32);
538}
539extern "C" {
540 #[doc = " Create a new cursor for executing a given query.\n\n The cursor stores the state that is needed to iteratively search\n for matches. To use the query cursor, first call `ts_query_cursor_exec`\n to start running a given query on a given syntax node. Then, there are\n two options for consuming the results of the query:\n 1. Repeatedly call `ts_query_cursor_next_match` to iterate over all of the\n *matches* in the order that they were found. Each match contains the\n index of the pattern that matched, and an array of captures. Because\n multiple patterns can match the same set of nodes, one match may contain\n captures that appear *before* some of the captures from a previous match.\n 2. Repeatedly call `ts_query_cursor_next_capture` to iterate over all of the\n individual *captures* in the order that they appear. This is useful if\n don't care about which pattern matched, and just want a single ordered\n sequence of captures.\n\n If you don't care about consuming all of the results, you can stop calling\n `ts_query_cursor_next_match` or `ts_query_cursor_next_capture` at any point.\n You can then start executing another query on another node by calling\n `ts_query_cursor_exec` again."]
541 pub fn ts_query_cursor_new() -> *mut TSQueryCursor;
542}
543extern "C" {
544 #[doc = " Delete a query cursor, freeing all of the memory that it used."]
545 pub fn ts_query_cursor_delete(arg1: *mut TSQueryCursor);
546}
547extern "C" {
548 #[doc = " Start running a given query on a given node."]
549 pub fn ts_query_cursor_exec(arg1: *mut TSQueryCursor, arg2: *const TSQuery, arg3: TSNode);
550}
551extern "C" {
552 #[doc = " Manage the maximum number of in-progress matches allowed by this query\n cursor.\n\n Query cursors have an optional maximum capacity for storing lists of\n in-progress captures. If this capacity is exceeded, then the\n earliest-starting match will silently be dropped to make room for further\n matches. This maximum capacity is optional — by default, query cursors allow\n any number of pending matches, dynamically allocating new space for them as\n needed as the query is executed."]
553 pub fn ts_query_cursor_did_exceed_match_limit(arg1: *const TSQueryCursor) -> bool;
554}
555extern "C" {
556 pub fn ts_query_cursor_match_limit(arg1: *const TSQueryCursor) -> u32;
557}
558extern "C" {
559 pub fn ts_query_cursor_set_match_limit(arg1: *mut TSQueryCursor, arg2: u32);
560}
561extern "C" {
562 #[doc = " Set the range of bytes or (row, column) positions in which the query\n will be executed."]
563 pub fn ts_query_cursor_set_byte_range(arg1: *mut TSQueryCursor, arg2: u32, arg3: u32);
564}
565extern "C" {
566 pub fn ts_query_cursor_set_point_range(arg1: *mut TSQueryCursor, arg2: TSPoint, arg3: TSPoint);
567}
568extern "C" {
569 #[doc = " Advance to the next match of the currently running query.\n\n If there is a match, write it to `*match` and return `true`.\n Otherwise, return `false`."]
570 pub fn ts_query_cursor_next_match(arg1: *mut TSQueryCursor, match_: *mut TSQueryMatch) -> bool;
571}
572extern "C" {
573 pub fn ts_query_cursor_remove_match(arg1: *mut TSQueryCursor, id: u32);
574}
575extern "C" {
576 #[doc = " Advance to the next capture of the currently running query.\n\n If there is a capture, write its match to `*match` and its index within\n the matche's capture list to `*capture_index`. Otherwise, return `false`."]
577 pub fn ts_query_cursor_next_capture(
578 arg1: *mut TSQueryCursor,
579 match_: *mut TSQueryMatch,
580 capture_index: *mut u32,
581 ) -> bool;
582}
583extern "C" {
584 #[doc = " Get the number of distinct node types in the language."]
585 pub fn ts_language_symbol_count(arg1: *const TSLanguage) -> u32;
586}
587extern "C" {
588 #[doc = " Get a node type string for the given numerical id."]
589 pub fn ts_language_symbol_name(
590 arg1: *const TSLanguage,
591 arg2: TSSymbol,
592 ) -> *const ::std::os::raw::c_char;
593}
594extern "C" {
595 #[doc = " Get the numerical id for the given node type string."]
596 pub fn ts_language_symbol_for_name(
597 self_: *const TSLanguage,
598 string: *const ::std::os::raw::c_char,
599 length: u32,
600 is_named: bool,
601 ) -> TSSymbol;
602}
603extern "C" {
604 #[doc = " Get the number of distinct field names in the language."]
605 pub fn ts_language_field_count(arg1: *const TSLanguage) -> u32;
606}
607extern "C" {
608 #[doc = " Get the field name string for the given numerical id."]
609 pub fn ts_language_field_name_for_id(
610 arg1: *const TSLanguage,
611 arg2: TSFieldId,
612 ) -> *const ::std::os::raw::c_char;
613}
614extern "C" {
615 #[doc = " Get the numerical id for the given field name string."]
616 pub fn ts_language_field_id_for_name(
617 arg1: *const TSLanguage,
618 arg2: *const ::std::os::raw::c_char,
619 arg3: u32,
620 ) -> TSFieldId;
621}
622extern "C" {
623 #[doc = " Check whether the given node type id belongs to named nodes, anonymous nodes,\n or a hidden nodes.\n\n See also `ts_node_is_named`. Hidden nodes are never returned from the API."]
624 pub fn ts_language_symbol_type(arg1: *const TSLanguage, arg2: TSSymbol) -> TSSymbolType;
625}
626extern "C" {
627 #[doc = " Get the ABI version number for this language. This version number is used\n to ensure that languages were generated by a compatible version of\n Tree-sitter.\n\n See also `ts_parser_set_language`."]
628 pub fn ts_language_version(arg1: *const TSLanguage) -> u32;
629}
630extern "C" {
631 #[doc = " Set the allocation functions used by the library.\n\n By default, Tree-sitter uses the standard libc allocation functions,\n but aborts the process when an allocation fails. This function lets\n you supply alternative allocation functions at runtime.\n\n If you pass `NULL` for any parameter, Tree-sitter will switch back to\n its default implementation of that function.\n\n If you call this function after the library has already been used, then\n you must ensure that either:\n 1. All the existing objects have been freed.\n 2. The new allocator shares its state with the old one, so it is capable\n of freeing memory that was allocated by the old allocator."]
632 pub fn ts_set_allocator(
633 new_malloc: ::std::option::Option<
634 unsafe extern "C" fn(arg1: usize) -> *mut ::std::os::raw::c_void,
635 >,
636 new_calloc: ::std::option::Option<
637 unsafe extern "C" fn(arg1: usize, arg2: usize) -> *mut ::std::os::raw::c_void,
638 >,
639 new_realloc: ::std::option::Option<
640 unsafe extern "C" fn(
641 arg1: *mut ::std::os::raw::c_void,
642 arg2: usize,
643 ) -> *mut ::std::os::raw::c_void,
644 >,
645 new_free: ::std::option::Option<unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void)>,
646 );
647}
648
649pub const TREE_SITTER_LANGUAGE_VERSION: usize = 14;
650pub const TREE_SITTER_MIN_COMPATIBLE_LANGUAGE_VERSION: usize = 13;