Skip to main content

LanguageParser

Trait LanguageParser 

Source
pub trait LanguageParser: Send + Sync {
    // Required methods
    fn extensions(&self) -> &[&str];
    fn extract_symbols(
        &self,
        source: &[u8],
        file_path: &Path,
    ) -> Result<Vec<Symbol>>;
    fn extract_calls(
        &self,
        source: &[u8],
        file_path: &Path,
    ) -> Result<Vec<RawCallEdge>>;
    fn extract_types(
        &self,
        source: &[u8],
        file_path: &Path,
    ) -> Result<Vec<TypeInfo>>;
    fn extract_imports(
        &self,
        source: &[u8],
        file_path: &Path,
    ) -> Result<Vec<Import>>;

    // Provided method
    fn parse_file(
        &self,
        source: &[u8],
        file_path: &Path,
    ) -> Result<FileAnalysis> { ... }
}
Expand description

Trait implemented by each language-specific parser.

Stub parsers return empty results; real tree-sitter implementations will be added in Tasks 5-7.

Required Methods§

Source

fn extensions(&self) -> &[&str]

File extensions this parser handles (without leading dot).

Source

fn extract_symbols( &self, source: &[u8], file_path: &Path, ) -> Result<Vec<Symbol>>

Extract all symbols from source code.

Source

fn extract_calls( &self, source: &[u8], file_path: &Path, ) -> Result<Vec<RawCallEdge>>

Extract raw call edges (unresolved names).

Source

fn extract_types( &self, source: &[u8], file_path: &Path, ) -> Result<Vec<TypeInfo>>

Extract type information for symbols.

Source

fn extract_imports( &self, source: &[u8], file_path: &Path, ) -> Result<Vec<Import>>

Extract import statements.

Provided Methods§

Source

fn parse_file(&self, source: &[u8], file_path: &Path) -> Result<FileAnalysis>

Parse a file and return all extracted data.

Default implementation delegates to the four individual extract methods.

Implementors§