1pub mod ast_import_parser;
8pub mod complexity;
9pub mod heuristics;
10pub mod language_support;
11
12pub mod analyzer;
14pub mod ast;
15pub mod dependencies;
16pub mod metrics;
17pub mod parser;
18pub mod symbols;
19
20pub use heuristics::{
22 get_template_score_boost, import_matches_file, is_template_file, DocumentAnalysis,
23 HeuristicScorer, HeuristicSystem, HeuristicWeights, ImportGraph, ImportGraphBuilder,
24 ScoreComponents, ScoringFeatures, TemplateDetector, TemplateEngine,
25};
26
27pub use complexity::{
29 ComplexityAnalyzer, ComplexityConfig, ComplexityMetrics as ComplexityAnalysisMetrics,
30 ComplexityThresholds, LanguageSpecificMetrics,
31};
32
33pub use language_support::{
35 analyze_file_language, AstLanguage, ClassInfo, DocumentationAnalyzer, DocumentationCoverage,
36 FunctionExtractor, FunctionInfo, LanguageAnalysisResult, LanguageFeatures, LanguageMetrics,
37 LanguageSpecificComplexity, LanguageSupport, LanguageTier, SymbolAnalyzer, SymbolType,
38 SymbolUsage,
39};
40
41pub use analyzer::{AnalysisResult, CodeAnalyzer};
43pub use ast::{AstNode, AstWalker};
44pub use metrics::{ComplexityMetrics as LegacyComplexityMetrics, Metrics};
45pub use parser::{ParseResult, Parser};
46pub use symbols::{Symbol, SymbolTable};
47
48use scribe_core::Result;
49
50pub use ast::types;
52
53pub struct Analysis {
55 parser: Parser,
56 analyzer: CodeAnalyzer,
57}
58
59impl Analysis {
60 pub fn new() -> Result<Self> {
62 Ok(Self {
63 parser: Parser::new()?,
64 analyzer: CodeAnalyzer::new(),
65 })
66 }
67
68 pub async fn analyze(&self, code: &str, language: &str) -> Result<AnalysisResult> {
70 let ast = self.parser.parse(code, language)?;
71 self.analyzer.analyze(&ast).await
72 }
73}
74
75impl Default for Analysis {
76 fn default() -> Self {
77 Self::new().expect("Failed to create Analysis")
78 }
79}
80
81#[cfg(test)]
82mod tests {
83 use super::*;
84
85 #[tokio::test]
86 async fn test_analysis_creation() {
87 let analysis = Analysis::new();
88 assert!(analysis.is_ok());
89 }
90}