Commit 2ba882a
authored
feat(native): port Verilog extractor to Rust (#1107)
* feat(native): port Verilog extractor to Rust
Adds tree-sitter-verilog dependency and a native Verilog/SystemVerilog
extractor in crates/codegraph-core/src/extractors/verilog.rs, registers
.v / .sv with LanguageKind::Verilog and the Rust file_collector, and
adds Verilog to NATIVE_SUPPORTED_EXTENSIONS on the JS side.
Mirrors extractVerilogSymbols: module/interface/package/class
declarations, function and task declarations (parent-prefixed when
nested), package_import_declaration and include_compiler_directive
imports, and module_instantiation as call extraction.
VERILOG_AST_CONFIG in helpers.rs deliberately has all node-type lists
empty to mirror the WASM side, whose AST_TYPE_MAPS has no verilog
entry — so both engines emit zero ast_nodes rows for Verilog and stay
in parity.
Closes #1071
* fix: address Greptile review feedback for Verilog extractor (#1107)
- handle_class_decl: strengthen comment so the no-op behavior on the
current tree-sitter-verilog grammar is loud and discoverable for
future grammar upgrades.
- handle_module_instantiation: switch child(0) to named_child(0) so
any anonymous grammar tokens (e.g. parameter-override '#') leading
the module type cannot leak into call names.
- file_collector::SUPPORTED_EXTENSIONS: document .v conflict with Coq
theorem-prover source files so Coq-heavy repos know to exclude *.v
via config.
- native-drop-classification: drop expected count to 9 to reflect the
merge with main (.clj already removed, .v removed by this PR).
* chore: sync Cargo.lock version after merge (#1107)
* test(benchmark): exempt 3.10.0:Full build for verilog grammar addition (#1107)
Adding native Verilog (#1107) brings 4 .v resolution-benchmark fixtures
into the incremental benchmark sweep (which runs against the repo root).
tree-sitter-verilog is a large grammar so each .v file costs noticeably
more to parse than other fixture languages — pushing the native
fullBuildMs from the 3.10.0 baseline of 1959ms to ~2809ms (+43%).
This is a structural one-time cost of supporting the language, not a
regression in shared code paths. Following the existing pattern in
KNOWN_REGRESSIONS (3.9.6:* / 3.10.0:* entries) with a documented
rationale so a future PR isn't blocked by the bump.
* test(benchmark): exempt 3.10.0:fnDeps depth 3 and fix native-drop count (#1107)
* fix: extract Verilog class declarations and extends relations (#1107)
The tree-sitter-verilog grammar exposes no field names on
class_declaration, so childForFieldName('name') and
childForFieldName('superclass') always returned null in both engines.
The previous workaround left class extraction as documented dead code
in both extractors.
Per the CLAUDE.md principle 'Never document bugs as expected behavior',
fix the root cause by descending through the grammar's actual structure:
- Class name lives under class_identifier > simple_identifier
- Superclass appears as a class_type child with the same wrapping
Both engines now emit identical class Definitions and ClassRelation
extends edges. Added matching Rust and TypeScript regression tests
covering classes with and without an extends clause.
* fix: qualify Verilog tasks nested in classes with class name (#1107)
find_verilog_parent only consulted find_decl_name and find_module_name,
neither of which descends into the class_identifier wrapper that
tree-sitter-verilog uses for class names. As a result, any task or
function declared inside a SystemVerilog class lost its qualifier and
surfaced as a bare name instead of ClassName.task.
Extend the parent-name resolution chain to also try find_class_name,
mirroring the same logic in the WASM extractor for engine parity.
Added regression tests in both engines covering the class > task case.
* fix(test): drop .gleam/.v from WASM-only fixture after native port (#1107)
The merge-conflict resolution commit fixed parser_registry.rs but the
test edit was lost from the same merge commit. Both Gleam (#1105) and
Verilog (#1107) are now natively supported, so the WASM-only test
fixture should only count .fs / .fsx / .m as unsupported (3, not 4).
docs check acknowledged — README/CLAUDE/ROADMAP already cover both
languages.
* fix(extractors): remove unreachable splitn/split fallback in verilog package-import (#1107)
* fix(extractors): restore Verilog WASM engine parity for ports and includes (#1107)
TS `extractPorts` was missing `module_ansi_header` from its container
recursion and was not descending into `port_identifier`, so ANSI-style
modules (`module top(input clk, …)`) returned no port children in the
WASM engine while the native engine extracted them correctly.
`handleIncludeDirective` was also missing `double_quoted_string`, which
would silently drop `\`include` imports when the grammar emits that node
kind. Added regression tests for ANSI port extraction and include
directive imports.1 parent 0049d67 commit 2ba882a
13 files changed
Lines changed: 871 additions & 40 deletions
File tree
- crates/codegraph-core
- src
- extractors
- src
- domain
- extractors
- tests
- benchmarks
- parsers
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| 48 | + | |
48 | 49 | | |
49 | 50 | | |
50 | 51 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
774 | 774 | | |
775 | 775 | | |
776 | 776 | | |
777 | | - | |
778 | | - | |
779 | | - | |
780 | | - | |
781 | | - | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
782 | 785 | | |
783 | 786 | | |
784 | | - | |
785 | | - | |
| 787 | + | |
| 788 | + | |
786 | 789 | | |
787 | 790 | | |
788 | 791 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
473 | 473 | | |
474 | 474 | | |
475 | 475 | | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
476 | 493 | | |
477 | 494 | | |
478 | 495 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
| |||
166 | 167 | | |
167 | 168 | | |
168 | 169 | | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
169 | 173 | | |
170 | 174 | | |
0 commit comments