Skip to main content

Module code_parser

Module code_parser 

Source
Expand description

Code parser — extracts entities and relationships from source code.

Extracts functions, classes, structs, and import relationships using language-specific pattern matching. Produces UcmEvent streams that the graph projection applies to build the dependency graph.

Supported languages: TypeScript, JavaScript, Rust, Python.

Edges produced: Each file gets a Module entity. Functions/structs emit DependsOn edges to their module. Import statements emit Imports edges from the importing module to the imported symbol. This gives the BFS traversal a complete path: callerFn → callerModule → importedSymbol.

Production upgrade path: replace extract_functions_* with tree-sitter grammars for sub-millisecond incremental re-parsing and error recovery. The event API surface stays identical — only the extraction backend changes.

Functions§

parse_source_code
Parse source code and emit entity + dependency events.
parse_source_code_full
Parse source code with full context including Python package root.
parse_source_code_with_context
Parse source code with project context for cross-file edge resolution.

Type Aliases§

PythonPackageRoot
The top-level Python package name for absolute import resolution. e.g. for marimo, this is “marimo” — so from marimo._runtime.dataflow import X resolves to marimo/_runtime/dataflow.py.
RustCrateMap
Maps Rust crate names (underscored, e.g. ucm_graph_core) to their src/ directory paths relative to the scan root (e.g. ucm-core/src). Built by the CLI scanner from workspace Cargo.toml files.