From d60ef9ad0a1a00f92b76873e623f159210614d68 Mon Sep 17 00:00:00 2001 From: Amaan Qureshi Date: Thu, 11 Sep 2025 03:11:07 -0400 Subject: [PATCH] feat(rust)!: remove deprecated functions --- crates/cli/src/main.rs | 7 - crates/xtask/src/check_wasm_exports.rs | 6 +- lib/binding_rust/bindings.rs | 34 +---- lib/binding_rust/lib.rs | 182 +------------------------ 4 files changed, 8 insertions(+), 221 deletions(-) diff --git a/crates/cli/src/main.rs b/crates/cli/src/main.rs index be27b596..dab1806a 100644 --- a/crates/cli/src/main.rs +++ b/crates/cli/src/main.rs @@ -158,9 +158,6 @@ struct Build { /// Build a Wasm module instead of a dynamic library #[arg(short, long)] pub wasm: bool, - /// No longer used. - #[arg(short, long)] - pub docker: bool, /// The path to output the compiled file #[arg(short, long)] pub output: Option, @@ -904,10 +901,6 @@ impl Build { fn run(self, mut loader: loader::Loader, current_dir: &Path) -> Result<()> { let grammar_path = current_dir.join(self.path.unwrap_or_default()); - if self.docker { - eprintln!("Warning: --docker flag is no longer used, and will be removed in a future release."); - } - loader.debug_build(self.debug); if self.wasm { diff --git a/crates/xtask/src/check_wasm_exports.rs b/crates/xtask/src/check_wasm_exports.rs index 73ab4ba0..b2193bb3 100644 --- a/crates/xtask/src/check_wasm_exports.rs +++ b/crates/xtask/src/check_wasm_exports.rs @@ -15,7 +15,7 @@ use notify_debouncer_full::new_debouncer; use crate::{bail_on_err, watch_wasm, CheckWasmExports}; -const EXCLUDES: [&str; 27] = [ +const EXCLUDES: [&str; 23] = [ // Unneeded because the JS side has its own way of implementing it "ts_node_child_by_field_name", "ts_node_edit", @@ -28,8 +28,6 @@ const EXCLUDES: [&str; 27] = [ // Not used in Wasm "ts_init", "ts_set_allocator", - "ts_parser_set_cancellation_flag", - "ts_parser_cancellation_flag", "ts_parser_print_dot_graphs", "ts_tree_print_dot_graph", "ts_parser_set_wasm_store", @@ -43,10 +41,8 @@ const EXCLUDES: [&str; 27] = [ "ts_parser_parse_string_encoding", // Query cursor is not managed by user in web bindings "ts_query_cursor_delete", - "ts_query_cursor_timeout_micros", "ts_query_cursor_match_limit", "ts_query_cursor_remove_match", - "ts_query_cursor_timeout_micros", ]; pub fn run(args: &CheckWasmExports) -> Result<()> { diff --git a/lib/binding_rust/bindings.rs b/lib/binding_rust/bindings.rs index c8d0e864..77bfef32 100644 --- a/lib/binding_rust/bindings.rs +++ b/lib/binding_rust/bindings.rs @@ -1,4 +1,4 @@ -/* automatically generated by rust-bindgen 0.72.0 */ +/* automatically generated by rust-bindgen 0.72.1 */ pub const TREE_SITTER_LANGUAGE_VERSION: u32 = 15; pub const TREE_SITTER_MIN_COMPATIBLE_LANGUAGE_VERSION: u32 = 13; @@ -218,7 +218,7 @@ extern "C" { pub fn ts_parser_included_ranges(self_: *const TSParser, count: *mut u32) -> *const TSRange; } extern "C" { - #[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 four 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.\n 4. Parsing was cancelled due to the progress callback returning true. This callback\n is passed in [`ts_parser_parse_with_options`] inside the [`TSParseOptions`] struct.\n\n [`read`]: TSInput::read\n [`payload`]: TSInput::payload\n [`encoding`]: TSInput::encoding\n [`bytes_read`]: TSInput::read"] + #[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 four 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 the progress callback returning true. This callback\n is passed in [`ts_parser_parse_with_options`] inside the [`TSParseOptions`] struct.\n\n [`read`]: TSInput::read\n [`payload`]: TSInput::payload\n [`encoding`]: TSInput::encoding\n [`bytes_read`]: TSInput::read"] pub fn ts_parser_parse( self_: *mut TSParser, old_tree: *const TSTree, @@ -254,25 +254,9 @@ extern "C" { ) -> *mut TSTree; } extern "C" { - #[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."] + #[doc = " Instruct the parser to start the next parse from the beginning.\n\n If the parser previously failed because of the progress callback, 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."] pub fn ts_parser_reset(self_: *mut TSParser); } -extern "C" { - #[doc = " @deprecated use [`ts_parser_parse_with_options`] and pass in a callback instead, this will be removed in 0.26.\n\n 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."] - pub fn ts_parser_set_timeout_micros(self_: *mut TSParser, timeout_micros: u64); -} -extern "C" { - #[doc = " @deprecated use [`ts_parser_parse_with_options`] and pass in a callback instead, this will be removed in 0.26.\n\n Get the duration in microseconds that parsing is allowed to take."] - pub fn ts_parser_timeout_micros(self_: *const TSParser) -> u64; -} -extern "C" { - #[doc = " @deprecated use [`ts_parser_parse_with_options`] and pass in a callback instead, this will be removed in 0.26.\n\n 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."] - pub fn ts_parser_set_cancellation_flag(self_: *mut TSParser, flag: *const usize); -} -extern "C" { - #[doc = " @deprecated use [`ts_parser_parse_with_options`] and pass in a callback instead, this will be removed in 0.26.\n\n Get the parser's current cancellation flag pointer."] - pub fn ts_parser_cancellation_flag(self_: *const TSParser) -> *const usize; -} extern "C" { #[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."] pub fn ts_parser_set_logger(self_: *mut TSParser, logger: TSLogger); @@ -704,14 +688,6 @@ extern "C" { extern "C" { pub fn ts_query_cursor_set_match_limit(self_: *mut TSQueryCursor, limit: u32); } -extern "C" { - #[doc = " @deprecated use [`ts_query_cursor_exec_with_options`] and pass in a callback instead, this will be removed in 0.26.\n\n Set the maximum duration in microseconds that query execution should be allowed to\n take before halting.\n\n If query execution takes longer than this, it will halt early, returning NULL.\n See [`ts_query_cursor_next_match`] or [`ts_query_cursor_next_capture`] for more information."] - pub fn ts_query_cursor_set_timeout_micros(self_: *mut TSQueryCursor, timeout_micros: u64); -} -extern "C" { - #[doc = " @deprecated use [`ts_query_cursor_exec_with_options`] and pass in a callback instead, this will be removed in 0.26.\n\n Get the duration in microseconds that query execution is allowed to take.\n\n This is set via [`ts_query_cursor_set_timeout_micros`]."] - pub fn ts_query_cursor_timeout_micros(self_: *const TSQueryCursor) -> u64; -} extern "C" { #[doc = " Set the range of bytes in which the query will be executed.\n\n The query cursor will return matches that intersect with the given point range.\n This means that a match may be returned even if some of its captures fall\n outside the specified range, as long as at least part of the match\n overlaps with the range.\n\n For example, if a query pattern matches a node that spans a larger area\n than the specified range, but part of that node intersects with the range,\n the entire match will be returned.\n\n This will return `false` if the start byte is greater than the end byte, otherwise\n it will return `true`."] pub fn ts_query_cursor_set_byte_range( @@ -815,10 +791,6 @@ extern "C" { #[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."] pub fn ts_language_symbol_type(self_: *const TSLanguage, symbol: TSSymbol) -> TSSymbolType; } -extern "C" { - #[doc = " @deprecated use [`ts_language_abi_version`] instead, this will be removed in 0.26.\n\n 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`]."] - pub fn ts_language_version(self_: *const TSLanguage) -> u32; -} extern "C" { #[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`]."] pub fn ts_language_abi_version(self_: *const TSLanguage) -> u32; diff --git a/lib/binding_rust/lib.rs b/lib/binding_rust/lib.rs index e3b2d950..074981da 100644 --- a/lib/binding_rust/lib.rs +++ b/lib/binding_rust/lib.rs @@ -19,7 +19,6 @@ use core::{ ops::{self, ControlFlow, Deref}, ptr::{self, NonNull}, slice, str, - sync::atomic::AtomicUsize, }; #[cfg(feature = "std")] use std::error; @@ -435,15 +434,6 @@ impl Language { (!ptr.is_null()).then(|| unsafe { CStr::from_ptr(ptr) }.to_str().unwrap()) } - /// Get the ABI version number that indicates which version of the - /// Tree-sitter CLI that was used to generate this [`Language`]. - #[doc(alias = "ts_language_version")] - #[deprecated(since = "0.25.0", note = "Use abi_version instead")] - #[must_use] - pub fn version(&self) -> usize { - unsafe { ffi::ts_language_version(self.0) as usize } - } - /// Get the ABI version number that indicates which version of the /// Tree-sitter CLI that was used to generate this [`Language`]. #[doc(alias = "ts_language_abi_version")] @@ -792,8 +782,6 @@ impl Parser { /// /// Returns a [`Tree`] if parsing succeeded, or `None` if: /// * The parser has not yet had a language assigned with [`Parser::set_language`] - /// * The timeout set with [`Parser::set_timeout_micros`] expired (deprecated) - /// * The cancellation flag set with [`Parser::set_cancellation_flag`] was flipped (deprecated) #[doc(alias = "ts_parser_parse")] pub fn parse(&mut self, text: impl AsRef<[u8]>, old_tree: Option<&Tree>) -> Option { let bytes = text.as_ref(); @@ -805,47 +793,6 @@ impl Parser { ) } - /// Parse a slice of UTF16 text. - /// - /// # Arguments: - /// * `text` The UTF16-encoded text to parse. - /// * `old_tree` A previous syntax tree parsed from the same document. If the text of the - /// document has changed since `old_tree` was created, then you must edit `old_tree` to match - /// the new text using [`Tree::edit`]. - #[deprecated(since = "0.25.0", note = "Prefer parse_utf16_le instead")] - pub fn parse_utf16( - &mut self, - input: impl AsRef<[u16]>, - old_tree: Option<&Tree>, - ) -> Option { - let code_points = input.as_ref(); - let len = code_points.len(); - self.parse_utf16_le_with_options( - &mut |i, _| (i < len).then(|| &code_points[i..]).unwrap_or_default(), - old_tree, - None, - ) - } - - /// Parse UTF8 text provided in chunks by a callback. - /// - /// # Arguments: - /// * `callback` A function that takes a byte offset and position and returns a slice of - /// UTF8-encoded text starting at that byte offset and position. The slices can be of any - /// length. If the given position is at the end of the text, the callback should return an - /// empty slice. - /// * `old_tree` A previous syntax tree parsed from the same document. If the text of the - /// document has changed since `old_tree` was created, then you must edit `old_tree` to match - /// the new text using [`Tree::edit`]. - #[deprecated(since = "0.25.0", note = "Prefer `parse_with_options` instead")] - pub fn parse_with, F: FnMut(usize, Point) -> T>( - &mut self, - callback: &mut F, - old_tree: Option<&Tree>, - ) -> Option { - self.parse_with_options(callback, old_tree, None) - } - /// Parse text provided in chunks by a callback. /// /// # Arguments: @@ -939,28 +886,6 @@ impl Parser { } } - /// Parse UTF16 text provided in chunks by a callback. - /// - /// # Arguments: - /// * `callback` A function that takes a code point offset and position and returns a slice of - /// UTF16-encoded text starting at that byte offset and position. The slices can be of any - /// length. If the given position is at the end of the text, the callback should return an - /// empty slice. - /// * `old_tree` A previous syntax tree parsed from the same document. If the text of the - /// document has changed since `old_tree` was created, then you must edit `old_tree` to match - /// the new text using [`Tree::edit`]. - #[deprecated( - since = "0.25.0", - note = "Prefer `parse_utf16_le_with_options` instead" - )] - pub fn parse_utf16_with, F: FnMut(usize, Point) -> T>( - &mut self, - callback: &mut F, - old_tree: Option<&Tree>, - ) -> Option { - self.parse_utf16_le_with_options(callback, old_tree, None) - } - /// Parse a slice of UTF16 little-endian text. /// /// # Arguments: @@ -1313,43 +1238,15 @@ impl Parser { /// Instruct the parser to start the next parse from the beginning. /// - /// If the parser previously failed because of a timeout, cancellation, - /// or callback, then by default, it will resume where it left off on the - /// next call to [`parse`](Parser::parse) or other parsing functions. - /// If you don't want to resume, and instead intend to use this parser to - /// parse some other document, you must call `reset` first. + /// If the parser previously failed because of a callback, then by default, + /// it will resume where it left off on the next call to [`parse`](Parser::parse) + /// or other parsing functions. If you don't want to resume, and instead intend to use + /// this parser to parse some other document, you must call `reset` first. #[doc(alias = "ts_parser_reset")] pub fn reset(&mut self) { unsafe { ffi::ts_parser_reset(self.0.as_ptr()) } } - /// Get the duration in microseconds that parsing is allowed to take. - /// - /// This is set via [`set_timeout_micros`](Parser::set_timeout_micros). - #[doc(alias = "ts_parser_timeout_micros")] - #[deprecated( - since = "0.25.0", - note = "Prefer using `parse_with_options` and using a callback" - )] - #[must_use] - pub fn timeout_micros(&self) -> u64 { - unsafe { ffi::ts_parser_timeout_micros(self.0.as_ptr()) } - } - - /// Set the maximum duration in microseconds that parsing should be allowed - /// to take before halting. - /// - /// If parsing takes longer than this, it will halt early, returning `None`. - /// See [`parse`](Parser::parse) for more information. - #[doc(alias = "ts_parser_set_timeout_micros")] - #[deprecated( - since = "0.25.0", - note = "Prefer using `parse_with_options` and using a callback" - )] - pub fn set_timeout_micros(&mut self, timeout_micros: u64) { - unsafe { ffi::ts_parser_set_timeout_micros(self.0.as_ptr(), timeout_micros) } - } - /// Set the ranges of text that the parser should include when parsing. /// /// By default, the parser will always include entire documents. This @@ -1405,49 +1302,6 @@ impl Parser { result } } - - /// Get the parser's current cancellation flag pointer. - /// - /// # Safety - /// - /// It uses FFI - #[doc(alias = "ts_parser_cancellation_flag")] - #[deprecated( - since = "0.25.0", - note = "Prefer using `parse_with_options` and using a callback" - )] - #[must_use] - pub unsafe fn cancellation_flag(&self) -> Option<&AtomicUsize> { - ffi::ts_parser_cancellation_flag(self.0.as_ptr()) - .cast::() - .as_ref() - } - - /// Set the parser's current cancellation flag pointer. - /// - /// If a pointer is assigned, then the parser will periodically read from - /// this pointer during parsing. If it reads a non-zero value, it will halt - /// early, returning `None`. See [`parse`](Parser::parse) for more - /// information. - /// - /// # Safety - /// - /// It uses FFI - #[doc(alias = "ts_parser_set_cancellation_flag")] - #[deprecated( - since = "0.25.0", - note = "Prefer using `parse_with_options` and using a callback" - )] - pub unsafe fn set_cancellation_flag(&mut self, flag: Option<&AtomicUsize>) { - if let Some(flag) = flag { - ffi::ts_parser_set_cancellation_flag( - self.0.as_ptr(), - core::ptr::from_ref::(flag).cast::(), - ); - } else { - ffi::ts_parser_set_cancellation_flag(self.0.as_ptr(), ptr::null()); - } - } } impl Drop for Parser { @@ -3025,34 +2879,6 @@ impl QueryCursor { } } - /// Set the maximum duration in microseconds that query execution should be allowed to - /// take before halting. - /// - /// If query execution takes longer than this, it will halt early, returning None. - #[doc(alias = "ts_query_cursor_set_timeout_micros")] - #[deprecated( - since = "0.25.0", - note = "Prefer using `matches_with_options` or `captures_with_options` and using a callback" - )] - pub fn set_timeout_micros(&mut self, timeout: u64) { - unsafe { - ffi::ts_query_cursor_set_timeout_micros(self.ptr.as_ptr(), timeout); - } - } - - /// Get the duration in microseconds that query execution is allowed to take. - /// - /// This is set via [`set_timeout_micros`](QueryCursor::set_timeout_micros). - #[doc(alias = "ts_query_cursor_timeout_micros")] - #[deprecated( - since = "0.25.0", - note = "Prefer using `matches_with_options` or `captures_with_options` and using a callback" - )] - #[must_use] - pub fn timeout_micros(&self) -> u64 { - unsafe { ffi::ts_query_cursor_timeout_micros(self.ptr.as_ptr()) } - } - /// Check if, on its last execution, this cursor exceeded its maximum number /// of in-progress matches. #[doc(alias = "ts_query_cursor_did_exceed_match_limit")]