Skip to content

[Rust] Add code-graph extractor #96

Description

@Yashasvi2229

Target branch: code-graph-preview

Goal

Add a Rust extractor against the frozen LanguageExtractor interface. The initial implementation should model common modules and type declarations while treating macro-expanded behavior conservatively.

Scope

  • Detect .rs files as rust.
  • Vendor and register a compatible Tree-sitter Rust WASM grammar.
  • Emit a file node and containment tree.
  • Extract functions, structs, enums and members, traits, implementations, methods, modules, constants, and static variables.
  • Capture signatures, visibility, documentation comments, return types, and generic parameters when explicit.
  • Emit use/module imports, calls, containment, trait implementation, type, and instantiation references where syntax is explicit.
  • Leave cross-file and module targets unresolved through targetName.

Required changes

  • Add src/graph/extraction/languages/rust.ts.
  • Register the extractor in src/graph/extraction/languages/index.ts.
  • Register .rs and the grammar filename in src/graph/extraction/grammars.ts.
  • Add the grammar WASM under src/graph/wasm/ and document its source, version, and license.
  • Add a representative Rust fixture and focused extractor tests.

Acceptance criteria

  • The extractor implements the frozen LanguageExtractor interface without changing it.
  • Extraction is pure, deterministic, and limited to one file.
  • Tests cover modules, functions, structs, enums, traits, impl methods, qualified names, containment, imports, calls, and explicit trait implementations.
  • Macro invocations and unsupported constructs degrade conservatively without invented edges.
  • Cross-file references remain unresolved for the engine to bind.
  • npm run typecheck, npm test, and npm run build pass.
  • The packed build contains the Rust grammar WASM.

Out of scope

  • Macro expansion or procedural macro execution.
  • Cargo metadata execution or dependency downloading.
  • Type inference and borrow-checker semantics.
  • Changes to identity, reconciliation, schema, or grounding semantics.

Contributor references

Contributor workflow

git switch code-graph-preview
git pull
git switch -c feat/rust-code-graph-extractor

Open the pull request with base branch code-graph-preview.

Metadata

Metadata

Assignees

Labels

code-graphWork related to the AST and Tree-sitter code graphdeveloper-previewPart of an unreleased developer previewhelp wantedExtra attention is neededlanguage-supportAdds or improves support for a programming languagetree-sitterTree-sitter grammars, parsing, or extraction

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions