@nowline/core 0.8.6 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (174) hide show
  1. package/README.md +9 -0
  2. package/dist/convert/printer.d.ts.map +1 -1
  3. package/dist/convert/printer.js +20 -9
  4. package/dist/convert/printer.js.map +1 -1
  5. package/dist/convert/schema.d.ts +7 -0
  6. package/dist/convert/schema.d.ts.map +1 -1
  7. package/dist/convert/schema.js +1 -1
  8. package/dist/convert/schema.js.map +1 -1
  9. package/dist/generated/ast.d.ts +134 -24
  10. package/dist/generated/ast.d.ts.map +1 -1
  11. package/dist/generated/ast.js +95 -3
  12. package/dist/generated/ast.js.map +1 -1
  13. package/dist/generated/grammar.d.ts.map +1 -1
  14. package/dist/generated/grammar.js +434 -148
  15. package/dist/generated/grammar.js.map +1 -1
  16. package/dist/i18n/codes.d.ts +1 -1
  17. package/dist/i18n/codes.d.ts.map +1 -1
  18. package/dist/i18n/codes.js +44 -1
  19. package/dist/i18n/codes.js.map +1 -1
  20. package/dist/i18n/index.d.ts +1 -0
  21. package/dist/i18n/index.d.ts.map +1 -1
  22. package/dist/i18n/index.js.map +1 -1
  23. package/dist/i18n/messages.en.d.ts +107 -0
  24. package/dist/i18n/messages.en.d.ts.map +1 -1
  25. package/dist/i18n/messages.en.js +220 -1
  26. package/dist/i18n/messages.en.js.map +1 -1
  27. package/dist/i18n/messages.fr.d.ts.map +1 -1
  28. package/dist/i18n/messages.fr.js +250 -1
  29. package/dist/i18n/messages.fr.js.map +1 -1
  30. package/dist/i18n/wave-message-types.d.ts +238 -0
  31. package/dist/i18n/wave-message-types.d.ts.map +1 -0
  32. package/dist/i18n/wave-message-types.js +11 -0
  33. package/dist/i18n/wave-message-types.js.map +1 -0
  34. package/dist/index.d.ts +6 -1
  35. package/dist/index.d.ts.map +1 -1
  36. package/dist/index.js +5 -1
  37. package/dist/index.js.map +1 -1
  38. package/dist/internal.d.ts +6 -0
  39. package/dist/internal.d.ts.map +1 -0
  40. package/dist/internal.js +9 -0
  41. package/dist/internal.js.map +1 -0
  42. package/dist/language/ast-walk.d.ts +31 -0
  43. package/dist/language/ast-walk.d.ts.map +1 -0
  44. package/dist/language/ast-walk.js +109 -0
  45. package/dist/language/ast-walk.js.map +1 -0
  46. package/dist/language/calendar-declarations.d.ts +31 -0
  47. package/dist/language/calendar-declarations.d.ts.map +1 -0
  48. package/dist/language/calendar-declarations.js +99 -0
  49. package/dist/language/calendar-declarations.js.map +1 -0
  50. package/dist/language/include-references.d.ts +11 -0
  51. package/dist/language/include-references.d.ts.map +1 -0
  52. package/dist/language/include-references.js +45 -0
  53. package/dist/language/include-references.js.map +1 -0
  54. package/dist/language/include-resolver.d.ts +78 -1
  55. package/dist/language/include-resolver.d.ts.map +1 -1
  56. package/dist/language/include-resolver.js +190 -12
  57. package/dist/language/include-resolver.js.map +1 -1
  58. package/dist/language/include-waves.d.ts +73 -0
  59. package/dist/language/include-waves.d.ts.map +1 -0
  60. package/dist/language/include-waves.js +319 -0
  61. package/dist/language/include-waves.js.map +1 -0
  62. package/dist/language/nowline-validator.d.ts +6 -1
  63. package/dist/language/nowline-validator.d.ts.map +1 -1
  64. package/dist/language/nowline-validator.js +95 -1589
  65. package/dist/language/nowline-validator.js.map +1 -1
  66. package/dist/language/references.d.ts +14 -0
  67. package/dist/language/references.d.ts.map +1 -0
  68. package/dist/language/references.js +36 -0
  69. package/dist/language/references.js.map +1 -0
  70. package/dist/language/style-chain.d.ts +37 -0
  71. package/dist/language/style-chain.d.ts.map +1 -0
  72. package/dist/language/style-chain.js +55 -0
  73. package/dist/language/style-chain.js.map +1 -0
  74. package/dist/language/validator/calendar.d.ts +9 -0
  75. package/dist/language/validator/calendar.d.ts.map +1 -0
  76. package/dist/language/validator/calendar.js +250 -0
  77. package/dist/language/validator/calendar.js.map +1 -0
  78. package/dist/language/validator/entities.d.ts +23 -0
  79. package/dist/language/validator/entities.d.ts.map +1 -0
  80. package/dist/language/validator/entities.js +261 -0
  81. package/dist/language/validator/entities.js.map +1 -0
  82. package/dist/language/validator/properties.d.ts +18 -0
  83. package/dist/language/validator/properties.d.ts.map +1 -0
  84. package/dist/language/validator/properties.js +356 -0
  85. package/dist/language/validator/properties.js.map +1 -0
  86. package/dist/language/validator/references.d.ts +7 -0
  87. package/dist/language/validator/references.d.ts.map +1 -0
  88. package/dist/language/validator/references.js +261 -0
  89. package/dist/language/validator/references.js.map +1 -0
  90. package/dist/language/validator/structure.d.ts +16 -0
  91. package/dist/language/validator/structure.d.ts.map +1 -0
  92. package/dist/language/validator/structure.js +166 -0
  93. package/dist/language/validator/structure.js.map +1 -0
  94. package/dist/language/validator/style.d.ts +5 -0
  95. package/dist/language/validator/style.d.ts.map +1 -0
  96. package/dist/language/validator/style.js +126 -0
  97. package/dist/language/validator/style.js.map +1 -0
  98. package/dist/language/validator/support.d.ts +35 -0
  99. package/dist/language/validator/support.d.ts.map +1 -0
  100. package/dist/language/validator/support.js +49 -0
  101. package/dist/language/validator/support.js.map +1 -0
  102. package/dist/language/validator/symbols.d.ts +6 -0
  103. package/dist/language/validator/symbols.d.ts.map +1 -0
  104. package/dist/language/validator/symbols.js +131 -0
  105. package/dist/language/validator/symbols.js.map +1 -0
  106. package/dist/language/validator/tables.d.ts +34 -0
  107. package/dist/language/validator/tables.d.ts.map +1 -0
  108. package/dist/language/validator/tables.js +120 -0
  109. package/dist/language/validator/tables.js.map +1 -0
  110. package/dist/language/validator-utils.d.ts +32 -0
  111. package/dist/language/validator-utils.d.ts.map +1 -0
  112. package/dist/language/validator-utils.js +118 -0
  113. package/dist/language/validator-utils.js.map +1 -0
  114. package/dist/language/value-tables.d.ts +107 -0
  115. package/dist/language/value-tables.d.ts.map +1 -0
  116. package/dist/language/value-tables.js +240 -0
  117. package/dist/language/value-tables.js.map +1 -0
  118. package/dist/language/waves-order.d.ts +51 -0
  119. package/dist/language/waves-order.d.ts.map +1 -0
  120. package/dist/language/waves-order.js +787 -0
  121. package/dist/language/waves-order.js.map +1 -0
  122. package/dist/language/waves-plan.d.ts +45 -0
  123. package/dist/language/waves-plan.d.ts.map +1 -0
  124. package/dist/language/waves-plan.js +64 -0
  125. package/dist/language/waves-plan.js.map +1 -0
  126. package/dist/language/waves.d.ts +96 -0
  127. package/dist/language/waves.d.ts.map +1 -0
  128. package/dist/language/waves.js +575 -0
  129. package/dist/language/waves.js.map +1 -0
  130. package/dist/util/props.d.ts +27 -0
  131. package/dist/util/props.d.ts.map +1 -0
  132. package/dist/util/props.js +49 -0
  133. package/dist/util/props.js.map +1 -0
  134. package/dist/util/single-line.d.ts +14 -0
  135. package/dist/util/single-line.d.ts.map +1 -0
  136. package/dist/util/single-line.js +16 -0
  137. package/dist/util/single-line.js.map +1 -0
  138. package/package.json +7 -3
  139. package/src/convert/printer.ts +20 -10
  140. package/src/convert/schema.ts +8 -1
  141. package/src/generated/ast.ts +159 -27
  142. package/src/generated/grammar.ts +434 -148
  143. package/src/i18n/codes.ts +95 -2
  144. package/src/i18n/index.ts +1 -0
  145. package/src/i18n/messages.en.ts +300 -1
  146. package/src/i18n/messages.fr.ts +335 -1
  147. package/src/i18n/wave-message-types.ts +206 -0
  148. package/src/index.ts +33 -0
  149. package/src/internal.ts +9 -0
  150. package/src/language/ast-walk.ts +158 -0
  151. package/src/language/calendar-declarations.ts +141 -0
  152. package/src/language/include-references.ts +49 -0
  153. package/src/language/include-resolver.ts +284 -10
  154. package/src/language/include-waves.ts +419 -0
  155. package/src/language/nowline-validator.ts +98 -1835
  156. package/src/language/nowline.langium +56 -22
  157. package/src/language/references.ts +40 -0
  158. package/src/language/style-chain.ts +95 -0
  159. package/src/language/validator/calendar.ts +319 -0
  160. package/src/language/validator/entities.ts +366 -0
  161. package/src/language/validator/properties.ts +425 -0
  162. package/src/language/validator/references.ts +295 -0
  163. package/src/language/validator/structure.ts +206 -0
  164. package/src/language/validator/style.ts +149 -0
  165. package/src/language/validator/support.ts +84 -0
  166. package/src/language/validator/symbols.ts +141 -0
  167. package/src/language/validator/tables.ts +171 -0
  168. package/src/language/validator-utils.ts +123 -0
  169. package/src/language/value-tables.ts +260 -0
  170. package/src/language/waves-order.ts +879 -0
  171. package/src/language/waves-plan.ts +101 -0
  172. package/src/language/waves.ts +731 -0
  173. package/src/util/props.ts +59 -0
  174. package/src/util/single-line.ts +15 -0
