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