Skip to main content

bynk_emit/project/
diagnostics.rs

1use super::*;
2use bynk_project::AttributedError;
3
4// P4.1 (#1115): `ProjectAnalysis`/`ContextSequenceInfo`/`ContextBoundaryInfo`
5// relocated verbatim (Decision C) to `bynk-check/src/analysis.rs`, alongside
6// the new `bynk-check`-native analysis entry point that also needs to build
7// one. Re-exported here so `crate::project::{ProjectAnalysis, ...}` (this
8// module's own `pub use` chain, `project.rs:80`) — and every downstream
9// caller, including `bynk-ide`'s `bynk_emit::project::ProjectAnalysis`
10// import — keeps resolving unchanged. `Mode`/`ErrorSink`/`ProjectFailure`
11// below are unaffected: `Mode` and `ProjectFailure` are pipeline-driving
12// facts specific to `bynk-emit`'s two callers (`compile_project`/
13// `analyse_project_with`), not project-model or checker output.
14pub use bynk_check::analysis::{ContextBoundaryInfo, ContextSequenceInfo, ProjectAnalysis};
15// `ErrorSink` relocated to `bynk-check::project_model` too — every
16// `phase_*` function it moved alongside takes `&mut ErrorSink`, so the type
17// had to travel with them (the same "shared logic pulls its own types down
18// with it" reasoning `UnitTable`/`ConsumedType` already went through when
19// `symbols.rs` moved). Re-exported at this crate-private path so every
20// existing `bynk-emit`-internal call site is unchanged.
21pub(crate) use bynk_check::project_model::ErrorSink;
22
23/// Internal: do the work, given a source root (for commons/contexts) and a
24/// test root (for test units). When both roots are the same path the
25/// behaviour is identical to the v0.4+ single-tree layout. When they differ
26/// — v0.9.1's split-paths mode — sources and tests are discovered separately
27/// and the new `inconsistent_test_path` check fires.
28/// v0.24 (ADR 0052): how the project pipeline is driven. `Build` preserves
29/// the CLI contract exactly (bail at the structural and pre-emit gates);
30/// `Analyse` never bails after discovery, skips all emission, and lets
31/// independent unit groups resolve/check past another group's errors.
32#[derive(Clone, Copy, PartialEq, Eq)]
33pub(crate) enum Mode {
34    Build,
35    Analyse,
36}
37
38/// v0.24: a failed build with its attribution and snapshots intact — what
39/// the CLI renders rich (ariadne source context per file); the plain
40/// `compile_project*` wrappers flatten it to the pre-v0.24 error list.
41pub struct ProjectFailure {
42    pub errors: Vec<AttributedError>,
43    pub snapshots: Vec<(PathBuf, String)>,
44}
45
46impl ProjectFailure {
47    /// The pre-v0.24 contract: collection-ordered, attribution dropped.
48    pub fn flatten(self) -> Vec<CompileError> {
49        self.errors.into_iter().map(|a| a.error).collect()
50    }
51}