@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,462 +1,40 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
AstNode,
|
|
3
|
-
Properties,
|
|
4
|
-
ValidationAcceptor,
|
|
5
|
-
ValidationChecks,
|
|
6
|
-
ValidationSeverity,
|
|
7
|
-
} from 'langium';
|
|
8
|
-
import { GrammarUtils } from 'langium';
|
|
1
|
+
import type { AstNode, ValidationAcceptor, ValidationChecks } from 'langium';
|
|
9
2
|
import type {
|
|
10
3
|
AnchorDeclaration,
|
|
11
4
|
CalendarBlock,
|
|
12
5
|
DefaultDeclaration,
|
|
13
|
-
DefaultEntityType,
|
|
14
6
|
EntityProperty,
|
|
15
7
|
FootnoteDeclaration,
|
|
16
8
|
GroupBlock,
|
|
17
|
-
GroupContent,
|
|
18
9
|
IncludeDeclaration,
|
|
19
10
|
IncludeOption,
|
|
20
11
|
ItemDeclaration,
|
|
21
12
|
MilestoneDeclaration,
|
|
13
|
+
NonWorkingDeclaration,
|
|
22
14
|
NowlineDirective,
|
|
23
15
|
NowlineFile,
|
|
24
16
|
ParallelBlock,
|
|
25
|
-
ParallelContent,
|
|
26
|
-
PersonDeclaration,
|
|
27
17
|
RoadmapDeclaration,
|
|
28
|
-
RoadmapEntry,
|
|
29
18
|
ScaleBlock,
|
|
30
19
|
SizeDeclaration,
|
|
31
20
|
StatusDeclaration,
|
|
32
21
|
StyleProperty,
|
|
33
|
-
SwimlaneContent,
|
|
34
22
|
SwimlaneDeclaration,
|
|
35
23
|
SymbolDeclaration,
|
|
36
|
-
|
|
37
|
-
} from '../generated/ast.js';
|
|
38
|
-
import {
|
|
39
|
-
isAnchorDeclaration,
|
|
40
|
-
isCalendarBlock,
|
|
41
|
-
isDefaultDeclaration,
|
|
42
|
-
isDescriptionDirective,
|
|
43
|
-
isFootnoteDeclaration,
|
|
44
|
-
isGroupBlock,
|
|
45
|
-
isItemDeclaration,
|
|
46
|
-
isLabelDeclaration,
|
|
47
|
-
isMilestoneDeclaration,
|
|
48
|
-
isParallelBlock,
|
|
49
|
-
isPersonDeclaration,
|
|
50
|
-
isPersonMemberRef,
|
|
51
|
-
isSizeDeclaration,
|
|
52
|
-
isStatusDeclaration,
|
|
53
|
-
isStyleDeclaration,
|
|
54
|
-
isSwimlaneDeclaration,
|
|
55
|
-
isSymbolDeclaration,
|
|
56
|
-
isTeamDeclaration,
|
|
24
|
+
WorkingDeclaration,
|
|
57
25
|
} from '../generated/ast.js';
|
|
58
|
-
import
|
|
59
|
-
import { tr } from '../i18n/index.js';
|
|
26
|
+
import { isSwimlaneDeclaration } from '../generated/ast.js';
|
|
60
27
|
import type { NowlineAstType, NowlineServices } from './nowline-module.js';
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
'in-progress',
|
|
72
|
-
'active',
|
|
73
|
-
'done',
|
|
74
|
-
'completed',
|
|
75
|
-
'at-risk',
|
|
76
|
-
'blocked',
|
|
77
|
-
]);
|
|
78
|
-
|
|
79
|
-
const STYLE_PROP_KEYS = new Set([
|
|
80
|
-
'bg',
|
|
81
|
-
'fg',
|
|
82
|
-
'text',
|
|
83
|
-
'border',
|
|
84
|
-
'icon',
|
|
85
|
-
'shadow',
|
|
86
|
-
'font',
|
|
87
|
-
'weight',
|
|
88
|
-
'italic',
|
|
89
|
-
'text-size',
|
|
90
|
-
'padding',
|
|
91
|
-
'spacing',
|
|
92
|
-
'header-height',
|
|
93
|
-
'corner-radius',
|
|
94
|
-
'bracket',
|
|
95
|
-
'header-position',
|
|
96
|
-
'capacity-icon',
|
|
97
|
-
'timeline-position',
|
|
98
|
-
'minor-grid',
|
|
99
|
-
]);
|
|
100
|
-
|
|
101
|
-
// Built-in capacity-icon vocabulary. Renderer-curated SVG glyphs (plus 'multiplier'
|
|
102
|
-
// which renders as the U+00D7 text character and 'none' which suppresses the glyph).
|
|
103
|
-
const BUILTIN_CAPACITY_ICONS = new Set([
|
|
104
|
-
'none',
|
|
105
|
-
'multiplier',
|
|
106
|
-
'person',
|
|
107
|
-
'people',
|
|
108
|
-
'points',
|
|
109
|
-
'time',
|
|
110
|
-
]);
|
|
111
|
-
|
|
112
|
-
// Built-in icon: vocabulary. Superset of capacity-icon names plus the entity-decoration
|
|
113
|
-
// icons currently shipped by the renderer. `calendar` is the renderer-side glyph the
|
|
114
|
-
// inline-date pin path (`after:DATE` / `before:DATE`) draws onto items, parallels, and
|
|
115
|
-
// groups; reserving it here prevents a `symbol calendar` declaration from shadowing it.
|
|
116
|
-
const BUILTIN_ICON_NAMES = new Set([
|
|
117
|
-
...BUILTIN_CAPACITY_ICONS,
|
|
118
|
-
'shield',
|
|
119
|
-
'warning',
|
|
120
|
-
'lock',
|
|
121
|
-
'calendar',
|
|
122
|
-
]);
|
|
123
|
-
|
|
124
|
-
// `utilization-warn-at:` / `utilization-over-at:` accept the literal `none`
|
|
125
|
-
// to opt out of that color band (per specs/dsl.md rule 17d). Numeric forms
|
|
126
|
-
// (positive percent, decimal, integer) are validated separately via
|
|
127
|
-
// POSITIVE_NUMBER_RE / POSITIVE_PERCENT_RE.
|
|
128
|
-
const UTILIZATION_NONE = 'none';
|
|
129
|
-
|
|
130
|
-
const STYLE_PROP_ENUMS: Record<string, Set<string>> = {
|
|
131
|
-
border: new Set(['solid', 'dashed', 'dotted']),
|
|
132
|
-
shadow: new Set(['none', 'subtle', 'soft', 'hard']),
|
|
133
|
-
font: new Set(['sans', 'serif', 'mono']),
|
|
134
|
-
weight: new Set(['thin', 'light', 'normal', 'bold']),
|
|
135
|
-
italic: new Set(['true', 'false']),
|
|
136
|
-
'text-size': new Set(['none', 'xs', 'sm', 'md', 'lg', 'xl']),
|
|
137
|
-
padding: new Set(['none', 'xs', 'sm', 'md', 'lg', 'xl']),
|
|
138
|
-
spacing: new Set(['none', 'xs', 'sm', 'md', 'lg', 'xl']),
|
|
139
|
-
'header-height': new Set(['none', 'xs', 'sm', 'md', 'lg', 'xl']),
|
|
140
|
-
'corner-radius': new Set(['none', 'xs', 'sm', 'md', 'lg', 'xl', 'full']),
|
|
141
|
-
bracket: new Set(['none', 'solid', 'dashed']),
|
|
142
|
-
'header-position': new Set(['beside', 'above']),
|
|
143
|
-
'timeline-position': new Set(['top', 'bottom', 'both']),
|
|
144
|
-
'minor-grid': new Set(['true', 'false']),
|
|
145
|
-
};
|
|
146
|
-
|
|
147
|
-
// Built-in color vocabulary. `grey` and `violet` are international-friendly
|
|
148
|
-
// aliases for `gray` and `purple` — they canonicalize at the theme
|
|
149
|
-
// boundary (resolveColor in packages/layout/src/themes/index.ts) so themes
|
|
150
|
-
// don't grow new fields. Both spellings remain valid input.
|
|
151
|
-
const COLOR_NAMES = new Set([
|
|
152
|
-
'red',
|
|
153
|
-
'blue',
|
|
154
|
-
'yellow',
|
|
155
|
-
'green',
|
|
156
|
-
'orange',
|
|
157
|
-
'purple',
|
|
158
|
-
'violet',
|
|
159
|
-
'gray',
|
|
160
|
-
'grey',
|
|
161
|
-
'navy',
|
|
162
|
-
'white',
|
|
163
|
-
'none',
|
|
164
|
-
]);
|
|
165
|
-
|
|
166
|
-
const CALENDAR_MODES = new Set(['business', 'full', 'custom']);
|
|
167
|
-
|
|
168
|
-
const CALENDAR_FIELDS = new Set([
|
|
169
|
-
'days-per-week',
|
|
170
|
-
'days-per-month',
|
|
171
|
-
'days-per-quarter',
|
|
172
|
-
'days-per-year',
|
|
173
|
-
]);
|
|
174
|
-
|
|
175
|
-
const SCALE_FIELDS = new Set(['name', 'label-every', 'label']);
|
|
176
|
-
|
|
177
|
-
const DEFAULT_ENTITY_TYPES = new Set([
|
|
178
|
-
'item',
|
|
179
|
-
'label',
|
|
180
|
-
'swimlane',
|
|
181
|
-
'roadmap',
|
|
182
|
-
'milestone',
|
|
183
|
-
'footnote',
|
|
184
|
-
'anchor',
|
|
185
|
-
'parallel',
|
|
186
|
-
'group',
|
|
187
|
-
]);
|
|
188
|
-
|
|
189
|
-
// Banned properties per entity type on `default <entity>` lines.
|
|
190
|
-
// `capacity` on `default swimlane` is banned because each lane's budget must be
|
|
191
|
-
// explicit at its declaration site (per dsl.md). `capacity` on `default item` is
|
|
192
|
-
// allowed (and a useful "every item consumes 1 unit by default" lever).
|
|
193
|
-
const DEFAULT_BANNED: Record<DefaultEntityType, Set<string>> = {
|
|
194
|
-
item: new Set([
|
|
195
|
-
'size',
|
|
196
|
-
'duration',
|
|
197
|
-
'after',
|
|
198
|
-
'before',
|
|
199
|
-
'remaining',
|
|
200
|
-
'link',
|
|
201
|
-
'description',
|
|
202
|
-
'owner',
|
|
203
|
-
]),
|
|
204
|
-
milestone: new Set(['date', 'after', 'link', 'description']),
|
|
205
|
-
anchor: new Set(['date', 'link', 'description']),
|
|
206
|
-
footnote: new Set(['on', 'link', 'description']),
|
|
207
|
-
label: new Set(['link', 'description']),
|
|
208
|
-
swimlane: new Set(['capacity']),
|
|
209
|
-
roadmap: new Set(),
|
|
210
|
-
parallel: new Set(),
|
|
211
|
-
group: new Set(),
|
|
212
|
-
};
|
|
213
|
-
|
|
214
|
-
// Properties every entity declaration may carry (`specs/dsl.md` § Universal Properties).
|
|
215
|
-
// `description` is technically a sub-directive (`description "text"` indented under the
|
|
216
|
-
// entity), not an EntityProperty, but we accept it here too: authors who type
|
|
217
|
-
// `description:"text"` as a property aren't doing anything meaningful, but the typo is
|
|
218
|
-
// common enough that warning on it adds noise rather than signal — the value is at
|
|
219
|
-
// least carried into the AST and could be surfaced later if we choose to.
|
|
220
|
-
const UNIVERSAL_ENTITY_PROPS = new Set(['labels', 'link', 'style', 'description']);
|
|
221
|
-
|
|
222
|
-
// Properties each entity declaration's `properties: EntityProperty[]` bag actually
|
|
223
|
-
// consumes downstream. Sourced from (a) the property tables in `specs/dsl.md` and
|
|
224
|
-
// (b) every `propValue(...)`/`propValues(...)` call site in `packages/layout/`. Keys
|
|
225
|
-
// outside this set + `UNIVERSAL_ENTITY_PROPS` are silently dropped by the layout —
|
|
226
|
-
// `checkUnknownEntityProperties` warns on them so authors notice typos like
|
|
227
|
-
// `now:2026-01-25` on a `roadmap` line.
|
|
228
|
-
//
|
|
229
|
-
// Raw style props (`bg`, `fg`, ...) intentionally stay OUT of this map — they are
|
|
230
|
-
// rejected as errors by `checkNoRawStyleProperties` and the unknown-property check
|
|
231
|
-
// short-circuits on them so authors don't see a duplicate diagnostic.
|
|
232
|
-
const ENTITY_KNOWN_PROPS: Record<string, Set<string>> = {
|
|
233
|
-
RoadmapDeclaration: new Set([
|
|
234
|
-
'author',
|
|
235
|
-
'start',
|
|
236
|
-
'length',
|
|
237
|
-
'scale',
|
|
238
|
-
'calendar',
|
|
239
|
-
'logo',
|
|
240
|
-
'logo-size',
|
|
241
|
-
]),
|
|
242
|
-
AnchorDeclaration: new Set(['date']),
|
|
243
|
-
SwimlaneDeclaration: new Set([
|
|
244
|
-
'owner',
|
|
245
|
-
'capacity',
|
|
246
|
-
'utilization-warn-at',
|
|
247
|
-
'utilization-over-at',
|
|
248
|
-
'status',
|
|
249
|
-
'after',
|
|
250
|
-
'before',
|
|
251
|
-
]),
|
|
252
|
-
// `date:` and `start:` on items are read by `packages/layout/src/layout.ts`
|
|
253
|
-
// (`resolveChildStart`, `walkNode`) to pin an item to a fixed start date. Not
|
|
254
|
-
// documented in `specs/dsl.md` yet — left allow-listed so authors don't see
|
|
255
|
-
// a spurious warning for a working code path. See plan's out-of-scope note.
|
|
256
|
-
ItemDeclaration: new Set([
|
|
257
|
-
'size',
|
|
258
|
-
'duration',
|
|
259
|
-
'status',
|
|
260
|
-
'owner',
|
|
261
|
-
'after',
|
|
262
|
-
'before',
|
|
263
|
-
'remaining',
|
|
264
|
-
'capacity',
|
|
265
|
-
'date',
|
|
266
|
-
'start',
|
|
267
|
-
]),
|
|
268
|
-
// size/duration/remaining/capacity on parallel/group are already errors via
|
|
269
|
-
// `checkNoComputedProperties`, so we don't list them here.
|
|
270
|
-
ParallelBlock: new Set(['owner', 'after', 'before', 'status']),
|
|
271
|
-
GroupBlock: new Set(['owner', 'after', 'before', 'status']),
|
|
272
|
-
MilestoneDeclaration: new Set(['date', 'after']),
|
|
273
|
-
FootnoteDeclaration: new Set(['on']),
|
|
274
|
-
PersonDeclaration: new Set(),
|
|
275
|
-
TeamDeclaration: new Set(),
|
|
276
|
-
LabelDeclaration: new Set(),
|
|
277
|
-
SizeDeclaration: new Set(['effort']),
|
|
278
|
-
StatusDeclaration: new Set(),
|
|
279
|
-
};
|
|
280
|
-
|
|
281
|
-
// Levenshtein distance with an early-exit cap: returns `cap + 1` once the running
|
|
282
|
-
// minimum exceeds the cap so we can short-circuit the matcher in the common case
|
|
283
|
-
// where the typo is much further than 2 edits from any valid key. The helper is
|
|
284
|
-
// only used by `checkUnknownEntityProperties` for the "did you mean?" suggestion.
|
|
285
|
-
function levenshteinCapped(a: string, b: string, cap: number): number {
|
|
286
|
-
if (a === b) return 0;
|
|
287
|
-
const an = a.length;
|
|
288
|
-
const bn = b.length;
|
|
289
|
-
if (Math.abs(an - bn) > cap) return cap + 1;
|
|
290
|
-
if (an === 0) return bn;
|
|
291
|
-
if (bn === 0) return an;
|
|
292
|
-
let prev = new Array<number>(bn + 1);
|
|
293
|
-
let curr = new Array<number>(bn + 1);
|
|
294
|
-
for (let j = 0; j <= bn; j++) prev[j] = j;
|
|
295
|
-
for (let i = 1; i <= an; i++) {
|
|
296
|
-
curr[0] = i;
|
|
297
|
-
let rowMin = i;
|
|
298
|
-
for (let j = 1; j <= bn; j++) {
|
|
299
|
-
const cost = a.charCodeAt(i - 1) === b.charCodeAt(j - 1) ? 0 : 1;
|
|
300
|
-
curr[j] = Math.min(
|
|
301
|
-
prev[j] + 1, // deletion
|
|
302
|
-
curr[j - 1] + 1, // insertion
|
|
303
|
-
prev[j - 1] + cost, // substitution
|
|
304
|
-
);
|
|
305
|
-
if (curr[j] < rowMin) rowMin = curr[j];
|
|
306
|
-
}
|
|
307
|
-
if (rowMin > cap) return cap + 1;
|
|
308
|
-
const tmp = prev;
|
|
309
|
-
prev = curr;
|
|
310
|
-
curr = tmp;
|
|
311
|
-
}
|
|
312
|
-
return prev[bn];
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
// Pick the closest known key within `cap` edits of `key`, or undefined. Ties are
|
|
316
|
-
// broken by the order of `candidates`, so callers should pass entity-specific keys
|
|
317
|
-
// first when both lists are searched.
|
|
318
|
-
function suggestKey(key: string, candidates: Iterable<string>, cap = 2): string | undefined {
|
|
319
|
-
let best: string | undefined;
|
|
320
|
-
let bestDist = cap + 1;
|
|
321
|
-
for (const c of candidates) {
|
|
322
|
-
const d = levenshteinCapped(key, c, cap);
|
|
323
|
-
if (d < bestDist) {
|
|
324
|
-
best = c;
|
|
325
|
-
bestDist = d;
|
|
326
|
-
if (d === 0) break;
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
return best;
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
// Conceptual mistakes that aren't typos of a real key — e.g. `progress:60` is a
|
|
333
|
-
// reasonable guess for "60% done", but Nowline models completion as
|
|
334
|
-
// `status:` + `remaining:` (work *left*). Levenshtein can't bridge that gap, so
|
|
335
|
-
// we map the concept directly. `requires` names a key the entity must support,
|
|
336
|
-
// so the hint only fires where it's actionable (e.g. on an `item`, which has
|
|
337
|
-
// `remaining`, not on a `roadmap` line).
|
|
338
|
-
const CONCEPT_ALIASES: ReadonlyArray<{
|
|
339
|
-
keys: ReadonlySet<string>;
|
|
340
|
-
requires: string;
|
|
341
|
-
suggest: string;
|
|
342
|
-
}> = [
|
|
343
|
-
{
|
|
344
|
-
keys: new Set(['progress', 'percent', 'percentage', 'pct', 'complete', 'completion']),
|
|
345
|
-
requires: 'remaining',
|
|
346
|
-
suggest: 'status: + remaining:',
|
|
347
|
-
},
|
|
348
|
-
];
|
|
349
|
-
|
|
350
|
-
// Suggest the canonical property (or combination) for a known conceptual
|
|
351
|
-
// mistake, gated to entities that actually support the target key. Returns
|
|
352
|
-
// undefined when no concept matches so callers fall back to `suggestKey`.
|
|
353
|
-
function suggestConcept(key: string, known: ReadonlySet<string>): string | undefined {
|
|
354
|
-
const lower = key.toLowerCase();
|
|
355
|
-
for (const alias of CONCEPT_ALIASES) {
|
|
356
|
-
if (alias.keys.has(lower) && known.has(alias.requires)) return alias.suggest;
|
|
357
|
-
}
|
|
358
|
-
return undefined;
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
function propKey(prop: { key: string }): string {
|
|
362
|
-
return prop.key.endsWith(':') ? prop.key.slice(0, -1) : prop.key;
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
// Matches duration literals including decimals, e.g. `2w`, `0.5d`, `1.5m`.
|
|
366
|
-
const DURATION_RE = /^\d+(?:\.\d+)?[dwmqy]$/;
|
|
367
|
-
const PERCENTAGE_RE = /^\d+%$/;
|
|
368
|
-
const DATE_RE = /^\d{4}-\d{2}-\d{2}$/;
|
|
369
|
-
const HEX_COLOR_RE = /^#[0-9a-fA-F]{3,8}$/;
|
|
370
|
-
const VERSION_RE = /^v\d+$/;
|
|
371
|
-
const INTEGER_RE = /^\d+$/;
|
|
372
|
-
const BARE_DURATION_SUFFIX_RE = /^[dwmqy]$/;
|
|
373
|
-
// Capacity numeric forms — the grammar already separates DECIMAL/INTEGER/PERCENTAGE
|
|
374
|
-
// terminals, but the validator needs to enforce the spec's "positive number" rule
|
|
375
|
-
// and to differentiate where percent is allowed (item) vs. banned (swimlane).
|
|
376
|
-
const POSITIVE_NUMBER_RE = /^\d+(\.\d+)?$/;
|
|
377
|
-
const POSITIVE_PERCENT_RE = /^\d+(\.\d+)?%$/;
|
|
378
|
-
// Disambiguated forms used by `utilization-warn-at:` / `utilization-over-at:`.
|
|
379
|
-
// A decimal-fraction MUST include the dot so its meaning is unambiguous; a
|
|
380
|
-
// bare integer matches the integer regex and is rejected by the validator
|
|
381
|
-
// with a hint to switch to either the percent or decimal-fraction form.
|
|
382
|
-
const POSITIVE_DECIMAL_FRACTION_RE = /^\d+\.\d+$/;
|
|
383
|
-
const POSITIVE_INTEGER_RE = /^\d+$/;
|
|
384
|
-
// ASCII printable, length 1-3 — used by the glyph declaration validator for the
|
|
385
|
-
// `ascii:"..."` fallback property after Langium has stripped the surrounding quotes.
|
|
386
|
-
const ASCII_FALLBACK_RE = /^[\x20-\x7E]{1,3}$/;
|
|
387
|
-
|
|
388
|
-
// BCP-47 language tag, simplified to the subset Nowline cares about: a 2- or 3-letter
|
|
389
|
-
// primary language subtag followed by an optional region subtag (2 letters or 3 digits).
|
|
390
|
-
// Permissive enough for `fr`, `fr-CA`, `zh-CN`, `es-419` while rejecting obvious typos.
|
|
391
|
-
// The runtime resolver does the actual fallback work; this regex just gates input shape.
|
|
392
|
-
const BCP47_RE = /^[a-zA-Z]{2,3}(-[a-zA-Z]{2}|-\d{3})?$/;
|
|
393
|
-
|
|
394
|
-
const INCLUDE_MODES = new Set(['merge', 'ignore', 'isolate']);
|
|
395
|
-
|
|
396
|
-
// Allow-listed property keys on the `nowline` directive line. The directive existed
|
|
397
|
-
// historically as `nowline v1` only; properties are a forward-extension point but stay
|
|
398
|
-
// restrictive so authors get an early error instead of typos rendering silently.
|
|
399
|
-
const DIRECTIVE_FIELDS = new Set(['locale']);
|
|
400
|
-
|
|
401
|
-
type StartState =
|
|
402
|
-
| { kind: 'valid'; iso: string; date: Date }
|
|
403
|
-
| { kind: 'invalid' }
|
|
404
|
-
| { kind: 'missing' };
|
|
405
|
-
|
|
406
|
-
function resolveLocalStart(file: NowlineFile | undefined): StartState {
|
|
407
|
-
const prop = file?.roadmapDecl?.properties.find((p) => propKey(p) === 'start');
|
|
408
|
-
if (!prop) return { kind: 'missing' };
|
|
409
|
-
const raw = prop.value;
|
|
410
|
-
if (!raw || !DATE_RE.test(raw)) return { kind: 'invalid' };
|
|
411
|
-
const d = new Date(raw);
|
|
412
|
-
if (Number.isNaN(d.getTime())) return { kind: 'invalid' };
|
|
413
|
-
return { kind: 'valid', iso: raw, date: d };
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
function displayName(node: { name?: string; title?: string }): string {
|
|
417
|
-
return node.name ?? node.title ?? '<unnamed>';
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
/**
|
|
421
|
-
* Returns the lowercase entity-type label for an AST node, suitable for
|
|
422
|
-
* embedding inside a validator message (e.g. `"item"`, `"milestone"`,
|
|
423
|
-
* `"swimlane"`). Mirrors `describeNode`'s normalization (strip
|
|
424
|
-
* `Declaration` / `Block` suffix, lowercase) but returns just the type so
|
|
425
|
-
* callers can compose their own message.
|
|
426
|
-
*/
|
|
427
|
-
function entityTypeLabel(node: AstNode): string {
|
|
428
|
-
return node.$type.replace(/Declaration$|Block$/, '').toLowerCase();
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
/**
|
|
432
|
-
* Emit a localized validator diagnostic.
|
|
433
|
-
*
|
|
434
|
-
* Validator runs at parse time when only the file's locale is in scope.
|
|
435
|
-
* The CLI re-formats with the operator's locale before printing —
|
|
436
|
-
* see `specs/localization.md` for the two-chain model. We always
|
|
437
|
-
* format the en-US text now so non-CLI consumers (LSP, tests) still
|
|
438
|
-
* see usable copy, and stash `{ code, args }` in `data` so the CLI
|
|
439
|
-
* can swap in the operator-locale text downstream.
|
|
440
|
-
*/
|
|
441
|
-
type DiagnosticInfo = {
|
|
442
|
-
node: AstNode;
|
|
443
|
-
property?: Properties<AstNode>;
|
|
444
|
-
keyword?: string;
|
|
445
|
-
index?: number;
|
|
446
|
-
};
|
|
447
|
-
|
|
448
|
-
function acceptTr<K extends MessageCode>(
|
|
449
|
-
accept: ValidationAcceptor,
|
|
450
|
-
severity: ValidationSeverity,
|
|
451
|
-
info: DiagnosticInfo,
|
|
452
|
-
code: K,
|
|
453
|
-
...args: MessageArgs<K>
|
|
454
|
-
): void {
|
|
455
|
-
accept(severity, tr('en-US', code, ...args), {
|
|
456
|
-
...info,
|
|
457
|
-
data: { code, args },
|
|
458
|
-
});
|
|
459
|
-
}
|
|
28
|
+
import * as calendar from './validator/calendar.js';
|
|
29
|
+
import * as entities from './validator/entities.js';
|
|
30
|
+
import * as properties from './validator/properties.js';
|
|
31
|
+
import * as references from './validator/references.js';
|
|
32
|
+
import * as structure from './validator/structure.js';
|
|
33
|
+
import * as style from './validator/style.js';
|
|
34
|
+
import { acceptWaveFinding } from './validator/support.js';
|
|
35
|
+
import * as symbols from './validator/symbols.js';
|
|
36
|
+
import { checkWaveDeclarations, evaluateWaveProperties, fileRefLookup, ownWaves } from './waves.js';
|
|
37
|
+
import { evaluateWaveOrder } from './waves-order.js';
|
|
460
38
|
|
|
461
39
|
export function registerValidationChecks(services: NowlineServices): void {
|
|
462
40
|
const registry = services.validation.ValidationRegistry;
|
|
@@ -472,11 +50,15 @@ export function registerValidationChecks(services: NowlineServices): void {
|
|
|
472
50
|
validator.checkReferenceResolution,
|
|
473
51
|
validator.checkInlineDatePins,
|
|
474
52
|
validator.checkCircularDependencies,
|
|
53
|
+
validator.checkWaves,
|
|
475
54
|
validator.checkDuplicateSizeIds,
|
|
476
55
|
validator.checkCalendarBlockConsistency,
|
|
56
|
+
validator.checkHiddenTimelineStrip,
|
|
477
57
|
validator.checkPersonDeclarations,
|
|
478
58
|
validator.checkDuplicateSymbolIds,
|
|
479
59
|
validator.checkSymbolReferences,
|
|
60
|
+
validator.checkCalendarWeek,
|
|
61
|
+
validator.checkDuplicateCalendarDeclarationIds,
|
|
480
62
|
],
|
|
481
63
|
NowlineDirective: [validator.checkDirectiveVersion, validator.checkDirectiveProperties],
|
|
482
64
|
IncludeOption: [validator.checkIncludeMode],
|
|
@@ -553,6 +135,10 @@ export function registerValidationChecks(services: NowlineServices): void {
|
|
|
553
135
|
StyleDeclaration: [validator.checkEntityIdOrTitle],
|
|
554
136
|
StyleProperty: [validator.checkStylePropertyEnum],
|
|
555
137
|
SymbolDeclaration: [validator.checkEntityIdOrTitle, validator.checkSymbolDeclaration],
|
|
138
|
+
// No checkEntityIdOrTitle: an id-less, title-less declaration is valid. The own-key
|
|
139
|
+
// check replaces checkUnknownEntityProperties, which skips `wave:` and style keys.
|
|
140
|
+
NonWorkingDeclaration: [validator.checkCalendarDeclaration],
|
|
141
|
+
WorkingDeclaration: [validator.checkCalendarDeclaration],
|
|
556
142
|
LabelDeclaration: [
|
|
557
143
|
validator.checkEntityIdOrTitle,
|
|
558
144
|
validator.checkNoRawStyleProperties,
|
|
@@ -570,6 +156,13 @@ export function registerValidationChecks(services: NowlineServices): void {
|
|
|
570
156
|
validator.checkNoRawStyleProperties,
|
|
571
157
|
validator.checkUnknownEntityProperties,
|
|
572
158
|
],
|
|
159
|
+
// No checkEntityIdOrTitle: a wave without an id is NL.E1100, not NL.E0301.
|
|
160
|
+
// The S rules run file-wide in checkWaves (one shared id lookup).
|
|
161
|
+
WaveDeclaration: [
|
|
162
|
+
validator.checkNoRawStyleProperties,
|
|
163
|
+
validator.checkNoFootnoteProperty,
|
|
164
|
+
validator.checkUnknownEntityProperties,
|
|
165
|
+
],
|
|
573
166
|
DefaultDeclaration: [validator.checkDefaultDeclaration, validator.checkUtilizationOrdering],
|
|
574
167
|
CalendarBlock: [validator.checkCalendarBlock],
|
|
575
168
|
ScaleBlock: [validator.checkScaleBlock],
|
|
@@ -578,524 +171,73 @@ export function registerValidationChecks(services: NowlineServices): void {
|
|
|
578
171
|
}
|
|
579
172
|
|
|
580
173
|
export class NowlineValidator {
|
|
581
|
-
// --- Structural Rule 4: Section order ---
|
|
582
174
|
checkFileStructure(file: NowlineFile, accept: ValidationAcceptor): void {
|
|
583
|
-
|
|
584
|
-
// INCLUDE_OPTION_KEY tokens (e.g. `config:isolate`) aren't mistaken for
|
|
585
|
-
// the top-level `config` section marker. See issue #1.
|
|
586
|
-
const configOffset = file.hasConfig
|
|
587
|
-
? GrammarUtils.findNodeForKeyword(file.$cstNode, 'config')?.offset
|
|
588
|
-
: undefined;
|
|
589
|
-
const roadmapOffset = file.roadmapDecl?.$cstNode?.offset;
|
|
590
|
-
|
|
591
|
-
if (
|
|
592
|
-
configOffset !== undefined &&
|
|
593
|
-
roadmapOffset !== undefined &&
|
|
594
|
-
configOffset > roadmapOffset
|
|
595
|
-
) {
|
|
596
|
-
acceptTr(accept, 'error', { node: file, property: 'hasConfig' }, 'NL.E0001');
|
|
597
|
-
}
|
|
598
|
-
|
|
599
|
-
for (const inc of file.includes) {
|
|
600
|
-
const incOffset = inc.$cstNode?.offset ?? 0;
|
|
601
|
-
if (configOffset !== undefined && incOffset > configOffset) {
|
|
602
|
-
acceptTr(accept, 'error', { node: inc }, 'NL.E0002');
|
|
603
|
-
}
|
|
604
|
-
if (roadmapOffset !== undefined && incOffset > roadmapOffset) {
|
|
605
|
-
acceptTr(accept, 'error', { node: inc }, 'NL.E0003');
|
|
606
|
-
}
|
|
607
|
-
}
|
|
175
|
+
structure.checkFileStructure(file, accept);
|
|
608
176
|
}
|
|
609
177
|
|
|
610
|
-
// --- Structural Rules 8/9/10: label/duration/status must live in roadmap section ---
|
|
611
|
-
// Parser enforces this by construction (these keywords are only valid as RoadmapEntry),
|
|
612
|
-
// so we mainly need to forbid custom statuses referenced before their declaration (rule 15).
|
|
613
178
|
checkRoadmapOnlyKeywordsPosition(_file: NowlineFile, _accept: ValidationAcceptor): void {
|
|
614
|
-
|
|
615
|
-
// Any attempt to declare them before `roadmap` surfaces as a parse error.
|
|
179
|
+
structure.checkRoadmapOnlyKeywordsPosition(_file, _accept);
|
|
616
180
|
}
|
|
617
181
|
|
|
618
|
-
// --- Rule 5: Directive version ---
|
|
619
182
|
checkDirectiveVersion(directive: NowlineDirective, accept: ValidationAcceptor): void {
|
|
620
|
-
|
|
621
|
-
acceptTr(accept, 'error', { node: directive, property: 'version' }, 'NL.E0100', {
|
|
622
|
-
version: directive.version,
|
|
623
|
-
});
|
|
624
|
-
return;
|
|
625
|
-
}
|
|
626
|
-
const num = parseInt(directive.version.slice(1), 10);
|
|
627
|
-
const supportedNum = parseInt(SUPPORTED_VERSION.slice(1), 10);
|
|
628
|
-
if (num > supportedNum) {
|
|
629
|
-
acceptTr(accept, 'error', { node: directive, property: 'version' }, 'NL.E0101', {
|
|
630
|
-
version: directive.version,
|
|
631
|
-
supported: SUPPORTED_VERSION,
|
|
632
|
-
});
|
|
633
|
-
}
|
|
183
|
+
structure.checkDirectiveVersion(directive, accept);
|
|
634
184
|
}
|
|
635
185
|
|
|
636
|
-
// --- Directive properties (locale) ---
|
|
637
|
-
// Validates the optional key:value pairs on the `nowline` directive line. Today the
|
|
638
|
-
// only allowed key is `locale:` (BCP-47 tag); unknown keys are rejected so typos
|
|
639
|
-
// surface immediately. Duplicate keys are also rejected.
|
|
640
186
|
checkDirectiveProperties(directive: NowlineDirective, accept: ValidationAcceptor): void {
|
|
641
|
-
|
|
642
|
-
for (const prop of directive.properties) {
|
|
643
|
-
const key = propKey(prop);
|
|
644
|
-
if (!DIRECTIVE_FIELDS.has(key)) {
|
|
645
|
-
acceptTr(accept, 'error', { node: prop, property: 'key' }, 'NL.E0102', {
|
|
646
|
-
key,
|
|
647
|
-
allowed: [...DIRECTIVE_FIELDS].join(', '),
|
|
648
|
-
});
|
|
649
|
-
continue;
|
|
650
|
-
}
|
|
651
|
-
if (seen.has(key)) {
|
|
652
|
-
acceptTr(accept, 'error', { node: prop, property: 'key' }, 'NL.E0103', { key });
|
|
653
|
-
}
|
|
654
|
-
seen.add(key);
|
|
655
|
-
|
|
656
|
-
if (key === 'locale') {
|
|
657
|
-
const raw = prop.value;
|
|
658
|
-
if (!BCP47_RE.test(raw)) {
|
|
659
|
-
acceptTr(accept, 'error', { node: prop, property: 'value' }, 'NL.E0104', {
|
|
660
|
-
value: raw,
|
|
661
|
-
});
|
|
662
|
-
}
|
|
663
|
-
}
|
|
664
|
-
}
|
|
187
|
+
structure.checkDirectiveProperties(directive, accept);
|
|
665
188
|
}
|
|
666
189
|
|
|
667
|
-
// --- Rule 3: Id or title required ---
|
|
668
190
|
checkEntityIdOrTitle(
|
|
669
191
|
node: AstNode & { name?: string; title?: string },
|
|
670
192
|
accept: ValidationAcceptor,
|
|
671
193
|
): void {
|
|
672
|
-
|
|
673
|
-
acceptTr(accept, 'error', { node }, 'NL.E0301', { type: node.$type });
|
|
674
|
-
}
|
|
194
|
+
structure.checkEntityIdOrTitle(node, accept);
|
|
675
195
|
}
|
|
676
196
|
|
|
677
|
-
// --- Rule 2: Unique identifiers ---
|
|
678
197
|
checkUniqueIdentifiers(file: NowlineFile, accept: ValidationAcceptor): void {
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
const register = (name: string | undefined, node: AstNode) => {
|
|
682
|
-
if (!name) return;
|
|
683
|
-
const existing = seen.get(name);
|
|
684
|
-
if (existing) {
|
|
685
|
-
acceptTr(accept, 'error', { node }, 'NL.E0300', {
|
|
686
|
-
name,
|
|
687
|
-
location: locationOf(existing),
|
|
688
|
-
});
|
|
689
|
-
} else {
|
|
690
|
-
seen.set(name, node);
|
|
691
|
-
}
|
|
692
|
-
};
|
|
693
|
-
|
|
694
|
-
if (file.roadmapDecl?.name) {
|
|
695
|
-
register(file.roadmapDecl.name, file.roadmapDecl);
|
|
696
|
-
}
|
|
697
|
-
|
|
698
|
-
for (const entry of file.roadmapEntries) {
|
|
699
|
-
registerEntity(entry, register);
|
|
700
|
-
}
|
|
701
|
-
|
|
702
|
-
for (const entry of file.configEntries) {
|
|
703
|
-
if (isStyleDeclaration(entry) && entry.name) {
|
|
704
|
-
register(entry.name, entry);
|
|
705
|
-
}
|
|
706
|
-
}
|
|
198
|
+
structure.checkUniqueIdentifiers(file, accept);
|
|
707
199
|
}
|
|
708
200
|
|
|
709
|
-
// --- Rule 7: Mixed tabs and spaces in indentation ---
|
|
710
201
|
checkIndentationConsistency(file: NowlineFile, accept: ValidationAcceptor): void {
|
|
711
|
-
|
|
712
|
-
if (!text) return;
|
|
713
|
-
const lines = text.split(/\r?\n/);
|
|
714
|
-
for (let i = 0; i < lines.length; i++) {
|
|
715
|
-
const line = lines[i];
|
|
716
|
-
if (line.length === 0) continue;
|
|
717
|
-
const match = line.match(/^([\t ]+)/);
|
|
718
|
-
if (!match) continue;
|
|
719
|
-
const indent = match[1];
|
|
720
|
-
if (indent.includes('\t') && indent.includes(' ')) {
|
|
721
|
-
acceptTr(accept, 'error', { node: file }, 'NL.E0005', { line: i + 1 });
|
|
722
|
-
return;
|
|
723
|
-
}
|
|
724
|
-
}
|
|
202
|
+
structure.checkIndentationConsistency(file, accept);
|
|
725
203
|
}
|
|
726
204
|
|
|
727
|
-
// --- Rule 6: At least one swimlane ---
|
|
728
205
|
checkSwimlaneRequired(file: NowlineFile, accept: ValidationAcceptor): void {
|
|
729
|
-
|
|
730
|
-
if (file.roadmapDecl && !hasSwimlane) {
|
|
731
|
-
acceptTr(accept, 'error', { node: file.roadmapDecl }, 'NL.E0004');
|
|
732
|
-
}
|
|
206
|
+
structure.checkSwimlaneRequired(file, accept);
|
|
733
207
|
}
|
|
734
208
|
|
|
735
|
-
// --- Include rules 5/6: mode values ---
|
|
736
209
|
checkIncludeMode(option: IncludeOption, accept: ValidationAcceptor): void {
|
|
737
|
-
|
|
738
|
-
acceptTr(accept, 'error', { node: option, property: 'value' }, 'NL.E0200', {
|
|
739
|
-
value: option.value,
|
|
740
|
-
});
|
|
741
|
-
}
|
|
210
|
+
structure.checkIncludeMode(option, accept);
|
|
742
211
|
}
|
|
743
212
|
|
|
744
|
-
// --- Include rule 4 (partial): Duplicate include options ---
|
|
745
213
|
checkIncludeDuplicateOptions(inc: IncludeDeclaration, accept: ValidationAcceptor): void {
|
|
746
|
-
|
|
747
|
-
for (const opt of inc.options) {
|
|
748
|
-
const normalized = opt.key.replace(/:$/, '');
|
|
749
|
-
if (keys.has(normalized)) {
|
|
750
|
-
acceptTr(accept, 'error', { node: opt }, 'NL.E0201', { key: normalized });
|
|
751
|
-
}
|
|
752
|
-
keys.add(normalized);
|
|
753
|
-
}
|
|
214
|
+
structure.checkIncludeDuplicateOptions(inc, accept);
|
|
754
215
|
}
|
|
755
216
|
|
|
756
|
-
// --- Property value validation (general) ---
|
|
757
217
|
checkPropertyValues(prop: EntityProperty, accept: ValidationAcceptor): void {
|
|
758
|
-
|
|
759
|
-
const val = prop.value;
|
|
760
|
-
const vals = prop.values;
|
|
761
|
-
const allValues = val ? [val] : vals;
|
|
762
|
-
|
|
763
|
-
switch (key) {
|
|
764
|
-
case 'status':
|
|
765
|
-
// Forward/resolution validated at file scope (checkForwardReferences).
|
|
766
|
-
break;
|
|
767
|
-
|
|
768
|
-
case 'duration':
|
|
769
|
-
// `duration:` is literal-only — no alias lookup. Authors who
|
|
770
|
-
// want a named alias use `size:NAME` instead, which resolves
|
|
771
|
-
// to the size's `effort:` (and divides by `capacity:` at
|
|
772
|
-
// layout time, m5).
|
|
773
|
-
if (val && !DURATION_RE.test(val)) {
|
|
774
|
-
acceptTr(accept, 'error', { node: prop, property: 'value' }, 'NL.E0400', {
|
|
775
|
-
value: val,
|
|
776
|
-
});
|
|
777
|
-
}
|
|
778
|
-
break;
|
|
779
|
-
|
|
780
|
-
case 'size':
|
|
781
|
-
if (val && !isIdentifier(val)) {
|
|
782
|
-
acceptTr(accept, 'error', { node: prop, property: 'value' }, 'NL.E0401', {
|
|
783
|
-
value: val,
|
|
784
|
-
});
|
|
785
|
-
}
|
|
786
|
-
break;
|
|
787
|
-
|
|
788
|
-
case 'effort':
|
|
789
|
-
if (val && !DURATION_RE.test(val)) {
|
|
790
|
-
acceptTr(accept, 'error', { node: prop, property: 'value' }, 'NL.E0402', {
|
|
791
|
-
value: val,
|
|
792
|
-
});
|
|
793
|
-
}
|
|
794
|
-
break;
|
|
795
|
-
|
|
796
|
-
case 'remaining': {
|
|
797
|
-
// Accepts either a percent (`30%`, validated 0-100) or a
|
|
798
|
-
// single-engineer effort literal (`1w`, `0.5d`). The literal
|
|
799
|
-
// form is normalized to a percent at layout time using the
|
|
800
|
-
// item's resolved total effort (m5); overflow there emits a
|
|
801
|
-
// soft warning and clamps the rendered bar to 100%.
|
|
802
|
-
if (val) {
|
|
803
|
-
if (PERCENTAGE_RE.test(val)) {
|
|
804
|
-
const pct = parseFloat(val);
|
|
805
|
-
if (pct < 0 || pct > 100) {
|
|
806
|
-
acceptTr(
|
|
807
|
-
accept,
|
|
808
|
-
'error',
|
|
809
|
-
{ node: prop, property: 'value' },
|
|
810
|
-
'NL.E0404',
|
|
811
|
-
{ value: val },
|
|
812
|
-
);
|
|
813
|
-
}
|
|
814
|
-
} else if (!DURATION_RE.test(val)) {
|
|
815
|
-
acceptTr(accept, 'error', { node: prop, property: 'value' }, 'NL.E0403', {
|
|
816
|
-
value: val,
|
|
817
|
-
});
|
|
818
|
-
}
|
|
819
|
-
}
|
|
820
|
-
break;
|
|
821
|
-
}
|
|
822
|
-
|
|
823
|
-
case 'date':
|
|
824
|
-
case 'start':
|
|
825
|
-
if (val && (!DATE_RE.test(val) || Number.isNaN(new Date(val).getTime()))) {
|
|
826
|
-
acceptTr(accept, 'error', { node: prop, property: 'value' }, 'NL.E0405', {
|
|
827
|
-
key,
|
|
828
|
-
value: val,
|
|
829
|
-
});
|
|
830
|
-
}
|
|
831
|
-
break;
|
|
832
|
-
|
|
833
|
-
case 'scale':
|
|
834
|
-
if (val && !DURATION_RE.test(val)) {
|
|
835
|
-
acceptTr(accept, 'error', { node: prop, property: 'value' }, 'NL.E0406', {
|
|
836
|
-
value: val,
|
|
837
|
-
});
|
|
838
|
-
}
|
|
839
|
-
break;
|
|
840
|
-
|
|
841
|
-
case 'calendar':
|
|
842
|
-
if (val && !CALENDAR_MODES.has(val)) {
|
|
843
|
-
acceptTr(accept, 'error', { node: prop, property: 'value' }, 'NL.E0407', {
|
|
844
|
-
value: val,
|
|
845
|
-
});
|
|
846
|
-
}
|
|
847
|
-
break;
|
|
848
|
-
|
|
849
|
-
case 'on':
|
|
850
|
-
case 'after':
|
|
851
|
-
case 'before':
|
|
852
|
-
if (allValues.length === 0) {
|
|
853
|
-
acceptTr(accept, 'error', { node: prop }, 'NL.E0408', { key });
|
|
854
|
-
}
|
|
855
|
-
break;
|
|
856
|
-
|
|
857
|
-
case 'capacity': {
|
|
858
|
-
if (!val) break;
|
|
859
|
-
const parent = prop.$container;
|
|
860
|
-
const parentKind = capacityParentKind(parent);
|
|
861
|
-
// Parallel/group ban is reported by checkNoComputedProperties; skip here.
|
|
862
|
-
if (parentKind === 'invalid') break;
|
|
863
|
-
if (parentKind === 'lane') {
|
|
864
|
-
if (!POSITIVE_NUMBER_RE.test(val) || parseFloat(val) <= 0) {
|
|
865
|
-
accept(
|
|
866
|
-
'error',
|
|
867
|
-
`Invalid swimlane capacity "${val}". Use a positive integer (e.g. capacity:5) or decimal (e.g. capacity:1.5). Percent literals are not allowed on swimlanes.`,
|
|
868
|
-
{ node: prop, property: 'value' },
|
|
869
|
-
);
|
|
870
|
-
}
|
|
871
|
-
} else {
|
|
872
|
-
if (POSITIVE_PERCENT_RE.test(val)) {
|
|
873
|
-
const pct = parseFloat(val);
|
|
874
|
-
if (pct <= 0) {
|
|
875
|
-
accept('error', `Item capacity "${val}" must be positive.`, {
|
|
876
|
-
node: prop,
|
|
877
|
-
property: 'value',
|
|
878
|
-
});
|
|
879
|
-
}
|
|
880
|
-
} else if (POSITIVE_NUMBER_RE.test(val)) {
|
|
881
|
-
if (parseFloat(val) <= 0) {
|
|
882
|
-
accept('error', `Item capacity "${val}" must be positive.`, {
|
|
883
|
-
node: prop,
|
|
884
|
-
property: 'value',
|
|
885
|
-
});
|
|
886
|
-
}
|
|
887
|
-
} else {
|
|
888
|
-
accept(
|
|
889
|
-
'error',
|
|
890
|
-
`Invalid item capacity "${val}". Use a positive integer (capacity:2), decimal (capacity:0.5), or percent literal (capacity:50%).`,
|
|
891
|
-
{ node: prop, property: 'value' },
|
|
892
|
-
);
|
|
893
|
-
}
|
|
894
|
-
}
|
|
895
|
-
break;
|
|
896
|
-
}
|
|
897
|
-
|
|
898
|
-
case 'overcapacity': {
|
|
899
|
-
// Removed in m9. Suppression is now expressed via
|
|
900
|
-
// `utilization-warn-at:none` / `utilization-over-at:none`
|
|
901
|
-
// (see specs/dsl.md § Capacity → Utilization thresholds).
|
|
902
|
-
accept(
|
|
903
|
-
'error',
|
|
904
|
-
`"overcapacity:" was removed. Use "utilization-over-at:none" (and/or "utilization-warn-at:none") to suppress the lane utilization underline.`,
|
|
905
|
-
{ node: prop },
|
|
906
|
-
);
|
|
907
|
-
break;
|
|
908
|
-
}
|
|
909
|
-
|
|
910
|
-
case 'utilization-warn-at':
|
|
911
|
-
case 'utilization-over-at': {
|
|
912
|
-
if (!val) break;
|
|
913
|
-
if (!isUtilizationAllowedHere(prop.$container)) {
|
|
914
|
-
accept(
|
|
915
|
-
'error',
|
|
916
|
-
`"${key}:" is only valid on "swimlane" or "default swimlane".`,
|
|
917
|
-
{ node: prop },
|
|
918
|
-
);
|
|
919
|
-
break;
|
|
920
|
-
}
|
|
921
|
-
if (val === UTILIZATION_NONE) break;
|
|
922
|
-
if (POSITIVE_PERCENT_RE.test(val)) {
|
|
923
|
-
if (parseFloat(val) <= 0) {
|
|
924
|
-
accept('error', `${key} value "${val}" must be positive.`, {
|
|
925
|
-
node: prop,
|
|
926
|
-
property: 'value',
|
|
927
|
-
});
|
|
928
|
-
}
|
|
929
|
-
break;
|
|
930
|
-
}
|
|
931
|
-
// Decimals must include the dot to read as fractions; bare
|
|
932
|
-
// integers are ambiguous (`80` could mean 80% or 8000% as a
|
|
933
|
-
// fraction) so we reject them with a hint to disambiguate.
|
|
934
|
-
if (POSITIVE_DECIMAL_FRACTION_RE.test(val)) {
|
|
935
|
-
if (parseFloat(val) <= 0) {
|
|
936
|
-
accept('error', `${key} value "${val}" must be positive.`, {
|
|
937
|
-
node: prop,
|
|
938
|
-
property: 'value',
|
|
939
|
-
});
|
|
940
|
-
}
|
|
941
|
-
break;
|
|
942
|
-
}
|
|
943
|
-
if (POSITIVE_INTEGER_RE.test(val)) {
|
|
944
|
-
accept(
|
|
945
|
-
'error',
|
|
946
|
-
`Ambiguous ${key} value "${val}". Use the percent form ("${val}%") or the decimal-fraction form ("0.${val}") to make the intent explicit.`,
|
|
947
|
-
{ node: prop, property: 'value' },
|
|
948
|
-
);
|
|
949
|
-
break;
|
|
950
|
-
}
|
|
951
|
-
accept(
|
|
952
|
-
'error',
|
|
953
|
-
`Invalid ${key} value "${val}". Use a positive percent (e.g. 80%), a positive decimal fraction (e.g. 0.8), or "none" to opt out.`,
|
|
954
|
-
{ node: prop, property: 'value' },
|
|
955
|
-
);
|
|
956
|
-
break;
|
|
957
|
-
}
|
|
958
|
-
|
|
959
|
-
case 'capacity-icon':
|
|
960
|
-
// Value-form rule (built-in / symbol id / string literal) and
|
|
961
|
-
// forward-reference rule are enforced together by
|
|
962
|
-
// checkSymbolReferences at file scope so style blocks and
|
|
963
|
-
// default-declaration property positions share one code path.
|
|
964
|
-
break;
|
|
965
|
-
|
|
966
|
-
case 'icon':
|
|
967
|
-
// Same handling as capacity-icon.
|
|
968
|
-
break;
|
|
969
|
-
|
|
970
|
-
default:
|
|
971
|
-
if (STYLE_PROP_KEYS.has(key)) {
|
|
972
|
-
if (key === 'bg' || key === 'fg' || key === 'text') {
|
|
973
|
-
if (val && !isColorValue(val)) {
|
|
974
|
-
accept(
|
|
975
|
-
'error',
|
|
976
|
-
`Invalid color "${val}" for "${key}". Use a named color, hex value, or "none".`,
|
|
977
|
-
{
|
|
978
|
-
node: prop,
|
|
979
|
-
property: 'value',
|
|
980
|
-
},
|
|
981
|
-
);
|
|
982
|
-
}
|
|
983
|
-
} else if (key in STYLE_PROP_ENUMS) {
|
|
984
|
-
const allowed = STYLE_PROP_ENUMS[key];
|
|
985
|
-
if (val && !allowed.has(val) && !isColorValue(val)) {
|
|
986
|
-
accept(
|
|
987
|
-
'error',
|
|
988
|
-
`Invalid value "${val}" for "${key}". Allowed: ${[...allowed].join(', ')}.`,
|
|
989
|
-
{
|
|
990
|
-
node: prop,
|
|
991
|
-
property: 'value',
|
|
992
|
-
},
|
|
993
|
-
);
|
|
994
|
-
}
|
|
995
|
-
}
|
|
996
|
-
}
|
|
997
|
-
break;
|
|
998
|
-
}
|
|
218
|
+
properties.checkPropertyValues(prop, accept);
|
|
999
219
|
}
|
|
1000
220
|
|
|
1001
|
-
// --- Rule 11: Anchor requires date: ---
|
|
1002
221
|
checkAnchorRequiredDate(anchor: AnchorDeclaration, accept: ValidationAcceptor): void {
|
|
1003
|
-
|
|
1004
|
-
if (!dateProp) {
|
|
1005
|
-
acceptTr(accept, 'error', { node: anchor }, 'NL.E0500', { name: displayName(anchor) });
|
|
1006
|
-
}
|
|
222
|
+
entities.checkAnchorRequiredDate(anchor, accept);
|
|
1007
223
|
}
|
|
1008
224
|
|
|
1009
|
-
// --- R2 + R3: anchor must not precede roadmap start; dated roadmap requires start: ---
|
|
1010
225
|
checkAnchorAgainstStart(anchor: AnchorDeclaration, accept: ValidationAcceptor): void {
|
|
1011
|
-
|
|
1012
|
-
if (!dateProp?.value) return;
|
|
1013
|
-
const raw = dateProp.value;
|
|
1014
|
-
if (!DATE_RE.test(raw)) return;
|
|
1015
|
-
const anchorDate = new Date(raw);
|
|
1016
|
-
if (Number.isNaN(anchorDate.getTime())) return;
|
|
1017
|
-
|
|
1018
|
-
const start = resolveLocalStart(anchor.$container);
|
|
1019
|
-
switch (start.kind) {
|
|
1020
|
-
case 'invalid':
|
|
1021
|
-
return;
|
|
1022
|
-
case 'missing':
|
|
1023
|
-
acceptTr(accept, 'error', { node: dateProp, property: 'value' }, 'NL.E0501', {
|
|
1024
|
-
name: displayName(anchor),
|
|
1025
|
-
});
|
|
1026
|
-
return;
|
|
1027
|
-
case 'valid':
|
|
1028
|
-
if (anchorDate < start.date) {
|
|
1029
|
-
acceptTr(accept, 'error', { node: dateProp, property: 'value' }, 'NL.E0502', {
|
|
1030
|
-
name: displayName(anchor),
|
|
1031
|
-
date: raw,
|
|
1032
|
-
start: start.iso,
|
|
1033
|
-
});
|
|
1034
|
-
}
|
|
1035
|
-
return;
|
|
1036
|
-
}
|
|
226
|
+
entities.checkAnchorAgainstStart(anchor, accept);
|
|
1037
227
|
}
|
|
1038
228
|
|
|
1039
|
-
// --- Rule 12: Milestone requires date: or after: ---
|
|
1040
229
|
checkMilestoneRequirement(milestone: MilestoneDeclaration, accept: ValidationAcceptor): void {
|
|
1041
|
-
|
|
1042
|
-
const hasAfter = milestone.properties.some((p) => propKey(p) === 'after');
|
|
1043
|
-
if (!hasDate && !hasAfter) {
|
|
1044
|
-
acceptTr(accept, 'error', { node: milestone }, 'NL.E0503', {
|
|
1045
|
-
name: displayName(milestone),
|
|
1046
|
-
});
|
|
1047
|
-
}
|
|
230
|
+
entities.checkMilestoneRequirement(milestone, accept);
|
|
1048
231
|
}
|
|
1049
232
|
|
|
1050
|
-
// --- R2 + R3: dated milestone must not precede roadmap start ---
|
|
1051
233
|
checkMilestoneAgainstStart(milestone: MilestoneDeclaration, accept: ValidationAcceptor): void {
|
|
1052
|
-
|
|
1053
|
-
if (!dateProp?.value) return;
|
|
1054
|
-
const raw = dateProp.value;
|
|
1055
|
-
if (!DATE_RE.test(raw)) return;
|
|
1056
|
-
const milestoneDate = new Date(raw);
|
|
1057
|
-
if (Number.isNaN(milestoneDate.getTime())) return;
|
|
1058
|
-
|
|
1059
|
-
const start = resolveLocalStart(milestone.$container);
|
|
1060
|
-
switch (start.kind) {
|
|
1061
|
-
case 'invalid':
|
|
1062
|
-
return;
|
|
1063
|
-
case 'missing':
|
|
1064
|
-
accept(
|
|
1065
|
-
'error',
|
|
1066
|
-
`Milestone "${displayName(milestone)}" has a date but the roadmap is missing "start:". Add start:YYYY-MM-DD to the roadmap.`,
|
|
1067
|
-
{
|
|
1068
|
-
node: dateProp,
|
|
1069
|
-
property: 'value',
|
|
1070
|
-
},
|
|
1071
|
-
);
|
|
1072
|
-
return;
|
|
1073
|
-
case 'valid':
|
|
1074
|
-
if (milestoneDate < start.date) {
|
|
1075
|
-
acceptTr(accept, 'error', { node: dateProp, property: 'value' }, 'NL.E0504', {
|
|
1076
|
-
name: displayName(milestone),
|
|
1077
|
-
date: raw,
|
|
1078
|
-
start: start.iso,
|
|
1079
|
-
});
|
|
1080
|
-
}
|
|
1081
|
-
return;
|
|
1082
|
-
}
|
|
234
|
+
entities.checkMilestoneAgainstStart(milestone, accept);
|
|
1083
235
|
}
|
|
1084
236
|
|
|
1085
|
-
// --- Rule 13: Footnote requires on ---
|
|
1086
237
|
checkFootnoteOn(footnote: FootnoteDeclaration, accept: ValidationAcceptor): void {
|
|
1087
|
-
|
|
1088
|
-
if (!hasOn) {
|
|
1089
|
-
acceptTr(accept, 'error', { node: footnote }, 'NL.E0505');
|
|
1090
|
-
}
|
|
238
|
+
entities.checkFootnoteOn(footnote, accept);
|
|
1091
239
|
}
|
|
1092
240
|
|
|
1093
|
-
// --- Rule 13a: `footnote:` is not a valid property on host entities ---
|
|
1094
|
-
// The spec attaches footnotes via the `on:` property on the footnote
|
|
1095
|
-
// declaration only; there is no forward `footnote:` property on the
|
|
1096
|
-
// referenced item / swimlane / etc. Surface a fix-it style error so
|
|
1097
|
-
// authors who reach for the (legacy, undocumented) forward form get
|
|
1098
|
-
// a clear nudge toward the spec-mandated direction.
|
|
1099
241
|
checkNoFootnoteProperty(
|
|
1100
242
|
node: {
|
|
1101
243
|
$type: string;
|
|
@@ -1105,67 +247,25 @@ export class NowlineValidator {
|
|
|
1105
247
|
},
|
|
1106
248
|
accept: ValidationAcceptor,
|
|
1107
249
|
): void {
|
|
1108
|
-
|
|
1109
|
-
if (propKey(prop) === 'footnote') {
|
|
1110
|
-
accept(
|
|
1111
|
-
'error',
|
|
1112
|
-
`Property "footnote:" is not valid on ${describeNode(node)}. ` +
|
|
1113
|
-
'Footnotes attach via "on:" on the footnote declaration — ' +
|
|
1114
|
-
'declare `footnote <id> on:<target-id>` instead.',
|
|
1115
|
-
{ node: prop },
|
|
1116
|
-
);
|
|
1117
|
-
}
|
|
1118
|
-
}
|
|
250
|
+
entities.checkNoFootnoteProperty(node, accept);
|
|
1119
251
|
}
|
|
1120
252
|
|
|
1121
|
-
// --- Rule 10: Item requires either size: or duration: ---
|
|
1122
253
|
checkItemRequiredDuration(item: ItemDeclaration, accept: ValidationAcceptor): void {
|
|
1123
|
-
|
|
1124
|
-
const hasSize = item.properties.some((p) => propKey(p) === 'size');
|
|
1125
|
-
if (!hasDuration && !hasSize) {
|
|
1126
|
-
acceptTr(accept, 'error', { node: item }, 'NL.E0600', { name: displayName(item) });
|
|
1127
|
-
}
|
|
254
|
+
entities.checkItemRequiredDuration(item, accept);
|
|
1128
255
|
}
|
|
1129
256
|
|
|
1130
|
-
// --- Parallel/group rule 3: size/duration/remaining/capacity not valid on parallel/group ---
|
|
1131
257
|
checkNoComputedProperties(node: ParallelBlock | GroupBlock, accept: ValidationAcceptor): void {
|
|
1132
|
-
|
|
1133
|
-
const key = propKey(prop);
|
|
1134
|
-
if (key === 'size' || key === 'duration' || key === 'remaining' || key === 'capacity') {
|
|
1135
|
-
accept(
|
|
1136
|
-
'error',
|
|
1137
|
-
`"${key}" is not valid on ${node.$type === 'ParallelBlock' ? 'parallel' : 'group'} (computed from children).`,
|
|
1138
|
-
{
|
|
1139
|
-
node: prop,
|
|
1140
|
-
},
|
|
1141
|
-
);
|
|
1142
|
-
}
|
|
1143
|
-
}
|
|
258
|
+
entities.checkNoComputedProperties(node, accept);
|
|
1144
259
|
}
|
|
1145
260
|
|
|
1146
|
-
// --- Parallel/group rule 1: Parallel requires >= 2 children ---
|
|
1147
261
|
checkParallelMinChildren(node: ParallelBlock, accept: ValidationAcceptor): void {
|
|
1148
|
-
|
|
1149
|
-
if (children.length === 0) {
|
|
1150
|
-
accept('error', 'Parallel block must contain at least 2 children.', { node });
|
|
1151
|
-
} else if (children.length === 1) {
|
|
1152
|
-
accept(
|
|
1153
|
-
'warning',
|
|
1154
|
-
'Parallel block has only 1 child. Use at least 2 for parallel execution.',
|
|
1155
|
-
{ node },
|
|
1156
|
-
);
|
|
1157
|
-
}
|
|
262
|
+
entities.checkParallelMinChildren(node, accept);
|
|
1158
263
|
}
|
|
1159
264
|
|
|
1160
|
-
// --- Parallel/group rule 2: Group requires >= 1 child ---
|
|
1161
265
|
checkGroupMinChildren(node: GroupBlock, accept: ValidationAcceptor): void {
|
|
1162
|
-
|
|
1163
|
-
if (children.length === 0) {
|
|
1164
|
-
accept('error', 'Group must contain at least 1 child.', { node });
|
|
1165
|
-
}
|
|
266
|
+
entities.checkGroupMinChildren(node, accept);
|
|
1166
267
|
}
|
|
1167
268
|
|
|
1168
|
-
// --- Rule 20: Raw style properties banned on roadmap-section entities ---
|
|
1169
269
|
checkNoRawStyleProperties(
|
|
1170
270
|
node: {
|
|
1171
271
|
$type: string;
|
|
@@ -1175,32 +275,9 @@ export class NowlineValidator {
|
|
|
1175
275
|
},
|
|
1176
276
|
accept: ValidationAcceptor,
|
|
1177
277
|
): void {
|
|
1178
|
-
|
|
1179
|
-
const key = propKey(prop);
|
|
1180
|
-
if (STYLE_PROP_KEYS.has(key)) {
|
|
1181
|
-
accept(
|
|
1182
|
-
'error',
|
|
1183
|
-
`Raw style property "${key}" is not allowed on ${describeNode(node)}. ` +
|
|
1184
|
-
`Declare a named style in config and reference it via "style:id".`,
|
|
1185
|
-
{ node: prop },
|
|
1186
|
-
);
|
|
1187
|
-
}
|
|
1188
|
-
}
|
|
278
|
+
properties.checkNoRawStyleProperties(node, accept);
|
|
1189
279
|
}
|
|
1190
280
|
|
|
1191
|
-
// Warn on property keys the runtime never reads. Severity is `warning` so a
|
|
1192
|
-
// file that happened to render with a bogus key (e.g. `roadmap r now:2026-01-25`)
|
|
1193
|
-
// keeps parsing — promoting to error would break files that work today even
|
|
1194
|
-
// though the bogus key was a no-op all along.
|
|
1195
|
-
//
|
|
1196
|
-
// Skips:
|
|
1197
|
-
// - raw style keys (already an error from `checkNoRawStyleProperties`)
|
|
1198
|
-
// - `footnote` (already an error from `checkNoFootnoteProperty`)
|
|
1199
|
-
// - sizing keys on parallel/group (already an error from `checkNoComputedProperties`)
|
|
1200
|
-
//
|
|
1201
|
-
// Suggests the closest known key within 2 edits when one exists, so the
|
|
1202
|
-
// existing `DID_YOU_MEAN_RE` in `packages/cli/src/diagnostics/adapt.ts` picks
|
|
1203
|
-
// it up as a structured suggestion alongside the rendered message.
|
|
1204
281
|
checkUnknownEntityProperties(
|
|
1205
282
|
node: {
|
|
1206
283
|
$type: string;
|
|
@@ -1210,929 +287,115 @@ export class NowlineValidator {
|
|
|
1210
287
|
},
|
|
1211
288
|
accept: ValidationAcceptor,
|
|
1212
289
|
): void {
|
|
1213
|
-
|
|
1214
|
-
if (!known) return;
|
|
1215
|
-
const computedBanned =
|
|
1216
|
-
node.$type === 'ParallelBlock' || node.$type === 'GroupBlock'
|
|
1217
|
-
? new Set(['size', 'duration', 'remaining', 'capacity'])
|
|
1218
|
-
: null;
|
|
1219
|
-
for (const prop of node.properties) {
|
|
1220
|
-
const key = propKey(prop);
|
|
1221
|
-
if (known.has(key)) continue;
|
|
1222
|
-
if (UNIVERSAL_ENTITY_PROPS.has(key)) continue;
|
|
1223
|
-
if (STYLE_PROP_KEYS.has(key)) continue;
|
|
1224
|
-
if (key === 'footnote') continue;
|
|
1225
|
-
if (computedBanned?.has(key)) continue;
|
|
1226
|
-
const candidates: string[] = [...known, ...UNIVERSAL_ENTITY_PROPS];
|
|
1227
|
-
const suggested = suggestConcept(key, known) ?? suggestKey(key, candidates) ?? '';
|
|
1228
|
-
acceptTr(accept, 'warning', { node: prop, property: 'key' }, 'NL.W0700', {
|
|
1229
|
-
key,
|
|
1230
|
-
entity: describeNode(node),
|
|
1231
|
-
suggested,
|
|
1232
|
-
});
|
|
1233
|
-
}
|
|
290
|
+
properties.checkUnknownEntityProperties(node, accept);
|
|
1234
291
|
}
|
|
1235
292
|
|
|
1236
|
-
// --- Roadmap declaration specific property checks ---
|
|
1237
|
-
// Property-level validation of start:/date: lives in the generic EntityProperty check;
|
|
1238
|
-
// this hook is kept for future roadmap-scoped rules (and to make registration symmetric).
|
|
1239
293
|
checkRoadmapProperties(_roadmap: RoadmapDeclaration, _accept: ValidationAcceptor): void {
|
|
1240
|
-
|
|
294
|
+
properties.checkRoadmapProperties(_roadmap, _accept);
|
|
1241
295
|
}
|
|
1242
296
|
|
|
1243
|
-
// --- Rule 18: Style property enum values ---
|
|
1244
|
-
// Value forms accepted by `icon:` and `capacity-icon:` (built-in identifier,
|
|
1245
|
-
// symbol name, or inline string literal) plus forward-reference resolution are
|
|
1246
|
-
// enforced by checkSymbolReferences at file scope so style blocks and
|
|
1247
|
-
// `default <entity>` lines share a single code path.
|
|
1248
297
|
checkStylePropertyEnum(prop: StyleProperty, accept: ValidationAcceptor): void {
|
|
1249
|
-
|
|
1250
|
-
const val = prop.value;
|
|
1251
|
-
|
|
1252
|
-
if (key === 'bg' || key === 'fg' || key === 'text') {
|
|
1253
|
-
if (!isColorValue(val)) {
|
|
1254
|
-
accept(
|
|
1255
|
-
'error',
|
|
1256
|
-
`Invalid color "${val}" for "${key}". Use a named color, hex value, or "none".`,
|
|
1257
|
-
{
|
|
1258
|
-
node: prop,
|
|
1259
|
-
property: 'value',
|
|
1260
|
-
},
|
|
1261
|
-
);
|
|
1262
|
-
}
|
|
1263
|
-
} else if (key in STYLE_PROP_ENUMS) {
|
|
1264
|
-
const allowed = STYLE_PROP_ENUMS[key];
|
|
1265
|
-
if (!allowed.has(val)) {
|
|
1266
|
-
accept(
|
|
1267
|
-
'error',
|
|
1268
|
-
`Invalid value "${val}" for "${key}". Allowed: ${[...allowed].join(', ')}.`,
|
|
1269
|
-
{
|
|
1270
|
-
node: prop,
|
|
1271
|
-
property: 'value',
|
|
1272
|
-
},
|
|
1273
|
-
);
|
|
1274
|
-
}
|
|
1275
|
-
} else if (!STYLE_PROP_KEYS.has(key)) {
|
|
1276
|
-
accept('error', `Unknown style property "${key}".`, {
|
|
1277
|
-
node: prop,
|
|
1278
|
-
property: 'key',
|
|
1279
|
-
});
|
|
1280
|
-
}
|
|
298
|
+
properties.checkStylePropertyEnum(prop, accept);
|
|
1281
299
|
}
|
|
1282
300
|
|
|
1283
|
-
// --- Size declaration: rule 5 (effort: required), rule 4 (id format) ---
|
|
1284
301
|
checkSizeDeclaration(decl: SizeDeclaration, accept: ValidationAcceptor): void {
|
|
1285
|
-
|
|
1286
|
-
if (!effortProp) {
|
|
1287
|
-
accept('error', `Size "${displayName(decl)}" requires an "effort:" property.`, {
|
|
1288
|
-
node: decl,
|
|
1289
|
-
});
|
|
1290
|
-
}
|
|
1291
|
-
|
|
1292
|
-
if (decl.name) {
|
|
1293
|
-
if (DURATION_RE.test(decl.name) || BARE_DURATION_SUFFIX_RE.test(decl.name)) {
|
|
1294
|
-
accept(
|
|
1295
|
-
'error',
|
|
1296
|
-
`Size id "${decl.name}" collides with the raw duration pattern. Choose a different name (e.g. "xs", "small", "quarter").`,
|
|
1297
|
-
{ node: decl, property: 'name' },
|
|
1298
|
-
);
|
|
1299
|
-
}
|
|
1300
|
-
}
|
|
302
|
+
entities.checkSizeDeclaration(decl, accept);
|
|
1301
303
|
}
|
|
1302
304
|
|
|
1303
|
-
// --- Status declaration: id collision with built-ins ---
|
|
1304
305
|
checkStatusDeclaration(decl: StatusDeclaration, accept: ValidationAcceptor): void {
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
306
|
+
entities.checkStatusDeclaration(decl, accept);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
// --- Waves (specs/waves.md §6.2): set S (WV1/WV3/WV4, wave declarations),
|
|
310
|
+
// set P (WV5-WV9, `wave:` properties) and, when the roadmap has waves,
|
|
311
|
+
// set G (WV10-WV12) over the file's own lanes in order ---
|
|
312
|
+
checkWaves(file: NowlineFile, accept: ValidationAcceptor): void {
|
|
313
|
+
for (const finding of checkWaveDeclarations(file)) acceptWaveFinding(accept, finding);
|
|
314
|
+
for (const finding of evaluateWaveProperties(file)) acceptWaveFinding(accept, finding);
|
|
315
|
+
const waves = ownWaves(file);
|
|
316
|
+
if (waves.length === 0) return;
|
|
317
|
+
const scope = {
|
|
318
|
+
lanes: file.roadmapEntries.filter(isSwimlaneDeclaration),
|
|
319
|
+
lookup: fileRefLookup(file),
|
|
320
|
+
};
|
|
321
|
+
for (const finding of evaluateWaveOrder(scope, waves)) acceptWaveFinding(accept, finding);
|
|
1314
322
|
}
|
|
1315
323
|
|
|
1316
|
-
// --- Rule 5: Duplicate size ids ---
|
|
1317
324
|
checkDuplicateSizeIds(file: NowlineFile, accept: ValidationAcceptor): void {
|
|
1318
|
-
|
|
1319
|
-
for (const entry of file.roadmapEntries) {
|
|
1320
|
-
if (isSizeDeclaration(entry) && entry.name) {
|
|
1321
|
-
const existing = seen.get(entry.name);
|
|
1322
|
-
if (existing) {
|
|
1323
|
-
accept(
|
|
1324
|
-
'error',
|
|
1325
|
-
`Duplicate size id "${entry.name}". First declared at ${locationOf(existing)}.`,
|
|
1326
|
-
{ node: entry, property: 'name' },
|
|
1327
|
-
);
|
|
1328
|
-
} else {
|
|
1329
|
-
seen.set(entry.name, entry);
|
|
1330
|
-
}
|
|
1331
|
-
}
|
|
1332
|
-
}
|
|
325
|
+
entities.checkDuplicateSizeIds(file, accept);
|
|
1333
326
|
}
|
|
1334
327
|
|
|
1335
|
-
// --- Rule 17d (ordering half): utilization-warn-at <= utilization-over-at ---
|
|
1336
|
-
// Runs on both `SwimlaneDeclaration` and `DefaultDeclaration` (when its
|
|
1337
|
-
// entityType is `swimlane`). The value-form check in checkPropertyValues
|
|
1338
|
-
// has already run by the time this fires; this method only re-reads the
|
|
1339
|
-
// values and compares fractions when both are numeric. `none` on either
|
|
1340
|
-
// side opts that side out and skips the comparison (the spec treats the
|
|
1341
|
-
// two thresholds as independent — see specs/dsl.md rule 17d).
|
|
1342
328
|
checkUtilizationOrdering(
|
|
1343
329
|
decl: SwimlaneDeclaration | DefaultDeclaration,
|
|
1344
330
|
accept: ValidationAcceptor,
|
|
1345
331
|
): void {
|
|
1346
|
-
|
|
1347
|
-
const warnProp = decl.properties.find((p) => propKey(p) === 'utilization-warn-at');
|
|
1348
|
-
const overProp = decl.properties.find((p) => propKey(p) === 'utilization-over-at');
|
|
1349
|
-
if (!warnProp || !overProp) return;
|
|
1350
|
-
const warn = parseUtilizationFraction(warnProp.value);
|
|
1351
|
-
const over = parseUtilizationFraction(overProp.value);
|
|
1352
|
-
if (warn === null || over === null) return;
|
|
1353
|
-
if (warn > over) {
|
|
1354
|
-
accept(
|
|
1355
|
-
'error',
|
|
1356
|
-
`utilization-warn-at (${warnProp.value}) must be ≤ utilization-over-at (${overProp.value}). Warn fires below over; if both fire at the same point, the warn band collapses to zero.`,
|
|
1357
|
-
{ node: warnProp, property: 'value' },
|
|
1358
|
-
);
|
|
1359
|
-
}
|
|
332
|
+
entities.checkUtilizationOrdering(decl, accept);
|
|
1360
333
|
}
|
|
1361
334
|
|
|
1362
|
-
// --- Defaults rules 21-23: entity-type whitelist, duplicate-per-entity, banned props ---
|
|
1363
335
|
checkDefaultDeclaration(decl: DefaultDeclaration, accept: ValidationAcceptor): void {
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
'error',
|
|
1367
|
-
`"${decl.entityType}" is not a supported entity type for default. Allowed: ${[...DEFAULT_ENTITY_TYPES].join(', ')}.`,
|
|
1368
|
-
{ node: decl, property: 'entityType' },
|
|
1369
|
-
);
|
|
1370
|
-
return;
|
|
1371
|
-
}
|
|
1372
|
-
|
|
1373
|
-
// Duplicate default <entity> within the same file.
|
|
1374
|
-
const file = decl.$container;
|
|
1375
|
-
let firstIdx = -1;
|
|
1376
|
-
for (let i = 0; i < file.configEntries.length; i++) {
|
|
1377
|
-
const other = file.configEntries[i];
|
|
1378
|
-
if (isDefaultDeclaration(other) && other.entityType === decl.entityType) {
|
|
1379
|
-
if (firstIdx < 0) {
|
|
1380
|
-
firstIdx = i;
|
|
1381
|
-
} else if (other === decl) {
|
|
1382
|
-
accept(
|
|
1383
|
-
'error',
|
|
1384
|
-
`Duplicate "default ${decl.entityType}" declaration. Only one is allowed per entity type per file.`,
|
|
1385
|
-
{ node: decl },
|
|
1386
|
-
);
|
|
1387
|
-
break;
|
|
1388
|
-
}
|
|
1389
|
-
}
|
|
1390
|
-
}
|
|
336
|
+
style.checkDefaultDeclaration(decl, accept);
|
|
337
|
+
}
|
|
1391
338
|
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
for (const prop of decl.properties) {
|
|
1395
|
-
const key = propKey(prop);
|
|
1396
|
-
if (banned.has(key)) {
|
|
1397
|
-
accept(
|
|
1398
|
-
'error',
|
|
1399
|
-
`"${key}" cannot be set on "default ${decl.entityType}". Identity-defining, sizing, sequencing, reference, and prose properties must be explicit on each entity.`,
|
|
1400
|
-
{ node: prop },
|
|
1401
|
-
);
|
|
1402
|
-
}
|
|
1403
|
-
}
|
|
1404
|
-
}
|
|
339
|
+
checkHiddenTimelineStrip(file: NowlineFile, accept: ValidationAcceptor): void {
|
|
340
|
+
style.checkHiddenTimelineStrip(file, accept);
|
|
1405
341
|
}
|
|
1406
342
|
|
|
1407
|
-
// --- Rule 7 (calendar): calendar block only valid when roadmap calendar:custom ---
|
|
1408
|
-
// Rule 8: custom calendar requires all four fields.
|
|
1409
343
|
checkCalendarBlockConsistency(file: NowlineFile, accept: ValidationAcceptor): void {
|
|
1410
|
-
|
|
1411
|
-
const calendarProp = file.roadmapDecl?.properties.find((p) => propKey(p) === 'calendar');
|
|
1412
|
-
const calendarMode = calendarProp?.value;
|
|
1413
|
-
|
|
1414
|
-
if (calendarBlocks.length > 0 && calendarMode !== 'custom') {
|
|
1415
|
-
for (const block of calendarBlocks) {
|
|
1416
|
-
accept(
|
|
1417
|
-
'error',
|
|
1418
|
-
`A "calendar" config block is only valid when the roadmap declares calendar:custom.`,
|
|
1419
|
-
{ node: block },
|
|
1420
|
-
);
|
|
1421
|
-
}
|
|
1422
|
-
}
|
|
1423
|
-
|
|
1424
|
-
if (calendarMode === 'custom' && calendarBlocks.length === 0) {
|
|
1425
|
-
accept(
|
|
1426
|
-
'error',
|
|
1427
|
-
`calendar:custom requires a "calendar" config block with days-per-week, days-per-month, days-per-quarter, and days-per-year.`,
|
|
1428
|
-
{ node: file.roadmapDecl!, property: 'properties' },
|
|
1429
|
-
);
|
|
1430
|
-
}
|
|
1431
|
-
|
|
1432
|
-
if (calendarMode === 'custom' && calendarBlocks.length > 0) {
|
|
1433
|
-
for (const block of calendarBlocks) {
|
|
1434
|
-
const presentKeys = new Set(block.properties.map((p) => propKey(p)));
|
|
1435
|
-
for (const field of CALENDAR_FIELDS) {
|
|
1436
|
-
if (!presentKeys.has(field)) {
|
|
1437
|
-
accept(
|
|
1438
|
-
'error',
|
|
1439
|
-
`calendar:custom requires "${field}" in the calendar config block.`,
|
|
1440
|
-
{ node: block },
|
|
1441
|
-
);
|
|
1442
|
-
}
|
|
1443
|
-
}
|
|
1444
|
-
}
|
|
1445
|
-
}
|
|
344
|
+
calendar.checkCalendarBlockConsistency(file, accept);
|
|
1446
345
|
}
|
|
1447
346
|
|
|
1448
|
-
// --- Rule 9: calendar block property values must be positive integers ---
|
|
1449
347
|
checkCalendarBlock(block: CalendarBlock, accept: ValidationAcceptor): void {
|
|
1450
|
-
|
|
1451
|
-
for (const prop of block.properties) {
|
|
1452
|
-
const key = propKey(prop);
|
|
1453
|
-
if (!CALENDAR_FIELDS.has(key)) {
|
|
1454
|
-
accept(
|
|
1455
|
-
'error',
|
|
1456
|
-
`Unknown calendar property "${key}". Allowed: ${[...CALENDAR_FIELDS].join(', ')}.`,
|
|
1457
|
-
{ node: prop, property: 'key' },
|
|
1458
|
-
);
|
|
1459
|
-
continue;
|
|
1460
|
-
}
|
|
1461
|
-
if (seen.has(key)) {
|
|
1462
|
-
accept('error', `Duplicate calendar property "${key}".`, {
|
|
1463
|
-
node: prop,
|
|
1464
|
-
property: 'key',
|
|
1465
|
-
});
|
|
1466
|
-
}
|
|
1467
|
-
seen.add(key);
|
|
1468
|
-
|
|
1469
|
-
if (!INTEGER_RE.test(prop.value) || parseInt(prop.value, 10) <= 0) {
|
|
1470
|
-
accept('error', `"${key}" must be a positive integer, got "${prop.value}".`, {
|
|
1471
|
-
node: prop,
|
|
1472
|
-
property: 'value',
|
|
1473
|
-
});
|
|
1474
|
-
}
|
|
1475
|
-
}
|
|
348
|
+
calendar.checkCalendarBlock(block, accept);
|
|
1476
349
|
}
|
|
1477
350
|
|
|
1478
|
-
// --- Scale block property validation ---
|
|
1479
351
|
checkScaleBlock(block: ScaleBlock, accept: ValidationAcceptor): void {
|
|
1480
|
-
|
|
1481
|
-
for (const prop of block.properties) {
|
|
1482
|
-
const key = propKey(prop);
|
|
1483
|
-
if (!SCALE_FIELDS.has(key)) {
|
|
1484
|
-
accept(
|
|
1485
|
-
'error',
|
|
1486
|
-
`Unknown scale property "${key}". Allowed: ${[...SCALE_FIELDS].join(', ')}.`,
|
|
1487
|
-
{ node: prop, property: 'key' },
|
|
1488
|
-
);
|
|
1489
|
-
continue;
|
|
1490
|
-
}
|
|
1491
|
-
if (seen.has(key)) {
|
|
1492
|
-
accept('error', `Duplicate scale property "${key}".`, {
|
|
1493
|
-
node: prop,
|
|
1494
|
-
property: 'key',
|
|
1495
|
-
});
|
|
1496
|
-
}
|
|
1497
|
-
seen.add(key);
|
|
1498
|
-
|
|
1499
|
-
if (key === 'label-every') {
|
|
1500
|
-
if (!INTEGER_RE.test(prop.value) || parseInt(prop.value, 10) <= 0) {
|
|
1501
|
-
accept(
|
|
1502
|
-
'error',
|
|
1503
|
-
`"label-every" must be a positive integer, got "${prop.value}".`,
|
|
1504
|
-
{ node: prop, property: 'value' },
|
|
1505
|
-
);
|
|
1506
|
-
}
|
|
1507
|
-
}
|
|
1508
|
-
}
|
|
352
|
+
calendar.checkScaleBlock(block, accept);
|
|
1509
353
|
}
|
|
1510
354
|
|
|
1511
|
-
// --- Rule 15: size:/status: references resolve to earlier declarations ---
|
|
1512
355
|
checkForwardReferences(file: NowlineFile, accept: ValidationAcceptor): void {
|
|
1513
|
-
|
|
1514
|
-
const sizeOrder = new Map<string, number>();
|
|
1515
|
-
const statusOrder = new Map<string, number>();
|
|
1516
|
-
|
|
1517
|
-
for (let i = 0; i < file.roadmapEntries.length; i++) {
|
|
1518
|
-
const entry = file.roadmapEntries[i];
|
|
1519
|
-
if (isSizeDeclaration(entry) && entry.name) {
|
|
1520
|
-
if (!sizeOrder.has(entry.name)) sizeOrder.set(entry.name, i);
|
|
1521
|
-
} else if (isStatusDeclaration(entry) && entry.name) {
|
|
1522
|
-
if (!statusOrder.has(entry.name)) statusOrder.set(entry.name, i);
|
|
1523
|
-
}
|
|
1524
|
-
}
|
|
1525
|
-
|
|
1526
|
-
for (let i = 0; i < file.roadmapEntries.length; i++) {
|
|
1527
|
-
const entry = file.roadmapEntries[i];
|
|
1528
|
-
visitPropertiesDeep(entry, (prop) => {
|
|
1529
|
-
const key = propKey(prop);
|
|
1530
|
-
if (key === 'size' && prop.value) {
|
|
1531
|
-
const val = prop.value;
|
|
1532
|
-
const declIdx = sizeOrder.get(val);
|
|
1533
|
-
if (declIdx === undefined) {
|
|
1534
|
-
accept(
|
|
1535
|
-
'error',
|
|
1536
|
-
`Size "${val}" is not declared. Add "size ${val} effort:<literal>" earlier in the roadmap section.`,
|
|
1537
|
-
{ node: prop, property: 'value' },
|
|
1538
|
-
);
|
|
1539
|
-
} else if (declIdx >= i) {
|
|
1540
|
-
accept(
|
|
1541
|
-
'error',
|
|
1542
|
-
`Size "${val}" is referenced before its declaration. Move "size ${val}" above this entity.`,
|
|
1543
|
-
{ node: prop, property: 'value' },
|
|
1544
|
-
);
|
|
1545
|
-
}
|
|
1546
|
-
} else if (key === 'status' && prop.value) {
|
|
1547
|
-
const val = prop.value;
|
|
1548
|
-
if (BUILTIN_STATUSES.has(val)) return;
|
|
1549
|
-
const declIdx = statusOrder.get(val);
|
|
1550
|
-
if (declIdx === undefined) {
|
|
1551
|
-
accept(
|
|
1552
|
-
'error',
|
|
1553
|
-
`Status "${val}" is not a built-in and has no declaration. Add "status ${val}" earlier in the roadmap section.`,
|
|
1554
|
-
{ node: prop, property: 'value' },
|
|
1555
|
-
);
|
|
1556
|
-
} else if (declIdx >= i) {
|
|
1557
|
-
accept(
|
|
1558
|
-
'error',
|
|
1559
|
-
`Status "${val}" is referenced before its declaration. Move "status ${val}" above this entity.`,
|
|
1560
|
-
{ node: prop, property: 'value' },
|
|
1561
|
-
);
|
|
1562
|
-
}
|
|
1563
|
-
}
|
|
1564
|
-
});
|
|
1565
|
-
}
|
|
356
|
+
references.checkForwardReferences(file, accept);
|
|
1566
357
|
}
|
|
1567
358
|
|
|
1568
|
-
// --- Rules 24/1 (reference): after/before/on must resolve to declared ids ---
|
|
1569
|
-
// `owner:` is intentionally NOT checked here. Per specs/dsl.md ("Declarations
|
|
1570
|
-
// are optional"), `owner:sam` is valid even if no `person sam` declaration
|
|
1571
|
-
// exists — it renders as the bare id. Sequencing properties (`after`,
|
|
1572
|
-
// `before`, `on`) stay strict because a phantom dependency silently breaks
|
|
1573
|
-
// the timeline / footnote target.
|
|
1574
|
-
//
|
|
1575
|
-
// Inline date literals in `after:` / `before:` (e.g. `after:2026-03-15`)
|
|
1576
|
-
// are intentionally NOT id references — they pin the entity directly to a
|
|
1577
|
-
// calendar date without a named anchor. The DATE_RE check below skips them
|
|
1578
|
-
// here; their own validation (entity-type allowlist, multi-date-per-direction,
|
|
1579
|
-
// roadmap-start: requirements) lives in `checkInlineDatePins` below.
|
|
1580
359
|
checkReferenceResolution(file: NowlineFile, accept: ValidationAcceptor): void {
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
const visit = (entry: RoadmapEntry) => {
|
|
1584
|
-
visitPropertiesDeep(entry, (prop) => {
|
|
1585
|
-
const key = propKey(prop);
|
|
1586
|
-
if (key !== 'after' && key !== 'before' && key !== 'on') return;
|
|
1587
|
-
const vals = prop.value ? [prop.value] : prop.values;
|
|
1588
|
-
for (const v of vals) {
|
|
1589
|
-
if (!v) continue;
|
|
1590
|
-
if ((key === 'after' || key === 'before') && DATE_RE.test(v)) continue;
|
|
1591
|
-
if (!declaredIds.has(v)) {
|
|
1592
|
-
accept(
|
|
1593
|
-
'error',
|
|
1594
|
-
`${key}: reference "${v}" does not resolve to any declared entity in this file.`,
|
|
1595
|
-
{ node: prop },
|
|
1596
|
-
);
|
|
1597
|
-
}
|
|
1598
|
-
}
|
|
1599
|
-
});
|
|
1600
|
-
};
|
|
1601
|
-
|
|
1602
|
-
for (const entry of file.roadmapEntries) {
|
|
1603
|
-
visit(entry);
|
|
1604
|
-
}
|
|
360
|
+
references.checkReferenceResolution(file, accept);
|
|
1605
361
|
}
|
|
1606
362
|
|
|
1607
|
-
// --- Rules 24a/24b/27/28 (inline-date pins on after:/before:) ---
|
|
1608
|
-
// An inline ISO date literal in `after:` or `before:` pins the entity
|
|
1609
|
-
// directly to a calendar position without a named `anchor` declaration
|
|
1610
|
-
// (see specs/dsl.md "Inline date pins"). This check enforces:
|
|
1611
|
-
// - 24a: inline date allowed only on item / parallel / group
|
|
1612
|
-
// - 24b: at most one inline date per direction (per `after:` / `before:`)
|
|
1613
|
-
// - 27: file with any inline date requires roadmap `start:`
|
|
1614
|
-
// - 28: every inline date must be on or after roadmap `start:`
|
|
1615
|
-
//
|
|
1616
|
-
// Cycle detection (`checkCircularDependencies`) skips dates entirely —
|
|
1617
|
-
// they are not graph nodes — so this is the only validator that touches
|
|
1618
|
-
// their date semantics. The grammar's DATE_LITERAL terminal already
|
|
1619
|
-
// enforces the YYYY-MM-DD shape; we only need to verify calendar validity
|
|
1620
|
-
// for the start: comparison.
|
|
1621
363
|
checkInlineDatePins(file: NowlineFile, accept: ValidationAcceptor): void {
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
const visit = (entry: AstNode): void => {
|
|
1625
|
-
const props = (entry as { properties?: EntityProperty[] }).properties ?? [];
|
|
1626
|
-
const allowed =
|
|
1627
|
-
isItemDeclaration(entry) || isParallelBlock(entry) || isGroupBlock(entry);
|
|
1628
|
-
|
|
1629
|
-
for (const prop of props) {
|
|
1630
|
-
const key = propKey(prop);
|
|
1631
|
-
if (key !== 'after' && key !== 'before') continue;
|
|
1632
|
-
const vals = prop.value ? [prop.value] : prop.values;
|
|
1633
|
-
const dateVals = vals.filter((v): v is string => !!v && DATE_RE.test(v));
|
|
1634
|
-
if (dateVals.length === 0) continue;
|
|
1635
|
-
|
|
1636
|
-
if (!allowed) {
|
|
1637
|
-
acceptTr(accept, 'error', { node: prop }, 'NL.E0411', {
|
|
1638
|
-
key,
|
|
1639
|
-
type: entityTypeLabel(entry),
|
|
1640
|
-
});
|
|
1641
|
-
continue;
|
|
1642
|
-
}
|
|
1643
|
-
|
|
1644
|
-
if (dateVals.length > 1) {
|
|
1645
|
-
acceptTr(accept, 'error', { node: prop }, 'NL.E0410', { key });
|
|
1646
|
-
}
|
|
1647
|
-
|
|
1648
|
-
for (const dateVal of dateVals) {
|
|
1649
|
-
switch (start.kind) {
|
|
1650
|
-
case 'invalid':
|
|
1651
|
-
// Roadmap start: itself is malformed; the user
|
|
1652
|
-
// already sees that error. Suppress this one to
|
|
1653
|
-
// avoid noise (mirrors anchor / milestone behavior).
|
|
1654
|
-
continue;
|
|
1655
|
-
case 'missing':
|
|
1656
|
-
acceptTr(accept, 'error', { node: prop }, 'NL.E0412', {
|
|
1657
|
-
key,
|
|
1658
|
-
date: dateVal,
|
|
1659
|
-
});
|
|
1660
|
-
continue;
|
|
1661
|
-
case 'valid': {
|
|
1662
|
-
const d = new Date(dateVal);
|
|
1663
|
-
if (Number.isNaN(d.getTime())) continue;
|
|
1664
|
-
if (d < start.date) {
|
|
1665
|
-
acceptTr(accept, 'error', { node: prop }, 'NL.E0413', {
|
|
1666
|
-
key,
|
|
1667
|
-
date: dateVal,
|
|
1668
|
-
start: start.iso,
|
|
1669
|
-
});
|
|
1670
|
-
}
|
|
1671
|
-
}
|
|
1672
|
-
}
|
|
1673
|
-
}
|
|
1674
|
-
}
|
|
1675
|
-
|
|
1676
|
-
if (isSwimlaneDeclaration(entry)) {
|
|
1677
|
-
for (const c of entry.content) visit(c);
|
|
1678
|
-
} else if (isParallelBlock(entry) || isGroupBlock(entry)) {
|
|
1679
|
-
for (const c of entry.content) visit(c);
|
|
1680
|
-
}
|
|
1681
|
-
};
|
|
1682
|
-
|
|
1683
|
-
for (const entry of file.roadmapEntries) visit(entry);
|
|
364
|
+
references.checkInlineDatePins(file, accept);
|
|
1684
365
|
}
|
|
1685
366
|
|
|
1686
|
-
// --- Rule 25: circular dependencies in after/before graph ---
|
|
1687
367
|
checkCircularDependencies(file: NowlineFile, accept: ValidationAcceptor): void {
|
|
1688
|
-
|
|
1689
|
-
// `after:x` on entity y means y depends on x (edge y -> x).
|
|
1690
|
-
// `before:y` on entity x means x must finish before y starts, so y depends on x (edge y -> x).
|
|
1691
|
-
const deps = new Map<string, Set<string>>();
|
|
1692
|
-
const addDep = (node: string, dep: string) => {
|
|
1693
|
-
if (!deps.has(node)) deps.set(node, new Set());
|
|
1694
|
-
deps.get(node)!.add(dep);
|
|
1695
|
-
};
|
|
1696
|
-
|
|
1697
|
-
const indexDependents = (
|
|
1698
|
-
idName: string | undefined,
|
|
1699
|
-
props: EntityProperty[],
|
|
1700
|
-
file: NowlineFile,
|
|
1701
|
-
) => {
|
|
1702
|
-
if (!idName) return;
|
|
1703
|
-
for (const prop of props) {
|
|
1704
|
-
const key = propKey(prop);
|
|
1705
|
-
if (key === 'after') {
|
|
1706
|
-
const refs = prop.value ? [prop.value] : prop.values;
|
|
1707
|
-
for (const r of refs) {
|
|
1708
|
-
if (!r) continue;
|
|
1709
|
-
// Inline date literals are not graph nodes — they pin
|
|
1710
|
-
// to a calendar position, not to another entity. Skip
|
|
1711
|
-
// them so they never participate in a cycle (per
|
|
1712
|
-
// specs/dsl.md rule 25).
|
|
1713
|
-
if (DATE_RE.test(r)) continue;
|
|
1714
|
-
addDep(idName, r);
|
|
1715
|
-
}
|
|
1716
|
-
} else if (key === 'before') {
|
|
1717
|
-
const refs = prop.value ? [prop.value] : prop.values;
|
|
1718
|
-
for (const r of refs) {
|
|
1719
|
-
if (!r) continue;
|
|
1720
|
-
if (DATE_RE.test(r)) continue;
|
|
1721
|
-
addDep(r, idName);
|
|
1722
|
-
}
|
|
1723
|
-
}
|
|
1724
|
-
}
|
|
1725
|
-
void file;
|
|
1726
|
-
};
|
|
1727
|
-
|
|
1728
|
-
const visitEntry = (entry: AstNode): void => {
|
|
1729
|
-
const id = (entry as { name?: string }).name;
|
|
1730
|
-
const props = (entry as { properties?: EntityProperty[] }).properties ?? [];
|
|
1731
|
-
indexDependents(id, props, file);
|
|
1732
|
-
|
|
1733
|
-
if (isSwimlaneDeclaration(entry)) {
|
|
1734
|
-
for (const c of entry.content) visitEntry(c);
|
|
1735
|
-
} else if (isParallelBlock(entry) || isGroupBlock(entry)) {
|
|
1736
|
-
for (const c of entry.content) visitEntry(c);
|
|
1737
|
-
}
|
|
1738
|
-
};
|
|
1739
|
-
|
|
1740
|
-
for (const entry of file.roadmapEntries) visitEntry(entry);
|
|
1741
|
-
|
|
1742
|
-
// DFS for cycles.
|
|
1743
|
-
const WHITE = 0,
|
|
1744
|
-
GRAY = 1,
|
|
1745
|
-
BLACK = 2;
|
|
1746
|
-
const color = new Map<string, number>();
|
|
1747
|
-
for (const id of deps.keys()) color.set(id, WHITE);
|
|
1748
|
-
|
|
1749
|
-
const reported = new Set<string>();
|
|
1750
|
-
const dfs = (node: string, path: string[]): void => {
|
|
1751
|
-
color.set(node, GRAY);
|
|
1752
|
-
path.push(node);
|
|
1753
|
-
for (const dep of deps.get(node) ?? []) {
|
|
1754
|
-
const c = color.get(dep) ?? WHITE;
|
|
1755
|
-
if (c === GRAY) {
|
|
1756
|
-
const cycleStart = path.indexOf(dep);
|
|
1757
|
-
const cycle = path.slice(cycleStart).concat(dep);
|
|
1758
|
-
const key = [...cycle].sort().join('→');
|
|
1759
|
-
if (!reported.has(key)) {
|
|
1760
|
-
reported.add(key);
|
|
1761
|
-
accept('error', `Circular dependency detected: ${cycle.join(' → ')}.`, {
|
|
1762
|
-
node: file.roadmapDecl ?? file,
|
|
1763
|
-
});
|
|
1764
|
-
}
|
|
1765
|
-
} else if (c === WHITE) {
|
|
1766
|
-
dfs(dep, path);
|
|
1767
|
-
}
|
|
1768
|
-
}
|
|
1769
|
-
path.pop();
|
|
1770
|
-
color.set(node, BLACK);
|
|
1771
|
-
};
|
|
1772
|
-
|
|
1773
|
-
for (const node of deps.keys()) {
|
|
1774
|
-
if ((color.get(node) ?? WHITE) === WHITE) dfs(node, []);
|
|
1775
|
-
}
|
|
368
|
+
references.checkCircularDependencies(file, accept);
|
|
1776
369
|
}
|
|
1777
370
|
|
|
1778
|
-
// --- Rules 30-32: Person declare-once + bare top-level warning ---
|
|
1779
371
|
checkPersonDeclarations(file: NowlineFile, accept: ValidationAcceptor): void {
|
|
1780
|
-
|
|
1781
|
-
const declarations = new Map<string, DeclSite[]>();
|
|
1782
|
-
|
|
1783
|
-
const isRealDeclaration = (p: PersonDeclaration): boolean => {
|
|
1784
|
-
return Boolean(p.title) || p.properties.length > 0 || p.description !== undefined;
|
|
1785
|
-
};
|
|
1786
|
-
|
|
1787
|
-
const visitPerson = (p: PersonDeclaration) => {
|
|
1788
|
-
if (!p.name) return;
|
|
1789
|
-
const isDecl = isRealDeclaration(p);
|
|
1790
|
-
if (!declarations.has(p.name)) declarations.set(p.name, []);
|
|
1791
|
-
declarations.get(p.name)!.push({ node: p, isDeclaration: isDecl });
|
|
1792
|
-
if (!isDecl && p.$container.$type === 'NowlineFile') {
|
|
1793
|
-
accept(
|
|
1794
|
-
'warning',
|
|
1795
|
-
`Bare "person ${p.name}" at roadmap top level has no declaration. Either add properties (title, link, etc.) or remove the line.`,
|
|
1796
|
-
{ node: p },
|
|
1797
|
-
);
|
|
1798
|
-
}
|
|
1799
|
-
};
|
|
1800
|
-
|
|
1801
|
-
const visitTeam = (t: TeamDeclaration) => {
|
|
1802
|
-
for (const c of t.content) {
|
|
1803
|
-
if (isPersonDeclaration(c)) visitPerson(c);
|
|
1804
|
-
else if (isTeamDeclaration(c)) visitTeam(c);
|
|
1805
|
-
}
|
|
1806
|
-
};
|
|
1807
|
-
|
|
1808
|
-
for (const entry of file.roadmapEntries) {
|
|
1809
|
-
if (isPersonDeclaration(entry)) visitPerson(entry);
|
|
1810
|
-
else if (isTeamDeclaration(entry)) visitTeam(entry);
|
|
1811
|
-
}
|
|
1812
|
-
|
|
1813
|
-
for (const [name, sites] of declarations) {
|
|
1814
|
-
const decls = sites.filter((s) => s.isDeclaration);
|
|
1815
|
-
if (decls.length > 1) {
|
|
1816
|
-
for (let i = 1; i < decls.length; i++) {
|
|
1817
|
-
accept(
|
|
1818
|
-
'error',
|
|
1819
|
-
`Person "${name}" is declared more than once. First declaration at ${locationOf(decls[0].node)}.`,
|
|
1820
|
-
{ node: decls[i].node },
|
|
1821
|
-
);
|
|
1822
|
-
}
|
|
1823
|
-
}
|
|
1824
|
-
}
|
|
372
|
+
entities.checkPersonDeclarations(file, accept);
|
|
1825
373
|
}
|
|
1826
374
|
|
|
1827
|
-
// --- Rules 17f / 17g / 17h / 17i: per-declaration symbol checks ---
|
|
1828
|
-
// Note: Langium's default ValueConverter strips surrounding quotes from STRING
|
|
1829
|
-
// tokens before they reach the AST, so unicode:"💰" arrives here as just "💰"
|
|
1830
|
-
// — we validate the *content* (length / ASCII range) rather than presence of
|
|
1831
|
-
// quotes. The grammar already restricts `unicode:` and `ascii:` to PropertyAtom,
|
|
1832
|
-
// so the only quoteless form an author can pass is a bare identifier like
|
|
1833
|
-
// `unicode:foo`, which we treat permissively (it's a single-grapheme literal).
|
|
1834
375
|
checkSymbolDeclaration(decl: SymbolDeclaration, accept: ValidationAcceptor): void {
|
|
1835
|
-
|
|
1836
|
-
accept(
|
|
1837
|
-
'error',
|
|
1838
|
-
`Symbol id "${decl.name}" collides with a built-in icon name. Reserved built-ins: ${[...BUILTIN_ICON_NAMES].sort().join(', ')}.`,
|
|
1839
|
-
{ node: decl, property: 'name' },
|
|
1840
|
-
);
|
|
1841
|
-
}
|
|
1842
|
-
|
|
1843
|
-
const unicodeProp = decl.properties.find((p) => propKey(p) === 'unicode');
|
|
1844
|
-
if (!unicodeProp) {
|
|
1845
|
-
accept(
|
|
1846
|
-
'error',
|
|
1847
|
-
`Symbol "${displayName(decl)}" requires a "unicode:" property (e.g. unicode:"💰" or unicode:"\\u{1F464}").`,
|
|
1848
|
-
{ node: decl },
|
|
1849
|
-
);
|
|
1850
|
-
} else if (!unicodeProp.value || unicodeProp.value.length === 0) {
|
|
1851
|
-
accept('error', `Symbol "${displayName(decl)}" unicode: must be a non-empty value.`, {
|
|
1852
|
-
node: unicodeProp,
|
|
1853
|
-
property: 'value',
|
|
1854
|
-
});
|
|
1855
|
-
}
|
|
1856
|
-
|
|
1857
|
-
const asciiProp = decl.properties.find((p) => propKey(p) === 'ascii');
|
|
1858
|
-
if (asciiProp) {
|
|
1859
|
-
const raw = asciiProp.value ?? '';
|
|
1860
|
-
if (!ASCII_FALLBACK_RE.test(raw)) {
|
|
1861
|
-
accept(
|
|
1862
|
-
'error',
|
|
1863
|
-
`Symbol "${displayName(decl)}" ascii: must be 1-3 ASCII characters (got ${raw.length} character${raw.length === 1 ? '' : 's'}).`,
|
|
1864
|
-
{ node: asciiProp, property: 'value' },
|
|
1865
|
-
);
|
|
1866
|
-
}
|
|
1867
|
-
}
|
|
1868
|
-
|
|
1869
|
-
for (const prop of decl.properties) {
|
|
1870
|
-
const key = propKey(prop);
|
|
1871
|
-
if (key !== 'unicode' && key !== 'ascii' && key !== 'link' && key !== 'description') {
|
|
1872
|
-
accept(
|
|
1873
|
-
'error',
|
|
1874
|
-
`Unknown symbol property "${key}". Allowed: unicode, ascii, link, description.`,
|
|
1875
|
-
{ node: prop, property: 'key' },
|
|
1876
|
-
);
|
|
1877
|
-
}
|
|
1878
|
-
}
|
|
376
|
+
symbols.checkSymbolDeclaration(decl, accept);
|
|
1879
377
|
}
|
|
1880
378
|
|
|
1881
|
-
// --- Rule 17j: duplicate symbol ids in the same file ---
|
|
1882
379
|
checkDuplicateSymbolIds(file: NowlineFile, accept: ValidationAcceptor): void {
|
|
1883
|
-
|
|
1884
|
-
for (const entry of file.configEntries) {
|
|
1885
|
-
if (isSymbolDeclaration(entry) && entry.name) {
|
|
1886
|
-
const existing = seen.get(entry.name);
|
|
1887
|
-
if (existing) {
|
|
1888
|
-
accept(
|
|
1889
|
-
'error',
|
|
1890
|
-
`Duplicate symbol id "${entry.name}". First declared at ${locationOf(existing)}.`,
|
|
1891
|
-
{ node: entry, property: 'name' },
|
|
1892
|
-
);
|
|
1893
|
-
} else {
|
|
1894
|
-
seen.set(entry.name, entry);
|
|
1895
|
-
}
|
|
1896
|
-
}
|
|
1897
|
-
}
|
|
380
|
+
symbols.checkDuplicateSymbolIds(file, accept);
|
|
1898
381
|
}
|
|
1899
382
|
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
checkSymbolReferences(file: NowlineFile, accept: ValidationAcceptor): void {
|
|
1906
|
-
const symbolOrder = new Map<string, number>();
|
|
1907
|
-
for (let i = 0; i < file.configEntries.length; i++) {
|
|
1908
|
-
const entry = file.configEntries[i];
|
|
1909
|
-
if (isSymbolDeclaration(entry) && entry.name) {
|
|
1910
|
-
if (!symbolOrder.has(entry.name)) symbolOrder.set(entry.name, i);
|
|
1911
|
-
}
|
|
1912
|
-
}
|
|
1913
|
-
|
|
1914
|
-
const checkRef = (
|
|
1915
|
-
entryIdx: number,
|
|
1916
|
-
key: string,
|
|
1917
|
-
val: string | undefined,
|
|
1918
|
-
propNode: AstNode,
|
|
1919
|
-
) => {
|
|
1920
|
-
if (key !== 'icon' && key !== 'capacity-icon') return;
|
|
1921
|
-
if (!val) return;
|
|
1922
|
-
// Inline Unicode literals (`capacity-icon:"💰"`) reach the AST as their
|
|
1923
|
-
// unquoted content — the only way to tell them from an identifier
|
|
1924
|
-
// reference is by checking the character set. Anything that doesn't
|
|
1925
|
-
// look like an identifier is treated as a literal and
|
|
1926
|
-
// accepted as-is. Authors who genuinely want to write a literal that
|
|
1927
|
-
// happens to spell a real identifier should declare a symbol instead.
|
|
1928
|
-
if (!isIdentifier(val)) return;
|
|
1929
|
-
if (key === 'capacity-icon' && BUILTIN_CAPACITY_ICONS.has(val)) return;
|
|
1930
|
-
if (key === 'icon' && BUILTIN_ICON_NAMES.has(val)) return;
|
|
1931
|
-
const declIdx = symbolOrder.get(val);
|
|
1932
|
-
if (declIdx === undefined) {
|
|
1933
|
-
const builtins =
|
|
1934
|
-
key === 'capacity-icon'
|
|
1935
|
-
? [...BUILTIN_CAPACITY_ICONS].sort().join(', ')
|
|
1936
|
-
: [...BUILTIN_ICON_NAMES].sort().join(', ');
|
|
1937
|
-
accept(
|
|
1938
|
-
'error',
|
|
1939
|
-
`${key}: "${val}" is neither a built-in (${builtins}) nor a declared symbol. Add "symbol ${val} unicode:..." earlier in config or use a quoted Unicode literal.`,
|
|
1940
|
-
{ node: propNode, property: 'value' },
|
|
1941
|
-
);
|
|
1942
|
-
} else if (declIdx >= entryIdx) {
|
|
1943
|
-
accept(
|
|
1944
|
-
'error',
|
|
1945
|
-
`${key}: symbol "${val}" is referenced before its declaration. Move "symbol ${val}" above this entry.`,
|
|
1946
|
-
{ node: propNode, property: 'value' },
|
|
1947
|
-
);
|
|
1948
|
-
}
|
|
1949
|
-
};
|
|
1950
|
-
|
|
1951
|
-
for (let i = 0; i < file.configEntries.length; i++) {
|
|
1952
|
-
const entry = file.configEntries[i];
|
|
1953
|
-
if (isStyleDeclaration(entry)) {
|
|
1954
|
-
for (const sp of entry.properties) {
|
|
1955
|
-
checkRef(i, propKey(sp), sp.value, sp);
|
|
1956
|
-
}
|
|
1957
|
-
} else if (isDefaultDeclaration(entry)) {
|
|
1958
|
-
for (const ep of entry.properties) {
|
|
1959
|
-
checkRef(i, propKey(ep), ep.value, ep);
|
|
1960
|
-
}
|
|
1961
|
-
}
|
|
1962
|
-
}
|
|
1963
|
-
}
|
|
1964
|
-
}
|
|
1965
|
-
|
|
1966
|
-
// --- Helpers ---
|
|
1967
|
-
|
|
1968
|
-
function isColorValue(val: string): boolean {
|
|
1969
|
-
return COLOR_NAMES.has(val) || HEX_COLOR_RE.test(val);
|
|
1970
|
-
}
|
|
1971
|
-
|
|
1972
|
-
function isIdentifier(val: string): boolean {
|
|
1973
|
-
return /^[a-zA-Z_][a-zA-Z0-9_-]*$/.test(val);
|
|
1974
|
-
}
|
|
1975
|
-
|
|
1976
|
-
type CapacityParentKind = 'lane' | 'item' | 'invalid';
|
|
1977
|
-
|
|
1978
|
-
function capacityParentKind(parent: AstNode | undefined): CapacityParentKind {
|
|
1979
|
-
if (!parent) return 'invalid';
|
|
1980
|
-
if (isSwimlaneDeclaration(parent)) return 'lane';
|
|
1981
|
-
if (isItemDeclaration(parent)) return 'item';
|
|
1982
|
-
if (isDefaultDeclaration(parent)) {
|
|
1983
|
-
return parent.entityType === 'swimlane' ? 'lane' : 'item';
|
|
1984
|
-
}
|
|
1985
|
-
return 'invalid';
|
|
1986
|
-
}
|
|
1987
|
-
|
|
1988
|
-
function isUtilizationAllowedHere(parent: AstNode | undefined): boolean {
|
|
1989
|
-
if (!parent) return false;
|
|
1990
|
-
if (isSwimlaneDeclaration(parent)) return true;
|
|
1991
|
-
if (isDefaultDeclaration(parent) && parent.entityType === 'swimlane') return true;
|
|
1992
|
-
return false;
|
|
1993
|
-
}
|
|
1994
|
-
|
|
1995
|
-
/**
|
|
1996
|
-
* Parse a numeric utilization-threshold value into a fraction. Mirrors the
|
|
1997
|
-
* accepted value forms in checkPropertyValues (case `utilization-warn-at` /
|
|
1998
|
-
* `utilization-over-at`):
|
|
1999
|
-
*
|
|
2000
|
-
* - `'none'` → null (opt-out; ordering check skips this side).
|
|
2001
|
-
* - positive percent (`80%`) → 0.8.
|
|
2002
|
-
* - positive decimal fraction (`0.8`) → 0.8 (or `1.25` → 1.25 for the
|
|
2003
|
-
* intentionally-stretched-over case `utilization-over-at:125%`).
|
|
2004
|
-
* - bare integer or anything else → null. Bare integers are rejected with
|
|
2005
|
-
* a disambiguation hint by the value-form check before this helper runs;
|
|
2006
|
-
* returning null here makes the ordering check skip that side instead of
|
|
2007
|
-
* double-reporting.
|
|
2008
|
-
*/
|
|
2009
|
-
function parseUtilizationFraction(val: string | undefined): number | null {
|
|
2010
|
-
if (!val || val === UTILIZATION_NONE) return null;
|
|
2011
|
-
if (POSITIVE_PERCENT_RE.test(val)) {
|
|
2012
|
-
const n = parseFloat(val);
|
|
2013
|
-
return Number.isFinite(n) && n > 0 ? n / 100 : null;
|
|
2014
|
-
}
|
|
2015
|
-
if (POSITIVE_DECIMAL_FRACTION_RE.test(val)) {
|
|
2016
|
-
const n = parseFloat(val);
|
|
2017
|
-
return Number.isFinite(n) && n > 0 ? n : null;
|
|
2018
|
-
}
|
|
2019
|
-
return null;
|
|
2020
|
-
}
|
|
2021
|
-
|
|
2022
|
-
function locationOf(node: AstNode): string {
|
|
2023
|
-
const cst = node.$cstNode;
|
|
2024
|
-
if (cst) {
|
|
2025
|
-
return `line ${cst.range.start.line + 1}`;
|
|
383
|
+
checkCalendarDeclaration(
|
|
384
|
+
decl: NonWorkingDeclaration | WorkingDeclaration,
|
|
385
|
+
accept: ValidationAcceptor,
|
|
386
|
+
): void {
|
|
387
|
+
calendar.checkCalendarDeclaration(decl, accept);
|
|
2026
388
|
}
|
|
2027
|
-
return 'unknown location';
|
|
2028
|
-
}
|
|
2029
|
-
|
|
2030
|
-
function describeNode(node: { $type: string; name?: string; title?: string }): string {
|
|
2031
|
-
const kind = node.$type.replace(/Declaration$|Block$/, '').toLowerCase();
|
|
2032
|
-
const label = node.name ?? node.title;
|
|
2033
|
-
return label ? `${kind} "${label}"` : kind;
|
|
2034
|
-
}
|
|
2035
389
|
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
register: (name: string | undefined, node: AstNode) => void,
|
|
2039
|
-
): void {
|
|
2040
|
-
if (isSwimlaneDeclaration(entry)) {
|
|
2041
|
-
register(entry.name, entry);
|
|
2042
|
-
for (const child of entry.content) {
|
|
2043
|
-
registerSwimlaneContent(child, register);
|
|
2044
|
-
}
|
|
2045
|
-
} else if (isPersonDeclaration(entry)) {
|
|
2046
|
-
register(entry.name, entry);
|
|
2047
|
-
} else if (isTeamDeclaration(entry)) {
|
|
2048
|
-
registerTeam(entry, register);
|
|
2049
|
-
} else if (isAnchorDeclaration(entry)) {
|
|
2050
|
-
register(entry.name, entry);
|
|
2051
|
-
} else if (isMilestoneDeclaration(entry)) {
|
|
2052
|
-
register(entry.name, entry);
|
|
2053
|
-
} else if (isFootnoteDeclaration(entry)) {
|
|
2054
|
-
register(entry.name, entry);
|
|
2055
|
-
} else if (isLabelDeclaration(entry)) {
|
|
2056
|
-
register(entry.name, entry);
|
|
2057
|
-
} else if (isSizeDeclaration(entry)) {
|
|
2058
|
-
register(entry.name, entry);
|
|
2059
|
-
} else if (isStatusDeclaration(entry)) {
|
|
2060
|
-
register(entry.name, entry);
|
|
390
|
+
checkCalendarWeek(file: NowlineFile, accept: ValidationAcceptor): void {
|
|
391
|
+
calendar.checkCalendarWeek(file, accept);
|
|
2061
392
|
}
|
|
2062
|
-
}
|
|
2063
393
|
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
register: (name: string | undefined, node: AstNode) => void,
|
|
2067
|
-
): void {
|
|
2068
|
-
register(team.name, team);
|
|
2069
|
-
for (const member of team.content) {
|
|
2070
|
-
if (isTeamDeclaration(member)) {
|
|
2071
|
-
registerTeam(member, register);
|
|
2072
|
-
}
|
|
2073
|
-
// PersonMemberRef and bare person <id> are references, not declarations — skip.
|
|
394
|
+
checkDuplicateCalendarDeclarationIds(file: NowlineFile, accept: ValidationAcceptor): void {
|
|
395
|
+
calendar.checkDuplicateCalendarDeclarationIds(file, accept);
|
|
2074
396
|
}
|
|
2075
|
-
}
|
|
2076
397
|
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
register: (name: string | undefined, node: AstNode) => void,
|
|
2080
|
-
): void {
|
|
2081
|
-
if (isItemDeclaration(child)) {
|
|
2082
|
-
register(child.name, child);
|
|
2083
|
-
} else if (isParallelBlock(child)) {
|
|
2084
|
-
register(child.name, child);
|
|
2085
|
-
for (const pc of child.content) {
|
|
2086
|
-
registerSwimlaneContent(pc, register);
|
|
2087
|
-
}
|
|
2088
|
-
} else if (isGroupBlock(child)) {
|
|
2089
|
-
register(child.name, child);
|
|
2090
|
-
for (const gc of child.content) {
|
|
2091
|
-
registerSwimlaneContent(gc, register);
|
|
2092
|
-
}
|
|
398
|
+
checkSymbolReferences(file: NowlineFile, accept: ValidationAcceptor): void {
|
|
399
|
+
symbols.checkSymbolReferences(file, accept);
|
|
2093
400
|
}
|
|
2094
401
|
}
|
|
2095
|
-
|
|
2096
|
-
function visitPropertiesDeep(node: AstNode, visit: (prop: EntityProperty) => void): void {
|
|
2097
|
-
const walk = (n: AstNode) => {
|
|
2098
|
-
const props = (n as unknown as { properties?: EntityProperty[] }).properties;
|
|
2099
|
-
if (Array.isArray(props)) {
|
|
2100
|
-
for (const p of props) visit(p);
|
|
2101
|
-
}
|
|
2102
|
-
if (isSwimlaneDeclaration(n)) {
|
|
2103
|
-
for (const c of n.content) walk(c);
|
|
2104
|
-
} else if (isParallelBlock(n) || isGroupBlock(n)) {
|
|
2105
|
-
for (const c of n.content) walk(c);
|
|
2106
|
-
} else if (isTeamDeclaration(n)) {
|
|
2107
|
-
for (const c of n.content) {
|
|
2108
|
-
if (isTeamDeclaration(c) || isPersonDeclaration(c)) walk(c);
|
|
2109
|
-
}
|
|
2110
|
-
}
|
|
2111
|
-
};
|
|
2112
|
-
walk(node);
|
|
2113
|
-
}
|
|
2114
|
-
|
|
2115
|
-
function collectReferenceableIds(file: NowlineFile): Set<string> {
|
|
2116
|
-
const ids = new Set<string>();
|
|
2117
|
-
if (file.roadmapDecl?.name) ids.add(file.roadmapDecl.name);
|
|
2118
|
-
|
|
2119
|
-
const addEntry = (entry: AstNode): void => {
|
|
2120
|
-
const name = (entry as { name?: string }).name;
|
|
2121
|
-
if (name) ids.add(name);
|
|
2122
|
-
if (isSwimlaneDeclaration(entry)) {
|
|
2123
|
-
for (const c of entry.content) addEntry(c);
|
|
2124
|
-
} else if (isParallelBlock(entry) || isGroupBlock(entry)) {
|
|
2125
|
-
for (const c of entry.content) addEntry(c);
|
|
2126
|
-
} else if (isTeamDeclaration(entry)) {
|
|
2127
|
-
for (const c of entry.content) {
|
|
2128
|
-
if (isTeamDeclaration(c) || isPersonDeclaration(c)) addEntry(c);
|
|
2129
|
-
else if (isPersonMemberRef(c)) {
|
|
2130
|
-
// Don't register member refs — they reference persons declared elsewhere.
|
|
2131
|
-
}
|
|
2132
|
-
}
|
|
2133
|
-
}
|
|
2134
|
-
};
|
|
2135
|
-
|
|
2136
|
-
for (const entry of file.roadmapEntries) addEntry(entry);
|
|
2137
|
-
return ids;
|
|
2138
|
-
}
|