1pub mod heuristics;
8pub mod ast_import_parser;
9
10pub mod ast;
12pub mod parser;
13pub mod analyzer;
14pub mod metrics;
15pub mod symbols;
16pub mod dependencies;
17
18pub use heuristics::{
20 HeuristicSystem,
21 HeuristicScorer,
22 ScoreComponents,
23 HeuristicWeights,
24 ScoringFeatures,
25 DocumentAnalysis,
26 TemplateDetector,
27 TemplateEngine,
28 ImportGraphBuilder,
29 ImportGraph,
30 is_template_file,
31 get_template_score_boost,
32 import_matches_file,
33};
34
35pub use ast::{AstNode, AstWalker};
37pub use parser::{Parser, ParseResult};
38pub use analyzer::{CodeAnalyzer, AnalysisResult};
39pub use metrics::{Metrics, ComplexityMetrics};
40pub use symbols::{Symbol, SymbolTable};
41
42use scribe_core::Result;
43
44pub use ast::types;
46
47pub struct Analysis {
49 parser: Parser,
50 analyzer: CodeAnalyzer,
51}
52
53impl Analysis {
54 pub fn new() -> Result<Self> {
56 Ok(Self {
57 parser: Parser::new()?,
58 analyzer: CodeAnalyzer::new(),
59 })
60 }
61
62 pub async fn analyze(&self, code: &str, language: &str) -> Result<AnalysisResult> {
64 let ast = self.parser.parse(code, language)?;
65 self.analyzer.analyze(&ast).await
66 }
67}
68
69impl Default for Analysis {
70 fn default() -> Self {
71 Self::new().expect("Failed to create Analysis")
72 }
73}
74
75#[cfg(test)]
76mod tests {
77 use super::*;
78
79 #[tokio::test]
80 async fn test_analysis_creation() {
81 let analysis = Analysis::new();
82 assert!(analysis.is_ok());
83 }
84}