Update tree-sitter to 0.24 (#24492)

I didn't update it to 0.25 because its Wasm support seems to be
partially broken due to
https://github.com/tree-sitter/tree-sitter/pull/3938: it didn't
introduce a check that the Wasm module's ABI is new enough to include
supertype info while parsing it, and so in the case where it isn't it
ends up interpreting random bytes as the number of supertypes, causing
out-of-bounds memory accesses.

Closes #24489

Release Notes:

- Fixed a rare crash during syntax highlighting
This commit is contained in:
Liam Murphy 2025-02-11 05:52:27 +11:00 committed by GitHub
parent d9909c691d
commit 72e1947025
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 141 additions and 127 deletions

View file

@ -15,6 +15,7 @@ doctest = false
[dependencies]
collections.workspace = true
convert_case.workspace = true
streaming-iterator.workspace = true
tree-sitter-json.workspace = true
tree-sitter.workspace = true

View file

@ -1,6 +1,7 @@
use collections::HashMap;
use convert_case::{Case, Casing};
use std::{cmp::Reverse, ops::Range, sync::LazyLock};
use streaming_iterator::StreamingIterator;
use tree_sitter::{Query, QueryMatch};
fn migrate(text: &str, patterns: MigrationPatterns, query: &Query) -> Option<String> {
@ -11,10 +12,10 @@ fn migrate(text: &str, patterns: MigrationPatterns, query: &Query) -> Option<Str
let syntax_tree = parser.parse(&text, None).unwrap();
let mut cursor = tree_sitter::QueryCursor::new();
let matches = cursor.matches(query, syntax_tree.root_node(), text.as_bytes());
let mut matches = cursor.matches(query, syntax_tree.root_node(), text.as_bytes());
let mut edits = vec![];
for mat in matches {
while let Some(mat) = matches.next() {
if let Some((_, callback)) = patterns.get(mat.pattern_index) {
edits.extend(callback(&text, &mat, query));
}