Skip to content

Commit edd60a8

Browse files
authored
feat(native): port Solidity extractor to Rust (#1100)
* feat(native): port Solidity extractor to Rust Adds tree-sitter-solidity dependency and native extractor matching the WASM-side behavior for Solidity symbol, import, and call extraction. Part of #1071 * fix(extractors): emit class relation for every Solidity parent `extract_inheritance` / `extractInheritance` previously called `find_child(node, 'inheritance_specifier')` and stopped at the first match, but the tree-sitter-solidity grammar models each parent in `contract A is B, C, D { }` as a separate `inheritance_specifier` sibling under the contract node (`_class_heritage: "is" commaSep1($.inheritance_specifier)`). All parents past the first were silently dropped on both the native and WASM paths. Walk every direct child of the contract node and emit a ClassRelation for each parent on both engines, and add multi-parent unit tests in Rust and TypeScript to lock the behaviour in. * fix: update native-drop test for cu still unsupported (#1100)
1 parent aa7812b commit edd60a8

12 files changed

Lines changed: 700 additions & 14 deletions

File tree

Cargo.lock

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/codegraph-core/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ tree-sitter-haskell = "0.23"
3838
tree-sitter-ocaml = "0.24"
3939
tree-sitter-julia = "0.23"
4040
tree-sitter-clojure-orchard = "0.2"
41+
tree-sitter-solidity = "1.2"
4142
rayon = "1"
4243
ignore = "0.4"
4344
globset = "0.4"

crates/codegraph-core/src/extractors/helpers.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,16 @@ pub const CLOJURE_AST_CONFIG: LangAstConfig = LangAstConfig {
394394
string_prefixes: &[],
395395
};
396396

397+
pub const SOLIDITY_AST_CONFIG: LangAstConfig = LangAstConfig {
398+
new_types: &["new_expression"],
399+
throw_types: &["revert_statement"],
400+
await_types: &[],
401+
string_types: &["string_literal", "hex_string_literal", "unicode_string_literal"],
402+
regex_types: &[],
403+
quote_chars: &['"', '\''],
404+
string_prefixes: &[],
405+
};
406+
397407
// ── Generic AST node walker ──────────────────────────────────────────────────
398408

399409
/// Node types that represent identifiers across languages.

crates/codegraph-core/src/extractors/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ pub mod python;
2121
pub mod ruby;
2222
pub mod rust_lang;
2323
pub mod scala;
24+
pub mod solidity;
2425
pub mod swift;
2526
pub mod zig;
2627

@@ -138,5 +139,8 @@ pub fn extract_symbols_with_opts(
138139
LanguageKind::Clojure => {
139140
clojure::ClojureExtractor.extract_with_opts(tree, source, file_path, include_ast_nodes)
140141
}
142+
LanguageKind::Solidity => {
143+
solidity::SolidityExtractor.extract_with_opts(tree, source, file_path, include_ast_nodes)
144+
}
141145
}
142146
}

0 commit comments

Comments
 (0)