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§
Sourcefn parse_content(&self, content: &str) -> Result<AstAnalysis, ParseError>
fn parse_content(&self, content: &str) -> Result<AstAnalysis, ParseError>
Parse source code content and return AST analysis
Sourcefn extract_functions(&self, content: &str) -> Vec<FunctionInfo>
fn extract_functions(&self, content: &str) -> Vec<FunctionInfo>
Extract functions from source code
Sourcefn extract_classes(&self, content: &str) -> Vec<ClassInfo>
fn extract_classes(&self, content: &str) -> Vec<ClassInfo>
Extract classes/structs from source code
Sourcefn extract_imports(&self, content: &str) -> Vec<ImportInfo>
fn extract_imports(&self, content: &str) -> Vec<ImportInfo>
Extract imports from source code
Sourcefn extract_variables(&self, content: &str) -> Vec<VariableInfo>
fn extract_variables(&self, content: &str) -> Vec<VariableInfo>
Extract variables from source code
Sourcefn language_name(&self) -> &'static str
fn language_name(&self) -> &'static str
Get the language name this parser handles
Sourcefn extensions(&self) -> &[&'static str]
fn extensions(&self) -> &[&'static str]
Get file extensions this parser supports
Provided Methods§
Sourcefn parse_file(&self, path: &Path) -> Result<AstAnalysis, ParseError>
fn parse_file(&self, path: &Path) -> Result<AstAnalysis, ParseError>
Parse a file and return AST analysis