@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.
- package/README.md +9 -0
- package/dist/convert/printer.d.ts.map +1 -1
- package/dist/convert/printer.js +20 -9
- package/dist/convert/printer.js.map +1 -1
- package/dist/convert/schema.d.ts +7 -0
- package/dist/convert/schema.d.ts.map +1 -1
- package/dist/convert/schema.js +1 -1
- package/dist/convert/schema.js.map +1 -1
- package/dist/generated/ast.d.ts +134 -24
- package/dist/generated/ast.d.ts.map +1 -1
- package/dist/generated/ast.js +95 -3
- package/dist/generated/ast.js.map +1 -1
- package/dist/generated/grammar.d.ts.map +1 -1
- package/dist/generated/grammar.js +434 -148
- package/dist/generated/grammar.js.map +1 -1
- package/dist/i18n/codes.d.ts +1 -1
- package/dist/i18n/codes.d.ts.map +1 -1
- package/dist/i18n/codes.js +44 -1
- package/dist/i18n/codes.js.map +1 -1
- package/dist/i18n/index.d.ts +1 -0
- package/dist/i18n/index.d.ts.map +1 -1
- package/dist/i18n/index.js.map +1 -1
- package/dist/i18n/messages.en.d.ts +107 -0
- package/dist/i18n/messages.en.d.ts.map +1 -1
- package/dist/i18n/messages.en.js +220 -1
- package/dist/i18n/messages.en.js.map +1 -1
- package/dist/i18n/messages.fr.d.ts.map +1 -1
- package/dist/i18n/messages.fr.js +250 -1
- package/dist/i18n/messages.fr.js.map +1 -1
- package/dist/i18n/wave-message-types.d.ts +238 -0
- package/dist/i18n/wave-message-types.d.ts.map +1 -0
- package/dist/i18n/wave-message-types.js +11 -0
- package/dist/i18n/wave-message-types.js.map +1 -0
- package/dist/index.d.ts +6 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +6 -0
- package/dist/internal.d.ts.map +1 -0
- package/dist/internal.js +9 -0
- package/dist/internal.js.map +1 -0
- package/dist/language/ast-walk.d.ts +31 -0
- package/dist/language/ast-walk.d.ts.map +1 -0
- package/dist/language/ast-walk.js +109 -0
- package/dist/language/ast-walk.js.map +1 -0
- package/dist/language/calendar-declarations.d.ts +31 -0
- package/dist/language/calendar-declarations.d.ts.map +1 -0
- package/dist/language/calendar-declarations.js +99 -0
- package/dist/language/calendar-declarations.js.map +1 -0
- package/dist/language/include-references.d.ts +11 -0
- package/dist/language/include-references.d.ts.map +1 -0
- package/dist/language/include-references.js +45 -0
- package/dist/language/include-references.js.map +1 -0
- package/dist/language/include-resolver.d.ts +78 -1
- package/dist/language/include-resolver.d.ts.map +1 -1
- package/dist/language/include-resolver.js +190 -12
- package/dist/language/include-resolver.js.map +1 -1
- package/dist/language/include-waves.d.ts +73 -0
- package/dist/language/include-waves.d.ts.map +1 -0
- package/dist/language/include-waves.js +319 -0
- package/dist/language/include-waves.js.map +1 -0
- package/dist/language/nowline-validator.d.ts +6 -1
- package/dist/language/nowline-validator.d.ts.map +1 -1
- package/dist/language/nowline-validator.js +95 -1589
- package/dist/language/nowline-validator.js.map +1 -1
- package/dist/language/references.d.ts +14 -0
- package/dist/language/references.d.ts.map +1 -0
- package/dist/language/references.js +36 -0
- package/dist/language/references.js.map +1 -0
- package/dist/language/style-chain.d.ts +37 -0
- package/dist/language/style-chain.d.ts.map +1 -0
- package/dist/language/style-chain.js +55 -0
- package/dist/language/style-chain.js.map +1 -0
- package/dist/language/validator/calendar.d.ts +9 -0
- package/dist/language/validator/calendar.d.ts.map +1 -0
- package/dist/language/validator/calendar.js +250 -0
- package/dist/language/validator/calendar.js.map +1 -0
- package/dist/language/validator/entities.d.ts +23 -0
- package/dist/language/validator/entities.d.ts.map +1 -0
- package/dist/language/validator/entities.js +261 -0
- package/dist/language/validator/entities.js.map +1 -0
- package/dist/language/validator/properties.d.ts +18 -0
- package/dist/language/validator/properties.d.ts.map +1 -0
- package/dist/language/validator/properties.js +356 -0
- package/dist/language/validator/properties.js.map +1 -0
- package/dist/language/validator/references.d.ts +7 -0
- package/dist/language/validator/references.d.ts.map +1 -0
- package/dist/language/validator/references.js +261 -0
- package/dist/language/validator/references.js.map +1 -0
- package/dist/language/validator/structure.d.ts +16 -0
- package/dist/language/validator/structure.d.ts.map +1 -0
- package/dist/language/validator/structure.js +166 -0
- package/dist/language/validator/structure.js.map +1 -0
- package/dist/language/validator/style.d.ts +5 -0
- package/dist/language/validator/style.d.ts.map +1 -0
- package/dist/language/validator/style.js +126 -0
- package/dist/language/validator/style.js.map +1 -0
- package/dist/language/validator/support.d.ts +35 -0
- package/dist/language/validator/support.d.ts.map +1 -0
- package/dist/language/validator/support.js +49 -0
- package/dist/language/validator/support.js.map +1 -0
- package/dist/language/validator/symbols.d.ts +6 -0
- package/dist/language/validator/symbols.d.ts.map +1 -0
- package/dist/language/validator/symbols.js +131 -0
- package/dist/language/validator/symbols.js.map +1 -0
- package/dist/language/validator/tables.d.ts +34 -0
- package/dist/language/validator/tables.d.ts.map +1 -0
- package/dist/language/validator/tables.js +120 -0
- package/dist/language/validator/tables.js.map +1 -0
- package/dist/language/validator-utils.d.ts +32 -0
- package/dist/language/validator-utils.d.ts.map +1 -0
- package/dist/language/validator-utils.js +118 -0
- package/dist/language/validator-utils.js.map +1 -0
- package/dist/language/value-tables.d.ts +107 -0
- package/dist/language/value-tables.d.ts.map +1 -0
- package/dist/language/value-tables.js +240 -0
- package/dist/language/value-tables.js.map +1 -0
- package/dist/language/waves-order.d.ts +51 -0
- package/dist/language/waves-order.d.ts.map +1 -0
- package/dist/language/waves-order.js +787 -0
- package/dist/language/waves-order.js.map +1 -0
- package/dist/language/waves-plan.d.ts +45 -0
- package/dist/language/waves-plan.d.ts.map +1 -0
- package/dist/language/waves-plan.js +64 -0
- package/dist/language/waves-plan.js.map +1 -0
- package/dist/language/waves.d.ts +96 -0
- package/dist/language/waves.d.ts.map +1 -0
- package/dist/language/waves.js +575 -0
- package/dist/language/waves.js.map +1 -0
- package/dist/util/props.d.ts +27 -0
- package/dist/util/props.d.ts.map +1 -0
- package/dist/util/props.js +49 -0
- package/dist/util/props.js.map +1 -0
- package/dist/util/single-line.d.ts +14 -0
- package/dist/util/single-line.d.ts.map +1 -0
- package/dist/util/single-line.js +16 -0
- package/dist/util/single-line.js.map +1 -0
- package/package.json +7 -3
- package/src/convert/printer.ts +20 -10
- package/src/convert/schema.ts +8 -1
- package/src/generated/ast.ts +159 -27
- package/src/generated/grammar.ts +434 -148
- package/src/i18n/codes.ts +95 -2
- package/src/i18n/index.ts +1 -0
- package/src/i18n/messages.en.ts +300 -1
- package/src/i18n/messages.fr.ts +335 -1
- package/src/i18n/wave-message-types.ts +206 -0
- package/src/index.ts +33 -0
- package/src/internal.ts +9 -0
- package/src/language/ast-walk.ts +158 -0
- package/src/language/calendar-declarations.ts +141 -0
- package/src/language/include-references.ts +49 -0
- package/src/language/include-resolver.ts +284 -10
- package/src/language/include-waves.ts +419 -0
- package/src/language/nowline-validator.ts +98 -1835
- package/src/language/nowline.langium +56 -22
- package/src/language/references.ts +40 -0
- package/src/language/style-chain.ts +95 -0
- package/src/language/validator/calendar.ts +319 -0
- package/src/language/validator/entities.ts +366 -0
- package/src/language/validator/properties.ts +425 -0
- package/src/language/validator/references.ts +295 -0
- package/src/language/validator/structure.ts +206 -0
- package/src/language/validator/style.ts +149 -0
- package/src/language/validator/support.ts +84 -0
- package/src/language/validator/symbols.ts +141 -0
- package/src/language/validator/tables.ts +171 -0
- package/src/language/validator-utils.ts +123 -0
- package/src/language/value-tables.ts +260 -0
- package/src/language/waves-order.ts +879 -0
- package/src/language/waves-plan.ts +101 -0
- package/src/language/waves.ts +731 -0
- package/src/util/props.ts +59 -0
- package/src/util/single-line.ts +15 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { URI } from 'langium';
|
|
2
|
+
import { collectDocumentDiagnostics, type RawDiagnostic } from '../diagnostics/index.js';
|
|
2
3
|
import type {
|
|
3
4
|
AnchorDeclaration,
|
|
4
5
|
CalendarBlock,
|
|
@@ -8,6 +9,7 @@ import type {
|
|
|
8
9
|
IncludeDeclaration,
|
|
9
10
|
LabelDeclaration,
|
|
10
11
|
MilestoneDeclaration,
|
|
12
|
+
NonWorkingDeclaration,
|
|
11
13
|
NowlineFile,
|
|
12
14
|
PersonDeclaration,
|
|
13
15
|
RoadmapDeclaration,
|
|
@@ -19,6 +21,8 @@ import type {
|
|
|
19
21
|
SwimlaneDeclaration,
|
|
20
22
|
SymbolDeclaration,
|
|
21
23
|
TeamDeclaration,
|
|
24
|
+
WaveDeclaration,
|
|
25
|
+
WorkingDeclaration,
|
|
22
26
|
} from '../generated/ast.js';
|
|
23
27
|
import {
|
|
24
28
|
isAnchorDeclaration,
|
|
@@ -27,6 +31,7 @@ import {
|
|
|
27
31
|
isFootnoteDeclaration,
|
|
28
32
|
isLabelDeclaration,
|
|
29
33
|
isMilestoneDeclaration,
|
|
34
|
+
isNonWorkingDeclaration,
|
|
30
35
|
isPersonDeclaration,
|
|
31
36
|
isScaleBlock,
|
|
32
37
|
isSizeDeclaration,
|
|
@@ -35,19 +40,31 @@ import {
|
|
|
35
40
|
isSwimlaneDeclaration,
|
|
36
41
|
isSymbolDeclaration,
|
|
37
42
|
isTeamDeclaration,
|
|
43
|
+
isWaveDeclaration,
|
|
44
|
+
isWorkingDeclaration,
|
|
38
45
|
} from '../generated/ast.js';
|
|
46
|
+
import type { MessageCode } from '../i18n/codes.js';
|
|
39
47
|
import { basename, dirname, resolve as resolvePath } from '../util/posix-path.js';
|
|
48
|
+
import { isRealIsoDate } from '../util/props.js';
|
|
49
|
+
import { checkIncludedReferences } from './include-references.js';
|
|
50
|
+
import {
|
|
51
|
+
checkWaveAgreement,
|
|
52
|
+
hasParseErrors,
|
|
53
|
+
participates,
|
|
54
|
+
runResolverWaveChecks,
|
|
55
|
+
type WaveIncludeEdge,
|
|
56
|
+
} from './include-waves.js';
|
|
40
57
|
import type { NowlineServices } from './nowline-module.js';
|
|
58
|
+
import { ownWaves } from './waves.js';
|
|
41
59
|
|
|
42
60
|
export type IncludeMode = 'merge' | 'ignore' | 'isolate';
|
|
43
61
|
|
|
44
|
-
|
|
45
|
-
|
|
62
|
+
// An impossible `start:` (`2026-02-30`) reads as absent, as it does in layout;
|
|
63
|
+
// the validator reports it as NL.E0405. (`new Date` would roll it over to
|
|
64
|
+
// March 2, so a parent and child could disagree on a day neither names.)
|
|
46
65
|
function readStartProp(decl: RoadmapDeclaration | undefined): string | undefined {
|
|
47
66
|
const prop = decl?.properties.find((p) => p.key === 'start');
|
|
48
|
-
if (!prop?.value) return undefined;
|
|
49
|
-
if (!DATE_RE.test(prop.value)) return undefined;
|
|
50
|
-
if (Number.isNaN(new Date(prop.value).getTime())) return undefined;
|
|
67
|
+
if (!prop?.value || !isRealIsoDate(prop.value)) return undefined;
|
|
51
68
|
return prop.value;
|
|
52
69
|
}
|
|
53
70
|
|
|
@@ -75,8 +92,19 @@ export interface ResolvedConfig {
|
|
|
75
92
|
// a built-in identifier or an inline Unicode literal. See specs/dsl.md §
|
|
76
93
|
// Symbol Declaration.
|
|
77
94
|
symbols: Map<string, SymbolDeclaration>;
|
|
95
|
+
/**
|
|
96
|
+
* Every `non-working` and `working` declaration of the file and its merged
|
|
97
|
+
* includes (specs/working-calendar.md §4). Unnamed ones always merge; a
|
|
98
|
+
* child's named one is dropped, with a warning, when the parent already
|
|
99
|
+
* holds one with the same keyword and name. The order carries no meaning:
|
|
100
|
+
* the layout's calendar resolver sorts the rules it builds from them.
|
|
101
|
+
*/
|
|
102
|
+
calendarDeclarations: CalendarDeclaration[];
|
|
78
103
|
}
|
|
79
104
|
|
|
105
|
+
/** A `non-working` or `working` config declaration. */
|
|
106
|
+
type CalendarDeclaration = NonWorkingDeclaration | WorkingDeclaration;
|
|
107
|
+
|
|
80
108
|
export interface ResolvedContent {
|
|
81
109
|
roadmap?: RoadmapDeclaration;
|
|
82
110
|
persons: Map<string, PersonDeclaration>;
|
|
@@ -89,6 +117,13 @@ export interface ResolvedContent {
|
|
|
89
117
|
milestones: Map<string, MilestoneDeclaration>;
|
|
90
118
|
footnotes: Map<string, FootnoteDeclaration>;
|
|
91
119
|
isolatedRegions: IsolatedRegion[];
|
|
120
|
+
/**
|
|
121
|
+
* The file's own waves (specs/waves.md §7.4), by id; insertion order is
|
|
122
|
+
* the wave order. Absent when the file declares none. Children's waves
|
|
123
|
+
* are never merged in: include rule 12 makes every participating file
|
|
124
|
+
* declare the same waves. Consumers read `content.waves ?? EMPTY`.
|
|
125
|
+
*/
|
|
126
|
+
waves?: Map<string, WaveDeclaration>;
|
|
92
127
|
}
|
|
93
128
|
|
|
94
129
|
export interface IsolatedRegion {
|
|
@@ -101,11 +136,65 @@ export interface IsolatedRegion {
|
|
|
101
136
|
content: ResolvedContent;
|
|
102
137
|
}
|
|
103
138
|
|
|
139
|
+
/** A 0-based, end-exclusive source range, the shape of an LSP `Range`. */
|
|
140
|
+
export interface ResolveRange {
|
|
141
|
+
start: { line: number; character: number };
|
|
142
|
+
end: { line: number; character: number };
|
|
143
|
+
}
|
|
144
|
+
|
|
104
145
|
export interface ResolveDiagnostic {
|
|
105
146
|
severity: 'error' | 'warning';
|
|
147
|
+
/** en-US text; `localizeResolveDiagnostic` renders a coded one in another locale. */
|
|
106
148
|
message: string;
|
|
149
|
+
/** Absolute path of the file the diagnostic points into. */
|
|
107
150
|
sourcePath: string;
|
|
151
|
+
/** 0-based line in `sourcePath`; `range.start.line` when `range` is set. */
|
|
108
152
|
line?: number;
|
|
153
|
+
/**
|
|
154
|
+
* 0-based range in `sourcePath` of the node the diagnostic is about,
|
|
155
|
+
* narrowed to the property where the validator narrows its copy, so a
|
|
156
|
+
* consumer can point at the same column and span. Set on the routed
|
|
157
|
+
* diagnostics (see `isRoutedResolveDiagnostic`) whose node has a CST
|
|
158
|
+
* node; consumers fall back to the whole of `line` without it. An
|
|
159
|
+
* included file's syntax error has none: consumers adapt its `syntax`.
|
|
160
|
+
*/
|
|
161
|
+
range?: ResolveRange;
|
|
162
|
+
/**
|
|
163
|
+
* Stable code of a coded diagnostic (the wave rules, specs/waves.md
|
|
164
|
+
* §7.4, and an included file's unresolved reference, NL.E0302). Absent
|
|
165
|
+
* on every other resolver diagnostic.
|
|
166
|
+
*/
|
|
167
|
+
code?: MessageCode;
|
|
168
|
+
/** The message arguments as a rest tuple, as `acceptTr` stores them. */
|
|
169
|
+
args?: unknown[];
|
|
170
|
+
/**
|
|
171
|
+
* `'wave'` on every diagnostic of the wave checks (specs/waves.md §6.1),
|
|
172
|
+
* coded or not (WV8 reuses an uncoded message). Absent on every other
|
|
173
|
+
* resolver diagnostic. See `isRoutedResolveDiagnostic`.
|
|
174
|
+
*/
|
|
175
|
+
rule?: 'wave';
|
|
176
|
+
/**
|
|
177
|
+
* The lexer or parser error of an included file that failed to parse
|
|
178
|
+
* (specs/dsl.md, Include rule 13), as `collectDocumentDiagnostics`
|
|
179
|
+
* reports it. A surface adapts it with its own lexer/parser adapter, so it
|
|
180
|
+
* reads as it does when that file is checked on its own. Absent on every
|
|
181
|
+
* other resolver diagnostic.
|
|
182
|
+
*/
|
|
183
|
+
syntax?: IncludedSyntaxError;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/** A lexer or parser error of an included file. */
|
|
187
|
+
export type IncludedSyntaxError = Extract<RawDiagnostic, { origin: 'lexer' | 'parser' }>;
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* True for a resolver diagnostic that consumers report like a validator
|
|
191
|
+
* diagnostic (file, line, localized, exit 1): a coded one (the wave rules and
|
|
192
|
+
* NL.E0302), one from the wave checks, or an included file's syntax error.
|
|
193
|
+
* Every other resolver diagnostic keeps the include-error path
|
|
194
|
+
* (specs/waves.md §6.1).
|
|
195
|
+
*/
|
|
196
|
+
export function isRoutedResolveDiagnostic(d: ResolveDiagnostic): boolean {
|
|
197
|
+
return d.code !== undefined || d.rule === 'wave' || d.syntax !== undefined;
|
|
109
198
|
}
|
|
110
199
|
|
|
111
200
|
export interface ResolveResult {
|
|
@@ -117,10 +206,20 @@ export interface ResolveResult {
|
|
|
117
206
|
|
|
118
207
|
interface ResolveContext {
|
|
119
208
|
services: NowlineServices;
|
|
209
|
+
/** Absolute path of the root file, whose syntax errors the validator reports. */
|
|
210
|
+
rootAbs: string;
|
|
120
211
|
diagnostics: ResolveDiagnostic[];
|
|
121
212
|
resolving: string[];
|
|
122
213
|
processed: Map<string, { config: ResolvedConfig; content: ResolvedContent }>;
|
|
123
214
|
readFile: (absPath: string) => Promise<string>;
|
|
215
|
+
/** Every parsed file, the root included, with its absolute path. */
|
|
216
|
+
files: Map<NowlineFile, string>;
|
|
217
|
+
/** Include edges whose child was read, per including file, in include order. */
|
|
218
|
+
edges: Map<string, WaveIncludeEdge[]>;
|
|
219
|
+
/** Contents returned for a circular include (they never participate). */
|
|
220
|
+
stubs: Set<ResolvedContent>;
|
|
221
|
+
/** Children that failed include rule 12 (NL.E0202). */
|
|
222
|
+
failedWaves: Set<string>;
|
|
124
223
|
}
|
|
125
224
|
|
|
126
225
|
function emptyConfig(): ResolvedConfig {
|
|
@@ -128,6 +227,7 @@ function emptyConfig(): ResolvedConfig {
|
|
|
128
227
|
styles: new Map(),
|
|
129
228
|
defaults: new Map(),
|
|
130
229
|
symbols: new Map(),
|
|
230
|
+
calendarDeclarations: [],
|
|
131
231
|
};
|
|
132
232
|
}
|
|
133
233
|
|
|
@@ -165,15 +265,34 @@ export async function resolveIncludes(
|
|
|
165
265
|
const { nodeReadFile } = await import('../util/node-read-file.js');
|
|
166
266
|
return nodeReadFile(p);
|
|
167
267
|
});
|
|
268
|
+
const absPath = resolvePath('', filePath);
|
|
168
269
|
const ctx: ResolveContext = {
|
|
169
270
|
services: options.services,
|
|
271
|
+
rootAbs: absPath,
|
|
170
272
|
diagnostics: [],
|
|
171
273
|
resolving: [],
|
|
172
274
|
processed: new Map(),
|
|
173
275
|
readFile,
|
|
276
|
+
files: new Map(),
|
|
277
|
+
edges: new Map(),
|
|
278
|
+
stubs: new Set(),
|
|
279
|
+
failedWaves: new Set(),
|
|
174
280
|
};
|
|
175
|
-
const absPath = resolvePath('', filePath);
|
|
176
281
|
const { config, content } = await resolveFile(file, absPath, ctx);
|
|
282
|
+
// The wave S, P and G evaluations run once, over everything resolved.
|
|
283
|
+
ctx.diagnostics.push(
|
|
284
|
+
...runResolverWaveChecks({
|
|
285
|
+
rootFile: file,
|
|
286
|
+
rootAbs: absPath,
|
|
287
|
+
rootContent: content,
|
|
288
|
+
files: ctx.files,
|
|
289
|
+
edges: ctx.edges,
|
|
290
|
+
failed: ctx.failedWaves,
|
|
291
|
+
}),
|
|
292
|
+
);
|
|
293
|
+
// References never cross a file boundary; report each included file's
|
|
294
|
+
// unresolved ones in that file (an included file is never validated).
|
|
295
|
+
ctx.diagnostics.push(...checkIncludedReferences(absPath, ctx.edges));
|
|
177
296
|
return {
|
|
178
297
|
config,
|
|
179
298
|
content,
|
|
@@ -197,11 +316,19 @@ async function resolveFile(
|
|
|
197
316
|
sourcePath: absPath,
|
|
198
317
|
});
|
|
199
318
|
const empty = { config: emptyConfig(), content: emptyContent() };
|
|
319
|
+
ctx.stubs.add(empty.content);
|
|
200
320
|
ctx.processed.set(absPath, empty);
|
|
201
321
|
return empty;
|
|
202
322
|
}
|
|
203
323
|
|
|
324
|
+
// Each included file once, in every include mode: a `roadmap:ignore`
|
|
325
|
+
// child's config is still merged (Include rule 13).
|
|
326
|
+
if (absPath !== ctx.rootAbs) ctx.diagnostics.push(...syntaxDiagnostics(file, absPath));
|
|
327
|
+
|
|
204
328
|
ctx.resolving.push(absPath);
|
|
329
|
+
// The root is parsed from a `memory:` URI by every surface, so files are
|
|
330
|
+
// mapped by object, never by `$document.uri`.
|
|
331
|
+
ctx.files.set(file, absPath);
|
|
205
332
|
|
|
206
333
|
const config = emptyConfig();
|
|
207
334
|
const content = emptyContent();
|
|
@@ -210,7 +337,13 @@ async function resolveFile(
|
|
|
210
337
|
// files shadow to the parent (parent wins) and produce a warning pointing at the child.
|
|
211
338
|
mergeLocalConfig(config, file);
|
|
212
339
|
mergeLocalContent(content, file);
|
|
340
|
+
const waves = ownWaves(file);
|
|
341
|
+
if (waves.length > 0) {
|
|
342
|
+
content.waves = new Map(waves.map((w) => [w.name as string, w]));
|
|
343
|
+
}
|
|
213
344
|
|
|
345
|
+
const edges: WaveIncludeEdge[] = [];
|
|
346
|
+
ctx.edges.set(absPath, edges);
|
|
214
347
|
const seenIncludes = new Set<string>();
|
|
215
348
|
for (const inc of file.includes) {
|
|
216
349
|
const childRelPath = inc.path;
|
|
@@ -249,6 +382,16 @@ async function resolveFile(
|
|
|
249
382
|
childAbsPath,
|
|
250
383
|
ctx,
|
|
251
384
|
);
|
|
385
|
+
edges.push({
|
|
386
|
+
parentAbs: absPath,
|
|
387
|
+
inc,
|
|
388
|
+
childRelPath,
|
|
389
|
+
childAbs: childAbsPath,
|
|
390
|
+
mode: roadmapMode,
|
|
391
|
+
childFile,
|
|
392
|
+
childContent,
|
|
393
|
+
participates: participates(childFile, childContent, ctx.stubs.has(childContent)),
|
|
394
|
+
});
|
|
252
395
|
|
|
253
396
|
applyConfigMode(config, childConfig, configMode, childAbsPath, ctx.diagnostics);
|
|
254
397
|
applyRoadmapMode(
|
|
@@ -261,7 +404,11 @@ async function resolveFile(
|
|
|
261
404
|
ctx.diagnostics,
|
|
262
405
|
);
|
|
263
406
|
|
|
264
|
-
|
|
407
|
+
// A partial AST would report a roadmap or start: the parser lost, as
|
|
408
|
+
// an include error that hides the syntax error (Include rule 13).
|
|
409
|
+
const isParsed = !hasParseErrors(childFile);
|
|
410
|
+
|
|
411
|
+
if (isParsed && roadmapMode === 'isolate' && !childContent.roadmap) {
|
|
265
412
|
ctx.diagnostics.push({
|
|
266
413
|
severity: 'error',
|
|
267
414
|
message: `Cannot isolate "${childRelPath}": it has no roadmap declaration.`,
|
|
@@ -273,7 +420,7 @@ async function resolveFile(
|
|
|
273
420
|
// Non-ignored includes with a child roadmap must agree on start: with the parent.
|
|
274
421
|
// Deliberate divergence from the usual "parent wins with warning" merge behaviour
|
|
275
422
|
// because start: defines the shared timeline baseline.
|
|
276
|
-
if (roadmapMode !== 'ignore' && childFile.roadmapDecl) {
|
|
423
|
+
if (isParsed && roadmapMode !== 'ignore' && childFile.roadmapDecl) {
|
|
277
424
|
const parentStart = readStartProp(file.roadmapDecl);
|
|
278
425
|
const childStart = readStartProp(childFile.roadmapDecl);
|
|
279
426
|
if (parentStart !== childStart) {
|
|
@@ -287,12 +434,46 @@ async function resolveFile(
|
|
|
287
434
|
}
|
|
288
435
|
}
|
|
289
436
|
|
|
437
|
+
if (content.waves) rekeyWaveSlugs(content, content.waves);
|
|
438
|
+
|
|
439
|
+
// Include rule 12 runs after the include loop, so its result does not
|
|
440
|
+
// depend on include order (specs/waves.md §7.4).
|
|
441
|
+
for (const edge of edges) {
|
|
442
|
+
const { diagnostics, failed } = checkWaveAgreement(file, content, edge);
|
|
443
|
+
ctx.diagnostics.push(...diagnostics);
|
|
444
|
+
if (failed) ctx.failedWaves.add(edge.childAbs);
|
|
445
|
+
}
|
|
446
|
+
|
|
290
447
|
ctx.resolving.pop();
|
|
291
448
|
const result = { config, content };
|
|
292
449
|
ctx.processed.set(absPath, result);
|
|
293
450
|
return result;
|
|
294
451
|
}
|
|
295
452
|
|
|
453
|
+
/**
|
|
454
|
+
* An included file's lexer and parser errors, at their line in that file.
|
|
455
|
+
* An included file is parsed without validation, so nothing else reports
|
|
456
|
+
* them.
|
|
457
|
+
*/
|
|
458
|
+
function syntaxDiagnostics(file: NowlineFile, absPath: string): ResolveDiagnostic[] {
|
|
459
|
+
const doc = file.$document;
|
|
460
|
+
if (!doc) return [];
|
|
461
|
+
const out: ResolveDiagnostic[] = [];
|
|
462
|
+
for (const raw of collectDocumentDiagnostics(doc)) {
|
|
463
|
+
if (raw.origin === 'validation') continue;
|
|
464
|
+
// Chevrotain lines are 1-based; an error at end of input has NaN.
|
|
465
|
+
const line = raw.origin === 'lexer' ? raw.error.line : raw.error.token?.startLine;
|
|
466
|
+
out.push({
|
|
467
|
+
severity: 'error',
|
|
468
|
+
message: raw.error.message,
|
|
469
|
+
sourcePath: absPath,
|
|
470
|
+
...(line !== undefined && Number.isFinite(line) ? { line: line - 1 } : {}),
|
|
471
|
+
syntax: raw,
|
|
472
|
+
});
|
|
473
|
+
}
|
|
474
|
+
return out;
|
|
475
|
+
}
|
|
476
|
+
|
|
296
477
|
function getIncludeMode(
|
|
297
478
|
inc: IncludeDeclaration,
|
|
298
479
|
key: 'config' | 'roadmap',
|
|
@@ -336,6 +517,9 @@ function applyConfigMode(
|
|
|
336
517
|
mergeMap(target.styles, child.styles, (name) => warn(name, 'Style'));
|
|
337
518
|
mergeMap(target.defaults, child.defaults, (name) => warn(name, 'Default'));
|
|
338
519
|
mergeMap(target.symbols, child.symbols, (name) => warn(name, 'Symbol'));
|
|
520
|
+
mergeCalendarDeclarations(target.calendarDeclarations, child.calendarDeclarations, (decl) =>
|
|
521
|
+
warn(decl.name as string, calendarKeywordLabel(decl)),
|
|
522
|
+
);
|
|
339
523
|
if (child.scale && !target.scale) {
|
|
340
524
|
target.scale = child.scale;
|
|
341
525
|
}
|
|
@@ -394,25 +578,69 @@ function mergeMap<V>(
|
|
|
394
578
|
): void {
|
|
395
579
|
for (const [name, value] of source) {
|
|
396
580
|
if (target.has(name)) {
|
|
397
|
-
|
|
581
|
+
// The same declaration arriving again through a diamond include
|
|
582
|
+
// is not a collision.
|
|
583
|
+
if (target.get(name) !== value) onConflict(name);
|
|
398
584
|
continue;
|
|
399
585
|
}
|
|
400
586
|
target.set(name, value);
|
|
401
587
|
}
|
|
402
588
|
}
|
|
403
589
|
|
|
590
|
+
/**
|
|
591
|
+
* Append a child's calendar declarations to the parent's list. An unnamed
|
|
592
|
+
* declaration always merges. A named one is dropped, and reported, when the
|
|
593
|
+
* list already holds one with the same keyword and name (parent wins); a
|
|
594
|
+
* `non-working h` and a `working h` never collide. A declaration already in
|
|
595
|
+
* the list (a diamond include delivers the shared file's cached config
|
|
596
|
+
* through every path) is skipped silently.
|
|
597
|
+
*/
|
|
598
|
+
function mergeCalendarDeclarations(
|
|
599
|
+
target: CalendarDeclaration[],
|
|
600
|
+
source: readonly CalendarDeclaration[],
|
|
601
|
+
onConflict: (decl: CalendarDeclaration) => void,
|
|
602
|
+
): void {
|
|
603
|
+
const merged = new Set(target);
|
|
604
|
+
// Names held before this merge: a child's own duplicate id is NL.E0907 in
|
|
605
|
+
// that file, not a shadowing by the parent, so both of its copies merge.
|
|
606
|
+
const held = new Set(target.filter((t) => t.name).map(calendarDeclarationKey));
|
|
607
|
+
for (const decl of source) {
|
|
608
|
+
if (merged.has(decl)) continue;
|
|
609
|
+
if (decl.name && held.has(calendarDeclarationKey(decl))) {
|
|
610
|
+
onConflict(decl);
|
|
611
|
+
continue;
|
|
612
|
+
}
|
|
613
|
+
target.push(decl);
|
|
614
|
+
merged.add(decl);
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
/** Keyword and id: the identity two named calendar declarations collide on. */
|
|
619
|
+
function calendarDeclarationKey(decl: CalendarDeclaration): string {
|
|
620
|
+
return `${decl.$type}:${decl.name}`;
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
/** The shadow-warning category of a calendar declaration: its keyword, capitalized. */
|
|
624
|
+
function calendarKeywordLabel(decl: CalendarDeclaration): string {
|
|
625
|
+
return isNonWorkingDeclaration(decl) ? 'Non-working' : 'Working';
|
|
626
|
+
}
|
|
627
|
+
|
|
404
628
|
/**
|
|
405
629
|
* Merge a child content map into the parent. Explicit-id entries keep the
|
|
406
630
|
* parent-wins-on-collision behavior (and warn). Title-only (auto-slugged)
|
|
407
631
|
* entries are internal and non-referenceable, so they never shadow and never
|
|
408
|
-
* warn — each is re-keyed around the parent's entries and kept.
|
|
632
|
+
* warn — each is re-keyed around the parent's entries and kept. A declaration
|
|
633
|
+
* already in the parent (a diamond include delivers the shared file's cached
|
|
634
|
+
* content through every path) is skipped silently, whatever its key.
|
|
409
635
|
*/
|
|
410
636
|
function mergeContentMap<V extends { name?: string; title?: string }>(
|
|
411
637
|
target: Map<string, V>,
|
|
412
638
|
source: Map<string, V>,
|
|
413
639
|
onConflict: (name: string) => void,
|
|
414
640
|
): void {
|
|
641
|
+
const merged = new Set(target.values());
|
|
415
642
|
for (const [name, value] of source) {
|
|
643
|
+
if (merged.has(value)) continue;
|
|
416
644
|
if (!value.name && value.title) {
|
|
417
645
|
target.set(
|
|
418
646
|
uniqueMapKey(target as Map<string, unknown>, slugifyTitle(value.title)),
|
|
@@ -451,6 +679,10 @@ function addConfigEntry(config: ResolvedConfig, entry: ConfigEntry): void {
|
|
|
451
679
|
if (!config.defaults.has(entry.entityType)) {
|
|
452
680
|
config.defaults.set(entry.entityType, entry);
|
|
453
681
|
}
|
|
682
|
+
} else if (isNonWorkingDeclaration(entry) || isWorkingDeclaration(entry)) {
|
|
683
|
+
// Every declaration of the file, named or not: a duplicate id in one
|
|
684
|
+
// file is the validator's NL.E0907, not a merge question.
|
|
685
|
+
config.calendarDeclarations.push(entry);
|
|
454
686
|
}
|
|
455
687
|
}
|
|
456
688
|
|
|
@@ -467,6 +699,8 @@ interface ReservedRoadmapIds {
|
|
|
467
699
|
footnotes: Set<string>;
|
|
468
700
|
}
|
|
469
701
|
|
|
702
|
+
// Wave ids are reserved in every map: layout seeds its edge maps by key, so a
|
|
703
|
+
// title-only `milestone "Launch"` must not take the key of `wave launch`.
|
|
470
704
|
function collectExplicitRoadmapIds(entries: RoadmapEntry[]): ReservedRoadmapIds {
|
|
471
705
|
const reserved: ReservedRoadmapIds = {
|
|
472
706
|
swimlanes: new Set(),
|
|
@@ -491,10 +725,50 @@ function collectExplicitRoadmapIds(entries: RoadmapEntry[]): ReservedRoadmapIds
|
|
|
491
725
|
else if (isStatusDeclaration(entry)) reserved.statuses.add(name);
|
|
492
726
|
else if (isMilestoneDeclaration(entry)) reserved.milestones.add(name);
|
|
493
727
|
else if (isFootnoteDeclaration(entry)) reserved.footnotes.add(name);
|
|
728
|
+
else if (isWaveDeclaration(entry)) {
|
|
729
|
+
for (const set of Object.values(reserved)) set.add(name);
|
|
730
|
+
}
|
|
494
731
|
}
|
|
495
732
|
return reserved;
|
|
496
733
|
}
|
|
497
734
|
|
|
735
|
+
/**
|
|
736
|
+
* Re-key every title-only entry whose slug key equals a wave id (merged in
|
|
737
|
+
* from a child, whose slugs are recomputed by `mergeContentMap`), keeping
|
|
738
|
+
* each map's insertion order. Layout seeds its edge maps by key.
|
|
739
|
+
*/
|
|
740
|
+
function rekeyWaveSlugs(
|
|
741
|
+
content: ResolvedContent,
|
|
742
|
+
waves: ReadonlyMap<string, WaveDeclaration>,
|
|
743
|
+
): void {
|
|
744
|
+
const maps: Array<Map<string, { name?: string; title?: string }>> = [
|
|
745
|
+
content.persons,
|
|
746
|
+
content.teams,
|
|
747
|
+
content.anchors,
|
|
748
|
+
content.labels,
|
|
749
|
+
content.sizes,
|
|
750
|
+
content.statuses,
|
|
751
|
+
content.swimlanes,
|
|
752
|
+
content.milestones,
|
|
753
|
+
content.footnotes,
|
|
754
|
+
];
|
|
755
|
+
const titleOnlyOnWave = (key: string, v: { name?: string; title?: string }): boolean =>
|
|
756
|
+
waves.has(key) && !v.name && !!v.title;
|
|
757
|
+
for (const map of maps) {
|
|
758
|
+
const entries = [...map];
|
|
759
|
+
if (!entries.some(([k, v]) => titleOnlyOnWave(k, v))) continue;
|
|
760
|
+
const reserved = new Set<string>([...map.keys(), ...waves.keys()]);
|
|
761
|
+
map.clear();
|
|
762
|
+
for (const [k, v] of entries) {
|
|
763
|
+
const key = titleOnlyOnWave(k, v)
|
|
764
|
+
? uniqueMapKey(map as Map<string, unknown>, k, reserved)
|
|
765
|
+
: k;
|
|
766
|
+
reserved.add(key);
|
|
767
|
+
map.set(key, v);
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
|
|
498
772
|
function mergeLocalContent(content: ResolvedContent, file: NowlineFile): void {
|
|
499
773
|
if (file.roadmapDecl && !content.roadmap) {
|
|
500
774
|
content.roadmap = file.roadmapDecl;
|