### Get pattern start byte offset Source: https://docs.rs/tree-sitter/latest/tree_sitter/struct.Query.html Retrieves the byte offset where a specific pattern starts within the query's source string. ```rust pub fn start_byte_for_pattern(&self, pattern_index: usize) -> usize ``` -------------------------------- ### Get Query Pattern Start Byte - Rust Source: https://docs.rs/tree-sitter/latest/tree_sitter/ffi/fn.ts_query_start_byte_for_pattern.html Use this function to find the byte offset where a specific pattern begins in a query's source code. This is particularly helpful when concatenating query strings. ```rust pub unsafe extern "C" fn ts_query_start_byte_for_pattern( self_: *const TSQuery, pattern_index: u32, ) -> u32 ``` -------------------------------- ### reset Source: https://docs.rs/tree-sitter/latest/tree_sitter/struct.Parser.html Instruct the parser to start the next parse from the beginning. ```APIDOC ## reset ### Description Instruct the parser to start the next parse from the beginning. Useful if the parser previously failed and you want to start fresh. ``` -------------------------------- ### Execute Query with Options in Rust Source: https://docs.rs/tree-sitter/latest/tree_sitter/ffi/fn.ts_query_cursor_exec_with_options.html This function is used to start running a query on a node with specific execution options. ```Rust pub unsafe extern "C" fn ts_query_cursor_exec_with_options( self_: *mut TSQueryCursor, query: *const TSQuery, node: TSNode, query_options: *const TSQueryCursorOptions, ) ``` -------------------------------- ### Get Node Start Point - Rust Source: https://docs.rs/tree-sitter/latest/tree_sitter/ffi/fn.ts_node_start_point.html Use this function to get the node's start position in terms of rows and columns. Requires a valid TSNode. ```rust pub unsafe extern "C" fn ts_node_start_point(self_: TSNode) -> TSPoint ``` -------------------------------- ### Initialize Tree-sitter Parser in Rust Source: https://docs.rs/tree-sitter/latest/tree_sitter/index.html Create a new parser instance. No specific setup is required beyond importing the necessary types. ```rust use tree_sitter::{InputEdit, Language, Parser, Point}; let mut parser = Parser::new(); ``` -------------------------------- ### ts_node_start_byte Function Source: https://docs.rs/tree-sitter/latest/tree_sitter/ffi/fn.ts_node_start_byte.html Retrieves the starting byte position of a given tree-sitter node. ```APIDOC ## ts_node_start_byte ### Description Get the node’s start byte. ### Method `pub unsafe extern "C" fn` ### Endpoint `tree_sitter::ffi` ### Parameters #### Path Parameters - **self_** (TSNode) - Required - The node to get the start byte from. ### Response #### Success Response (u32) - **return value** (u32) - The start byte of the node. ``` -------------------------------- ### Retrieve node start byte via FFI Source: https://docs.rs/tree-sitter/latest/tree_sitter/ffi/fn.ts_node_start_byte.html Use this function to obtain the byte offset where a node begins in the source text. This is an unsafe C-compatible function. ```rust pub unsafe extern "C" fn ts_node_start_byte(self_: TSNode) -> u32 ``` -------------------------------- ### Parser Initialization and Configuration Source: https://docs.rs/tree-sitter/latest/tree_sitter/struct.Parser.html Methods for creating a new parser, reconstructing from a raw pointer, and managing its language and logger settings. ```APIDOC ## Parser Initialization and Configuration ### `new()` Creates a new parser instance. ### `from_raw(ptr: *mut TSParser)` Reconstructs a `Parser` from a raw pointer. This is an unsafe operation. **Safety**: `ptr` must be non-null. ### `set_language(&mut self, language: &Language) -> Result<(), LanguageError>` Sets the language for the parser. Returns an error if the language version is incompatible. ### `language(&self) -> Option>` Retrieves the parser's current language. ### `set_logger(&mut self, logger: Option>)` Sets a callback for logging during parsing. ### `logger(&self) -> Option<&Box>` Retrieves the parser's current logger callback. ### `into_raw(self) -> *mut TSParser` Consumes the `Parser` and returns a raw pointer to the underlying C structure. This is an unsafe operation. **Safety**: The caller is responsible for managing the parser's state after this operation to prevent issues like use-after-free. ``` -------------------------------- ### Create New QueryCursorOptions Source: https://docs.rs/tree-sitter/latest/tree_sitter/struct.QueryCursorOptions.html Initializes a new QueryCursorOptions instance. ```rust pub fn new() -> Self ``` -------------------------------- ### Get Standard Library Symbols Source: https://docs.rs/tree-sitter/latest/tree_sitter/fn.wasm_stdlib_symbols.html Use this function to obtain an iterator over static string slices representing standard library symbols. No setup or imports are required beyond the function itself. ```rust pub fn wasm_stdlib_symbols() -> impl Iterator ``` -------------------------------- ### TryFrom and TryInto Implementations Source: https://docs.rs/tree-sitter/latest/tree_sitter/struct.LossyUtf8.html Implementations for attempting conversions between types. ```APIDOC ### impl TryFrom for T #### type Error = Infallible ### Description Provides a way to attempt a conversion from type `U` into type `T`. ### Method POST (conceptual, as this is a trait implementation) ### Endpoint N/A (Trait implementation) ### Parameters - **value** (U) - The value to convert. ### Request Example N/A ### Response #### Success Response (200) - **T** - The successfully converted value of type `T`. #### Error Response - **Infallible** - This conversion is infallible, meaning it will always succeed. #### Response Example (Success) ```json "converted_value" ``` ### impl TryInto for T #### type Error = >::Error ### Description Provides a way to attempt a conversion from type `T` into type `U`. ### Method POST (conceptual, as this is a trait implementation) ### Endpoint N/A (Trait implementation) ### Parameters None (method is called on an instance of `T`) ### Request Example N/A ### Response #### Success Response (200) - **U** - The successfully converted value of type `U`. #### Error Response - **>::Error** - The error type associated with the `TryFrom` implementation for `U`. #### Response Example (Success) ```json 123 ``` ``` -------------------------------- ### Navigate to child node by byte offset Source: https://docs.rs/tree-sitter/latest/tree_sitter/ffi/fn.ts_tree_cursor_goto_first_child_for_byte.html Moves the cursor to the first child node that contains or starts after the specified byte offset. Returns the child index or -1 if no match is found. ```rust pub unsafe extern "C" fn ts_tree_cursor_goto_first_child_for_byte( self_: *mut TSTreeCursor, goal_byte: u32, ) -> i64 ``` -------------------------------- ### Get First Child Node for Byte Offset Source: https://docs.rs/tree-sitter/latest/tree_sitter/ffi/fn.ts_node_first_child_for_byte.html Use this function to find the first child node that contains or starts after a specific byte offset within the parent node. Requires a valid TSNode and byte offset. ```rust pub unsafe extern "C" fn ts_node_first_child_for_byte( self_: TSNode, byte: u32, ) -> TSNode ``` -------------------------------- ### Get First Named Child for Byte Offset Source: https://docs.rs/tree-sitter/latest/tree_sitter/ffi/fn.ts_node_first_named_child_for_byte.html Use this function to find the first named child node that contains or starts after a specific byte offset within the current node. It requires the node and the byte offset as input. ```rust pub unsafe extern "C" fn ts_node_first_named_child_for_byte( self_: TSNode, byte: u32, ) -> TSNode ``` -------------------------------- ### ts_wasm_store_new Source: https://docs.rs/tree-sitter/latest/tree_sitter/ffi/fn.ts_wasm_store_new.html Creates a new WebAssembly store for tree-sitter. ```APIDOC ## ts_wasm_store_new ### Description Create a Wasm store. ### Method `pub unsafe extern "C"` ### Endpoint `tree_sitter::ffi` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - ***mut TSWasmStore** - A pointer to the newly created Wasm store. #### Response Example None ``` -------------------------------- ### Get Current Symbol of Lookahead Iterator Source: https://docs.rs/tree-sitter/latest/tree_sitter/ffi/fn.ts_lookahead_iterator_current_symbol.html Use this function to get the current symbol of the lookahead iterator. It requires a pointer to a TSLookaheadIterator. ```rust pub unsafe extern "C" fn ts_lookahead_iterator_current_symbol( self_: *const TSLookaheadIterator, ) -> TSSymbol ``` -------------------------------- ### Initialize Tree-sitter Parser with Wasm Store Source: https://docs.rs/tree-sitter/latest/tree_sitter/index.html Create a parser instance configured for WebAssembly grammar files. This requires enabling the 'wasm' feature and using the wasmtime crate. ```rust use tree_sitter::{wasmtime::Engine, Parser, WasmStore}; let engine = Engine::default(); let store = WasmStore::new(&engine).unwrap(); let mut parser = Parser::new(); parser.set_wasm_store(store).unwrap(); ``` -------------------------------- ### Standard Trait Implementations Source: https://docs.rs/tree-sitter/latest/tree_sitter/struct.LanguageRef.html Documentation for TryFrom and TryInto trait implementations. ```APIDOC ## impl TryFrom for T ### Description Implementation of TryFrom for conversion between types. ### Associated Types - **Error** (Infallible) - The type returned in the event of a conversion error. ### Methods - **try_from(value: U) -> Result** - Performs the conversion. ## impl TryInto for T ### Description Implementation of TryInto for conversion between types. ### Associated Types - **Error** (>::Error) - The type returned in the event of a conversion error. ### Methods - **try_into(self) -> Result** - Performs the conversion. ``` -------------------------------- ### Get Node Type - Rust Source: https://docs.rs/tree-sitter/latest/tree_sitter/ffi/fn.ts_node_type.html Use this function to get the node's type as a null-terminated string. It is an unsafe external C function. ```rust pub unsafe extern "C" fn ts_node_type(self_: TSNode) -> *const c_char ``` -------------------------------- ### Create New Tree Cursor Source: https://docs.rs/tree-sitter/latest/tree_sitter/ffi/fn.ts_tree_cursor_new.html Use this function to create a new tree cursor starting from a given node. The cursor allows efficient traversal of a syntax tree and is mutable, always positioned on a specific node. The cursor cannot navigate outside the root node provided. ```rust pub unsafe extern "C" fn ts_tree_cursor_new( node: TSNode, ) -> TSTreeCursor ``` -------------------------------- ### Get Next Sibling Node Source: https://docs.rs/tree-sitter/latest/tree_sitter/ffi/fn.ts_node_next_sibling.html Use this function to get the next sibling of a given tree-sitter node. This is part of the C FFI for tree-sitter. ```c pub unsafe extern "C" fn ts_node_next_sibling(self_: TSNode) -> TSNode ``` -------------------------------- ### Create a Wasm store using ts_wasm_store_new Source: https://docs.rs/tree-sitter/latest/tree_sitter/ffi/fn.ts_wasm_store_new.html Function signature for initializing a new Wasm store instance. ```rust pub unsafe extern "C" fn ts_wasm_store_new( engine: *mut TSWasmEngine, error: *mut TSWasmError, ) -> *mut TSWasmStore ``` -------------------------------- ### Get Node Parse State - Rust FFI Source: https://docs.rs/tree-sitter/latest/tree_sitter/ffi/fn.ts_node_parse_state.html Use this function to get the parse state ID associated with a node. This is an unsafe FFI function. ```rust pub unsafe extern "C" fn ts_node_parse_state( self_: TSNode, ) -> TSStateId ``` -------------------------------- ### Product Implementation Source: https://docs.rs/tree-sitter/latest/tree_sitter/ffi/type.TSDecodeFunction.html Calculates the product of an iterator of Options. ```APIDOC ## Product> for Option ### Description Takes each element in the Iterator: if it is a None, no further elements are taken, and the None is returned. Should no None occur, the product of all elements is returned. ### Methods - **product(iter: I) -> Option** where I: Iterator> ``` -------------------------------- ### Get Next Named Sibling Node Source: https://docs.rs/tree-sitter/latest/tree_sitter/ffi/fn.ts_node_next_named_sibling.html Use this function to get the next named sibling of a given node. It is an unsafe C external function. ```rust pub unsafe extern "C" fn ts_node_next_named_sibling( self_: TSNode, ) -> TSNode ``` -------------------------------- ### WasmStore::new Source: https://docs.rs/tree-sitter/latest/tree_sitter/struct.WasmStore.html Creates a new instance of WasmStore associated with the provided Engine. ```APIDOC ## WasmStore::new ### Description Creates a new WasmStore instance using the provided Engine. ### Method Constructor ### Parameters #### Request Body - **engine** (&Engine) - Required - The engine instance to associate with the store. ### Response #### Success Response (200) - **Result** - Returns a new WasmStore instance or a WasmError if initialization fails. ``` -------------------------------- ### Implement CloneToUninit for T (Nightly) Source: https://docs.rs/tree-sitter/latest/tree_sitter/struct.QueryCapture.html A nightly-only experimental API for performing copy-assignment from self to an uninitialized memory location. Requires T to implement Clone. ```rust impl CloneToUninit for T where T: Clone, { unsafe fn clone_to_uninit(&self, dest: *mut u8) } ``` -------------------------------- ### Define TSRange Struct Source: https://docs.rs/tree-sitter/latest/tree_sitter/ffi/struct.TSRange.html Defines the TSRange struct with start and end points, and start and end byte offsets. This struct is used to represent a range within a document. ```rust #[repr(C)] pub struct TSRange { pub start_point: TSPoint, pub end_point: TSPoint, pub start_byte: u32, pub end_byte: u32, } ``` -------------------------------- ### Get Node Grammar Symbol ID Source: https://docs.rs/tree-sitter/latest/tree_sitter/ffi/fn.ts_node_grammar_symbol.html Use this function to get the node's type as a numerical ID from the grammar, ignoring aliases. Prefer this over ts_node_symbol when using ts_language_next_state. ```rust pub unsafe extern "C" fn ts_node_grammar_symbol( self_: TSNode, ) -> TSSymbol ``` -------------------------------- ### Create Wasm Store Source: https://docs.rs/tree-sitter/latest/tree_sitter/ffi/index.html Initializes a new Wasm store for use with Tree-sitter parsers. ```APIDOC ## ts_wasm_store_new ### Description Create a new Wasm store instance. ### Method Function Call ### Endpoint ts_wasm_store_new ``` -------------------------------- ### Get Root Node with Offset - Rust FFI Source: https://docs.rs/tree-sitter/latest/tree_sitter/ffi/fn.ts_tree_root_node_with_offset.html Use this function to get the root node of a syntax tree, with its position shifted by a given byte offset and extent. This is an FFI function. ```rust pub unsafe extern "C" fn ts_tree_root_node_with_offset( self_: *const TSTree, offset_bytes: u32, offset_extent: TSPoint, ) -> TSNode ``` -------------------------------- ### Option Implementations Source: https://docs.rs/tree-sitter/latest/tree_sitter/ffi/type.TSDecodeFunction.html Provides documentation for various methods implemented for the Option type, including iterators, checking for Some/None values, and converting to references or slices. ```APIDOC ## Implementations for Option ### impl Option #### pub fn into_flat_iter(self) -> OptionFlatten Transforms an optional iterator into an iterator. If `self` is `None`, the resulting iterator is empty. Otherwise, an iterator is made from the `Some` value and returned. ##### Examples ```rust #![feature(option_into_flat_iter)] let o1 = Some([1, 2]); let o2 = None::<&[usize]>; assert_eq!(o1.into_flat_iter().collect::>(), [1, 2]); assert_eq!(o2.into_flat_iter().collect::>(), Vec::<&usize>::new()); ``` ### impl Option #### pub const fn is_some(&self) -> bool Returns `true` if the option is a `Some` value. ##### Examples ```rust let x: Option = Some(2); assert_eq!(x.is_some(), true); let x: Option = None; assert_eq!(x.is_some(), false); ``` #### pub fn is_some_and(self, f: impl FnOnce(T) -> bool) -> bool Returns `true` if the option is a `Some` and the value inside of it matches a predicate. ##### Examples ```rust let x: Option = Some(2); assert_eq!(x.is_some_and(|x| x > 1), true); let x: Option = Some(0); assert_eq!(x.is_some_and(|x| x > 1), false); let x: Option = None; assert_eq!(x.is_some_and(|x| x > 1), false); let x: Option = Some("ownership".to_string()); assert_eq!(x.as_ref().is_some_and(|x| x.len() > 1), true); println!("still alive {:?}", x); ``` #### pub const fn is_none(&self) -> bool Returns `true` if the option is a `None` value. ##### Examples ```rust let x: Option = Some(2); assert_eq!(x.is_none(), false); let x: Option = None; assert_eq!(x.is_none(), true); ``` #### pub fn is_none_or(self, f: impl FnOnce(T) -> bool) -> bool Returns `true` if the option is a `None` or the value inside of it matches a predicate. ##### Examples ```rust let x: Option = Some(2); assert_eq!(x.is_none_or(|x| x > 1), true); let x: Option = Some(0); assert_eq!(x.is_none_or(|x| x > 1), false); let x: Option = None; assert_eq!(x.is_none_or(|x| x > 1), true); let x: Option = Some("ownership".to_string()); assert_eq!(x.as_ref().is_none_or(|x| x.len() > 1), true); println!("still alive {:?}", x); ``` #### pub const fn as_ref(&self) -> Option<&T> Converts from `&Option` to `Option<&T>`. ##### Examples ```rust let text: Option = Some("Hello, world!".to_string()); let text_length: Option = text.as_ref().map(|s| s.len()); println!("still can print text: {:?}", text); ``` #### pub const fn as_mut(&mut self) -> Option<&mut T> Converts from `&mut Option` to `Option<&mut T>`. ##### Examples ```rust let mut x = Some(2); match x.as_mut() { Some(v) => *v = 42, None => {}, } assert_eq!(x, Some(42)); ``` #### pub const fn as_pin_ref(self: Pin<&Option>) -> Option> Converts from `Pin<&Option>` to `Option>`. #### pub const fn as_pin_mut(self: Pin<&mut Option>) -> Option> Converts from `Pin<&mut Option>` to `Option>`. #### pub const fn as_slice(&self) -> &[T] Returns a slice of the contained value, if any. If this is `None`, an empty slice is returned. This can be useful to have a single type of iterator over an `Option` or slice. Note: Should you have an `Option<&T>` and wish to get a slice of `T`, you can unpack it via `opt.map_or(&[], std::slice::from_ref)`. ``` -------------------------------- ### Add Tree-sitter Dependencies Source: https://docs.rs/tree-sitter/latest/tree_sitter/index.html Include the tree-sitter and a language-specific grammar crate in your Cargo.toml file. ```toml [dependencies] tree-sitter = "0.24" tree-sitter-rust = "0.23" ``` -------------------------------- ### Get Current Symbol Name - Rust Source: https://docs.rs/tree-sitter/latest/tree_sitter/ffi/fn.ts_lookahead_iterator_current_symbol_name.html Use this function to get the current symbol type of the lookahead iterator as a null-terminated string. It requires an unsafe block due to raw pointer manipulation. ```rust pub unsafe extern "C" fn ts_lookahead_iterator_current_symbol_name( self_: *const TSLookaheadIterator, ) -> *const c_char ``` -------------------------------- ### ts_query_cursor_new Source: https://docs.rs/tree-sitter/latest/tree_sitter/ffi/fn.ts_query_cursor_new.html Creates a new cursor for executing a given query. The cursor stores the state needed to iteratively search for matches. It can be used with `ts_query_cursor_exec` to start a query and then either `ts_query_cursor_next_match` or `ts_query_cursor_next_capture` to consume the results. ```APIDOC ## ts_query_cursor_new ### Description Create a new cursor for executing a given query. The cursor stores the state that is needed to iteratively search for matches. ### Method `pub unsafe extern "C" fn` ### Endpoint N/A (Function) ### Parameters None ### Request Example N/A ### Response #### Success Response - `*mut TSQueryCursor` - A pointer to the newly created query cursor. #### Response Example N/A ``` -------------------------------- ### Get Current Descendant Index of Tree Cursor Source: https://docs.rs/tree-sitter/latest/tree_sitter/ffi/fn.ts_tree_cursor_current_descendant_index.html Use this function to get the index of the cursor's current node among all descendants of the node the cursor was initialized with. This is an unsafe function and requires a valid TSTreeCursor pointer. ```rust pub unsafe extern "C" fn ts_tree_cursor_current_descendant_index( self_: *const TSTreeCursor, ) -> u32 ``` -------------------------------- ### Create a default Option Source: https://docs.rs/tree-sitter/latest/tree_sitter/ffi/type.TSDecodeFunction.html Returns None when calling the default implementation for Option. ```rust let opt: Option = Option::default(); assert!(opt.is_none()); ``` -------------------------------- ### Get Next Parse State - Rust FFI Source: https://docs.rs/tree-sitter/latest/tree_sitter/ffi/fn.ts_language_next_state.html Use this function to get the next parse state. Combine with lookahead iterators for completion suggestions or valid symbols in error nodes. Use `ts_node_grammar_symbol` for valid symbols. ```rust pub unsafe extern "C" fn ts_language_next_state( self_: *const TSLanguage, state: TSStateId, symbol: TSSymbol, ) -> TSStateId ``` -------------------------------- ### Implement TextProvider for byte slices Source: https://docs.rs/tree-sitter/latest/tree_sitter/trait.TextProvider.html Implementation of TextProvider for references to byte slices. ```rust impl<'a> TextProvider<&'a [u8]> for &'a [u8] Source§ #### type I = Once<&'a [u8]> Source§ #### fn text(&mut self, node: Node<'_>) -> Self::I ``` -------------------------------- ### ts_language_state_count Source: https://docs.rs/tree-sitter/latest/tree_sitter/ffi/fn.ts_language_state_count.html Get the number of valid states in this language. ```APIDOC ## ts_language_state_count ### Description Get the number of valid states in this language. ### Method N/A (This is a function signature, not an HTTP endpoint) ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (200) - **return value** (u32) - The number of valid states in the language. #### Response Example N/A ``` -------------------------------- ### StreamingIterator::is_done Method Source: https://docs.rs/tree-sitter/latest/tree_sitter/trait.StreamingIterator.html Checks if `get()` will return `None`. ```rust fn is_done(&self) -> bool { ... } ``` -------------------------------- ### Implement Equivalent for Q Source: https://docs.rs/tree-sitter/latest/tree_sitter/enum.QueryErrorKind.html Checks if a value Q is equivalent to a key K. This is useful for collections and lookups. ```rust impl Equivalent for Q where Q: Eq + ?Sized, K: Borrow + ?Sized { ... } ``` -------------------------------- ### Implement CloneToUninit for T Source: https://docs.rs/tree-sitter/latest/tree_sitter/ffi/struct.TSLanguageMetadata.html Provides an experimental, nightly-only method `clone_to_uninit` for copying data to an uninitialized memory location. ```rust impl CloneToUninit for T where T: Clone, Source #### unsafe fn clone_to_uninit(&self, dest: *mut u8) 🔬This is a nightly-only experimental API. (`clone_to_uninit`) Performs copy-assignment from `self` to `dest`. Read more Source ``` -------------------------------- ### QueryProperty Constructor Source: https://docs.rs/tree-sitter/latest/tree_sitter/struct.QueryProperty.html Creates a new instance of a QueryProperty. ```APIDOC ## pub fn new(key: &str, value: Option<&str>, capture_id: Option) -> Self ### Description Creates a new QueryProperty instance with the specified key, optional value, and optional capture ID. ### Parameters - **key** (&str) - Required - The key associated with the pattern. - **value** (Option<&str>) - Optional - The value associated with the key. - **capture_id** (Option) - Optional - The ID of the capture associated with the property. ``` -------------------------------- ### ts_node_start_point Source: https://docs.rs/tree-sitter/latest/tree_sitter/ffi/fn.ts_node_start_point.html Retrieves the start position of a node in terms of rows and columns. ```APIDOC ## ts_node_start_point ### Description Get the node’s start position in terms of rows and columns. ### Method FFI Function Call ### Endpoint tree_sitter::ffi::ts_node_start_point ### Parameters #### Request Body - **self_** (TSNode) - Required - The node for which to retrieve the start position. ### Response #### Success Response - **TSPoint** - The start position of the node, containing row and column information. ``` -------------------------------- ### MIN_COMPATIBLE_LANGUAGE_VERSION Constant Source: https://docs.rs/tree-sitter/latest/tree_sitter/constant.MIN_COMPATIBLE_LANGUAGE_VERSION.html Details regarding the minimum ABI version supported by the current tree-sitter library. ```APIDOC ## Constant: MIN_COMPATIBLE_LANGUAGE_VERSION ### Description The earliest ABI version that is supported by the current version of the library. ### Value 13 (usize) ``` -------------------------------- ### Get capture quantifiers Source: https://docs.rs/tree-sitter/latest/tree_sitter/struct.Query.html Retrieves the quantifiers for a specific capture at the given index. ```rust pub const fn capture_quantifiers(&self, index: usize) -> &[CaptureQuantifier] ``` -------------------------------- ### Iterate over Query matches with options Source: https://docs.rs/tree-sitter/latest/tree_sitter/struct.QueryCursor.html Iterates over all matches in the order they were found, with specified options. ```rust pub fn matches_with_options<'query, 'cursor: 'query, 'tree, T: TextProvider, I: AsRef<[u8]>>( &'cursor mut self, query: &'query Query, node: Node<'tree>, text_provider: T, options: QueryCursorOptions<'_>, ) -> QueryMatches<'query, 'tree, T, I> ``` -------------------------------- ### Get number of patterns Source: https://docs.rs/tree-sitter/latest/tree_sitter/struct.Query.html Returns the total count of patterns defined in the query. ```rust pub fn pattern_count(&self) -> usize ``` -------------------------------- ### Constants Source: https://docs.rs/tree-sitter/latest/tree_sitter/all.html Versioning and configuration constants for the Tree-sitter library. ```APIDOC ## Constants ### Description Library versioning, encoding types, query error codes, and WASM error states. ### Categories - **Versioning**: LANGUAGE_VERSION, MIN_COMPATIBLE_LANGUAGE_VERSION, PARSER_HEADER - **Encodings**: TSInputEncodingUTF8, TSInputEncodingUTF16LE, TSInputEncodingUTF16BE, TSInputEncodingCustom - **Query Errors**: TSQueryErrorNone, TSQueryErrorSyntax, TSQueryErrorNodeType, TSQueryErrorField, TSQueryErrorCapture, TSQueryErrorStructure, TSQueryErrorLanguage - **WASM Errors**: TSWasmErrorKindNone, TSWasmErrorKindParse, TSWasmErrorKindAllocate, TSWasmErrorKindCompile, TSWasmErrorKindInstantiate ``` -------------------------------- ### Get Parser Language Source: https://docs.rs/tree-sitter/latest/tree_sitter/ffi/fn.ts_parser_language.html Retrieves the language currently associated with the tree-sitter parser. ```APIDOC ## ts_parser_language ### Description Get the parser’s current language. ### Method `unsafe extern "C" fn` ### Endpoint N/A (Function within a library) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```rust // Example usage within Rust FFI context let language = ts_parser_language(parser); ``` ### Response #### Success Response (200) - **TSLanguage** (*const TSLanguage*) - A pointer to the TSLanguage struct representing the parser's current language. #### Response Example ```rust // Assuming 'language' is a *const TSLanguage // You would typically use this pointer to interact with language-specific features. println!("Language pointer: {:?}", language); ``` ``` -------------------------------- ### ts_tree_cursor_current_depth Source: https://docs.rs/tree-sitter/latest/tree_sitter/ffi/fn.ts_tree_cursor_current_depth.html Retrieves the current depth of a tree-sitter cursor relative to its starting node. ```APIDOC ## ts_tree_cursor_current_depth ### Description Get the depth of the cursor’s current node relative to the original node that the cursor was constructed with. ### Method `pub unsafe extern "C" fn` ### Endpoint `tree_sitter::ffi` ### Parameters #### Path Parameters - **self_** (*const TSTreeCursor*) - Required - The tree cursor to query. ### Response #### Success Response (u32) - **depth** (*u32*) - The current depth of the cursor. ### Request Example ```json { "self_": "" } ``` ### Response Example ```json { "depth": 5 } ``` ``` -------------------------------- ### Combinatorial Adaptors Source: https://docs.rs/tree-sitter/latest/tree_sitter/struct.LossyUtf8.html Methods for generating combinations, permutations, and powersets. ```APIDOC ## tuple_combinations ### Description Iterates over the combinations of the elements from an iterator. ## array_combinations ### Description Iterates over the combinations of the elements from an iterator. Requires `use_alloc` feature. ## combinations ### Description Iterates over the k-length combinations of the elements from an iterator. Requires `use_alloc` feature. ## combinations_with_replacement ### Description Iterates over the k-length combinations with replacement. Requires `use_alloc` feature. ## permutations ### Description Iterates over all k-permutations of the elements. Requires `use_alloc` feature. ## powerset ### Description Iterates through the powerset of the elements. Requires `use_alloc` feature. ``` -------------------------------- ### Get Current Language of LookaheadIterator Source: https://docs.rs/tree-sitter/latest/tree_sitter/struct.LookaheadIterator.html Retrieves the current language associated with the lookahead iterator. ```rust pub fn language(&self) -> LanguageRef<'_> ``` -------------------------------- ### Implement Nightly-Only Trait: CloneToUninit Source: https://docs.rs/tree-sitter/latest/tree_sitter/ffi/struct.TSInputEdit.html Nightly-only experimental API for copying data to uninitialized memory. ```rust unsafe fn clone_to_uninit(&self, dest: *mut u8) ``` -------------------------------- ### Get QueryCursor match limit Source: https://docs.rs/tree-sitter/latest/tree_sitter/struct.QueryCursor.html Returns the maximum number of in-progress matches for this cursor. ```rust pub fn match_limit(&self) -> u32 ``` -------------------------------- ### Get capture names Source: https://docs.rs/tree-sitter/latest/tree_sitter/struct.Query.html Returns a slice containing the names of all captures used in the query. ```rust pub const fn capture_names(&self) -> &[&str] ``` -------------------------------- ### Implement TextProvider for closures Source: https://docs.rs/tree-sitter/latest/tree_sitter/trait.TextProvider.html Generic implementation of TextProvider for closure types. ```rust impl TextProvider for F where F: FnMut(Node<'_>) -> R, R: Iterator, I: AsRef<[u8]>, Source§ #### type I = R ``` -------------------------------- ### Implement Equivalent for Q, K Source: https://docs.rs/tree-sitter/latest/tree_sitter/struct.QueryPredicate.html Checks if a value is equivalent to a given key, useful for collections. ```rust fn equivalent(&self, key: &K) -> bool ``` ```rust fn equivalent(&self, key: &K) -> bool ``` ```rust fn equivalent(&self, key: &K) -> bool ``` -------------------------------- ### ts_query_cursor_set_max_start_depth Source: https://docs.rs/tree-sitter/latest/tree_sitter/ffi/fn.ts_query_cursor_set_max_start_depth.html Configures the maximum start depth for a query cursor to limit tree traversal. ```APIDOC ## FFI Function: ts_query_cursor_set_max_start_depth ### Description Sets the maximum start depth for a query cursor. This prevents cursors from exploring children nodes beyond a certain depth. Setting the value to 0 allows for subtree destructuring, while setting it to UINT32_MAX removes the depth limit. ### Method FFI Call ### Parameters #### Arguments - **self_** (*mut TSQueryCursor) - Required - Pointer to the query cursor instance. - **max_start_depth** (u32) - Required - The maximum depth to search. Use 0 for special subtree destructuring behavior or UINT32_MAX to disable the limit. ``` -------------------------------- ### ts_node_first_child_for_byte Source: https://docs.rs/tree-sitter/latest/tree_sitter/ffi/fn.ts_node_first_child_for_byte.html Retrieves the first child node that contains or starts after a given byte offset. ```APIDOC ## ts_node_first_child_for_byte ### Description Get the node’s first child that contains or starts after the given byte offset. ### Method `unsafe extern "C" fn` ### Endpoint `tree_sitter::ffi` ### Parameters #### Path Parameters - **self_** (TSNode) - Required - The node to search within. - **byte** (u32) - Required - The byte offset to search from. ### Response #### Success Response (TSNode) - **TSNode** - The first child node found. ### Request Example ```json { "self_": "", "byte": 123 } ``` ### Response Example ```json { "ts_node": "" } ``` ``` -------------------------------- ### Get Current Symbol of LookaheadIterator Source: https://docs.rs/tree-sitter/latest/tree_sitter/struct.LookaheadIterator.html Retrieves the current symbol identifier (u16) of the lookahead iterator. ```rust pub fn current_symbol(&self) -> u16 ``` -------------------------------- ### Implement From for T Source: https://docs.rs/tree-sitter/latest/tree_sitter/ffi/struct.TSLanguageMetadata.html A trivial implementation of `From` for `T`, where the `from` method simply returns the input value unchanged. ```rust impl From for T Source #### fn from(t: T) -> T Returns the argument unchanged. Source ``` -------------------------------- ### Get Symbol Name Source: https://docs.rs/tree-sitter/latest/tree_sitter/ffi/fn.ts_language_symbol_name.html Retrieves the string representation of a symbol type given its numerical ID. ```APIDOC ## ts_language_symbol_name ### Description Get a node type string for the given numerical id. ### Method `unsafe extern "C"` (C function) ### Endpoint N/A (This is a library function, not a web endpoint) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```c // Example usage within C/Rust FFI context // Assuming `language` is a valid TSLanguage pointer and `symbol` is a TSSymbol const char* symbol_name = ts_language_symbol_name(language, symbol); ``` ### Response #### Success Response (Pointer to C String) - `*const c_char` - A pointer to a null-terminated C string representing the symbol name. This pointer is valid as long as the `TSLanguage` is valid. #### Response Example ```c // Assuming ts_language_symbol_name returns a valid pointer printf("Symbol name: %s\n", symbol_name); ``` ``` -------------------------------- ### QueryCursor Methods Source: https://docs.rs/tree-sitter/latest/tree_sitter/struct.QueryCursor.html Methods for creating, configuring, and executing queries using the QueryCursor. ```APIDOC ## QueryCursor::new ### Description Creates a new cursor for executing a given query. The cursor stores the state needed to iteratively search for matches. ### Method Rust Constructor ### Response - **QueryCursor** (struct) - A new instance of QueryCursor. ## QueryCursor::set_match_limit ### Description Sets the maximum number of in-progress matches for this cursor. ### Parameters #### Request Body - **limit** (u32) - Required - The maximum number of matches (must be > 0 and <= 65536). ## QueryCursor::matches ### Description Iterate over all of the matches in the order that they were found. ### Parameters #### Request Body - **query** (Query) - Required - The query to execute. - **node** (Node) - Required - The root node to start the search. - **text_provider** (TextProvider) - Required - The provider for source text. ### Response - **QueryMatches** (iterator) - An iterator over matches. ## QueryCursor::set_byte_range ### Description Set the range in which the query will be executed, in terms of byte offsets. ### Parameters #### Request Body - **range** (Range) - Required - The byte range to search within. ``` -------------------------------- ### Iterate over Query captures with options Source: https://docs.rs/tree-sitter/latest/tree_sitter/struct.QueryCursor.html Iterates over all individual captures in the order they appear, with specified options. Useful when the specific pattern matched is not important. ```rust pub fn captures_with_options<'query, 'cursor: 'query, 'tree, T: TextProvider, I: AsRef<[u8]>>( &'cursor mut self, query: &'query Query, node: Node<'tree>, text_provider: T, options: QueryCursorOptions<'_>, ) -> QueryCaptures<'query, 'tree, T, I> ``` -------------------------------- ### ts_parser_reset Source: https://docs.rs/tree-sitter/latest/tree_sitter/ffi/fn.ts_parser_reset.html Instructs the parser to start the next parse from the beginning, clearing any previous state or progress. ```APIDOC ## ts_parser_reset ### Description Instruct the parser to start the next parse from the beginning. If the parser previously failed because of the progress callback, it will resume where it left off by default. Calling this function ensures the parser starts fresh, which is required if you intend to use the parser for a different document. ### Method FFI Function Call ### Parameters #### Path Parameters - **self_** (*mut TSParser) - Required - A pointer to the TSParser instance to be reset. ``` -------------------------------- ### Language Implementations Source: https://docs.rs/tree-sitter/latest/tree_sitter/struct.Language.html Details on the trait implementations for the Language struct. ```APIDOC ### impl PartialEq for Language Source§ ``` ```APIDOC ### impl Eq for Language Source§ ``` ```APIDOC ### impl Send for Language Source§ ``` ```APIDOC ### impl Sync for Language Source§ ``` ```APIDOC ### impl Freeze for Language Source§ ``` ```APIDOC ### impl RefUnwindSafe for Language Source§ ``` ```APIDOC ### impl Unpin for Language Source§ ``` ```APIDOC ### impl UnsafeUnpin for Language Source§ ``` ```APIDOC ### impl UnwindSafe for Language Source§ ``` -------------------------------- ### ts_node_first_named_child_for_byte Source: https://docs.rs/tree-sitter/latest/tree_sitter/ffi/fn.ts_node_first_named_child_for_byte.html Retrieves the first named child node that contains or starts after a specified byte offset. ```APIDOC ## ts_node_first_named_child_for_byte ### Description Get the node’s first named child that contains or starts after the given byte offset. ### Method `unsafe extern "C"` (Implied C-style function) ### Endpoint `tree_sitter::ffi` (Namespace/Module) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```json { "self_": "TSNode", "byte": "u32" } ``` ### Response #### Success Response (TSNode) - **Return Value** (TSNode) - The first named child node found. #### Response Example ```json { "node": "TSNode" } ``` ``` -------------------------------- ### Print DOT graphs for debugging Source: https://docs.rs/tree-sitter/latest/tree_sitter/struct.Parser.html Enable the parser to write debugging graphs in DOT language to a specified file. This is useful for visualizing the parsing process. Requires the `std` feature flag. ```rust pub fn print_dot_graphs(&mut self, file: &impl AsRawFd) ``` -------------------------------- ### StreamingIterator::fuse Source: https://docs.rs/tree-sitter/latest/tree_sitter/struct.QueryCaptures.html Creates a 'well-behaved' iterator from QueryCaptures, ensuring predictable behavior at the start and end of iteration. ```rust fn fuse(self) -> Fuse where Self: Sized, ``` -------------------------------- ### Implement Clone for TSParseOptions Source: https://docs.rs/tree-sitter/latest/tree_sitter/ffi/struct.TSParseOptions.html Provides methods for cloning TSParseOptions. The `clone` method creates a duplicate of the options. ```rust fn clone(&self) -> TSParseOptions ``` ```rust fn clone_from(&mut self, source: &Self) ``` -------------------------------- ### ts_tree_cursor_goto_first_child_for_byte Source: https://docs.rs/tree-sitter/latest/tree_sitter/ffi/fn.ts_tree_cursor_goto_first_child_for_byte.html Moves the cursor to the first child of its current node that contains or starts after the given byte offset. ```APIDOC ## FFI Function: ts_tree_cursor_goto_first_child_for_byte ### Description Move the cursor to the first child of its current node that contains or starts after the given byte offset or point. ### Parameters - **self_** (*mut TSTreeCursor) - Required - A pointer to the tree cursor instance. - **goal_byte** (u32) - Required - The byte offset to search for. ### Response - **Returns** (i64) - The index of the child node if found, or -1 if no such child exists. ``` -------------------------------- ### Get Current Symbol Name of LookaheadIterator Source: https://docs.rs/tree-sitter/latest/tree_sitter/struct.LookaheadIterator.html Retrieves the static string name of the current symbol being looked at by the iterator. ```rust pub fn current_symbol_name(&self) -> &'static str ``` -------------------------------- ### Partitioning and Grouping Methods Source: https://docs.rs/tree-sitter/latest/tree_sitter/struct.LossyUtf8.html Methods for partitioning iterators into distinct types or grouping elements into HashMaps. ```APIDOC ## partition_map ### Description Collect all iterator elements into one of two partitions. Each partition may have a distinct type. ### Parameters #### Request Body - **predicate** (FnMut) - Required - Function returning Either ## into_group_map ### Description Return a HashMap of keys mapped to Vecs of values. Keys and values are taken from (Key, Value) tuple pairs yielded by the input iterator. ### Response #### Success Response (200) - **HashMap>** (Object) - Map of keys to vectors of values ``` -------------------------------- ### StreamingIterator::advance Method Source: https://docs.rs/tree-sitter/latest/tree_sitter/trait.StreamingIterator.html Advances the iterator to the next element. It should be called before `get`. The behavior after the end of the iterator is unspecified. ```rust fn advance(&mut self); ``` -------------------------------- ### QueryCaptures Methods Source: https://docs.rs/tree-sitter/latest/tree_sitter/struct.QueryCaptures.html Methods available for configuring the range of the QueryCaptures iterator. ```APIDOC ## set_byte_range ### Description Sets the byte range for the query captures iterator. ### Parameters #### Request Body - **range** (Range) - Required - The byte range to restrict the search. ## set_point_range ### Description Sets the point range for the query captures iterator. ### Parameters #### Request Body - **range** (Range) - Required - The point range to restrict the search. ``` -------------------------------- ### Get the current language of the Parser Source: https://docs.rs/tree-sitter/latest/tree_sitter/struct.Parser.html Retrieves the `LanguageRef` currently associated with the parser. Returns `None` if no language has been set. ```rust pub fn language(&self) -> Option> ``` -------------------------------- ### QueryCursorOptions Struct Source: https://docs.rs/tree-sitter/latest/tree_sitter/struct.QueryCursorOptions.html Details about the QueryCursorOptions struct, its fields, and how to create instances. ```APIDOC ## Struct QueryCursorOptions ### Description Represents options for configuring a `QueryCursor`. ### Fields - **progress_callback** (`Option<&'a mut dyn FnMut(&QueryCursorState) -> ControlFlow<()>>`) - An optional callback function that is invoked during query execution to monitor progress and potentially control the flow. ### Methods #### `new()` ```rust pub fn new() -> Self ``` Creates a new `QueryCursorOptions` with default values. #### `progress_callback ControlFlow<()>>()` ```rust pub fn progress_callback(self, callback: &'a mut F) -> Self ``` Sets the `progress_callback` option. #### `reborrow()` ```rust pub fn reborrow(&mut self) -> QueryCursorOptions<'_> ``` Creates a new `QueryCursorOptions` with a shorter lifetime, borrowing from this one. This is useful when you need to reuse query cursor options multiple times, e.g., calling `QueryCursor::matches` multiple times with the same options. ### Default Implementation #### `default()` ```rust fn default() -> QueryCursorOptions<'a> ``` Returns the default value for `QueryCursorOptions`. ``` -------------------------------- ### Get property settings Source: https://docs.rs/tree-sitter/latest/tree_sitter/struct.Query.html Retrieves the properties that are set for a given pattern index, including predicates with the `set!` operator. ```rust pub const fn property_settings(&self, index: usize) -> &[QueryProperty] ``` -------------------------------- ### LossyUtf8::new Source: https://docs.rs/tree-sitter/latest/tree_sitter/struct.LossyUtf8.html Creates a new LossyUtf8 iterator from a byte slice. ```APIDOC ## pub const fn new(bytes: &'a [u8]) -> Self ### Description Creates a new LossyUtf8 iterator from the provided byte slice. ### Parameters #### Request Body - **bytes** (&[u8]) - Required - The byte slice to be iterated over as UTF-8. ```