1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
use std::path::{Path, PathBuf};
use anyhow::Result;
use tree_sitter::Tree;
use crate::types::{Component, Dependency};
/// A parsed source file with its tree-sitter AST and original content.
pub struct ParsedFile {
pub path: PathBuf,
pub tree: Tree,
pub content: String,
}
/// Trait that each language analyzer must implement.
pub trait LanguageAnalyzer: Send + Sync {
/// Language name (e.g., "go", "rust")
fn language(&self) -> &'static str;
/// File extensions this analyzer handles (e.g., &["go"])
fn file_extensions(&self) -> &[&str];
/// Parse a source file into a ParsedFile.
fn parse_file(&self, path: &Path, content: &str) -> Result<ParsedFile>;
/// Extract architectural components from a parsed file.
fn extract_components(&self, parsed: &ParsedFile) -> Vec<Component>;
/// Extract dependencies (imports, type references, etc.) from a parsed file.
fn extract_dependencies(&self, parsed: &ParsedFile) -> Vec<Dependency>;
/// Returns true if the given import path is a standard library import
/// that should be excluded from architectural analysis.
fn is_stdlib_import(&self, _import_path: &str) -> bool {
false
}
}