Skip to content

Commit

Permalink
Bump tree-sitter to 0.24.x
Browse files Browse the repository at this point in the history
  • Loading branch information
Wilfred committed Dec 20, 2024
1 parent 527b701 commit 943ea4b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
12 changes: 10 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ typed-arena = "2.0.2"
rustc-hash = "2.0.0"
strsim = "0.10.0"
lazy_static = "1.4.0"
tree-sitter = "0.23.0"
tree-sitter = "0.24.0"
libc = "0.2.108"
log = "0.4.14"
pretty_env_logger = "0.5.0"
Expand Down Expand Up @@ -77,6 +77,7 @@ serde_json = "1.0"
line-numbers = "0.3.0"
smallvec = "1.13.2"
tree-sitter-language = "0.1.3"
streaming-iterator = "0.1.9"

[dev-dependencies]
# assert_cmd 2.0.10 requires predicates 3.
Expand Down
11 changes: 8 additions & 3 deletions src/parse/tree_sitter_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use std::collections::HashSet;

use line_numbers::LinePositions;
use streaming_iterator::StreamingIterator as _;
use tree_sitter as ts;
use typed_arena::Arena;

Expand Down Expand Up @@ -1247,7 +1248,10 @@ pub(crate) fn parse_subtrees(

for language in &config.sub_languages {
let mut query_cursor = tree_sitter::QueryCursor::new();
for m in query_cursor.matches(&language.query, tree.root_node(), src.as_bytes()) {
let mut query_matches =
query_cursor.matches(&language.query, tree.root_node(), src.as_bytes());

while let Some(m) = query_matches.next() {
let node = m.nodes_for_capture_index(0).next().unwrap();
if node.byte_range().is_empty() {
continue;
Expand Down Expand Up @@ -1337,13 +1341,14 @@ fn tree_highlights(
}

let mut qc = ts::QueryCursor::new();
let q_matches = qc.matches(&config.highlight_query, tree.root_node(), src.as_bytes());
let mut q_matches = qc.matches(&config.highlight_query, tree.root_node(), src.as_bytes());

let mut comment_ids = HashSet::new();
let mut keyword_ids = HashSet::new();
let mut string_ids = HashSet::new();
let mut type_ids = HashSet::new();
for m in q_matches {

while let Some(m) = q_matches.next() {
for c in m.captures {
if comment_capture_ids.contains(&c.index) {
comment_ids.insert(c.node.id());
Expand Down

0 comments on commit 943ea4b

Please sign in to comment.