Skip to main content

CodeParser

Trait CodeParser 

Source
pub trait CodeParser: Send + Sync {
    // Required methods
    fn parse_content(&self, content: &str) -> Result<AstAnalysis, ParseError>;
    fn extract_functions(&self, content: &str) -> Vec<FunctionInfo>;
    fn extract_classes(&self, content: &str) -> Vec<ClassInfo>;
    fn extract_imports(&self, content: &str) -> Vec<ImportInfo>;
    fn extract_variables(&self, content: &str) -> Vec<VariableInfo>;
    fn language_name(&self) -> &'static str;
    fn extensions(&self) -> &[&'static str];

    // Provided method
    fn parse_file(&self, path: &Path) -> Result<AstAnalysis, ParseError> { ... }
}
Expand description

Core parser trait that all language parsers must implement

Required Methods§

Source

fn parse_content(&self, content: &str) -> Result<AstAnalysis, ParseError>

Parse source code content and return AST analysis

Source

fn extract_functions(&self, content: &str) -> Vec<FunctionInfo>

Extract functions from source code

Source

fn extract_classes(&self, content: &str) -> Vec<ClassInfo>

Extract classes/structs from source code

Source

fn extract_imports(&self, content: &str) -> Vec<ImportInfo>

Extract imports from source code

Source

fn extract_variables(&self, content: &str) -> Vec<VariableInfo>

Extract variables from source code

Source

fn language_name(&self) -> &'static str

Get the language name this parser handles

Source

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

Get file extensions this parser supports

Provided Methods§

Source

fn parse_file(&self, path: &Path) -> Result<AstAnalysis, ParseError>

Parse a file and return AST analysis

Implementors§