@nowline/core 0.8.6 → 0.10.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
|
@@ -0,0 +1,731 @@
|
|
|
1
|
+
// Wave rules (specs/waves.md §4, §5.1, §6). Pure functions over the AST: the
|
|
2
|
+
// validator translates the findings into Langium diagnostics, and the
|
|
3
|
+
// include resolver (children are parsed with `validation:false`) and layout
|
|
4
|
+
// call the same helpers.
|
|
5
|
+
//
|
|
6
|
+
// Rule sets implemented here:
|
|
7
|
+
// - S (declarations): WV1 NL.E1100, WV3 NL.E1105, WV4 NL.E1106
|
|
8
|
+
// (`checkWaveDeclaration` / `checkWaveDeclarations`).
|
|
9
|
+
// - P (properties): WV5 NL.E1104, WV6 NL.E1101, WV7 NL.E1102, WV8 (the
|
|
10
|
+
// rule-23 message for `wave` on a default line), WV9 NL.W0702
|
|
11
|
+
// (`evaluateWaveProperties`).
|
|
12
|
+
// WV2 is the validator's existing `checkUniqueIdentifiers` (NL.E0300). The G
|
|
13
|
+
// rules (WV10-WV12) live in `waves-order.ts`, which builds on `assignWaves`.
|
|
14
|
+
|
|
15
|
+
import type { AstNode } from 'langium';
|
|
16
|
+
import type {
|
|
17
|
+
EntityProperty,
|
|
18
|
+
NowlineFile,
|
|
19
|
+
SwimlaneDeclaration,
|
|
20
|
+
WaveDeclaration,
|
|
21
|
+
} from '../generated/ast.js';
|
|
22
|
+
import {
|
|
23
|
+
isAnchorDeclaration,
|
|
24
|
+
isConfigEntry,
|
|
25
|
+
isDefaultDeclaration,
|
|
26
|
+
isGroupBlock,
|
|
27
|
+
isItemDeclaration,
|
|
28
|
+
isMilestoneDeclaration,
|
|
29
|
+
isNowlineFile,
|
|
30
|
+
isParallelBlock,
|
|
31
|
+
isStyleDeclaration,
|
|
32
|
+
isSwimlaneDeclaration,
|
|
33
|
+
isSymbolDeclaration,
|
|
34
|
+
isWaveDeclaration,
|
|
35
|
+
} from '../generated/ast.js';
|
|
36
|
+
import type { MessageArgs } from '../i18n/index.js';
|
|
37
|
+
import type { WaveKind, WaveSuggestion } from '../i18n/wave-message-types.js';
|
|
38
|
+
import { ISO_DATE_RE, isRealIsoDate, propKey } from '../util/props.js';
|
|
39
|
+
import { singleLine } from '../util/single-line.js';
|
|
40
|
+
import {
|
|
41
|
+
type DeclarationNode,
|
|
42
|
+
declarations,
|
|
43
|
+
firstDeclarations,
|
|
44
|
+
trackChildren,
|
|
45
|
+
} from './ast-walk.js';
|
|
46
|
+
import {
|
|
47
|
+
defaultBannedMessage,
|
|
48
|
+
displayName,
|
|
49
|
+
entityTypeLabel,
|
|
50
|
+
lineOf,
|
|
51
|
+
suggestUniqueKey,
|
|
52
|
+
} from './validator-utils.js';
|
|
53
|
+
|
|
54
|
+
// --- Findings ---
|
|
55
|
+
|
|
56
|
+
/** Codes the wave rules emit. */
|
|
57
|
+
export type WaveFindingCode =
|
|
58
|
+
| 'NL.E1100'
|
|
59
|
+
| 'NL.E1101'
|
|
60
|
+
| 'NL.E1102'
|
|
61
|
+
| 'NL.E1103'
|
|
62
|
+
| 'NL.E1104'
|
|
63
|
+
| 'NL.E1105'
|
|
64
|
+
| 'NL.E1106'
|
|
65
|
+
| 'NL.W0702'
|
|
66
|
+
| 'NL.W1100'
|
|
67
|
+
| 'NL.W1101';
|
|
68
|
+
|
|
69
|
+
type FindingBase = {
|
|
70
|
+
severity: 'error' | 'warning';
|
|
71
|
+
/** Node whose range the diagnostic covers. */
|
|
72
|
+
node: AstNode;
|
|
73
|
+
/** Optional property of `node` to narrow the range (e.g. `'key'`). */
|
|
74
|
+
property?: string;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
/** A localized finding: the caller formats it with `tr(locale, code, args)`. */
|
|
78
|
+
export type CodedWaveFinding = {
|
|
79
|
+
[K in WaveFindingCode]: FindingBase & { code: K; args: MessageArgs<K>[0] };
|
|
80
|
+
}[WaveFindingCode];
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* An uncoded finding with a fixed English message. Only WV8 uses it: `wave`
|
|
84
|
+
* on a `default <entity>` line reuses the existing (uncoded) rule-23 text.
|
|
85
|
+
*/
|
|
86
|
+
export type UncodedWaveFinding = FindingBase & { message: string };
|
|
87
|
+
|
|
88
|
+
export type WaveFinding = CodedWaveFinding | UncodedWaveFinding;
|
|
89
|
+
|
|
90
|
+
// --- Wave list and index ---
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* The file's own waves in declaration order: every wave declaration with a
|
|
94
|
+
* valid (non-empty) id. A wave that failed WV1 is not in the list, and a
|
|
95
|
+
* repeated id (NL.E0300) keeps only its first declaration. A roadmap "has
|
|
96
|
+
* waves" when this list is non-empty.
|
|
97
|
+
*/
|
|
98
|
+
export function ownWaves(file: NowlineFile): WaveDeclaration[] {
|
|
99
|
+
const seen = new Set<string>();
|
|
100
|
+
const out: WaveDeclaration[] = [];
|
|
101
|
+
for (const entry of file.roadmapEntries) {
|
|
102
|
+
if (!isWaveDeclaration(entry) || !entry.name) continue;
|
|
103
|
+
if (seen.has(entry.name)) continue;
|
|
104
|
+
seen.add(entry.name);
|
|
105
|
+
out.push(entry);
|
|
106
|
+
}
|
|
107
|
+
return out;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** Wave id to its 1-based index in declaration order (`ownWaves`). */
|
|
111
|
+
export function waveIndexMap(file: NowlineFile): Map<string, number> {
|
|
112
|
+
const map = new Map<string, number>();
|
|
113
|
+
ownWaves(file).forEach((w, i) => {
|
|
114
|
+
map.set(w.name as string, i + 1);
|
|
115
|
+
});
|
|
116
|
+
return map;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// --- Effective wave, lead wave ---
|
|
120
|
+
|
|
121
|
+
type WaveValue =
|
|
122
|
+
| { status: 'valid'; id: string; index: number }
|
|
123
|
+
| { status: 'list'; value: string }
|
|
124
|
+
| { status: 'forward'; value: string; line: number }
|
|
125
|
+
| { status: 'missing'; value: string };
|
|
126
|
+
|
|
127
|
+
// Every `wave:` key on the node, in source order. A repeated key is a WV6
|
|
128
|
+
// error (one wave per entity); the first key is the one that applies.
|
|
129
|
+
function waveProps(node: AstNode): EntityProperty[] {
|
|
130
|
+
const props = (node as { properties?: EntityProperty[] }).properties ?? [];
|
|
131
|
+
return props.filter((p) => propKey(p) === 'wave');
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function waveProp(node: AstNode): EntityProperty | undefined {
|
|
135
|
+
return waveProps(node)[0];
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// `wave:[a, b]` is echoed back as `[a, b]`; `wave:[a]` is the same as `wave:a`.
|
|
139
|
+
function waveValueText(prop: EntityProperty): string {
|
|
140
|
+
if (prop.value !== undefined) return prop.value;
|
|
141
|
+
return prop.values.length === 1 ? prop.values[0] : `[${prop.values.join(', ')}]`;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// The top-level roadmap entry that contains `node`, and the file it lives in.
|
|
145
|
+
function topLevel(node: AstNode): TopLevel | undefined {
|
|
146
|
+
let n: AstNode | undefined = node;
|
|
147
|
+
while (n?.$container && !isNowlineFile(n.$container)) n = n.$container;
|
|
148
|
+
const file = n?.$container;
|
|
149
|
+
if (!n || !file || !isNowlineFile(file)) return undefined;
|
|
150
|
+
return {
|
|
151
|
+
file,
|
|
152
|
+
index: (file.roadmapEntries as AstNode[]).indexOf(n),
|
|
153
|
+
waveDecls: waveDeclarationIndex(file),
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// Where each wave is first declared among the file's roadmap entries.
|
|
158
|
+
function waveDeclarationIndex(file: NowlineFile): Map<string, number> {
|
|
159
|
+
const map = new Map<string, number>();
|
|
160
|
+
file.roadmapEntries.forEach((e, i) => {
|
|
161
|
+
if (isWaveDeclaration(e) && e.name && !map.has(e.name)) map.set(e.name, i);
|
|
162
|
+
});
|
|
163
|
+
return map;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// The top-level entry holding a reference, with its file's wave declaration
|
|
167
|
+
// index (`assignWaves` computes both once per lane).
|
|
168
|
+
type TopLevel = { file: NowlineFile; index: number; waveDecls: ReadonlyMap<string, number> };
|
|
169
|
+
|
|
170
|
+
// WV6 classification of a `wave:` value. A declared wave must be declared
|
|
171
|
+
// earlier in the roadmap section than the top-level entry holding the
|
|
172
|
+
// reference (rule-15 model). The check runs against the node's own file, so
|
|
173
|
+
// layout can pass a wave index built from another file that agrees on the
|
|
174
|
+
// waves (include rule 12).
|
|
175
|
+
function classifyWaveValue(
|
|
176
|
+
prop: EntityProperty,
|
|
177
|
+
node: AstNode,
|
|
178
|
+
waveIds: ReadonlyMap<string, number>,
|
|
179
|
+
top: TopLevel | undefined = topLevel(node),
|
|
180
|
+
): WaveValue {
|
|
181
|
+
const value = waveValueText(prop);
|
|
182
|
+
if (prop.value === undefined && prop.values.length !== 1) return { status: 'list', value };
|
|
183
|
+
const index = waveIds.get(value);
|
|
184
|
+
if (index === undefined) return { status: 'missing', value };
|
|
185
|
+
if (top) {
|
|
186
|
+
const declIdx = top.waveDecls.get(value);
|
|
187
|
+
if (declIdx !== undefined && (top.index < 0 || declIdx > top.index)) {
|
|
188
|
+
return {
|
|
189
|
+
status: 'forward',
|
|
190
|
+
value,
|
|
191
|
+
line: lineOf(top.file.roadmapEntries[declIdx]),
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
return { status: 'valid', id: value, index };
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
function isWaveContainer(node: AstNode | undefined): boolean {
|
|
199
|
+
return isGroupBlock(node) || isParallelBlock(node);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* `ew(x)` from specs/waves.md §4.4, one step: the 1-based index of the node's
|
|
204
|
+
* effective wave, or undefined for background work (`assignWaves` runs it
|
|
205
|
+
* down the tree).
|
|
206
|
+
*
|
|
207
|
+
* - A `wave:` that names a valid declared wave applies, unless an enclosing
|
|
208
|
+
* group or parallel already has an effective wave (`inherited`): then the
|
|
209
|
+
* container's wave wins (a WV7 conflict uses the container's wave).
|
|
210
|
+
* - An invalid `wave:` value (WV6) makes the node background.
|
|
211
|
+
* - With no `wave:`, the nearest enclosing group or parallel decides.
|
|
212
|
+
* Swimlanes never contribute.
|
|
213
|
+
*/
|
|
214
|
+
function effectiveWaveStep(
|
|
215
|
+
node: AstNode,
|
|
216
|
+
inherited: number | undefined,
|
|
217
|
+
waveIds: ReadonlyMap<string, number>,
|
|
218
|
+
top: TopLevel | undefined,
|
|
219
|
+
): number | undefined {
|
|
220
|
+
const prop = waveProp(node);
|
|
221
|
+
if (!prop) return inherited;
|
|
222
|
+
const own = classifyWaveValue(prop, node, waveIds, top);
|
|
223
|
+
if (own.status !== 'valid') return undefined;
|
|
224
|
+
return inherited ?? own.index;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/** `ew` and `lw` for every item, group and parallel under a list of lanes. */
|
|
228
|
+
export interface WaveAssignment {
|
|
229
|
+
/** `ew(x)`, for every node with an effective wave (absent: background). */
|
|
230
|
+
waveOf: Map<AstNode, number>;
|
|
231
|
+
/** `lw(x)`, for every node with a lead wave (absent: none). */
|
|
232
|
+
leadOf: Map<AstNode, number>;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* `ew` and `lw` (specs/waves.md §4.4 and §5.1) for every item, group and
|
|
237
|
+
* parallel under `lanes`, in one pass: `ew` top-down, `lw` bottom-up. The
|
|
238
|
+
* lanes may come from several files that agree on the waves (include rule
|
|
239
|
+
* 12); each `wave:` is still checked against its own file's declaration order.
|
|
240
|
+
*
|
|
241
|
+
* `lw(C)` is the wave a container's box may not open before. An item's lead
|
|
242
|
+
* wave is its effective wave. A group without an effective wave takes its
|
|
243
|
+
* first child's; a parallel without one takes the minimum over its tracks, or
|
|
244
|
+
* background when any track is background. An empty container is background.
|
|
245
|
+
*/
|
|
246
|
+
export function assignWaves(
|
|
247
|
+
lanes: readonly SwimlaneDeclaration[],
|
|
248
|
+
waveIds: ReadonlyMap<string, number>,
|
|
249
|
+
): WaveAssignment {
|
|
250
|
+
const waveOf = new Map<AstNode, number>();
|
|
251
|
+
const leadOf = new Map<AstNode, number>();
|
|
252
|
+
const declsByFile = new Map<NowlineFile, Map<string, number>>();
|
|
253
|
+
|
|
254
|
+
// Returns lw(node).
|
|
255
|
+
const visit = (
|
|
256
|
+
node: AstNode,
|
|
257
|
+
inherited: number | undefined,
|
|
258
|
+
top: TopLevel | undefined,
|
|
259
|
+
): number | undefined => {
|
|
260
|
+
const ew = effectiveWaveStep(node, inherited, waveIds, top);
|
|
261
|
+
if (ew !== undefined) waveOf.set(node, ew);
|
|
262
|
+
let lw = ew;
|
|
263
|
+
if (isGroupBlock(node) || isParallelBlock(node)) {
|
|
264
|
+
const leads: Array<number | undefined> = [];
|
|
265
|
+
for (const child of trackChildren(node)) leads.push(visit(child, ew, top));
|
|
266
|
+
if (ew === undefined) {
|
|
267
|
+
if (isGroupBlock(node)) lw = leads[0];
|
|
268
|
+
else if (leads.length > 0 && !leads.includes(undefined)) {
|
|
269
|
+
lw = Math.min(...(leads as number[]));
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
if (lw !== undefined) leadOf.set(node, lw);
|
|
274
|
+
return lw;
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
for (const lane of lanes) {
|
|
278
|
+
let top: TopLevel | undefined;
|
|
279
|
+
const file = lane.$container;
|
|
280
|
+
if (isNowlineFile(file)) {
|
|
281
|
+
let waveDecls = declsByFile.get(file);
|
|
282
|
+
if (!waveDecls) {
|
|
283
|
+
waveDecls = waveDeclarationIndex(file);
|
|
284
|
+
declsByFile.set(file, waveDecls);
|
|
285
|
+
}
|
|
286
|
+
top = { file, index: (file.roadmapEntries as AstNode[]).indexOf(lane), waveDecls };
|
|
287
|
+
}
|
|
288
|
+
for (const child of trackChildren(lane)) visit(child, undefined, top);
|
|
289
|
+
}
|
|
290
|
+
return { waveOf, leadOf };
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
// --- Start floor ---
|
|
294
|
+
|
|
295
|
+
/** Resolves an id to its declaration. Layout and includes pass merged lookups. */
|
|
296
|
+
export type WaveRefLookup = (id: string) => AstNode | undefined;
|
|
297
|
+
|
|
298
|
+
function dateProp(node: AstNode): string | undefined {
|
|
299
|
+
const props = (node as { properties?: EntityProperty[] }).properties ?? [];
|
|
300
|
+
return props.find((p) => propKey(p) === 'date')?.value;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/** A lookup over one file's declarations (see `WaveRefLookup`). */
|
|
304
|
+
export function fileRefLookup(file: NowlineFile): WaveRefLookup {
|
|
305
|
+
// Ids that `after:`, `before:` and `on:` can name; the first declaration
|
|
306
|
+
// of a repeated id wins.
|
|
307
|
+
const ids = firstDeclarations(file);
|
|
308
|
+
return (id) => ids.get(id);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* `A_k` from specs/waves.md §5.1: the latest date among the wave's `after:`
|
|
313
|
+
* elements (an anchor's `date:`, a dated milestone's `date:`, or an inline
|
|
314
|
+
* ISO date), with the element that set it as `ref`. Ties keep the first
|
|
315
|
+
* element. Elements that fail WV4, or that do not resolve, are ignored;
|
|
316
|
+
* null when no element gives a date.
|
|
317
|
+
*/
|
|
318
|
+
export function waveFloorDate(
|
|
319
|
+
wave: WaveDeclaration,
|
|
320
|
+
lookup: WaveRefLookup,
|
|
321
|
+
): { date: string; ref: string } | null {
|
|
322
|
+
let best: { date: string; ref: string } | null = null;
|
|
323
|
+
for (const prop of wave.properties) {
|
|
324
|
+
if (propKey(prop) !== 'after') continue;
|
|
325
|
+
const vals = prop.value !== undefined ? [prop.value] : prop.values;
|
|
326
|
+
for (const v of vals) {
|
|
327
|
+
if (!v) continue;
|
|
328
|
+
let date: string | undefined;
|
|
329
|
+
if (ISO_DATE_RE.test(v)) {
|
|
330
|
+
date = v;
|
|
331
|
+
} else {
|
|
332
|
+
const target = lookup(v);
|
|
333
|
+
if (isAnchorDeclaration(target) || isMilestoneDeclaration(target)) {
|
|
334
|
+
date = dateProp(target);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
if (date === undefined || !isRealIsoDate(date)) continue;
|
|
338
|
+
if (best === null || date > best.date) best = { date, ref: v };
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
return best;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
// --- S rules: declarations ---
|
|
345
|
+
|
|
346
|
+
// WV3: keys a wave declaration may not take. `before` has its own message.
|
|
347
|
+
const WAVE_BANNED_KEYS = new Set([
|
|
348
|
+
'before',
|
|
349
|
+
'date',
|
|
350
|
+
'start',
|
|
351
|
+
'length',
|
|
352
|
+
'duration',
|
|
353
|
+
'size',
|
|
354
|
+
'capacity',
|
|
355
|
+
'remaining',
|
|
356
|
+
'wave',
|
|
357
|
+
]);
|
|
358
|
+
|
|
359
|
+
/**
|
|
360
|
+
* True for a property that WV3 owns: a banned key on a wave declaration.
|
|
361
|
+
* Other checks skip it so NL.E1105 is the only diagnostic for that key.
|
|
362
|
+
*/
|
|
363
|
+
export function isWaveBannedProperty(prop: EntityProperty): boolean {
|
|
364
|
+
return isWaveDeclaration(prop.$container) && WAVE_BANNED_KEYS.has(propKey(prop));
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
const KIND_BY_TYPE: Record<string, WaveKind> = {
|
|
368
|
+
ItemDeclaration: 'item',
|
|
369
|
+
GroupBlock: 'group',
|
|
370
|
+
ParallelBlock: 'parallel',
|
|
371
|
+
SwimlaneDeclaration: 'swimlane',
|
|
372
|
+
AnchorDeclaration: 'anchor',
|
|
373
|
+
MilestoneDeclaration: 'milestone',
|
|
374
|
+
WaveDeclaration: 'wave',
|
|
375
|
+
LabelDeclaration: 'label',
|
|
376
|
+
SizeDeclaration: 'size',
|
|
377
|
+
StatusDeclaration: 'status',
|
|
378
|
+
PersonDeclaration: 'person',
|
|
379
|
+
TeamDeclaration: 'team',
|
|
380
|
+
FootnoteDeclaration: 'footnote',
|
|
381
|
+
RoadmapDeclaration: 'roadmap',
|
|
382
|
+
StyleDeclaration: 'style',
|
|
383
|
+
SymbolDeclaration: 'symbol',
|
|
384
|
+
};
|
|
385
|
+
|
|
386
|
+
function waveKindOf(node: AstNode): WaveKind {
|
|
387
|
+
return KIND_BY_TYPE[node.$type] ?? (entityTypeLabel(node) as WaveKind);
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
/**
|
|
391
|
+
* WV1, WV3 and WV4 for one wave declaration. `lookup` resolves its `after:`
|
|
392
|
+
* ids; build it once per file (`fileRefLookup`) or pass a merged lookup.
|
|
393
|
+
*/
|
|
394
|
+
export function checkWaveDeclaration(wave: WaveDeclaration, lookup: WaveRefLookup): WaveFinding[] {
|
|
395
|
+
const findings: WaveFinding[] = [];
|
|
396
|
+
const name = displayName(wave);
|
|
397
|
+
// A wave with neither id nor title has only NL.E1100: the other messages
|
|
398
|
+
// would have to name it "<unnamed>".
|
|
399
|
+
const nameless = !wave.name && wave.title === undefined;
|
|
400
|
+
|
|
401
|
+
if (!wave.name) {
|
|
402
|
+
findings.push({
|
|
403
|
+
severity: 'error',
|
|
404
|
+
code: 'NL.E1100',
|
|
405
|
+
args: {
|
|
406
|
+
...(wave.title === undefined ? {} : { title: singleLine(wave.title) }),
|
|
407
|
+
line: lineOf(wave),
|
|
408
|
+
},
|
|
409
|
+
node: wave,
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
if (nameless) return findings;
|
|
414
|
+
|
|
415
|
+
for (const prop of wave.properties) {
|
|
416
|
+
const key = propKey(prop);
|
|
417
|
+
if (WAVE_BANNED_KEYS.has(key)) {
|
|
418
|
+
findings.push({
|
|
419
|
+
severity: 'error',
|
|
420
|
+
code: 'NL.E1105',
|
|
421
|
+
args:
|
|
422
|
+
key === 'before' ? { reason: 'before', name } : { reason: 'other', key, name },
|
|
423
|
+
node: prop,
|
|
424
|
+
property: 'key',
|
|
425
|
+
});
|
|
426
|
+
continue;
|
|
427
|
+
}
|
|
428
|
+
if (key !== 'after') continue;
|
|
429
|
+
const vals = prop.value !== undefined ? [prop.value] : prop.values;
|
|
430
|
+
for (const ref of vals) {
|
|
431
|
+
// Dates are checked by checkInlineDatePins (E0410/E0412/E0413);
|
|
432
|
+
// an id that resolves to nothing gets only "does not resolve".
|
|
433
|
+
if (!ref || ISO_DATE_RE.test(ref)) continue;
|
|
434
|
+
const target = lookup(ref);
|
|
435
|
+
if (!target || isAnchorDeclaration(target)) continue;
|
|
436
|
+
if (isMilestoneDeclaration(target)) {
|
|
437
|
+
if (dateProp(target) !== undefined) continue;
|
|
438
|
+
findings.push({
|
|
439
|
+
severity: 'error',
|
|
440
|
+
code: 'NL.E1106',
|
|
441
|
+
args: { name, ref, kind: 'floating-milestone' },
|
|
442
|
+
node: prop,
|
|
443
|
+
});
|
|
444
|
+
continue;
|
|
445
|
+
}
|
|
446
|
+
findings.push({
|
|
447
|
+
severity: 'error',
|
|
448
|
+
code: 'NL.E1106',
|
|
449
|
+
args: { name, ref, kind: waveKindOf(target) },
|
|
450
|
+
node: prop,
|
|
451
|
+
});
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
return findings;
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
/** The S rules (WV1, WV3, WV4) for every wave declaration in the file. */
|
|
458
|
+
export function checkWaveDeclarations(file: NowlineFile): WaveFinding[] {
|
|
459
|
+
const lookup = fileRefLookup(file);
|
|
460
|
+
return file.roadmapEntries
|
|
461
|
+
.filter(isWaveDeclaration)
|
|
462
|
+
.flatMap((wave) => checkWaveDeclaration(wave, lookup));
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
// --- P rules: `wave:` properties ---
|
|
466
|
+
|
|
467
|
+
type W0702Target = MessageArgs<'NL.W0702'>[0]['target'];
|
|
468
|
+
type W0702Kind = Exclude<W0702Target, { kind: 'default' }>['kind'];
|
|
469
|
+
|
|
470
|
+
// Every node that can carry a `wave:` key, outside wave declarations (the S
|
|
471
|
+
// rules own those): `default <entity>` lines, the roadmap line, roadmap
|
|
472
|
+
// entries and their content, and teams nested in teams.
|
|
473
|
+
function waveHosts(file: NowlineFile): DeclarationNode[] {
|
|
474
|
+
return [...declarations(file, { config: true, roadmap: true })].filter((node) =>
|
|
475
|
+
isConfigEntry(node) ? isDefaultDeclaration(node) : !isWaveDeclaration(node),
|
|
476
|
+
);
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
// WV6 suggestion: a wave whose title matches the value (case-insensitive),
|
|
480
|
+
// else the unique closest id within two edits.
|
|
481
|
+
function suggestWave(value: string, waves: WaveDeclaration[]): WaveSuggestion | undefined {
|
|
482
|
+
const lower = value.toLowerCase();
|
|
483
|
+
const byTitle = waves.filter(
|
|
484
|
+
(w) => w.title !== undefined && singleLine(w.title).toLowerCase() === lower,
|
|
485
|
+
);
|
|
486
|
+
let match: WaveDeclaration | undefined;
|
|
487
|
+
if (byTitle.length === 1) {
|
|
488
|
+
match = byTitle[0];
|
|
489
|
+
} else {
|
|
490
|
+
const id = suggestUniqueKey(
|
|
491
|
+
value,
|
|
492
|
+
waves.map((w) => w.name as string),
|
|
493
|
+
);
|
|
494
|
+
match = id === undefined ? undefined : waves.find((w) => w.name === id);
|
|
495
|
+
}
|
|
496
|
+
if (!match) return undefined;
|
|
497
|
+
return match.title === undefined
|
|
498
|
+
? { id: match.name as string }
|
|
499
|
+
: { id: match.name as string, title: singleLine(match.title) };
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
// What a non-wave id names, for WV6 `not-a-wave`: roadmap declarations first,
|
|
503
|
+
// then config styles and symbols.
|
|
504
|
+
function nonWaveKind(
|
|
505
|
+
file: NowlineFile,
|
|
506
|
+
value: string,
|
|
507
|
+
lookup: WaveRefLookup,
|
|
508
|
+
): WaveKind | undefined {
|
|
509
|
+
const target = lookup(value);
|
|
510
|
+
if (target) return waveKindOf(target);
|
|
511
|
+
for (const entry of file.configEntries) {
|
|
512
|
+
if ((isStyleDeclaration(entry) || isSymbolDeclaration(entry)) && entry.name === value) {
|
|
513
|
+
return waveKindOf(entry);
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
return undefined;
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
// The nearest enclosing group or parallel that carries a `wave:` key. An
|
|
520
|
+
// enclosing `wave:` that failed WV6 stops the walk: that container is
|
|
521
|
+
// background, so it imposes nothing on its descendants (cascade control).
|
|
522
|
+
function nearestWaveContainer(
|
|
523
|
+
node: AstNode,
|
|
524
|
+
waveIds: ReadonlyMap<string, number>,
|
|
525
|
+
): { container: AstNode; prop: EntityProperty } | undefined {
|
|
526
|
+
let n = node.$container;
|
|
527
|
+
while (isWaveContainer(n)) {
|
|
528
|
+
const prop = waveProp(n as AstNode);
|
|
529
|
+
if (prop) {
|
|
530
|
+
const v = classifyWaveValue(prop, n as AstNode, waveIds);
|
|
531
|
+
return v.status === 'valid' ? { container: n as AstNode, prop } : undefined;
|
|
532
|
+
}
|
|
533
|
+
n = n?.$container;
|
|
534
|
+
}
|
|
535
|
+
return undefined;
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
// An entity or container as the E1102 message names it: its id or title, or
|
|
539
|
+
// its line when it has neither.
|
|
540
|
+
function e1102Ref<K extends 'item' | 'group' | 'parallel'>(
|
|
541
|
+
kind: K,
|
|
542
|
+
node: AstNode & { name?: string; title?: string },
|
|
543
|
+
): { kind: K; name: string; line?: number } {
|
|
544
|
+
const name = node.name ?? (node.title === undefined ? '' : singleLine(node.title));
|
|
545
|
+
return name ? { kind, name } : { kind, name, line: lineOf(node) };
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
// The NL.W0702 target: a default line by its entity type, anything else by
|
|
549
|
+
// its id or title, or by its line when it has neither (an anonymous block).
|
|
550
|
+
function w0702Target(node: AstNode): W0702Target {
|
|
551
|
+
if (isDefaultDeclaration(node)) return { kind: 'default', entityType: node.entityType };
|
|
552
|
+
const named = node as AstNode & { name?: string; title?: string };
|
|
553
|
+
const name = named.name ?? (named.title === undefined ? '' : singleLine(named.title));
|
|
554
|
+
const kind = waveKindOf(node) as W0702Kind;
|
|
555
|
+
return name ? { kind, name } : { kind, name, line: lineOf(node) };
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
// WV6 and WV7 for the `wave:` key that applies to an item, group or parallel.
|
|
559
|
+
function checkWaveValue(
|
|
560
|
+
file: NowlineFile,
|
|
561
|
+
node: AstNode,
|
|
562
|
+
prop: EntityProperty,
|
|
563
|
+
waves: WaveDeclaration[],
|
|
564
|
+
waveIds: ReadonlyMap<string, number>,
|
|
565
|
+
lookup: WaveRefLookup,
|
|
566
|
+
): WaveFinding | undefined {
|
|
567
|
+
const v = classifyWaveValue(prop, node, waveIds);
|
|
568
|
+
switch (v.status) {
|
|
569
|
+
case 'list':
|
|
570
|
+
return {
|
|
571
|
+
severity: 'error',
|
|
572
|
+
code: 'NL.E1101',
|
|
573
|
+
args: { reason: 'list', value: v.value },
|
|
574
|
+
node: prop,
|
|
575
|
+
};
|
|
576
|
+
case 'forward':
|
|
577
|
+
return {
|
|
578
|
+
severity: 'error',
|
|
579
|
+
code: 'NL.E1101',
|
|
580
|
+
args: { reason: 'forward', value: v.value, line: v.line },
|
|
581
|
+
node: prop,
|
|
582
|
+
};
|
|
583
|
+
case 'missing': {
|
|
584
|
+
const kind = nonWaveKind(file, v.value, lookup);
|
|
585
|
+
const suggestion = suggestWave(v.value, waves);
|
|
586
|
+
return {
|
|
587
|
+
severity: 'error',
|
|
588
|
+
code: 'NL.E1101',
|
|
589
|
+
args:
|
|
590
|
+
kind === undefined
|
|
591
|
+
? {
|
|
592
|
+
reason: 'unknown',
|
|
593
|
+
value: v.value,
|
|
594
|
+
declared: waves.map((w) => w.name as string),
|
|
595
|
+
...(suggestion ? { suggestion } : {}),
|
|
596
|
+
}
|
|
597
|
+
: {
|
|
598
|
+
reason: 'not-a-wave',
|
|
599
|
+
value: v.value,
|
|
600
|
+
kind,
|
|
601
|
+
...(suggestion ? { suggestion } : {}),
|
|
602
|
+
},
|
|
603
|
+
node: prop,
|
|
604
|
+
};
|
|
605
|
+
}
|
|
606
|
+
case 'valid':
|
|
607
|
+
break;
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
const outer = nearestWaveContainer(node, waveIds);
|
|
611
|
+
if (!outer) return undefined;
|
|
612
|
+
const containerWave = waveValueText(outer.prop);
|
|
613
|
+
if (containerWave === v.id) return undefined;
|
|
614
|
+
const entityKind = isItemDeclaration(node) ? 'item' : isGroupBlock(node) ? 'group' : 'parallel';
|
|
615
|
+
return {
|
|
616
|
+
severity: 'error',
|
|
617
|
+
code: 'NL.E1102',
|
|
618
|
+
args: {
|
|
619
|
+
entity: e1102Ref(entityKind, node as AstNode & { name?: string; title?: string }),
|
|
620
|
+
wave: v.id,
|
|
621
|
+
container: e1102Ref(
|
|
622
|
+
isGroupBlock(outer.container) ? 'group' : 'parallel',
|
|
623
|
+
outer.container as AstNode & { name?: string; title?: string },
|
|
624
|
+
),
|
|
625
|
+
containerWave,
|
|
626
|
+
},
|
|
627
|
+
node: prop,
|
|
628
|
+
};
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
/**
|
|
632
|
+
* The P rules (WV5-WV9) for every `wave:` key in the file.
|
|
633
|
+
*
|
|
634
|
+
* - With no waves (WV9), each `wave:` key gets one NL.W0702 and nothing else.
|
|
635
|
+
* - With waves: each `wave:` key on a `default <entity>` line gets the
|
|
636
|
+
* rule-23 error (WV8); each one on an entity other than item, group and
|
|
637
|
+
* parallel gets NL.E1104 (WV5). On item, group and parallel the first key
|
|
638
|
+
* is checked by WV6 (NL.E1101) and, when valid, against the enclosing
|
|
639
|
+
* container's wave by WV7 (NL.E1102); each repeated key is NL.E1101
|
|
640
|
+
* `list`.
|
|
641
|
+
*/
|
|
642
|
+
export function evaluateWaveProperties(file: NowlineFile): WaveFinding[] {
|
|
643
|
+
const waves = ownWaves(file);
|
|
644
|
+
const hasWaves = waves.length > 0;
|
|
645
|
+
const waveIds = waveIndexMap(file);
|
|
646
|
+
const lookup = fileRefLookup(file);
|
|
647
|
+
const findings: WaveFinding[] = [];
|
|
648
|
+
|
|
649
|
+
for (const node of waveHosts(file)) {
|
|
650
|
+
const props = waveProps(node);
|
|
651
|
+
if (props.length === 0) continue;
|
|
652
|
+
|
|
653
|
+
if (!hasWaves) {
|
|
654
|
+
for (const prop of props) {
|
|
655
|
+
findings.push({
|
|
656
|
+
severity: 'warning',
|
|
657
|
+
code: 'NL.W0702',
|
|
658
|
+
args: { target: w0702Target(node) },
|
|
659
|
+
node: prop,
|
|
660
|
+
property: 'key',
|
|
661
|
+
});
|
|
662
|
+
}
|
|
663
|
+
continue;
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
if (isDefaultDeclaration(node)) {
|
|
667
|
+
for (const prop of props) {
|
|
668
|
+
findings.push({
|
|
669
|
+
severity: 'error',
|
|
670
|
+
message: defaultBannedMessage('wave', node.entityType),
|
|
671
|
+
node: prop,
|
|
672
|
+
});
|
|
673
|
+
}
|
|
674
|
+
continue;
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
const named = node as AstNode & { name?: string; title?: string };
|
|
678
|
+
const name = displayName(named);
|
|
679
|
+
const nameless = !named.name && named.title === undefined;
|
|
680
|
+
// NL.E0301 already reports an entity with neither id nor title, and
|
|
681
|
+
// NL.E1104 would have to name it "<unnamed>".
|
|
682
|
+
if (nameless && !isItemDeclaration(node) && !isGroupBlock(node) && !isParallelBlock(node)) {
|
|
683
|
+
continue;
|
|
684
|
+
}
|
|
685
|
+
if (isSwimlaneDeclaration(node) || isMilestoneDeclaration(node)) {
|
|
686
|
+
for (const prop of props) {
|
|
687
|
+
findings.push({
|
|
688
|
+
severity: 'error',
|
|
689
|
+
code: 'NL.E1104',
|
|
690
|
+
args: {
|
|
691
|
+
reason: isSwimlaneDeclaration(node) ? 'swimlane' : 'milestone',
|
|
692
|
+
name,
|
|
693
|
+
value: waveValueText(prop),
|
|
694
|
+
},
|
|
695
|
+
node: prop,
|
|
696
|
+
});
|
|
697
|
+
}
|
|
698
|
+
continue;
|
|
699
|
+
}
|
|
700
|
+
if (!isItemDeclaration(node) && !isGroupBlock(node) && !isParallelBlock(node)) {
|
|
701
|
+
for (const prop of props) {
|
|
702
|
+
findings.push({
|
|
703
|
+
severity: 'error',
|
|
704
|
+
code: 'NL.E1104',
|
|
705
|
+
args: { reason: 'other', type: waveKindOf(node), name },
|
|
706
|
+
node: prop,
|
|
707
|
+
});
|
|
708
|
+
}
|
|
709
|
+
continue;
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
const [prop, ...repeated] = props;
|
|
713
|
+
const finding = checkWaveValue(file, node, prop, waves, waveIds, lookup);
|
|
714
|
+
if (finding) findings.push(finding);
|
|
715
|
+
// WV6: a repeated `wave:` key gives the entity more than one wave.
|
|
716
|
+
// The first key still applies (`ew`); each later key is
|
|
717
|
+
// reported with every value the entity names.
|
|
718
|
+
if (repeated.length > 0) {
|
|
719
|
+
const all = props.flatMap((p) => (p.value !== undefined ? [p.value] : p.values));
|
|
720
|
+
for (const extra of repeated) {
|
|
721
|
+
findings.push({
|
|
722
|
+
severity: 'error',
|
|
723
|
+
code: 'NL.E1101',
|
|
724
|
+
args: { reason: 'list', value: `[${all.join(', ')}]` },
|
|
725
|
+
node: extra,
|
|
726
|
+
});
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
return findings;
|
|
731
|
+
}
|