#![deny(unsafe_code)]
#![warn(missing_docs)]
mod graph;
mod lang;
pub use graph::{
DependencyRef, Entrypoint, GraphEdge, GraphEdgeKind, GraphNode, GraphNodeKind, ProjectFile,
ProjectGraph, ProjectPackage, Relationship,
};
pub use lang::{detect_languages, SourceLanguage, TargetLanguage};
use chrono::{DateTime, Utc};
use indexmap::IndexMap;
use parallax_core::{ErrorCode, ParallaxError};
use parallax_puir::{PuirProgram, TypeInferenceBundle};
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct ProjectAnalysis {
pub root: String,
pub primary_language: SourceLanguage,
pub language_mix: IndexMap<String, f64>,
pub graph: ProjectGraph,
pub puir: PuirProgram,
pub types: TypeInferenceBundle,
pub framework: Option<String>,
pub database: Option<String>,
pub analyzed_at: DateTime<Utc>,
}
impl ProjectAnalysis {
pub fn validate(&self) -> Result<(), ParallaxError> {
self.puir.validate()?;
if self.graph.version == 0 {
return Err(ParallaxError::new(
ErrorCode::InvalidArgument,
"project graph version 0 is invalid",
)
.with_source("parallax-project")
.with_operation("validate"));
}
Ok(())
}
}