Expand description
Code relationship extraction (definitions, references, call graphs). Code relationships module for definition/reference tracking and call graphs.
This module provides capabilities for understanding code relationships:
- Find where symbols are defined
- Find all references to a symbol
- Build call graphs for functions/methods
§Architecture
The module uses a hybrid approach:
- Stack-graphs (optional feature): High-precision name resolution for Python, TypeScript, Java, and Ruby (~95% accuracy)
- RepoMap: AST-based extraction with heuristic matching for all languages (~70% accuracy)
§Usage
ⓘ
use brainwires_cognition::code_analysis::{HybridRelationsProvider, RelationsProvider};
let provider = HybridRelationsProvider::new()?;
let definitions = provider.extract_definitions(&file_info)?;
let references = provider.extract_references(&file_info, &symbol_index)?;Modules§
- repomap
- RepoMap-style code relationship extraction.
- storage
- Storage layer for code relationships.
- types
- Type definitions for code relationships (definitions, references, call graphs).
Structs§
- Call
Edge - An edge in the call graph representing a function/method call.
- Call
Graph Node - A node in the call graph
- Definition
- A definition of a symbol in the codebase.
- Definition
Result - Result from find_definition containing the found definition
- Hybrid
Relations Provider - Hybrid provider that selects the best available provider per language.
- Reference
- A reference to a symbol from another location in the codebase.
- Reference
Result - Result from find_references containing a found reference
- Relations
Config - Configuration for relations extraction
- Symbol
Id - A unique identifier for a symbol in the codebase.
- Symbol
Info - Symbol info for call graph root
Enums§
- Precision
Level - Precision level of the relations provider
- Reference
Kind - Kind of reference to a symbol
- Symbol
Kind - Kind of symbol in the codebase
- Visibility
- Visibility/access modifier for a symbol
Traits§
- Relations
Provider - Trait for extracting code relationships from source files.