@driftsys/markspec 0.12.1 → 0.13.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/esm/ast/build.d.ts.map +1 -1
- package/esm/ast/build.js +19 -5
- package/esm/ast/equivalence.js +14 -2
- package/esm/ast/nodes.d.ts +15 -3
- package/esm/ast/nodes.d.ts.map +1 -1
- package/esm/compiler/inverses.d.ts.map +1 -1
- package/esm/compiler/inverses.js +18 -3
- package/esm/compiler/mod.d.ts +34 -1
- package/esm/compiler/mod.d.ts.map +1 -1
- package/esm/compiler/mod.js +112 -48
- package/esm/compiler/schema.d.ts +3 -2
- package/esm/compiler/schema.d.ts.map +1 -1
- package/esm/compiler/schema.js +6 -3
- package/esm/criteria/scenarios.d.ts +55 -0
- package/esm/criteria/scenarios.d.ts.map +1 -0
- package/esm/criteria/scenarios.js +133 -0
- package/esm/discovery/mod.d.ts +20 -1
- package/esm/discovery/mod.d.ts.map +1 -1
- package/esm/discovery/mod.js +105 -17
- package/esm/formatter/entry_body.d.ts +8 -5
- package/esm/formatter/entry_body.d.ts.map +1 -1
- package/esm/formatter/entry_body.js +12 -8
- package/esm/formatter/feature_file.d.ts +40 -0
- package/esm/formatter/feature_file.d.ts.map +1 -0
- package/esm/formatter/feature_file.js +88 -0
- package/esm/formatter/mod.d.ts +21 -2
- package/esm/formatter/mod.d.ts.map +1 -1
- package/esm/formatter/mod.js +64 -22
- package/esm/gates/mod.d.ts +2 -2
- package/esm/gates/mod.d.ts.map +1 -1
- package/esm/gates/mod.js +17 -2
- package/esm/gherkin/load.d.ts +35 -0
- package/esm/gherkin/load.d.ts.map +1 -0
- package/esm/gherkin/load.js +39 -0
- package/esm/gherkin/parse.d.ts +11 -0
- package/esm/gherkin/parse.d.ts.map +1 -0
- package/esm/gherkin/parse.js +311 -0
- package/esm/gherkin/position.d.ts +23 -0
- package/esm/gherkin/position.d.ts.map +1 -0
- package/esm/gherkin/position.js +21 -0
- package/esm/gherkin/procedure.d.ts +76 -0
- package/esm/gherkin/procedure.d.ts.map +1 -0
- package/esm/gherkin/procedure.js +164 -0
- package/esm/gherkin/project.d.ts +35 -0
- package/esm/gherkin/project.d.ts.map +1 -0
- package/esm/gherkin/project.js +64 -0
- package/esm/gherkin/role.d.ts +23 -0
- package/esm/gherkin/role.d.ts.map +1 -0
- package/esm/gherkin/role.js +28 -0
- package/esm/gherkin/types.d.ts +118 -0
- package/esm/gherkin/types.d.ts.map +1 -0
- package/esm/gherkin/types.js +12 -0
- package/esm/lock/acquire_compile.d.ts +12 -4
- package/esm/lock/acquire_compile.d.ts.map +1 -1
- package/esm/lock/acquire_compile.js +15 -5
- package/esm/lock/canonical_edges.d.ts +6 -2
- package/esm/lock/canonical_edges.d.ts.map +1 -1
- package/esm/lock/canonical_edges.js +10 -3
- package/esm/lock/model.d.ts +5 -0
- package/esm/lock/model.d.ts.map +1 -1
- package/esm/lock/parser.d.ts.map +1 -1
- package/esm/lock/parser.js +2 -0
- package/esm/lock/resolve.d.ts +6 -2
- package/esm/lock/resolve.d.ts.map +1 -1
- package/esm/lock/resolve.js +36 -4
- package/esm/lock/serializer.d.ts.map +1 -1
- package/esm/lock/serializer.js +7 -1
- package/esm/mod.d.ts +23 -6
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +18 -5
- package/esm/model/mod.d.ts +42 -1
- package/esm/model/mod.d.ts.map +1 -1
- package/esm/model/mod.js +1 -1
- package/esm/model/relations.d.ts +9 -0
- package/esm/model/relations.d.ts.map +1 -1
- package/esm/model/relations.js +16 -1
- package/esm/parser/attributes.d.ts +82 -3
- package/esm/parser/attributes.d.ts.map +1 -1
- package/esm/parser/attributes.js +199 -32
- package/esm/parser/body_tokens.d.ts +1 -1
- package/esm/parser/body_tokens.d.ts.map +1 -1
- package/esm/parser/body_tokens.js +49 -35
- package/esm/parser/feature_file.d.ts +116 -0
- package/esm/parser/feature_file.d.ts.map +1 -0
- package/esm/parser/feature_file.js +540 -0
- package/esm/parser/markdown.d.ts +7 -0
- package/esm/parser/markdown.d.ts.map +1 -1
- package/esm/parser/markdown.js +129 -40
- package/esm/parser/mod.d.ts +18 -0
- package/esm/parser/mod.d.ts.map +1 -1
- package/esm/parser/mod.js +51 -0
- package/esm/parser/translate.d.ts.map +1 -1
- package/esm/parser/translate.js +5 -0
- package/esm/refs/mod.d.ts +2 -1
- package/esm/refs/mod.d.ts.map +1 -1
- package/esm/refs/mod.js +12 -4
- package/esm/refs/split.d.ts +58 -0
- package/esm/refs/split.d.ts.map +1 -0
- package/esm/refs/split.js +137 -0
- package/esm/reporter/mod.d.ts +7 -0
- package/esm/reporter/mod.d.ts.map +1 -1
- package/esm/reporter/mod.js +113 -3
- package/esm/validator/attributes.d.ts.map +1 -1
- package/esm/validator/attributes.js +4 -1
- package/esm/validator/block_role.d.ts +40 -0
- package/esm/validator/block_role.d.ts.map +1 -0
- package/esm/validator/block_role.js +109 -0
- package/esm/validator/feature_ac.d.ts.map +1 -1
- package/esm/validator/feature_ac.js +6 -1
- package/esm/validator/feature_parse.d.ts +35 -0
- package/esm/validator/feature_parse.d.ts.map +1 -0
- package/esm/validator/feature_parse.js +69 -0
- package/esm/validator/locators.d.ts +36 -0
- package/esm/validator/locators.d.ts.map +1 -0
- package/esm/validator/locators.js +184 -0
- package/esm/validator/mod.d.ts +10 -1
- package/esm/validator/mod.d.ts.map +1 -1
- package/esm/validator/mod.js +38 -14
- package/esm/validator/normalize.d.ts.map +1 -1
- package/esm/validator/normalize.js +8 -3
- package/esm/validator/per_type_attrs.d.ts +3 -3
- package/esm/validator/per_type_attrs.js +3 -3
- package/esm/validator/pipeline.d.ts +4 -12
- package/esm/validator/pipeline.d.ts.map +1 -1
- package/esm/validator/pipeline.js +24 -5
- package/esm/validator/procedure.d.ts +22 -0
- package/esm/validator/procedure.d.ts.map +1 -0
- package/esm/validator/procedure.js +58 -0
- package/esm/validator/trace_types.d.ts.map +1 -1
- package/esm/validator/trace_types.js +4 -3
- package/esm/validator/traceability.d.ts.map +1 -1
- package/esm/validator/traceability.js +4 -1
- package/esm/validator/type_resolution.d.ts +5 -3
- package/esm/validator/type_resolution.d.ts.map +1 -1
- package/esm/validator/type_resolution.js +14 -2
- package/esm/validator/types.d.ts +11 -0
- package/esm/validator/types.d.ts.map +1 -1
- package/esm/validator/types.js +26 -4
- package/esm/validator/uxil_family.d.ts +1 -1
- package/package.json +3 -1
- package/script/ast/build.d.ts.map +1 -1
- package/script/ast/build.js +19 -5
- package/script/ast/equivalence.js +14 -2
- package/script/ast/nodes.d.ts +15 -3
- package/script/ast/nodes.d.ts.map +1 -1
- package/script/compiler/inverses.d.ts.map +1 -1
- package/script/compiler/inverses.js +18 -3
- package/script/compiler/mod.d.ts +34 -1
- package/script/compiler/mod.d.ts.map +1 -1
- package/script/compiler/mod.js +110 -46
- package/script/compiler/schema.d.ts +3 -2
- package/script/compiler/schema.d.ts.map +1 -1
- package/script/compiler/schema.js +6 -3
- package/script/criteria/scenarios.d.ts +55 -0
- package/script/criteria/scenarios.d.ts.map +1 -0
- package/script/criteria/scenarios.js +139 -0
- package/script/discovery/mod.d.ts +20 -1
- package/script/discovery/mod.d.ts.map +1 -1
- package/script/discovery/mod.js +106 -17
- package/script/formatter/entry_body.d.ts +8 -5
- package/script/formatter/entry_body.d.ts.map +1 -1
- package/script/formatter/entry_body.js +12 -8
- package/script/formatter/feature_file.d.ts +40 -0
- package/script/formatter/feature_file.d.ts.map +1 -0
- package/script/formatter/feature_file.js +92 -0
- package/script/formatter/mod.d.ts +21 -2
- package/script/formatter/mod.d.ts.map +1 -1
- package/script/formatter/mod.js +63 -21
- package/script/gates/mod.d.ts +2 -2
- package/script/gates/mod.d.ts.map +1 -1
- package/script/gates/mod.js +17 -2
- package/script/gherkin/load.d.ts +35 -0
- package/script/gherkin/load.d.ts.map +1 -0
- package/script/gherkin/load.js +76 -0
- package/script/gherkin/parse.d.ts +11 -0
- package/script/gherkin/parse.d.ts.map +1 -0
- package/script/gherkin/parse.js +314 -0
- package/script/gherkin/position.d.ts +23 -0
- package/script/gherkin/position.d.ts.map +1 -0
- package/script/gherkin/position.js +24 -0
- package/script/gherkin/procedure.d.ts +76 -0
- package/script/gherkin/procedure.d.ts.map +1 -0
- package/script/gherkin/procedure.js +169 -0
- package/script/gherkin/project.d.ts +35 -0
- package/script/gherkin/project.d.ts.map +1 -0
- package/script/gherkin/project.js +67 -0
- package/script/gherkin/role.d.ts +23 -0
- package/script/gherkin/role.d.ts.map +1 -0
- package/script/gherkin/role.js +31 -0
- package/script/gherkin/types.d.ts +118 -0
- package/script/gherkin/types.d.ts.map +1 -0
- package/script/gherkin/types.js +13 -0
- package/script/lock/acquire_compile.d.ts +12 -4
- package/script/lock/acquire_compile.d.ts.map +1 -1
- package/script/lock/acquire_compile.js +15 -5
- package/script/lock/canonical_edges.d.ts +6 -2
- package/script/lock/canonical_edges.d.ts.map +1 -1
- package/script/lock/canonical_edges.js +10 -3
- package/script/lock/model.d.ts +5 -0
- package/script/lock/model.d.ts.map +1 -1
- package/script/lock/parser.d.ts.map +1 -1
- package/script/lock/parser.js +2 -0
- package/script/lock/resolve.d.ts +6 -2
- package/script/lock/resolve.d.ts.map +1 -1
- package/script/lock/resolve.js +36 -4
- package/script/lock/serializer.d.ts.map +1 -1
- package/script/lock/serializer.js +7 -1
- package/script/mod.d.ts +23 -6
- package/script/mod.d.ts.map +1 -1
- package/script/mod.js +45 -6
- package/script/model/mod.d.ts +42 -1
- package/script/model/mod.d.ts.map +1 -1
- package/script/model/mod.js +2 -1
- package/script/model/relations.d.ts +9 -0
- package/script/model/relations.d.ts.map +1 -1
- package/script/model/relations.js +17 -1
- package/script/parser/attributes.d.ts +82 -3
- package/script/parser/attributes.d.ts.map +1 -1
- package/script/parser/attributes.js +205 -33
- package/script/parser/body_tokens.d.ts +1 -1
- package/script/parser/body_tokens.d.ts.map +1 -1
- package/script/parser/body_tokens.js +49 -35
- package/script/parser/feature_file.d.ts +116 -0
- package/script/parser/feature_file.d.ts.map +1 -0
- package/script/parser/feature_file.js +548 -0
- package/script/parser/markdown.d.ts +7 -0
- package/script/parser/markdown.d.ts.map +1 -1
- package/script/parser/markdown.js +128 -39
- package/script/parser/mod.d.ts +18 -0
- package/script/parser/mod.d.ts.map +1 -1
- package/script/parser/mod.js +52 -1
- package/script/parser/translate.d.ts.map +1 -1
- package/script/parser/translate.js +5 -0
- package/script/refs/mod.d.ts +2 -1
- package/script/refs/mod.d.ts.map +1 -1
- package/script/refs/mod.js +12 -4
- package/script/refs/split.d.ts +58 -0
- package/script/refs/split.d.ts.map +1 -0
- package/script/refs/split.js +145 -0
- package/script/reporter/mod.d.ts +7 -0
- package/script/reporter/mod.d.ts.map +1 -1
- package/script/reporter/mod.js +113 -3
- package/script/validator/attributes.d.ts.map +1 -1
- package/script/validator/attributes.js +4 -1
- package/script/validator/block_role.d.ts +40 -0
- package/script/validator/block_role.d.ts.map +1 -0
- package/script/validator/block_role.js +112 -0
- package/script/validator/feature_ac.d.ts.map +1 -1
- package/script/validator/feature_ac.js +6 -1
- package/script/validator/feature_parse.d.ts +35 -0
- package/script/validator/feature_parse.d.ts.map +1 -0
- package/script/validator/feature_parse.js +73 -0
- package/script/validator/locators.d.ts +36 -0
- package/script/validator/locators.d.ts.map +1 -0
- package/script/validator/locators.js +188 -0
- package/script/validator/mod.d.ts +10 -1
- package/script/validator/mod.d.ts.map +1 -1
- package/script/validator/mod.js +38 -14
- package/script/validator/normalize.d.ts.map +1 -1
- package/script/validator/normalize.js +8 -3
- package/script/validator/per_type_attrs.d.ts +3 -3
- package/script/validator/per_type_attrs.js +3 -3
- package/script/validator/pipeline.d.ts +4 -12
- package/script/validator/pipeline.d.ts.map +1 -1
- package/script/validator/pipeline.js +23 -5
- package/script/validator/procedure.d.ts +22 -0
- package/script/validator/procedure.d.ts.map +1 -0
- package/script/validator/procedure.js +61 -0
- package/script/validator/trace_types.d.ts.map +1 -1
- package/script/validator/trace_types.js +4 -3
- package/script/validator/traceability.d.ts.map +1 -1
- package/script/validator/traceability.js +4 -1
- package/script/validator/type_resolution.d.ts +5 -3
- package/script/validator/type_resolution.d.ts.map +1 -1
- package/script/validator/type_resolution.js +14 -2
- package/script/validator/types.d.ts +11 -0
- package/script/validator/types.d.ts.map +1 -1
- package/script/validator/types.js +27 -4
- package/script/validator/uxil_family.d.ts +1 -1
package/esm/reporter/mod.d.ts
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* traceability matrices and coverage reports in md, json, or csv format.
|
|
6
6
|
*/
|
|
7
7
|
import type { CompileResult } from "../compiler/mod.js";
|
|
8
|
+
import type { EffectiveProfile } from "../model/mod.js";
|
|
8
9
|
/** Supported report kinds. */
|
|
9
10
|
export type ReportKind = "traceability" | "coverage";
|
|
10
11
|
/** Supported output formats. */
|
|
@@ -30,6 +31,12 @@ export interface ReportOptions {
|
|
|
30
31
|
* reference leaf.
|
|
31
32
|
*/
|
|
32
33
|
readonly dependencyUpstreamIds?: ReadonlySet<string>;
|
|
34
|
+
/**
|
|
35
|
+
* The active profile. The criterion coverage section counts a verifier
|
|
36
|
+
* only when its type is, or extends, the core `Test` type; without a
|
|
37
|
+
* profile, only core types are resolved.
|
|
38
|
+
*/
|
|
39
|
+
readonly profile?: EffectiveProfile;
|
|
33
40
|
}
|
|
34
41
|
/**
|
|
35
42
|
* Generate a report from compiled traceability graph.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/reporter/mod.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/reporter/mod.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAa,gBAAgB,EAAS,MAAM,iBAAiB,CAAC;AAQ1E,8BAA8B;AAC9B,MAAM,MAAM,UAAU,GAAG,cAAc,GAAG,UAAU,CAAC;AAErD,gCAAgC;AAChC,MAAM,MAAM,YAAY,GAAG,IAAI,GAAG,MAAM,GAAG,KAAK,CAAC;AAEjD,sCAAsC;AACtC,MAAM,WAAW,aAAa;IAC5B,mBAAmB;IACnB,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,qBAAqB;IACrB,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,2DAA2D;IAC3D,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,qCAAqC;IACrC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB;;;;;;;;;OASG;IACH,QAAQ,CAAC,qBAAqB,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACrD;;;;OAIG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,gBAAgB,CAAC;CACrC;AAED;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,aAAa,GAAG,MAAM,CAa5E"}
|
package/esm/reporter/mod.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* Output reporters. Transforms compiled traceability graph into
|
|
5
5
|
* traceability matrices and coverage reports in md, json, or csv format.
|
|
6
6
|
*/
|
|
7
|
+
import { isTestEntry } from "../criteria/scenarios.js";
|
|
7
8
|
import { formatEntryOrigin, isCorpusEntry, isUpstreamEntry, } from "../model/mod.js";
|
|
8
9
|
/**
|
|
9
10
|
* Generate a report from compiled traceability graph.
|
|
@@ -17,7 +18,7 @@ export function report(result, options) {
|
|
|
17
18
|
if (options.kind === "traceability") {
|
|
18
19
|
return formatTraceability(result, entries, options.format);
|
|
19
20
|
}
|
|
20
|
-
return formatCoverage(result, entries, options.format, options.dependencyUpstreamIds);
|
|
21
|
+
return formatCoverage(result, entries, options.format, options.dependencyUpstreamIds, options.profile);
|
|
21
22
|
}
|
|
22
23
|
// ---------------------------------------------------------------------------
|
|
23
24
|
// Filtering
|
|
@@ -143,10 +144,13 @@ function computeCoverage(result, entries, opts = {}) {
|
|
|
143
144
|
gaps: { orphans, unsatisfied },
|
|
144
145
|
};
|
|
145
146
|
}
|
|
146
|
-
function formatCoverage(result, entries, format, dependencyUpstreamIds) {
|
|
147
|
+
function formatCoverage(result, entries, format, dependencyUpstreamIds, profile) {
|
|
147
148
|
const stats = computeCoverage(result, entries, { dependencyUpstreamIds });
|
|
149
|
+
// Absent when no reported entry has criteria, so coverage output for a
|
|
150
|
+
// project without feature blocks stays unchanged.
|
|
151
|
+
const criteria = computeCriterionCoverage(result, entries, profile);
|
|
148
152
|
if (format === "json") {
|
|
149
|
-
return JSON.stringify(stats, null, 2);
|
|
153
|
+
return JSON.stringify(criteria ? { ...stats, criteria } : stats, null, 2);
|
|
150
154
|
}
|
|
151
155
|
if (format === "csv") {
|
|
152
156
|
const lines = [
|
|
@@ -158,6 +162,9 @@ function formatCoverage(result, entries, format, dependencyUpstreamIds) {
|
|
|
158
162
|
`Orphans,${stats.gaps.orphans.length}`,
|
|
159
163
|
`Unsatisfied parents,${stats.gaps.unsatisfied.length}`,
|
|
160
164
|
];
|
|
165
|
+
if (criteria) {
|
|
166
|
+
lines.push(`Criteria total,${criteria.total}`, `Criteria verified,${criteria.verified}`);
|
|
167
|
+
}
|
|
161
168
|
return lines.join("\n");
|
|
162
169
|
}
|
|
163
170
|
// Markdown
|
|
@@ -182,8 +189,111 @@ function formatCoverage(result, entries, format, dependencyUpstreamIds) {
|
|
|
182
189
|
if (stats.gaps.unsatisfied.length > 0) {
|
|
183
190
|
lines.push("## Unsatisfied parents (STK/SYS with no children)", "", ...stats.gaps.unsatisfied.map((id) => `- ${id}`), "");
|
|
184
191
|
}
|
|
192
|
+
if (criteria)
|
|
193
|
+
lines.push(...formatCriteriaMarkdown(criteria));
|
|
185
194
|
return lines.join("\n");
|
|
186
195
|
}
|
|
196
|
+
/**
|
|
197
|
+
* Compute per-criterion verification for the reported entries that carry
|
|
198
|
+
* criteria. Returns `undefined` when none does.
|
|
199
|
+
*
|
|
200
|
+
* Only `verifies` links count, and only when the verifier's type is, or
|
|
201
|
+
* extends, the core `Test` type; an entry never verifies itself. A link
|
|
202
|
+
* without a locator verifies every criterion of its target. A link with a
|
|
203
|
+
* locator verifies the named criterion only when `locatorResolved` is
|
|
204
|
+
* `true`. A generated inverse runs from the target to the verifier; the
|
|
205
|
+
* verifier set removes the duplicate it makes of the authored link.
|
|
206
|
+
* Upstream (federated) entries are not reported.
|
|
207
|
+
*/
|
|
208
|
+
function computeCriterionCoverage(result, entries, profile) {
|
|
209
|
+
const withCriteria = entries.filter((e) => (e.criteria?.length ?? 0) > 0 && !isUpstreamEntry(e));
|
|
210
|
+
if (withCriteria.length === 0)
|
|
211
|
+
return undefined;
|
|
212
|
+
// A link end may be written as a ULID; report display IDs.
|
|
213
|
+
const byUlid = new Map();
|
|
214
|
+
for (const e of result.entries.values())
|
|
215
|
+
if (e.id)
|
|
216
|
+
byUlid.set(e.id, e);
|
|
217
|
+
const resolve = (id) => result.entries.get(id) ?? byUlid.get(id);
|
|
218
|
+
// Target display ID → criterion name ("" for whole entry) → verifiers.
|
|
219
|
+
const verifiers = new Map();
|
|
220
|
+
for (const link of result.links) {
|
|
221
|
+
if (link.kind !== "verifies")
|
|
222
|
+
continue;
|
|
223
|
+
if (link.locator !== undefined && link.locatorResolved !== true)
|
|
224
|
+
continue;
|
|
225
|
+
const generated = link.origin === "generated";
|
|
226
|
+
const targetEntry = resolve(generated ? link.from : link.to);
|
|
227
|
+
const verifierEntry = resolve(generated ? link.to : link.from);
|
|
228
|
+
if (!targetEntry || !verifierEntry)
|
|
229
|
+
continue;
|
|
230
|
+
if (targetEntry.displayId === verifierEntry.displayId)
|
|
231
|
+
continue;
|
|
232
|
+
if (!isTestEntry(verifierEntry, profile))
|
|
233
|
+
continue;
|
|
234
|
+
const target = targetEntry.displayId;
|
|
235
|
+
const verifier = verifierEntry.displayId;
|
|
236
|
+
let byName = verifiers.get(target);
|
|
237
|
+
if (!byName) {
|
|
238
|
+
byName = new Map();
|
|
239
|
+
verifiers.set(target, byName);
|
|
240
|
+
}
|
|
241
|
+
const key = link.locator ?? "";
|
|
242
|
+
let set = byName.get(key);
|
|
243
|
+
if (!set) {
|
|
244
|
+
set = new Set();
|
|
245
|
+
byName.set(key, set);
|
|
246
|
+
}
|
|
247
|
+
set.add(verifier);
|
|
248
|
+
}
|
|
249
|
+
let total = 0;
|
|
250
|
+
let verified = 0;
|
|
251
|
+
const rows = withCriteria.map((entry) => {
|
|
252
|
+
const byName = verifiers.get(entry.displayId);
|
|
253
|
+
const whole = byName?.get("") ?? new Set();
|
|
254
|
+
const criteria = entry.criteria.map((c) => {
|
|
255
|
+
const named = c.addressable ? byName?.get(c.name) : undefined;
|
|
256
|
+
const all = new Set([...whole, ...(named ?? [])]);
|
|
257
|
+
return {
|
|
258
|
+
name: c.name,
|
|
259
|
+
addressable: c.addressable,
|
|
260
|
+
verifiedBy: [...all].sort(),
|
|
261
|
+
};
|
|
262
|
+
});
|
|
263
|
+
const entryVerified = criteria.filter((c) => c.verifiedBy.length > 0)
|
|
264
|
+
.length;
|
|
265
|
+
total += criteria.length;
|
|
266
|
+
verified += entryVerified;
|
|
267
|
+
return {
|
|
268
|
+
displayId: entry.displayId,
|
|
269
|
+
title: entry.title,
|
|
270
|
+
state: entryVerified === criteria.length
|
|
271
|
+
? "full"
|
|
272
|
+
: entryVerified === 0
|
|
273
|
+
? "none"
|
|
274
|
+
: "partial",
|
|
275
|
+
verified: entryVerified,
|
|
276
|
+
total: criteria.length,
|
|
277
|
+
criteria,
|
|
278
|
+
};
|
|
279
|
+
});
|
|
280
|
+
return { total, verified, entries: rows };
|
|
281
|
+
}
|
|
282
|
+
/** Render the `## Criteria` Markdown section, one text block per entry. */
|
|
283
|
+
function formatCriteriaMarkdown(criteria) {
|
|
284
|
+
const lines = ["## Criteria", ""];
|
|
285
|
+
for (const entry of criteria.entries) {
|
|
286
|
+
const width = Math.max(...entry.criteria.map((c) => c.name.length));
|
|
287
|
+
lines.push("```text", `${entry.displayId} ${entry.title} ${entry.verified}/${entry.total} criteria verified`, ...entry.criteria.map((c) => {
|
|
288
|
+
const mark = c.verifiedBy.length > 0 ? "\u2713" : "\u2717";
|
|
289
|
+
const by = c.verifiedBy.length > 0
|
|
290
|
+
? c.verifiedBy.join(", ")
|
|
291
|
+
: "no verifier";
|
|
292
|
+
return ` ${mark} ${c.name.padEnd(width)} \u2190 ${by}`;
|
|
293
|
+
}), "```", "");
|
|
294
|
+
}
|
|
295
|
+
return lines;
|
|
296
|
+
}
|
|
187
297
|
// ---------------------------------------------------------------------------
|
|
188
298
|
// Helpers
|
|
189
299
|
// ---------------------------------------------------------------------------
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attributes.d.ts","sourceRoot":"","sources":["../../src/validator/attributes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EACV,QAAQ,EACR,UAAU,EACV,gBAAgB,EAChB,KAAK,EACN,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"attributes.d.ts","sourceRoot":"","sources":["../../src/validator/attributes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EACV,QAAQ,EACR,UAAU,EACV,gBAAgB,EAChB,KAAK,EACN,MAAM,iBAAiB,CAAC;AAYzB;;;;;;;;;;GAUG;AACH,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC,QAAQ,CAAC,UAAU,EAAE,WAAW,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;CACpD;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,gBAAgB,GACxB,kBAAkB,CAoCpB;AAqBD;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,gBAAgB,GACxB,UAAU,EAAE,CA8Ed"}
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
*/
|
|
13
13
|
import { UNIVERSAL_ATTRIBUTE_KEYS } from "../model/mod.js";
|
|
14
14
|
import { validateValue } from "./value_types.js";
|
|
15
|
+
import { traceTarget } from "../refs/split.js";
|
|
15
16
|
/** Core-reserved attribute keys that are always permitted regardless of profile. */
|
|
16
17
|
const CORE_RESERVED_KEYS = new Set([
|
|
17
18
|
"Id",
|
|
@@ -132,8 +133,10 @@ export function validateAttributesForEntry(entry, profile) {
|
|
|
132
133
|
});
|
|
133
134
|
}
|
|
134
135
|
// MSL-A004: value-type conformance.
|
|
136
|
+
// A bracket locator (`A [x]`) is not part of an id value.
|
|
137
|
+
const isIdType = decl.type === "id" || decl.type === "id-list";
|
|
135
138
|
for (const v of values) {
|
|
136
|
-
const detail = validateValue(v, decl);
|
|
139
|
+
const detail = validateValue(isIdType ? traceTarget(v) : v, decl);
|
|
137
140
|
if (detail !== null) {
|
|
138
141
|
diagnostics.push({
|
|
139
142
|
code: "MSL-A004",
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/validator/block_role
|
|
3
|
+
*
|
|
4
|
+
* Diagnostics for the role of a Gherkin block (epic #915, ADR-038).
|
|
5
|
+
*
|
|
6
|
+
* `MSL-B064` (warning): a scenario of a criteria block has no outcome step.
|
|
7
|
+
* A criteria block belongs to an entry that is, or extends, a Requirement
|
|
8
|
+
* or a Contract (see `blockRole`). The scenario has no `Then` step (or the
|
|
9
|
+
* keyword of the block language that means `Then`, including `And` and `But`
|
|
10
|
+
* after it), or no step at all. A scenario with `Given` and `Then` and no
|
|
11
|
+
* action is valid. `Scenario Outline` Examples are not considered.
|
|
12
|
+
*
|
|
13
|
+
* Each `feature` or `gherkin` block is checked in a top-level block or in a
|
|
14
|
+
* list item at any depth, as for `MSL-B062`. A block that has a `parseError`
|
|
15
|
+
* or no `feature` is skipped. Upstream entries are not checked
|
|
16
|
+
* (`emittableEntries`). An entry without a type after classification with
|
|
17
|
+
* the profile is not checked.
|
|
18
|
+
*
|
|
19
|
+
* The warning is reported at the file line of the `Scenario` keyword, in
|
|
20
|
+
* column 1.
|
|
21
|
+
*
|
|
22
|
+
* Four information diagnostics (severity `info`) complete the checks:
|
|
23
|
+
*
|
|
24
|
+
* - `MSL-B065`: in a procedure block (an entry that is, or extends, a Test),
|
|
25
|
+
* a step has an expected result and no action. Reported at the line of the
|
|
26
|
+
* first expected-result step.
|
|
27
|
+
* - `MSL-B066`: a scenario starts with `And` or `But`, which is read as an
|
|
28
|
+
* action. Reported at the line of that step. It applies to every role
|
|
29
|
+
* except an illustration.
|
|
30
|
+
* - `MSL-B067`: in a procedure block, a `# Step` label comment labels no
|
|
31
|
+
* step. Reported at the line of the comment.
|
|
32
|
+
* - `MSL-B068`: a feature block in a typed entry whose type has no role (an
|
|
33
|
+
* illustration). Reported at the first line of the block.
|
|
34
|
+
*
|
|
35
|
+
* The diagnostics of one entry are sorted by file line.
|
|
36
|
+
*/
|
|
37
|
+
import type { Diagnostic, EffectiveProfile, Entry } from "../model/mod.js";
|
|
38
|
+
/** Report the block-role diagnostics for `entries`. */
|
|
39
|
+
export declare function checkBlockRoles(entries: readonly Entry[], profile: EffectiveProfile | null): Diagnostic[];
|
|
40
|
+
//# sourceMappingURL=block_role.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"block_role.d.ts","sourceRoot":"","sources":["../../src/validator/block_role.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAY3E,uDAAuD;AACvD,wBAAgB,eAAe,CAC7B,OAAO,EAAE,SAAS,KAAK,EAAE,EACzB,OAAO,EAAE,gBAAgB,GAAG,IAAI,GAC/B,UAAU,EAAE,CAmGd"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/validator/block_role
|
|
3
|
+
*
|
|
4
|
+
* Diagnostics for the role of a Gherkin block (epic #915, ADR-038).
|
|
5
|
+
*
|
|
6
|
+
* `MSL-B064` (warning): a scenario of a criteria block has no outcome step.
|
|
7
|
+
* A criteria block belongs to an entry that is, or extends, a Requirement
|
|
8
|
+
* or a Contract (see `blockRole`). The scenario has no `Then` step (or the
|
|
9
|
+
* keyword of the block language that means `Then`, including `And` and `But`
|
|
10
|
+
* after it), or no step at all. A scenario with `Given` and `Then` and no
|
|
11
|
+
* action is valid. `Scenario Outline` Examples are not considered.
|
|
12
|
+
*
|
|
13
|
+
* Each `feature` or `gherkin` block is checked in a top-level block or in a
|
|
14
|
+
* list item at any depth, as for `MSL-B062`. A block that has a `parseError`
|
|
15
|
+
* or no `feature` is skipped. Upstream entries are not checked
|
|
16
|
+
* (`emittableEntries`). An entry without a type after classification with
|
|
17
|
+
* the profile is not checked.
|
|
18
|
+
*
|
|
19
|
+
* The warning is reported at the file line of the `Scenario` keyword, in
|
|
20
|
+
* column 1.
|
|
21
|
+
*
|
|
22
|
+
* Four information diagnostics (severity `info`) complete the checks:
|
|
23
|
+
*
|
|
24
|
+
* - `MSL-B065`: in a procedure block (an entry that is, or extends, a Test),
|
|
25
|
+
* a step has an expected result and no action. Reported at the line of the
|
|
26
|
+
* first expected-result step.
|
|
27
|
+
* - `MSL-B066`: a scenario starts with `And` or `But`, which is read as an
|
|
28
|
+
* action. Reported at the line of that step. It applies to every role
|
|
29
|
+
* except an illustration.
|
|
30
|
+
* - `MSL-B067`: in a procedure block, a `# Step` label comment labels no
|
|
31
|
+
* step. Reported at the line of the comment.
|
|
32
|
+
* - `MSL-B068`: a feature block in a typed entry whose type has no role (an
|
|
33
|
+
* illustration). Reported at the first line of the block.
|
|
34
|
+
*
|
|
35
|
+
* The diagnostics of one entry are sorted by file line.
|
|
36
|
+
*/
|
|
37
|
+
import { emittableEntries } from "../model/mod.js";
|
|
38
|
+
import { blockRole } from "../gherkin/role.js";
|
|
39
|
+
import { scenarioProcedure, stepRoles, unplacedStepLabels, } from "../gherkin/procedure.js";
|
|
40
|
+
import { featureFileLine } from "../gherkin/position.js";
|
|
41
|
+
import { featureNodes } from "./feature_parse.js";
|
|
42
|
+
import { withType } from "./locators.js";
|
|
43
|
+
/** Report the block-role diagnostics for `entries`. */
|
|
44
|
+
export function checkBlockRoles(entries, profile) {
|
|
45
|
+
const diagnostics = [];
|
|
46
|
+
for (const candidate of emittableEntries(entries)) {
|
|
47
|
+
const nodes = [...featureNodes(candidate.bodyAst ?? [])];
|
|
48
|
+
if (nodes.length === 0)
|
|
49
|
+
continue;
|
|
50
|
+
// Classify an unclassified entry, as `validateLocators` does.
|
|
51
|
+
const entry = withType(candidate, profile);
|
|
52
|
+
const role = blockRole(entry, profile);
|
|
53
|
+
if (role === undefined)
|
|
54
|
+
continue;
|
|
55
|
+
const found = [];
|
|
56
|
+
const report = (code, node, sourceLine, severity, message) => found.push({
|
|
57
|
+
code,
|
|
58
|
+
severity,
|
|
59
|
+
message: `${entry.displayId}: ${message}`,
|
|
60
|
+
location: {
|
|
61
|
+
file: entry.location.file,
|
|
62
|
+
line: featureFileLine(entry, node, sourceLine),
|
|
63
|
+
column: 1,
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
for (const node of nodes) {
|
|
67
|
+
if (node.parseError !== undefined || node.feature === undefined)
|
|
68
|
+
continue;
|
|
69
|
+
const feature = node.feature;
|
|
70
|
+
if (role === "illustration") {
|
|
71
|
+
report("MSL-B068", node, 1, "info", `Gherkin block in a ${entry.type} entry is an illustration; only ` +
|
|
72
|
+
"Requirement, Contract and Test entries give it a meaning");
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
for (const scenario of feature.scenarios) {
|
|
76
|
+
const first = scenario.steps[0];
|
|
77
|
+
if (first !== undefined &&
|
|
78
|
+
(first.normalized === "and" || first.normalized === "but")) {
|
|
79
|
+
report("MSL-B066", node, first.range.start.line, "info", `scenario "${scenario.name}" starts with "${first.keyword}"; ` +
|
|
80
|
+
"the step is read as an action; start with Given, When or Then");
|
|
81
|
+
}
|
|
82
|
+
if (role === "criteria") {
|
|
83
|
+
if (stepRoles(scenario.steps).includes("outcome"))
|
|
84
|
+
continue;
|
|
85
|
+
report("MSL-B064", node, scenario.range.start.line, "warning", `scenario "${scenario.name}" has no outcome (no Then step); a ` +
|
|
86
|
+
"criterion must state what has to hold; add a Then step");
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
const procedure = scenarioProcedure(scenario, feature.comments);
|
|
90
|
+
for (const step of procedure.steps) {
|
|
91
|
+
if (step.actions.length > 0 || step.expected.length === 0)
|
|
92
|
+
continue;
|
|
93
|
+
report("MSL-B065", node, step.expected[0].step.range.start.line, "info", `step ${step.n} of scenario "${scenario.name}" has an expected ` +
|
|
94
|
+
"result and no action; add a When step before the Then step");
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
if (role === "procedure") {
|
|
98
|
+
for (const comment of unplacedStepLabels(feature)) {
|
|
99
|
+
report("MSL-B067", node, comment.line, "info", `"${comment.text.trim()}" labels no procedure step; place it ` +
|
|
100
|
+
"on the first line of a procedure step");
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
// Stable sort: diagnostics of one entry follow the file order.
|
|
105
|
+
found.sort((a, b) => a.location.line - b.location.line);
|
|
106
|
+
diagnostics.push(...found);
|
|
107
|
+
}
|
|
108
|
+
return diagnostics;
|
|
109
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"feature_ac.d.ts","sourceRoot":"","sources":["../../src/validator/feature_ac.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;
|
|
1
|
+
{"version":3,"file":"feature_ac.d.ts","sourceRoot":"","sources":["../../src/validator/feature_ac.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AA2DzD;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,KAAK,GAAG,SAAS,UAAU,EAAE,CA+BrE"}
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
*
|
|
19
19
|
* This is an AST-only check; no external dependency.
|
|
20
20
|
*/
|
|
21
|
+
import { featureFileLine } from "../gherkin/position.js";
|
|
21
22
|
/** Case-insensitive match for "acceptance criteria" anywhere in text. */
|
|
22
23
|
const ACCEPTANCE_CRITERIA_RE = /acceptance\s+criteria/i;
|
|
23
24
|
/**
|
|
@@ -84,7 +85,11 @@ export function validateFeatureAc(entry) {
|
|
|
84
85
|
// Now check for an "Acceptance criteria" list.
|
|
85
86
|
if (!hasAcceptanceCriteriaList(blocks))
|
|
86
87
|
return [];
|
|
87
|
-
|
|
88
|
+
// A `.feature` entry's FeatureNode range is relative to the body start, so
|
|
89
|
+
// its first line comes from `featureFileLine`.
|
|
90
|
+
const fileLine = entry.source.kind === "feature-file"
|
|
91
|
+
? featureFileLine(entry, featureBlock, 1)
|
|
92
|
+
: entry.location.line + featureBlock.range.start.line;
|
|
88
93
|
return [
|
|
89
94
|
{
|
|
90
95
|
code: "MSL-B044",
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/validator/feature_parse
|
|
3
|
+
*
|
|
4
|
+
* `MSL-B062` (warning): a `gherkin` or `feature` block does not parse as
|
|
5
|
+
* Gherkin (epic #915). The warning is reported at the file line of the
|
|
6
|
+
* first parser error, for an entry of any type. A feature block is checked
|
|
7
|
+
* in a top-level block or in a list item at any depth. (Criteria
|
|
8
|
+
* are read from top-level blocks only; see `core/criteria/scenarios.ts`.)
|
|
9
|
+
* For a top-level block of a Requirement or Contract entry, the criteria of
|
|
10
|
+
* a block that does not parse come from the line scanner.
|
|
11
|
+
*
|
|
12
|
+
* The column is always 1. The parser column is relative to the block text,
|
|
13
|
+
* and the block indent (list-item and fence indent in Markdown, the comment
|
|
14
|
+
* prefix in source doc comments) is not recorded, so the file column cannot
|
|
15
|
+
* be derived reliably.
|
|
16
|
+
*
|
|
17
|
+
* A warning located in a delivered-corpus file is not published by the LSP
|
|
18
|
+
* (its corpus-file guard). In `check`, the corpus post-pass keeps it and
|
|
19
|
+
* prefixes the message with `delivered by <profile>@<version>: `
|
|
20
|
+
* (`attributeCorpusDiagnostics`). Upstream entries are not checked:
|
|
21
|
+
* `emittableEntries` skips them.
|
|
22
|
+
*
|
|
23
|
+
* Only a block that the Gherkin parser rejected carries `parseError`. When
|
|
24
|
+
* the parser was not loaded when the entry was built (a failed import, or
|
|
25
|
+
* the synchronous `parse()` before any load), no block has one and nothing
|
|
26
|
+
* is reported.
|
|
27
|
+
*/
|
|
28
|
+
import type { Diagnostic, Entry } from "../model/mod.js";
|
|
29
|
+
import type { BodyBlock, FeatureNode } from "../ast/nodes.js";
|
|
30
|
+
/** Report one MSL-B062 warning per feature block that failed to parse. */
|
|
31
|
+
export declare function checkFeatureParse(entries: readonly Entry[]): Diagnostic[];
|
|
32
|
+
/** Every feature node in `blocks`, including those nested in list items,
|
|
33
|
+
* in source order. */
|
|
34
|
+
export declare function featureNodes(blocks: readonly BodyBlock[]): Generator<FeatureNode>;
|
|
35
|
+
//# sourceMappingURL=feature_parse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"feature_parse.d.ts","sourceRoot":"","sources":["../../src/validator/feature_parse.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAI9D,0EAA0E;AAC1E,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,SAAS,KAAK,EAAE,GAAG,UAAU,EAAE,CAyBzE;AAED;sBACsB;AACtB,wBAAiB,YAAY,CAC3B,MAAM,EAAE,SAAS,SAAS,EAAE,GAC3B,SAAS,CAAC,WAAW,CAAC,CAOxB"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/validator/feature_parse
|
|
3
|
+
*
|
|
4
|
+
* `MSL-B062` (warning): a `gherkin` or `feature` block does not parse as
|
|
5
|
+
* Gherkin (epic #915). The warning is reported at the file line of the
|
|
6
|
+
* first parser error, for an entry of any type. A feature block is checked
|
|
7
|
+
* in a top-level block or in a list item at any depth. (Criteria
|
|
8
|
+
* are read from top-level blocks only; see `core/criteria/scenarios.ts`.)
|
|
9
|
+
* For a top-level block of a Requirement or Contract entry, the criteria of
|
|
10
|
+
* a block that does not parse come from the line scanner.
|
|
11
|
+
*
|
|
12
|
+
* The column is always 1. The parser column is relative to the block text,
|
|
13
|
+
* and the block indent (list-item and fence indent in Markdown, the comment
|
|
14
|
+
* prefix in source doc comments) is not recorded, so the file column cannot
|
|
15
|
+
* be derived reliably.
|
|
16
|
+
*
|
|
17
|
+
* A warning located in a delivered-corpus file is not published by the LSP
|
|
18
|
+
* (its corpus-file guard). In `check`, the corpus post-pass keeps it and
|
|
19
|
+
* prefixes the message with `delivered by <profile>@<version>: `
|
|
20
|
+
* (`attributeCorpusDiagnostics`). Upstream entries are not checked:
|
|
21
|
+
* `emittableEntries` skips them.
|
|
22
|
+
*
|
|
23
|
+
* Only a block that the Gherkin parser rejected carries `parseError`. When
|
|
24
|
+
* the parser was not loaded when the entry was built (a failed import, or
|
|
25
|
+
* the synchronous `parse()` before any load), no block has one and nothing
|
|
26
|
+
* is reported.
|
|
27
|
+
*/
|
|
28
|
+
import { emittableEntries } from "../model/mod.js";
|
|
29
|
+
import { featureFileLine } from "../gherkin/position.js";
|
|
30
|
+
/** Report one MSL-B062 warning per feature block that failed to parse. */
|
|
31
|
+
export function checkFeatureParse(entries) {
|
|
32
|
+
const diagnostics = [];
|
|
33
|
+
for (const entry of emittableEntries(entries)) {
|
|
34
|
+
for (const node of featureNodes(entry.bodyAst ?? [])) {
|
|
35
|
+
const error = node.parseError;
|
|
36
|
+
if (error === undefined)
|
|
37
|
+
continue;
|
|
38
|
+
// The parser message starts with a "(line:column): " position that
|
|
39
|
+
// is relative to the block, which would mislead; the location holds
|
|
40
|
+
// the file position.
|
|
41
|
+
const reason = error.message.split("\n")[0]
|
|
42
|
+
.replace(/^\(\d+:\d+\):\s*/, "").trim();
|
|
43
|
+
diagnostics.push({
|
|
44
|
+
code: "MSL-B062",
|
|
45
|
+
severity: "warning",
|
|
46
|
+
message: `${entry.displayId}: Gherkin block does not parse: ` +
|
|
47
|
+
`${reason}`,
|
|
48
|
+
location: {
|
|
49
|
+
file: entry.location.file,
|
|
50
|
+
line: featureFileLine(entry, node, error.line),
|
|
51
|
+
column: 1,
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return diagnostics;
|
|
57
|
+
}
|
|
58
|
+
/** Every feature node in `blocks`, including those nested in list items,
|
|
59
|
+
* in source order. */
|
|
60
|
+
export function* featureNodes(blocks) {
|
|
61
|
+
for (const block of blocks) {
|
|
62
|
+
if (block.kind === "feature")
|
|
63
|
+
yield block;
|
|
64
|
+
else if (block.kind === "list") {
|
|
65
|
+
for (const item of block.items)
|
|
66
|
+
yield* featureNodes(item.blocks);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/validator/locators
|
|
3
|
+
*
|
|
4
|
+
* Locator and scenario-name diagnostics (epic #915, scenario-locator
|
|
5
|
+
* slice):
|
|
6
|
+
*
|
|
7
|
+
* - `MSL-L007` (warning): a locator on a `"criterion"` relation
|
|
8
|
+
* (`Satisfies`, `Verifies`) names no addressable scenario of a resolved,
|
|
9
|
+
* criteria-bearing target. The edge to the target is kept.
|
|
10
|
+
* - `MSL-L008` (warning): a locator on a trace relation that does not
|
|
11
|
+
* accept one (every relation without a locator mode, including
|
|
12
|
+
* profile-declared relations and a hand-written `Verified-by`). The
|
|
13
|
+
* edge to the target is kept.
|
|
14
|
+
* - `MSL-L009` (warning): a trace value has a `[` after whitespace that
|
|
15
|
+
* no `]` closes. The value has no locator and is read as it was before
|
|
16
|
+
* scenario locators existed.
|
|
17
|
+
* - `MSL-B060` (warning): a scenario name occurs more than once in one
|
|
18
|
+
* entry; reported on the second and later occurrences.
|
|
19
|
+
* - `MSL-B061` (info): a scenario has an empty name.
|
|
20
|
+
*
|
|
21
|
+
* A locator on an unresolved target raises only `MSL-L006`, and a locator
|
|
22
|
+
* on a target that carries no criteria (not a Requirement or Contract, or a
|
|
23
|
+
* Reference entry) is free text: neither raises `MSL-L007`.
|
|
24
|
+
*/
|
|
25
|
+
import type { Diagnostic, EffectiveProfile, Entry } from "../model/mod.js";
|
|
26
|
+
/**
|
|
27
|
+
* Report the locator and scenario-name diagnostics for `entries`.
|
|
28
|
+
* Targets resolve against every entry (upstream entries included);
|
|
29
|
+
* diagnostics are emitted for emittable entries only. When `profile` is
|
|
30
|
+
* given, an entry without a `type` is classified against it first.
|
|
31
|
+
*/
|
|
32
|
+
export declare function validateLocators(entries: readonly Entry[], profile: EffectiveProfile | null): Diagnostic[];
|
|
33
|
+
/** `entry` with its type classified against `profile` when unset. Without a
|
|
34
|
+
* profile, a `.feature` header entry still gets its step-6a core type. */
|
|
35
|
+
export declare function withType(entry: Entry, profile: EffectiveProfile | null): Entry;
|
|
36
|
+
//# sourceMappingURL=locators.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"locators.d.ts","sourceRoot":"","sources":["../../src/validator/locators.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,KAAK,EACV,UAAU,EACV,gBAAgB,EAChB,KAAK,EAEN,MAAM,iBAAiB,CAAC;AA+BzB;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,SAAS,KAAK,EAAE,EACzB,OAAO,EAAE,gBAAgB,GAAG,IAAI,GAC/B,UAAU,EAAE,CA6Dd;AA+BD;0EAC0E;AAC1E,wBAAgB,QAAQ,CACtB,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,gBAAgB,GAAG,IAAI,GAC/B,KAAK,CAOP"}
|