1#![deny(unsafe_code)]
4#![warn(missing_docs)]
5
6mod graph;
7mod lang;
8
9pub use graph::{
10 DependencyRef, Entrypoint, GraphEdge, GraphEdgeKind, GraphNode, GraphNodeKind, ProjectFile,
11 ProjectGraph, ProjectPackage, Relationship,
12};
13pub use lang::{detect_languages, SourceLanguage, TargetLanguage};
14
15use chrono::{DateTime, Utc};
16use indexmap::IndexMap;
17use parallax_core::{ErrorCode, ParallaxError};
18use parallax_puir::{PuirProgram, TypeInferenceBundle};
19use serde::{Deserialize, Serialize};
20
21#[derive(Clone, Debug, Serialize, Deserialize)]
23pub struct ProjectAnalysis {
24 pub root: String,
26 pub primary_language: SourceLanguage,
28 pub language_mix: IndexMap<String, f64>,
30 pub graph: ProjectGraph,
32 pub puir: PuirProgram,
34 pub types: TypeInferenceBundle,
36 pub framework: Option<String>,
38 pub database: Option<String>,
40 pub analyzed_at: DateTime<Utc>,
42}
43
44impl ProjectAnalysis {
45 pub fn validate(&self) -> Result<(), ParallaxError> {
47 self.puir.validate()?;
48 if self.graph.version == 0 {
49 return Err(ParallaxError::new(
50 ErrorCode::InvalidArgument,
51 "project graph version 0 is invalid",
52 )
53 .with_source("parallax-project")
54 .with_operation("validate"));
55 }
56 Ok(())
57 }
58}