Skip to main content

Module parser

Module parser 

Source
Expand description

Parser module - the heart of code analysis.

This module wraps Tree-sitter and provides a clean API for parsing source files into CodeNodes. Language detection is automatic based on file extension.

Functionsยง

detect_language
Detects the programming language from a file path.
parse_file
Parses a source file and extracts all code nodes.
parse_file_usages
SDK usages for a file on disk, with the path as written used in records. Ok(None) when the file has no usage extractor: its extension is not in crate::usages::is_usage_extension and, for a file without one, its first line is not a Python shebang. Other files are not read past that.
parse_source
Parses source code directly (useful for testing or in-memory content).
parse_source_usages
SDK usages for in-memory source. Ok(None) when the language has no usage extractor (today: every language except Python). A file that mentions no tracked SDK is not parsed at all.
parse_source_with_usages
Parses source once and returns both the graph nodes and the SDK usages (see crate::usages). The nodes are exactly what parse_source returns; usages are None when the language has no usage extractor.