use std::path::PathBuf;
use serde::Serialize;
use crate::duplicates::{CloneInstance, RefactoringSuggestion};
use crate::serde_path;
#[derive(Debug, Serialize)]
pub struct ExportTrace {
#[serde(serialize_with = "serde_path::serialize")]
pub file: PathBuf,
pub export_name: String,
pub file_reachable: bool,
pub is_entry_point: bool,
pub is_used: bool,
pub direct_references: Vec<ExportReference>,
pub re_export_chains: Vec<ReExportChain>,
pub reason: String,
}
#[derive(Debug, Serialize)]
pub struct ExportReference {
#[serde(serialize_with = "serde_path::serialize")]
pub from_file: PathBuf,
pub kind: String,
}
#[derive(Debug, Serialize)]
pub struct ReExportChain {
#[serde(serialize_with = "serde_path::serialize")]
pub barrel_file: PathBuf,
pub exported_as: String,
pub reference_count: usize,
}
#[derive(Debug, Serialize)]
pub struct FileTrace {
#[serde(serialize_with = "serde_path::serialize")]
pub file: PathBuf,
pub is_reachable: bool,
pub is_entry_point: bool,
pub exports: Vec<TracedExport>,
#[serde(serialize_with = "serde_path::serialize_vec")]
pub imports_from: Vec<PathBuf>,
#[serde(serialize_with = "serde_path::serialize_vec")]
pub imported_by: Vec<PathBuf>,
pub re_exports: Vec<TracedReExport>,
}
#[derive(Debug, Serialize)]
pub struct TracedExport {
pub name: String,
pub is_type_only: bool,
pub reference_count: usize,
pub referenced_by: Vec<ExportReference>,
}
#[derive(Debug, Serialize)]
pub struct TracedReExport {
#[serde(serialize_with = "serde_path::serialize")]
pub source_file: PathBuf,
pub imported_name: String,
pub exported_name: String,
}
#[derive(Debug, Serialize)]
pub struct DependencyTrace {
pub package_name: String,
#[serde(serialize_with = "serde_path::serialize_vec")]
pub imported_by: Vec<PathBuf>,
#[serde(serialize_with = "serde_path::serialize_vec")]
pub type_only_imported_by: Vec<PathBuf>,
pub used_in_scripts: bool,
pub is_used: bool,
pub import_count: usize,
}
#[derive(Debug, Clone, Serialize)]
pub struct PipelineTimings {
pub discover_files_ms: f64,
pub file_count: usize,
pub workspaces_ms: f64,
pub workspace_count: usize,
pub plugins_ms: f64,
pub script_analysis_ms: f64,
pub parse_extract_ms: f64,
pub parse_cpu_ms: f64,
pub module_count: usize,
pub cache_hits: usize,
pub cache_misses: usize,
pub cache_update_ms: f64,
pub entry_points_ms: f64,
pub entry_point_count: usize,
pub resolve_imports_ms: f64,
pub build_graph_ms: f64,
pub analyze_ms: f64,
#[serde(skip_serializing_if = "Option::is_none")]
pub duplication_ms: Option<f64>,
pub total_ms: f64,
}
#[derive(Debug, Serialize)]
pub struct ImpactClosureTrace {
pub seed: String,
pub affected_not_shown: Vec<String>,
pub coordination_gap: Vec<ImpactClosureGap>,
}
#[derive(Debug, Serialize)]
pub struct ImpactClosureGap {
pub consumer_file: String,
pub consumed_symbols: Vec<String>,
pub note: String,
}
#[derive(Debug, Serialize)]
pub struct CloneTrace {
#[serde(serialize_with = "serde_path::serialize")]
pub file: PathBuf,
pub line: usize,
pub matched_instance: Option<CloneInstance>,
pub clone_groups: Vec<TracedCloneGroup>,
}
#[derive(Debug, Serialize)]
pub struct TracedCloneGroup {
pub fingerprint: String,
pub token_count: usize,
pub line_count: usize,
pub instances: Vec<CloneInstance>,
pub suggestion: RefactoringSuggestion,
#[serde(skip_serializing_if = "Option::is_none")]
pub suggested_name: Option<String>,
}