@@ -0,0 +1,419 @@
1
+ // Waves across includes (specs/waves.md §6.1, §7). The include resolver
2
+ // calls these helpers:
3
+ //
4
+ // - `checkWaveAgreement`: include rule 12 for one `P → C` edge (NL.E0202,
5
+ // then NL.W0701 for presentation drift when the waves agree).
6
+ // - `runResolverWaveChecks`: once per root pipeline, after resolution. The
7
+ // S and P rules for every participating child (children are parsed with
8
+ // `validation:false`, so the validator never sees them), the cross-file
9
+ // part of WV2 (NL.E0300), and the G rules over each layout scope: the
10
+ // merged main lanes and each isolated region.
11
+ //
12
+ // Every diagnostic produced here carries `rule: 'wave'` and is coded
13
+ // (`code` + `args`, the shape `acceptTr` stores), except WV8's fixed rule-23
14
+ // text.
15
+
16
+ import { type AstNode, getDiagnosticRange, type Properties } from 'langium';
17
+ import type { IncludeDeclaration, NowlineFile, WaveDeclaration } from '../generated/ast.js';
18
+ import {
19
+ isNowlineFile,
20
+ isStyleDeclaration,
21
+ isSwimlaneDeclaration,
22
+ isWaveDeclaration,
23
+ } from '../generated/ast.js';
24
+ import type { MessageArgs, MessageCode } from '../i18n/index.js';
25
+ import { tr } from '../i18n/index.js';
26
+ import type { WavePresentationField } from '../i18n/wave-message-types.js';
27
+ import { basename } from '../util/posix-path.js';
28
+ import { propKey } from '../util/props.js';
29
+ import { singleLine } from '../util/single-line.js';
30
+ import { forEachDeclaredId } from './ast-walk.js';
31
+ import type {
32
+ IncludeMode,
33
+ ResolveDiagnostic,
34
+ ResolvedContent,
35
+ ResolveRange,
36
+ } from './include-resolver.js';
37
+ import {
38
+ checkWaveDeclarations,
39
+ evaluateWaveProperties,
40
+ fileRefLookup,
41
+ ownWaves,
42
+ type WaveFinding,
43
+ type WaveRefLookup,
44
+ waveFloorDate,
45
+ } from './waves.js';
46
+ import { evaluateWaveOrder } from './waves-order.js';
47
+
48
+ /** One include edge `P → C` whose child was read and parsed. */
49
+ export interface WaveIncludeEdge {
50
+ /** Absolute path of the including file P. */
51
+ parentAbs: string;
52
+ inc: IncludeDeclaration;
53
+ /** The path as written in P's `include` line. */
54
+ childRelPath: string;
55
+ childAbs: string;
56
+ mode: IncludeMode;
57
+ childFile: NowlineFile;
58
+ childContent: ResolvedContent;
59
+ /** `participates(C)` (§7.1). */
60
+ participates: boolean;
61
+ }
62
+
63
+ /**
64
+ * Resolves an id against resolved content the way layout seeds its edge
65
+ * maps: anchors, then milestones, then waves, by map key.
66
+ */
67
+ export function resolvedContentLookup(content: ResolvedContent): WaveRefLookup {
68
+ return (id) => content.anchors.get(id) ?? content.milestones.get(id) ?? content.waves?.get(id);
69
+ }
70
+
71
+ /** True when the file had a lexer or parser error. */
72
+ export function hasParseErrors(file: NowlineFile): boolean {
73
+ const result = file.$document?.parseResult;
74
+ return !!result && (result.lexerErrors.length > 0 || result.parserErrors.length > 0);
75
+ }
76
+
77
+ /**
78
+ * `participates(C)` from specs/waves.md §7.1: C declares a roadmap, its
79
+ * resolved content has a swimlane, or it declares waves. A child that failed
80
+ * to parse, or a circular-include stub, never participates.
81
+ */
82
+ export function participates(
83
+ childFile: NowlineFile,
84
+ childContent: ResolvedContent,
85
+ isStub: boolean,
86
+ ): boolean {
87
+ if (isStub || hasParseErrors(childFile)) return false;
88
+ return (
89
+ !!childFile.roadmapDecl || childContent.swimlanes.size > 0 || ownWaves(childFile).length > 0
90
+ );
91
+ }
92
+
93
+ /** Where a resolver diagnostic points: both fields, or neither when unknown. */
94
+ export interface ResolveLocation {
95
+ line?: number;
96
+ range?: ResolveRange;
97
+ }
98
+
99
+ /**
100
+ * The location of a diagnostic about `node`, narrowed to `property` the way
101
+ * the validator narrows its copy (Langium's `getDiagnosticRange`), so the
102
+ * routed diagnostic points at the same column and span. Empty when the node
103
+ * has no CST node.
104
+ */
105
+ export function nodeLocation(node: AstNode, property?: string): ResolveLocation {
106
+ if (!node.$cstNode) return {};
107
+ const { start, end } = getDiagnosticRange({
108
+ node,
109
+ ...(property === undefined ? {} : { property: property as Properties<AstNode> }),
110
+ });
111
+ return {
112
+ line: start.line,
113
+ range: {
114
+ start: { line: start.line, character: start.character },
115
+ end: { line: end.line, character: end.character },
116
+ },
117
+ };
118
+ }
119
+
120
+ /** A coded resolver diagnostic: the en-US text plus `code` and `args`. */
121
+ function coded<K extends MessageCode>(
122
+ severity: 'error' | 'warning',
123
+ sourcePath: string,
124
+ at: ResolveLocation,
125
+ code: K,
126
+ ...args: MessageArgs<K>
127
+ ): ResolveDiagnostic {
128
+ return {
129
+ severity,
130
+ message: tr('en-US', code, ...args),
131
+ sourcePath,
132
+ ...at,
133
+ code,
134
+ args,
135
+ rule: 'wave',
136
+ };
137
+ }
138
+
139
+ function waveIds(waves: readonly WaveDeclaration[]): string[] {
140
+ return waves.map((w) => w.name as string);
141
+ }
142
+
143
+ // The fields NL.W0701 compares, as display text ('' when absent).
144
+ function presentation(wave: WaveDeclaration): Record<WavePresentationField, string> {
145
+ const prop = (key: string): string => {
146
+ const p = wave.properties.find((q) => propKey(q) === key);
147
+ if (!p) return '';
148
+ return p.value ?? p.values.join(', ');
149
+ };
150
+ return {
151
+ title: wave.title === undefined ? '' : singleLine(wave.title),
152
+ style: prop('style'),
153
+ labels: prop('labels'),
154
+ link: prop('link'),
155
+ description: wave.description ? singleLine(wave.description.text) : '',
156
+ };
157
+ }
158
+
159
+ const PRESENTATION_FIELDS: WavePresentationField[] = [
160
+ 'title',
161
+ 'style',
162
+ 'labels',
163
+ 'link',
164
+ 'description',
165
+ ];
166
+
167
+ /**
168
+ * Include rule 12 (§7.2) for one `merge` or `isolate` edge whose child
169
+ * participates: σ(C) must equal σ(P), where σ(F) is F's own waves with their
170
+ * floor dates resolved against F's resolved content. Reports the first
171
+ * difference as NL.E0202 on P's include line; when σ agrees, one NL.W0701 per
172
+ * wave whose presentation differs. `failed` marks a child that failed
173
+ * NL.E0202, which is not evaluated further.
174
+ */
175
+ export function checkWaveAgreement(
176
+ parentFile: NowlineFile,
177
+ parentContent: ResolvedContent,
178
+ edge: WaveIncludeEdge,
179
+ ): { diagnostics: ResolveDiagnostic[]; failed: boolean } {
180
+ const none = { diagnostics: [], failed: false };
181
+ if (edge.mode === 'ignore' || !edge.participates) return none;
182
+ // A child with a wave that has no id (NL.E1100) is not compared.
183
+ if (edge.childFile.roadmapEntries.some((e) => isWaveDeclaration(e) && !e.name)) return none;
184
+
185
+ const at = edge.parentAbs;
186
+ const loc = nodeLocation(edge.inc);
187
+ const path = edge.childRelPath;
188
+ const parent = ownWaves(parentFile);
189
+ const child = ownWaves(edge.childFile);
190
+ const fail = (d: ResolveDiagnostic) => ({ diagnostics: [d], failed: true });
191
+
192
+ if (parent.length === 0 && child.length === 0) return none;
193
+ if (child.length === 0) {
194
+ return fail(
195
+ coded('error', at, loc, 'NL.E0202', {
196
+ reason: 'child-none',
197
+ path,
198
+ parent: waveIds(parent),
199
+ }),
200
+ );
201
+ }
202
+ if (parent.length === 0) {
203
+ return fail(
204
+ coded('error', at, loc, 'NL.E0202', {
205
+ reason: 'parent-none',
206
+ path,
207
+ child: waveIds(child),
208
+ }),
209
+ );
210
+ }
211
+ if (parent.length !== child.length || parent.some((w, i) => w.name !== child[i].name)) {
212
+ return fail(
213
+ coded('error', at, loc, 'NL.E0202', {
214
+ reason: 'mismatch',
215
+ path,
216
+ child: waveIds(child),
217
+ parent: waveIds(parent),
218
+ }),
219
+ );
220
+ }
221
+
222
+ // Resolved floor dates are compared, never the written references.
223
+ const parentLookup = resolvedContentLookup(parentContent);
224
+ const childLookup = resolvedContentLookup(edge.childContent);
225
+ for (let i = 0; i < parent.length; i++) {
226
+ const parentFloor = waveFloorDate(parent[i], parentLookup)?.date ?? null;
227
+ const childFloor = waveFloorDate(child[i], childLookup)?.date ?? null;
228
+ if (parentFloor === childFloor) continue;
229
+ return fail(
230
+ coded('error', at, loc, 'NL.E0202', {
231
+ reason: 'floor',
232
+ id: parent[i].name as string,
233
+ path,
234
+ childFloor,
235
+ parentFloor,
236
+ }),
237
+ );
238
+ }
239
+
240
+ const diagnostics: ResolveDiagnostic[] = [];
241
+ for (let i = 0; i < parent.length; i++) {
242
+ const here = presentation(parent[i]);
243
+ const there = presentation(child[i]);
244
+ const fields = PRESENTATION_FIELDS.filter((f) => here[f] !== there[f]).map((field) => ({
245
+ field,
246
+ there: there[field],
247
+ here: here[field],
248
+ }));
249
+ if (fields.length === 0) continue;
250
+ diagnostics.push(
251
+ coded('warning', at, loc, 'NL.W0701', {
252
+ id: parent[i].name as string,
253
+ path,
254
+ fields,
255
+ }),
256
+ );
257
+ }
258
+ return { diagnostics, failed: false };
259
+ }
260
+
261
+ // The NowlineFile a node belongs to.
262
+ function fileOf(node: AstNode): NowlineFile | undefined {
263
+ let n: AstNode | undefined = node;
264
+ while (n && !isNowlineFile(n)) n = n.$container;
265
+ return n;
266
+ }
267
+
268
+ /** Inputs to `runResolverWaveChecks`, recorded during resolution. */
269
+ export interface ResolverWaveInput {
270
+ rootFile: NowlineFile;
271
+ rootAbs: string;
272
+ rootContent: ResolvedContent;
273
+ /** Every parsed file, the root included, by its absolute path. */
274
+ files: ReadonlyMap<NowlineFile, string>;
275
+ /** Every include edge whose child was read, per including file, in include order. */
276
+ edges: ReadonlyMap<string, readonly WaveIncludeEdge[]>;
277
+ /** Absolute paths of children that failed NL.E0202. */
278
+ failed: ReadonlySet<string>;
279
+ }
280
+
281
+ /**
282
+ * The S, P, cross-file WV2 and G evaluations of §6.1, run once per root
283
+ * pipeline over the files and scopes recorded during resolution.
284
+ */
285
+ export function runResolverWaveChecks(input: ResolverWaveInput): ResolveDiagnostic[] {
286
+ const { rootFile, rootAbs, rootContent, files, edges, failed } = input;
287
+ const out: ResolveDiagnostic[] = [];
288
+ // A file placed in two layout scopes (isolated by the root and merged by
289
+ // another child) yields the same G finding once per scope: keep one.
290
+ const emitted = new Set<string>();
291
+ const push = (d: ResolveDiagnostic): void => {
292
+ const key = JSON.stringify([d.sourcePath, d.line, d.code, d.args, d.message]);
293
+ if (emitted.has(key)) return;
294
+ emitted.add(key);
295
+ out.push(d);
296
+ };
297
+ const pathOf = (node: AstNode): string | undefined => {
298
+ const file = fileOf(node);
299
+ return file ? files.get(file) : undefined;
300
+ };
301
+ const toDiagnostic = (finding: WaveFinding, sourcePath: string): ResolveDiagnostic => {
302
+ const at = nodeLocation(finding.node, finding.property);
303
+ if ('message' in finding) {
304
+ return {
305
+ severity: finding.severity,
306
+ message: finding.message,
307
+ sourcePath,
308
+ ...at,
309
+ rule: 'wave',
310
+ };
311
+ }
312
+ return coded(
313
+ finding.severity,
314
+ sourcePath,
315
+ at,
316
+ finding.code as 'NL.E1100',
317
+ finding.args as MessageArgs<'NL.E1100'>[0],
318
+ );
319
+ };
320
+
321
+ // Participating children reachable from the root through merge and
322
+ // isolate edges, in include order (depth first, each file once).
323
+ const children: Array<{ file: NowlineFile; abs: string }> = [];
324
+ const seen = new Set<string>([rootAbs]);
325
+ const walk = (abs: string): void => {
326
+ for (const edge of edges.get(abs) ?? []) {
327
+ if (edge.mode === 'ignore' || !edge.participates || seen.has(edge.childAbs)) continue;
328
+ seen.add(edge.childAbs);
329
+ if (!failed.has(edge.childAbs)) {
330
+ children.push({ file: edge.childFile, abs: edge.childAbs });
331
+ }
332
+ walk(edge.childAbs);
333
+ }
334
+ };
335
+ walk(rootAbs);
336
+
337
+ const rootWaves = ownWaves(rootFile);
338
+ const rootWaveDecls = new Map(rootWaves.map((w) => [w.name as string, w]));
339
+
340
+ for (const { file, abs } of children) {
341
+ // S and P: the validator never sees a child (`validation:false`).
342
+ for (const f of checkWaveDeclarations(file)) push(toDiagnostic(f, abs));
343
+ for (const f of evaluateWaveProperties(file)) push(toDiagnostic(f, abs));
344
+
345
+ // WV2 across files: no explicit id may equal one of the root's wave
346
+ // ids. The child's own matching wave lines are what rule 12 asks for.
347
+ if (rootWaveDecls.size === 0) continue;
348
+ const register = (name: string | undefined, node: AstNode): void => {
349
+ const wave = name === undefined ? undefined : rootWaveDecls.get(name);
350
+ if (!wave || isWaveDeclaration(node)) return;
351
+ const waveLine = wave.$cstNode ? wave.$cstNode.range.start.line + 1 : 0;
352
+ push(
353
+ coded('error', abs, nodeLocation(node), 'NL.E0300', {
354
+ name: name as string,
355
+ location: `${basename(rootAbs)}:${waveLine}`,
356
+ }),
357
+ );
358
+ };
359
+ if (file.roadmapDecl) register(file.roadmapDecl.name, file.roadmapDecl);
360
+ for (const entry of file.roadmapEntries) forEachDeclaredId(entry, register);
361
+ for (const entry of file.configEntries) {
362
+ if (isStyleDeclaration(entry)) register(entry.name, entry);
363
+ }
364
+ }
365
+
366
+ // G: once per layout scope. The validator already evaluated the root's
367
+ // own lanes, so a finding it reproduces exactly is not repeated; what
368
+ // remains involves another file's work.
369
+ if (rootWaves.length === 0) return out;
370
+ const key = (f: WaveFinding): string =>
371
+ 'message' in f ? f.message : `${f.code}\u0000${JSON.stringify(f.args)}`;
372
+ const rootOnly = new Map<AstNode, Set<string>>();
373
+ const rootScope = {
374
+ lanes: rootFile.roadmapEntries.filter(isSwimlaneDeclaration),
375
+ lookup: fileRefLookup(rootFile),
376
+ };
377
+ for (const f of evaluateWaveOrder(rootScope, rootWaves, { suppressCycleRefs: false })) {
378
+ const set = rootOnly.get(f.node) ?? new Set<string>();
379
+ set.add(key(f));
380
+ rootOnly.set(f.node, set);
381
+ }
382
+ const report = (findings: WaveFinding[]): void => {
383
+ for (const f of findings) {
384
+ if (rootOnly.get(f.node)?.has(key(f))) continue;
385
+ const abs = pathOf(f.node);
386
+ if (abs === undefined || failed.has(abs)) continue;
387
+ push(toDiagnostic(f, abs));
388
+ }
389
+ };
390
+ report(
391
+ evaluateWaveOrder(
392
+ {
393
+ lanes: [...rootContent.swimlanes.values()],
394
+ lookup: resolvedContentLookup(rootContent),
395
+ },
396
+ rootWaves,
397
+ { suppressCycleRefs: false },
398
+ ),
399
+ );
400
+ // Each isolated region is its own scope (one level: layout does not draw
401
+ // nested regions). A region whose file failed NL.E0202 is skipped.
402
+ for (const region of rootContent.isolatedRegions) {
403
+ const regionRoot = region.content.roadmap ? pathOf(region.content.roadmap) : undefined;
404
+ if (regionRoot !== undefined && failed.has(regionRoot)) continue;
405
+ const regionWaves = [...(region.content.waves?.values() ?? [])];
406
+ if (regionWaves.length === 0) continue;
407
+ report(
408
+ evaluateWaveOrder(
409
+ {
410
+ lanes: [...region.content.swimlanes.values()],
411
+ lookup: resolvedContentLookup(region.content),
412
+ },
413
+ regionWaves,
414
+ { suppressCycleRefs: false },
415
+ ),
416
+ );
417
+ }
418
+ return out;
419
+ }