Skip to main content

Module code_analysis

Module code_analysis 

Source
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§

CallEdge
An edge in the call graph representing a function/method call.
CallGraphNode
A node in the call graph
Definition
A definition of a symbol in the codebase.
DefinitionResult
Result from find_definition containing the found definition
HybridRelationsProvider
Hybrid provider that selects the best available provider per language.
Reference
A reference to a symbol from another location in the codebase.
ReferenceResult
Result from find_references containing a found reference
RelationsConfig
Configuration for relations extraction
SymbolId
A unique identifier for a symbol in the codebase.
SymbolInfo
Symbol info for call graph root

Enums§

PrecisionLevel
Precision level of the relations provider
ReferenceKind
Kind of reference to a symbol
SymbolKind
Kind of symbol in the codebase
Visibility
Visibility/access modifier for a symbol

Traits§

RelationsProvider
Trait for extracting code relationships from source files.