fix(deps): bump tree-sitter to 0.26 and set sqlx default-features=false to fix RUSTSEC advisories (#7031)

Signed-off-by: Adrian Cole <adrian@tetrate.io>
This commit is contained in:
Adrian Cole
2026-02-06 18:39:24 +08:00
committed by GitHub
parent 2c7e2293b2
commit 81b0a348d6
9 changed files with 242 additions and 262 deletions
+9 -9
View File
@@ -40,15 +40,15 @@ image = { version = "0.24.9", features = ["jpeg"] }
umya-spreadsheet = "2.2.3"
which = {workspace = true}
lru = "0.16"
tree-sitter = "0.21"
tree-sitter-python = "0.21"
tree-sitter-rust = "0.21"
tree-sitter-javascript = "0.21"
tree-sitter-go = "0.21"
tree-sitter-java = "0.21"
tree-sitter-kotlin = "0.3.8"
devgen-tree-sitter-swift = "0.21.0"
tree-sitter-ruby = "0.21.0"
tree-sitter = "0.26"
tree-sitter-python = "0.25"
tree-sitter-rust = "0.24"
tree-sitter-javascript = "0.25"
tree-sitter-go = "0.25"
tree-sitter-java = "0.23"
tree-sitter-kotlin-ng = "1.1"
tree-sitter-swift = "0.7"
tree-sitter-ruby = "0.23"
rayon = "1.10"
libc = "0.2"
# TODO: Fork mpatch or replace with a custom implementation using `similar` crate
@@ -84,7 +84,7 @@ pub fn find_method_for_receiver(
let mut current = *receiver_node;
while let Some(parent) = current.parent() {
if parent.kind() == "method_declaration" {
for i in 0..parent.child_count() {
for i in 0..parent.child_count() as u32 {
if let Some(child) = parent.child(i) {
if child.kind() == "field_identifier" {
return source.get(child.byte_range()).map(|s| s.to_string());
@@ -1,27 +1,26 @@
/// Tree-sitter query for extracting Kotlin code elements
pub const ELEMENT_QUERY: &str = r#"
; Functions
(function_declaration (simple_identifier) @func)
(function_declaration name: (identifier) @func)
; Classes
(class_declaration (type_identifier) @class)
(class_declaration name: (identifier) @class)
; Objects (singleton classes)
(object_declaration (type_identifier) @class)
(object_declaration name: (identifier) @class)
; Imports
(import_header) @import
(import) @import
"#;
/// Tree-sitter query for extracting Kotlin function calls
pub const CALL_QUERY: &str = r#"
; Simple function calls
(call_expression
(simple_identifier) @function.call)
(identifier) @function.call)
; Method calls with navigation (obj.method())
(call_expression
(navigation_expression
(navigation_suffix
(simple_identifier) @method.call)))
(identifier) @method.call))
"#;
@@ -113,7 +113,7 @@ fn find_first_method_in_class(
source: &str,
max_depth: usize,
) -> Option<String> {
for i in 0..class_node.child_count() {
for i in 0..class_node.child_count() as u32 {
if let Some(child) = class_node.child(i) {
if child.kind() == "body_statement" {
return find_method_in_body_with_depth(&child, source, 0, max_depth);
@@ -134,10 +134,10 @@ fn find_method_in_body_with_depth(
return None;
}
for i in 0..node.child_count() {
for i in 0..node.child_count() as u32 {
if let Some(child) = node.child(i) {
if child.kind() == "method" {
for j in 0..child.child_count() {
for j in 0..child.child_count() as u32 {
if let Some(name_node) = child.child(j) {
if name_node.kind() == "identifier" {
return source.get(name_node.byte_range()).map(|s| s.to_string());
@@ -80,7 +80,7 @@ pub fn extract_function_name_for_kind(
) -> Option<String> {
if kind == "impl_item" {
// For impl blocks, find the type being implemented
for i in 0..node.child_count() {
for i in 0..node.child_count() as u32 {
if let Some(child) = node.child(i) {
if child.kind() == "type_identifier" {
return source
@@ -108,7 +108,7 @@ pub fn find_method_for_receiver(
while let Some(parent) = current.parent() {
if parent.kind() == "function_item" {
// Found the function, get its name
for i in 0..parent.child_count() {
for i in 0..parent.child_count() as u32 {
if let Some(child) = parent.child(i) {
if child.kind() == "identifier" {
return source.get(child.byte_range()).map(|s| s.to_string());
@@ -132,7 +132,7 @@ pub fn find_receiver_type(node: &tree_sitter::Node, source: &str) -> Option<Stri
while let Some(parent) = current.parent() {
if parent.kind() == "impl_item" {
// Find the type_identifier in the impl block
for i in 0..parent.child_count() {
for i in 0..parent.child_count() as u32 {
if let Some(child) = parent.child(i) {
if child.kind() == "type_identifier" {
return source.get(child.byte_range()).map(|s| s.to_string());
@@ -1,7 +1,7 @@
use rmcp::model::{ErrorCode, ErrorData};
use std::collections::HashMap;
use std::sync::{Arc, Mutex};
use tree_sitter::{Language, Parser, Tree};
use tree_sitter::{Language, Parser, StreamingIterator, Tree};
use super::lock_or_recover;
use crate::developer::analyze::types::{
@@ -33,14 +33,14 @@ impl ParserManager {
tracing::debug!("Creating new parser for {}", language);
let mut parser = Parser::new();
let language_config: Language = match language {
"python" => tree_sitter_python::language(),
"rust" => tree_sitter_rust::language(),
"javascript" | "typescript" => tree_sitter_javascript::language(),
"go" => tree_sitter_go::language(),
"java" => tree_sitter_java::language(),
"kotlin" => tree_sitter_kotlin::language(),
"swift" => devgen_tree_sitter_swift::language(),
"ruby" => tree_sitter_ruby::language(),
"python" => tree_sitter_python::LANGUAGE.into(),
"rust" => tree_sitter_rust::LANGUAGE.into(),
"javascript" | "typescript" => tree_sitter_javascript::LANGUAGE.into(),
"go" => tree_sitter_go::LANGUAGE.into(),
"java" => tree_sitter_java::LANGUAGE.into(),
"kotlin" => tree_sitter_kotlin_ng::LANGUAGE.into(),
"swift" => tree_sitter_swift::LANGUAGE.into(),
"ruby" => tree_sitter_ruby::LANGUAGE.into(),
_ => {
tracing::warn!("Unsupported language: {}", language);
return Err(ErrorData::new(
@@ -93,7 +93,7 @@ impl ElementExtractor {
node: &'a tree_sitter::Node,
kinds: &[&str],
) -> Option<tree_sitter::Node<'a>> {
(0..node.child_count())
(0..node.child_count() as u32)
.filter_map(|i| node.child(i))
.find(|child| kinds.contains(&child.kind()))
}
@@ -214,7 +214,7 @@ impl ElementExtractor {
let mut cursor = QueryCursor::new();
let mut matches = cursor.matches(&query, tree.root_node(), source.as_bytes());
for match_ in matches.by_ref() {
while let Some(match_) = matches.next() {
for capture in match_.captures {
let node = capture.node;
let Some(text) = source.get(node.byte_range()) else {
@@ -222,7 +222,7 @@ impl ElementExtractor {
};
let line = source
.get(..node.start_byte())
.map(|s| s.lines().count() + 1)
.map(|s: &str| s.lines().count() + 1)
.unwrap_or(1);
match query.capture_names()[capture.index as usize] {
@@ -287,7 +287,7 @@ impl ElementExtractor {
let mut cursor = QueryCursor::new();
let mut matches = cursor.matches(&query, tree.root_node(), source.as_bytes());
for match_ in matches.by_ref() {
while let Some(match_) = matches.next() {
for capture in match_.captures {
let node = capture.node;
let Some(text) = source.get(node.byte_range()) else {
@@ -297,17 +297,17 @@ impl ElementExtractor {
let line_start = source
.get(..node.start_byte())
.and_then(|s| s.rfind('\n'))
.and_then(|s: &str| s.rfind('\n'))
.map(|i| i + 1)
.unwrap_or(0);
let line_end = source
.get(node.end_byte()..)
.and_then(|s| s.find('\n'))
.and_then(|s: &str| s.find('\n'))
.map(|i| node.end_byte() + i)
.unwrap_or(source.len());
let context = source
.get(line_start..line_end)
.map(|s| s.trim().to_string())
.map(|s: &str| s.trim().to_string())
.unwrap_or_default();
let caller_name = Self::find_containing_function(&node, source, language);
@@ -366,7 +366,7 @@ impl ElementExtractor {
let mut cursor = QueryCursor::new();
let mut matches = cursor.matches(&query, tree.root_node(), source.as_bytes());
for match_ in matches.by_ref() {
while let Some(match_) = matches.next() {
for capture in match_.captures {
let node = capture.node;
let Some(text) = source.get(node.byte_range()) else {
@@ -376,17 +376,17 @@ impl ElementExtractor {
let line_start = source
.get(..node.start_byte())
.and_then(|s| s.rfind('\n'))
.and_then(|s: &str| s.rfind('\n'))
.map(|i| i + 1)
.unwrap_or(0);
let line_end = source
.get(node.end_byte()..)
.and_then(|s| s.find('\n'))
.and_then(|s: &str| s.find('\n'))
.map(|i| node.end_byte() + i)
.unwrap_or(source.len());
let context = source
.get(line_start..line_end)
.map(|s| s.trim().to_string())
.map(|s: &str| s.trim().to_string())
.unwrap_or_default();
let capture_name = query.capture_names()[capture.index as usize];
+3 -1
View File
@@ -82,11 +82,13 @@ utoipa = { version = "4.1", features = ["chrono"] }
tokio-cron-scheduler = "0.14.0"
urlencoding = "2.1"
v_htmlescape = "0.15"
sqlx = { version = "0.8", features = [
sqlx = { version = "0.8", default-features = false, features = [
"runtime-tokio-rustls",
"sqlite",
"chrono",
"json",
"macros",
"migrate",
] }
# For Bedrock provider