Skip to main content

vvv_engine/protocol/
notice.rs

1use vvv_core::RelPath;
2
3use serde::{Deserialize, Serialize};
4
5use vvv_core::{Address, Position, ReachKind};
6
7/// Something a plan could not do and a human should look at. Never fatal:
8/// the rest of the plan is still valid. Data only; the display layer words it.
9#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
10#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
11pub struct Notice {
12    pub path: RelPath,
13    pub start: Position,
14    #[serde(flatten)]
15    pub kind: NoticeKind,
16}
17
18#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
19#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
20#[serde(tag = "kind", rename_all = "snake_case")]
21pub enum NoticeKind {
22    /// An import the layout understood but the surgery could not rewrite in place;
23    /// `replacement` is what it should become.
24    UnrewritableImport { import: String, replacement: String },
25    /// After the move, `from` references `item` but may not see it, and the
26    /// widening it would take is not one vvv makes on its own (making a
27    /// declaration public across packages is the author's call).
28    Unreachable {
29        item: String,
30        from: Address,
31        needs: ReachKind,
32    },
33    /// An import that now names a declaration in its own file, inside a
34    /// grouped statement vvv does not split for this; remove the entry.
35    RedundantImport { import: String },
36}