-
-
Notifications
You must be signed in to change notification settings - Fork 323
Open
Labels
bugSomething isn't working correctlySomething isn't working correctlyenhancementNew feature or requestNew feature or requestrustRust languageRust language
Description
Problem
Rust enums, traits, type aliases, and unions are all being stored as CLASS nodes instead of their proper node labels (ENUM, INTERFACE, TYPE, UNION).
Root Cause
The determine_node_type function in codebase_rag/parsers/class_ingest/node_type.py has a match statement that handles TypeScript and C++ node types, but Rust-specific tree-sitter node types are missing.
Current behavior
All Rust types fall to the default case and become CLASS:
| Rust Construct | Tree-sitter Node Type | Current Label | Expected Label |
|---|---|---|---|
enum Foo {} |
enum_item |
CLASS | ENUM |
trait Foo {} |
trait_item |
CLASS | INTERFACE |
type Foo = Bar |
type_item |
CLASS | TYPE |
union Foo {} |
union_item |
CLASS | UNION |
struct Foo {} |
struct_item |
CLASS | CLASS |
Technical Details
Tree-sitter-rust does provide distinct node types (verified in tree-sitter-rust grammar):
enum_item- withbody: enum_variant_list,name: type_identifiertrait_item- withbody: declaration_list,name: type_identifiertype_item- withname: type_identifier,type: _typeunion_item- withbody: field_declaration_list,name: type_identifier
The fix requires adding these cases to determine_node_type():
case cs.TS_RS_ENUM_ITEM:
return NodeType.ENUM
case cs.TS_RS_TRAIT_ITEM:
return NodeType.INTERFACE
case cs.TS_RS_TYPE_ITEM:
return NodeType.TYPE
case cs.TS_RS_UNION_ITEM:
return NodeType.UNIONFiles to Modify
codebase_rag/parsers/class_ingest/node_type.py- Add Rust cases todetermine_node_type()codebase_rag/logs.py- Add log messages for Rust-specific types (e.g.,CLASS_FOUND_TRAIT)codebase_rag/tests/integration/test_node_label_e2e.py- Add tests for Rust ENUM, INTERFACE, TYPE, UNION
Impact
This enhancement would provide more accurate knowledge graph representation for Rust codebases, enabling better queries like "find all traits" or "find all enums in the project".
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't working correctlySomething isn't working correctlyenhancementNew feature or requestNew feature or requestrustRust languageRust language
Projects
Status
No status