Skip to content

Commit 8d1e922

Browse files
author
Marlon Costa
committed
build(deps): Update tree-sitter to 0.26.3 and related dependencies
Update major dependencies: - tree-sitter: 0.25.3 -> 0.26.3 - tree-sitter-javascript: 0.23.1 -> 0.25.0 - tree-sitter-python: 0.23.6 -> 0.25.0 - tree-sitter-rust: 0.23.2 -> 0.24.0 - askama: 0.14 -> 0.15 - tree-sitter-kotlin-ng -> tree-sitter-kotlin-codanna 0.3.9 Also update tree-sitter version in all subcrates. Regenerate language enums to match new grammar versions. Fix tree-sitter API change: Node.child() now takes u32 instead of usize. Fix clippy warnings for collapsible_if and lifetime elision.
1 parent 2dfadae commit 8d1e922

File tree

27 files changed

+1474
-1316
lines changed

27 files changed

+1474
-1316
lines changed

Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ serde = { version = "^1.0", features = ["derive"] }
2424
termcolor = "^1.2"
2525
walkdir = "^2.3"
2626

27-
tree-sitter = "=0.25.3"
27+
tree-sitter = "=0.26.3"
2828
tree-sitter-java = "=0.23.5"
29-
tree-sitter-kotlin-ng = "1.1.0"
29+
tree-sitter-kotlin-codanna = "0.3.9"
3030
tree-sitter-typescript = "=0.23.2"
31-
tree-sitter-javascript = "=0.23.1"
32-
tree-sitter-python = "=0.23.6"
33-
tree-sitter-rust = "=0.23.2"
31+
tree-sitter-javascript = "=0.25.0"
32+
tree-sitter-python = "=0.25.0"
33+
tree-sitter-rust = "=0.24.0"
3434
tree-sitter-preproc = { path = "./tree-sitter-preproc", version = "=0.20.3" }
3535
tree-sitter-ccomment = { path = "./tree-sitter-ccomment", version = "=0.20.3" }
3636
tree-sitter-mozcpp = { path = "./tree-sitter-mozcpp", version = "=0.20.4" }

enums/Cargo.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ edition = "2024"
66

77
[dependencies]
88
clap = { version = "^4.0", features = ["derive"] }
9-
askama = "^0.14"
9+
askama = "^0.15"
1010

11-
tree-sitter = "=0.25.3"
11+
tree-sitter = "=0.26.3"
1212
tree-sitter-java = "=0.23.5"
13-
tree-sitter-kotlin-ng = "1.1.0"
13+
tree-sitter-kotlin-codanna = "0.3.9"
1414
tree-sitter-typescript = "=0.23.2"
15-
tree-sitter-javascript = "=0.23.1"
16-
tree-sitter-python = "=0.23.6"
17-
tree-sitter-rust = "=0.23.2"
15+
tree-sitter-javascript = "=0.25.0"
16+
tree-sitter-python = "=0.25.0"
17+
tree-sitter-rust = "=0.24.0"
1818
tree-sitter-preproc = { path = "../tree-sitter-preproc", version = "=0.20.3" }
1919
tree-sitter-ccomment = { path = "../tree-sitter-ccomment", version = "=0.20.3" }
2020
tree-sitter-mozcpp = { path = "../tree-sitter-mozcpp", version = "=0.20.4" }

