Trait LanguageAnalyzer

Source
pub trait LanguageAnalyzer: Send + Sync {
    // Required methods
    fn language_name(&self) -> &'static str;
    fn analyze_file(
        &self,
        path: &Path,
        content: &str,
        context: &SemanticContext,
    ) -> SemanticResult<AnalysisResult>;
    fn can_handle_extension(&self, extension: &str) -> bool;
    fn supported_extensions(&self) -> Vec<&'static str>;

    // Provided methods
    fn analyze_imports(
        &self,
        content: &str,
        context: &SemanticContext,
    ) -> SemanticResult<Vec<Import>> { ... }
    fn analyze_function_calls(
        &self,
        content: &str,
        context: &SemanticContext,
    ) -> SemanticResult<Vec<FunctionCall>> { ... }
    fn analyze_type_references(
        &self,
        content: &str,
        context: &SemanticContext,
    ) -> SemanticResult<Vec<TypeReference>> { ... }
    fn resolve_type_definition(
        &self,
        _type_ref: &TypeReference,
        _context: &SemanticContext,
    ) -> Option<PathBuf> { ... }
}
Expand description

Base trait for language-specific analyzers

Required Methods§

Source

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

Get the language name

Source

fn analyze_file( &self, path: &Path, content: &str, context: &SemanticContext, ) -> SemanticResult<AnalysisResult>

Analyze a file and extract semantic information

Source

fn can_handle_extension(&self, extension: &str) -> bool

Check if this analyzer can handle the given file extension

Source

fn supported_extensions(&self) -> Vec<&'static str>

Get file extensions this analyzer handles

Provided Methods§

Source

fn analyze_imports( &self, content: &str, context: &SemanticContext, ) -> SemanticResult<Vec<Import>>

Parse and analyze imports from the file

Source

fn analyze_function_calls( &self, content: &str, context: &SemanticContext, ) -> SemanticResult<Vec<FunctionCall>>

Parse and analyze function calls from the file

Source

fn analyze_type_references( &self, content: &str, context: &SemanticContext, ) -> SemanticResult<Vec<TypeReference>>

Parse and analyze type references from the file

Source

fn resolve_type_definition( &self, _type_ref: &TypeReference, _context: &SemanticContext, ) -> Option<PathBuf>

Resolve a type reference to its definition file Returns None if the type cannot be resolved or is external

Implementors§