enums/src/languages.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use tree_sitter::Language;
33
mk_langs!(
44
// 1) Name for enum
55
// 2) tree-sitter function to call to get a Language
6-
(Kotlin, tree_sitter_kotlin_ng),
6+
(Kotlin, tree_sitter_kotlin_codanna),
77
(Java, tree_sitter_java),
88
(Rust, tree_sitter_rust),
99
(Cpp, tree_sitter_cpp),

enums/src/macros.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ macro_rules! mk_get_language {
1919
( $( ($camel:ident, $name:ident) ),* ) => {
2020
pub fn get_language(lang: &Lang) -> Language {
2121
match lang {
22-
Lang::Kotlin => tree_sitter_kotlin_ng::LANGUAGE.into(),
22+
Lang::Kotlin => tree_sitter_kotlin_codanna::language().into(),
2323
Lang::Java => tree_sitter_java::LANGUAGE.into(),
2424
Lang::Typescript => tree_sitter_typescript::LANGUAGE_TYPESCRIPT.into(),
2525
Lang::Tsx => tree_sitter_typescript::LANGUAGE_TSX.into(),

rust-code-analysis-cli/src/main.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -139,15 +139,15 @@ fn act_on_file(path: PathBuf, cfg: &Config) -> std::io::Result<()> {
139139
};
140140
action::<Count>(&language, source, &path, pr, cfg)
141141
} else if cfg.preproc_lock.is_some() {
142-
if let Some(language) = guess_language(&source, &path).0 {
143-
if language == LANG::Cpp {
144-
let mut results = cfg.preproc_lock.as_ref().unwrap().lock().unwrap();
145-
preprocess(
146-
&PreprocParser::new(source, &path, None),
147-
&path,
148-
&mut results,
149-
);
150-
}
142+
if let Some(language) = guess_language(&source, &path).0
143+
&& language == LANG::Cpp
144+
{
145+
let mut results = cfg.preproc_lock.as_ref().unwrap().lock().unwrap();
146+
preprocess(
147+
&PreprocParser::new(source, &path, None),
148+
&path,
149+
&mut results,
150+
);
151151
}
152152
Ok(())
153153
} else {

src/alterator.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@ impl Alterator for CppCode {
7070
AstNode::new(node.kind(), text, span, Vec::new())
7171
}
7272
Cpp::PreprocDef | Cpp::PreprocFunctionDef | Cpp::PreprocCall => {
73-
if let Some(last) = children.last() {
74-
if last.r#type == "\n" {
75-
children.pop();
76-
}
73+
if let Some(last) = children.last()
74+
&& last.r#type == "\n"
75+
{
76+
children.pop();
7777
}
7878
Self::get_default(node, code, span, children)
7979
}

src/checker.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -601,11 +601,11 @@ impl Checker for RustCode {
601601
}
602602

603603
fn is_useful_comment(node: &Node, code: &[u8]) -> bool {
604-
if let Some(parent) = node.parent() {
605-
if parent.kind_id() == Rust::TokenTree {
606-
// A comment could be a macro token
607-
return true;
608-
}
604+
if let Some(parent) = node.parent()
605+
&& parent.kind_id() == Rust::TokenTree
606+
{
607+
// A comment could be a macro token
608+
return true;
609609
}
610610
let code = &code[node.start_byte()..node.end_byte()];
611611
code.starts_with(b"/// cbindgen:")

src/find.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,14 @@ impl Callback for Find {
6565
type Cfg = FindCfg;
6666

6767
fn call<T: ParserTrait>(cfg: Self::Cfg, parser: &T) -> Self::Res {
68-
if let Some(good) = find(parser, &cfg.filters) {
69-
if !good.is_empty() {
70-
println!("In file {}", cfg.path.to_str().unwrap());
71-
for node in good {
72-
dump_node(parser.get_code(), &node, 1, cfg.line_start, cfg.line_end)?;
73-
}
74-
println!();
68+
if let Some(good) = find(parser, &cfg.filters)
69+
&& !good.is_empty()
70+
{
71+
println!("In file {}", cfg.path.to_str().unwrap());
72+
for node in good {
73+
dump_node(parser.get_code(), &node, 1, cfg.line_start, cfg.line_end)?;
7574
}
75+
println!();
7676
}
7777
Ok(())
7878
}

src/getter.rs

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,11 @@ impl Getter for PythonCode {
7575
String => {
7676
let mut operator = HalsteadType::Unknown;
7777
// check if we've a documentation string or a multiline comment
78-
if let Some(parent) = node.parent() {
79-
if parent.kind_id() != ExpressionStatement || parent.child_count() != 1 {
80-
operator = HalsteadType::Operand;
81-
};
82-
}
78+
if let Some(parent) = node.parent()
79+
&& (parent.kind_id() != ExpressionStatement || parent.child_count() != 1)
80+
{
81+
operator = HalsteadType::Operand;
82+
};
8383
operator
8484
}
8585
_ => HalsteadType::Unknown,
@@ -444,25 +444,24 @@ impl Getter for CppCode {
444444
Cpp::FunctionDeclarator == id
445445
|| Cpp::FunctionDeclarator2 == id
446446
|| Cpp::FunctionDeclarator3 == id
447-
}) {
448-
if let Some(first) = fd.child(0) {
449-
match first.kind_id().into() {
450-
Cpp::TypeIdentifier
451-
| Cpp::Identifier
452-
| Cpp::FieldIdentifier
453-
| Cpp::DestructorName
454-
| Cpp::OperatorName
455-
| Cpp::QualifiedIdentifier
456-
| Cpp::QualifiedIdentifier2
457-
| Cpp::QualifiedIdentifier3
458-
| Cpp::QualifiedIdentifier4
459-
| Cpp::TemplateFunction
460-
| Cpp::TemplateMethod => {
461-
let code = &code[first.start_byte()..first.end_byte()];
462-
return std::str::from_utf8(code).ok();
463-
}
464-
_ => {}
447+
}) && let Some(first) = fd.child(0)
448+
{
449+
match first.kind_id().into() {
450+
Cpp::TypeIdentifier
451+
| Cpp::Identifier
452+
| Cpp::FieldIdentifier
453+
| Cpp::DestructorName
454+
| Cpp::OperatorName
455+
| Cpp::QualifiedIdentifier
456+
| Cpp::QualifiedIdentifier2
457+
| Cpp::QualifiedIdentifier3
458+
| Cpp::QualifiedIdentifier4
459+
| Cpp::TemplateFunction
460+
| Cpp::TemplateMethod => {
461+
let code = &code[first.start_byte()..first.end_byte()];
462+
return std::str::from_utf8(code).ok();
465463
}
464+
_ => {}
466465
}
467466
}
468467
}

src/langs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ mk_langs!(
5353
"kotlin",
5454
KotlinCode,
5555
KotlinParser,
56-
tree_sitter_kotlin_ng,
56+
tree_sitter_kotlin_codanna,
5757
[kt, kts],
5858
["kotlin"]
5959
),

0 commit comments

Comments
 (0)