@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.
Files changed (279) hide show
  1. package/esm/ast/build.d.ts.map +1 -1
  2. package/esm/ast/build.js +19 -5
  3. package/esm/ast/equivalence.js +14 -2
  4. package/esm/ast/nodes.d.ts +15 -3
  5. package/esm/ast/nodes.d.ts.map +1 -1
  6. package/esm/compiler/inverses.d.ts.map +1 -1
  7. package/esm/compiler/inverses.js +18 -3
  8. package/esm/compiler/mod.d.ts +34 -1
  9. package/esm/compiler/mod.d.ts.map +1 -1
  10. package/esm/compiler/mod.js +112 -48
  11. package/esm/compiler/schema.d.ts +3 -2
  12. package/esm/compiler/schema.d.ts.map +1 -1
  13. package/esm/compiler/schema.js +6 -3
  14. package/esm/criteria/scenarios.d.ts +55 -0
  15. package/esm/criteria/scenarios.d.ts.map +1 -0
  16. package/esm/criteria/scenarios.js +133 -0
  17. package/esm/discovery/mod.d.ts +20 -1
  18. package/esm/discovery/mod.d.ts.map +1 -1
  19. package/esm/discovery/mod.js +105 -17
  20. package/esm/formatter/entry_body.d.ts +8 -5
  21. package/esm/formatter/entry_body.d.ts.map +1 -1
  22. package/esm/formatter/entry_body.js +12 -8
  23. package/esm/formatter/feature_file.d.ts +40 -0
  24. package/esm/formatter/feature_file.d.ts.map +1 -0
  25. package/esm/formatter/feature_file.js +88 -0
  26. package/esm/formatter/mod.d.ts +21 -2
  27. package/esm/formatter/mod.d.ts.map +1 -1
  28. package/esm/formatter/mod.js +64 -22
  29. package/esm/gates/mod.d.ts +2 -2
  30. package/esm/gates/mod.d.ts.map +1 -1
  31. package/esm/gates/mod.js +17 -2
  32. package/esm/gherkin/load.d.ts +35 -0
  33. package/esm/gherkin/load.d.ts.map +1 -0
  34. package/esm/gherkin/load.js +39 -0
  35. package/esm/gherkin/parse.d.ts +11 -0
  36. package/esm/gherkin/parse.d.ts.map +1 -0
  37. package/esm/gherkin/parse.js +311 -0
  38. package/esm/gherkin/position.d.ts +23 -0
  39. package/esm/gherkin/position.d.ts.map +1 -0
  40. package/esm/gherkin/position.js +21 -0
  41. package/esm/gherkin/procedure.d.ts +76 -0
  42. package/esm/gherkin/procedure.d.ts.map +1 -0
  43. package/esm/gherkin/procedure.js +164 -0
  44. package/esm/gherkin/project.d.ts +35 -0
  45. package/esm/gherkin/project.d.ts.map +1 -0
  46. package/esm/gherkin/project.js +64 -0
  47. package/esm/gherkin/role.d.ts +23 -0
  48. package/esm/gherkin/role.d.ts.map +1 -0
  49. package/esm/gherkin/role.js +28 -0
  50. package/esm/gherkin/types.d.ts +118 -0
  51. package/esm/gherkin/types.d.ts.map +1 -0
  52. package/esm/gherkin/types.js +12 -0
  53. package/esm/lock/acquire_compile.d.ts +12 -4
  54. package/esm/lock/acquire_compile.d.ts.map +1 -1
  55. package/esm/lock/acquire_compile.js +15 -5
  56. package/esm/lock/canonical_edges.d.ts +6 -2
  57. package/esm/lock/canonical_edges.d.ts.map +1 -1
  58. package/esm/lock/canonical_edges.js +10 -3
  59. package/esm/lock/model.d.ts +5 -0
  60. package/esm/lock/model.d.ts.map +1 -1
  61. package/esm/lock/parser.d.ts.map +1 -1
  62. package/esm/lock/parser.js +2 -0
  63. package/esm/lock/resolve.d.ts +6 -2
  64. package/esm/lock/resolve.d.ts.map +1 -1
  65. package/esm/lock/resolve.js +36 -4
  66. package/esm/lock/serializer.d.ts.map +1 -1
  67. package/esm/lock/serializer.js +7 -1
  68. package/esm/mod.d.ts +23 -6
  69. package/esm/mod.d.ts.map +1 -1
  70. package/esm/mod.js +18 -5
  71. package/esm/model/mod.d.ts +42 -1
  72. package/esm/model/mod.d.ts.map +1 -1
  73. package/esm/model/mod.js +1 -1
  74. package/esm/model/relations.d.ts +9 -0
  75. package/esm/model/relations.d.ts.map +1 -1
  76. package/esm/model/relations.js +16 -1
  77. package/esm/parser/attributes.d.ts +82 -3
  78. package/esm/parser/attributes.d.ts.map +1 -1
  79. package/esm/parser/attributes.js +199 -32
  80. package/esm/parser/body_tokens.d.ts +1 -1
  81. package/esm/parser/body_tokens.d.ts.map +1 -1
  82. package/esm/parser/body_tokens.js +49 -35
  83. package/esm/parser/feature_file.d.ts +116 -0
  84. package/esm/parser/feature_file.d.ts.map +1 -0
  85. package/esm/parser/feature_file.js +540 -0
  86. package/esm/parser/markdown.d.ts +7 -0
  87. package/esm/parser/markdown.d.ts.map +1 -1
  88. package/esm/parser/markdown.js +129 -40
  89. package/esm/parser/mod.d.ts +18 -0
  90. package/esm/parser/mod.d.ts.map +1 -1
  91. package/esm/parser/mod.js +51 -0
  92. package/esm/parser/translate.d.ts.map +1 -1
  93. package/esm/parser/translate.js +5 -0
  94. package/esm/refs/mod.d.ts +2 -1
  95. package/esm/refs/mod.d.ts.map +1 -1
  96. package/esm/refs/mod.js +12 -4
  97. package/esm/refs/split.d.ts +58 -0
  98. package/esm/refs/split.d.ts.map +1 -0
  99. package/esm/refs/split.js +137 -0
  100. package/esm/reporter/mod.d.ts +7 -0
  101. package/esm/reporter/mod.d.ts.map +1 -1
  102. package/esm/reporter/mod.js +113 -3
  103. package/esm/validator/attributes.d.ts.map +1 -1
  104. package/esm/validator/attributes.js +4 -1
  105. package/esm/validator/block_role.d.ts +40 -0
  106. package/esm/validator/block_role.d.ts.map +1 -0
  107. package/esm/validator/block_role.js +109 -0
  108. package/esm/validator/feature_ac.d.ts.map +1 -1
  109. package/esm/validator/feature_ac.js +6 -1
  110. package/esm/validator/feature_parse.d.ts +35 -0
  111. package/esm/validator/feature_parse.d.ts.map +1 -0
  112. package/esm/validator/feature_parse.js +69 -0
  113. package/esm/validator/locators.d.ts +36 -0
  114. package/esm/validator/locators.d.ts.map +1 -0
  115. package/esm/validator/locators.js +184 -0
  116. package/esm/validator/mod.d.ts +10 -1
  117. package/esm/validator/mod.d.ts.map +1 -1
  118. package/esm/validator/mod.js +38 -14
  119. package/esm/validator/normalize.d.ts.map +1 -1
  120. package/esm/validator/normalize.js +8 -3
  121. package/esm/validator/per_type_attrs.d.ts +3 -3
  122. package/esm/validator/per_type_attrs.js +3 -3
  123. package/esm/validator/pipeline.d.ts +4 -12
  124. package/esm/validator/pipeline.d.ts.map +1 -1
  125. package/esm/validator/pipeline.js +24 -5
  126. package/esm/validator/procedure.d.ts +22 -0
  127. package/esm/validator/procedure.d.ts.map +1 -0
  128. package/esm/validator/procedure.js +58 -0
  129. package/esm/validator/trace_types.d.ts.map +1 -1
  130. package/esm/validator/trace_types.js +4 -3
  131. package/esm/validator/traceability.d.ts.map +1 -1
  132. package/esm/validator/traceability.js +4 -1
  133. package/esm/validator/type_resolution.d.ts +5 -3
  134. package/esm/validator/type_resolution.d.ts.map +1 -1
  135. package/esm/validator/type_resolution.js +14 -2
  136. package/esm/validator/types.d.ts +11 -0
  137. package/esm/validator/types.d.ts.map +1 -1
  138. package/esm/validator/types.js +26 -4
  139. package/esm/validator/uxil_family.d.ts +1 -1
  140. package/package.json +3 -1
  141. package/script/ast/build.d.ts.map +1 -1
  142. package/script/ast/build.js +19 -5
  143. package/script/ast/equivalence.js +14 -2
  144. package/script/ast/nodes.d.ts +15 -3
  145. package/script/ast/nodes.d.ts.map +1 -1
  146. package/script/compiler/inverses.d.ts.map +1 -1
  147. package/script/compiler/inverses.js +18 -3
  148. package/script/compiler/mod.d.ts +34 -1
  149. package/script/compiler/mod.d.ts.map +1 -1
  150. package/script/compiler/mod.js +110 -46
  151. package/script/compiler/schema.d.ts +3 -2
  152. package/script/compiler/schema.d.ts.map +1 -1
  153. package/script/compiler/schema.js +6 -3
  154. package/script/criteria/scenarios.d.ts +55 -0
  155. package/script/criteria/scenarios.d.ts.map +1 -0
  156. package/script/criteria/scenarios.js +139 -0
  157. package/script/discovery/mod.d.ts +20 -1
  158. package/script/discovery/mod.d.ts.map +1 -1
  159. package/script/discovery/mod.js +106 -17
  160. package/script/formatter/entry_body.d.ts +8 -5
  161. package/script/formatter/entry_body.d.ts.map +1 -1
  162. package/script/formatter/entry_body.js +12 -8
  163. package/script/formatter/feature_file.d.ts +40 -0
  164. package/script/formatter/feature_file.d.ts.map +1 -0
  165. package/script/formatter/feature_file.js +92 -0
  166. package/script/formatter/mod.d.ts +21 -2
  167. package/script/formatter/mod.d.ts.map +1 -1
  168. package/script/formatter/mod.js +63 -21
  169. package/script/gates/mod.d.ts +2 -2
  170. package/script/gates/mod.d.ts.map +1 -1
  171. package/script/gates/mod.js +17 -2
  172. package/script/gherkin/load.d.ts +35 -0
  173. package/script/gherkin/load.d.ts.map +1 -0
  174. package/script/gherkin/load.js +76 -0
  175. package/script/gherkin/parse.d.ts +11 -0
  176. package/script/gherkin/parse.d.ts.map +1 -0
  177. package/script/gherkin/parse.js +314 -0
  178. package/script/gherkin/position.d.ts +23 -0
  179. package/script/gherkin/position.d.ts.map +1 -0
  180. package/script/gherkin/position.js +24 -0
  181. package/script/gherkin/procedure.d.ts +76 -0
  182. package/script/gherkin/procedure.d.ts.map +1 -0
  183. package/script/gherkin/procedure.js +169 -0
  184. package/script/gherkin/project.d.ts +35 -0
  185. package/script/gherkin/project.d.ts.map +1 -0
  186. package/script/gherkin/project.js +67 -0
  187. package/script/gherkin/role.d.ts +23 -0
  188. package/script/gherkin/role.d.ts.map +1 -0
  189. package/script/gherkin/role.js +31 -0
  190. package/script/gherkin/types.d.ts +118 -0
  191. package/script/gherkin/types.d.ts.map +1 -0
  192. package/script/gherkin/types.js +13 -0
  193. package/script/lock/acquire_compile.d.ts +12 -4
  194. package/script/lock/acquire_compile.d.ts.map +1 -1
  195. package/script/lock/acquire_compile.js +15 -5
  196. package/script/lock/canonical_edges.d.ts +6 -2
  197. package/script/lock/canonical_edges.d.ts.map +1 -1
  198. package/script/lock/canonical_edges.js +10 -3
  199. package/script/lock/model.d.ts +5 -0
  200. package/script/lock/model.d.ts.map +1 -1
  201. package/script/lock/parser.d.ts.map +1 -1
  202. package/script/lock/parser.js +2 -0
  203. package/script/lock/resolve.d.ts +6 -2
  204. package/script/lock/resolve.d.ts.map +1 -1
  205. package/script/lock/resolve.js +36 -4
  206. package/script/lock/serializer.d.ts.map +1 -1
  207. package/script/lock/serializer.js +7 -1
  208. package/script/mod.d.ts +23 -6
  209. package/script/mod.d.ts.map +1 -1
  210. package/script/mod.js +45 -6
  211. package/script/model/mod.d.ts +42 -1
  212. package/script/model/mod.d.ts.map +1 -1
  213. package/script/model/mod.js +2 -1
  214. package/script/model/relations.d.ts +9 -0
  215. package/script/model/relations.d.ts.map +1 -1
  216. package/script/model/relations.js +17 -1
  217. package/script/parser/attributes.d.ts +82 -3
  218. package/script/parser/attributes.d.ts.map +1 -1
  219. package/script/parser/attributes.js +205 -33
  220. package/script/parser/body_tokens.d.ts +1 -1
  221. package/script/parser/body_tokens.d.ts.map +1 -1
  222. package/script/parser/body_tokens.js +49 -35
  223. package/script/parser/feature_file.d.ts +116 -0
  224. package/script/parser/feature_file.d.ts.map +1 -0
  225. package/script/parser/feature_file.js +548 -0
  226. package/script/parser/markdown.d.ts +7 -0
  227. package/script/parser/markdown.d.ts.map +1 -1
  228. package/script/parser/markdown.js +128 -39
  229. package/script/parser/mod.d.ts +18 -0
  230. package/script/parser/mod.d.ts.map +1 -1
  231. package/script/parser/mod.js +52 -1
  232. package/script/parser/translate.d.ts.map +1 -1
  233. package/script/parser/translate.js +5 -0
  234. package/script/refs/mod.d.ts +2 -1
  235. package/script/refs/mod.d.ts.map +1 -1
  236. package/script/refs/mod.js +12 -4
  237. package/script/refs/split.d.ts +58 -0
  238. package/script/refs/split.d.ts.map +1 -0
  239. package/script/refs/split.js +145 -0
  240. package/script/reporter/mod.d.ts +7 -0
  241. package/script/reporter/mod.d.ts.map +1 -1
  242. package/script/reporter/mod.js +113 -3
  243. package/script/validator/attributes.d.ts.map +1 -1
  244. package/script/validator/attributes.js +4 -1
  245. package/script/validator/block_role.d.ts +40 -0
  246. package/script/validator/block_role.d.ts.map +1 -0
  247. package/script/validator/block_role.js +112 -0
  248. package/script/validator/feature_ac.d.ts.map +1 -1
  249. package/script/validator/feature_ac.js +6 -1
  250. package/script/validator/feature_parse.d.ts +35 -0
  251. package/script/validator/feature_parse.d.ts.map +1 -0
  252. package/script/validator/feature_parse.js +73 -0
  253. package/script/validator/locators.d.ts +36 -0
  254. package/script/validator/locators.d.ts.map +1 -0
  255. package/script/validator/locators.js +188 -0
  256. package/script/validator/mod.d.ts +10 -1
  257. package/script/validator/mod.d.ts.map +1 -1
  258. package/script/validator/mod.js +38 -14
  259. package/script/validator/normalize.d.ts.map +1 -1
  260. package/script/validator/normalize.js +8 -3
  261. package/script/validator/per_type_attrs.d.ts +3 -3
  262. package/script/validator/per_type_attrs.js +3 -3
  263. package/script/validator/pipeline.d.ts +4 -12
  264. package/script/validator/pipeline.d.ts.map +1 -1
  265. package/script/validator/pipeline.js +23 -5
  266. package/script/validator/procedure.d.ts +22 -0
  267. package/script/validator/procedure.d.ts.map +1 -0
  268. package/script/validator/procedure.js +61 -0
  269. package/script/validator/trace_types.d.ts.map +1 -1
  270. package/script/validator/trace_types.js +4 -3
  271. package/script/validator/traceability.d.ts.map +1 -1
  272. package/script/validator/traceability.js +4 -1
  273. package/script/validator/type_resolution.d.ts +5 -3
  274. package/script/validator/type_resolution.d.ts.map +1 -1
  275. package/script/validator/type_resolution.js +14 -2
  276. package/script/validator/types.d.ts +11 -0
  277. package/script/validator/types.d.ts.map +1 -1
  278. package/script/validator/types.js +27 -4
  279. package/script/validator/uxil_family.d.ts +1 -1
@@ -0,0 +1,145 @@
1
+ "use strict";
2
+ /**
3
+ * @module refs/split
4
+ *
5
+ * Bracket-aware splitting of trace attribute values. A value is
6
+ * `target [ 1*WSP "[" locator "]" ]`. A locator can contain commas, so a
7
+ * plain split on commas is wrong for it. The escapes `\]` and `\\` are
8
+ * valid inside a locator only; any other backslash sequence (such as `\x`)
9
+ * is kept as written. A locator must follow whitespace after the target,
10
+ * so `A[x]` has no locator. A value without a closed locator is read
11
+ * exactly as before scenario locators existed.
12
+ */
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.normalizeLocator = normalizeLocator;
15
+ exports.splitTraceValues = splitTraceValues;
16
+ exports.parseTraceValue = parseTraceValue;
17
+ exports.isUnterminatedLocator = isUnterminatedLocator;
18
+ exports.traceTarget = traceTarget;
19
+ exports.referenceTokens = referenceTokens;
20
+ /**
21
+ * Normalize locator text for comparison: Unicode NFC, trim, and collapse
22
+ * each whitespace run to one space.
23
+ */
24
+ function normalizeLocator(text) {
25
+ return text.normalize("NFC").trim().replace(/\s+/g, " ");
26
+ }
27
+ /**
28
+ * Split a trace attribute value into its parts. When at least one part has
29
+ * a closed bracket locator after whitespace, commas inside a locator do not
30
+ * split. Otherwise the value is split on every comma, exactly as before
31
+ * scenario locators existed, so an unterminated `[` does not change how a
32
+ * value is read. Parts are trimmed and empty parts are dropped.
33
+ */
34
+ function splitTraceValues(value) {
35
+ // An unclosed `[` never protects commas (see splitOutsideLocators).
36
+ const bracketParts = splitOutsideLocators(value);
37
+ if (bracketParts.some((p) => LOCATOR_VALUE_RE.test(p)))
38
+ return bracketParts;
39
+ return value.split(",").map((p) => p.trim()).filter((p) => p.length > 0);
40
+ }
41
+ /** Split on commas outside a closed locator. A `[` opens a locator only
42
+ * after whitespace; an unclosed locator does not protect its commas. */
43
+ function splitOutsideLocators(value) {
44
+ const parts = [];
45
+ let current = "";
46
+ let inLocator = false;
47
+ for (let i = 0; i < value.length; i++) {
48
+ const ch = value[i];
49
+ if (inLocator) {
50
+ if (ch === "\\" && i + 1 < value.length) {
51
+ current += ch + value[++i];
52
+ continue;
53
+ }
54
+ if (ch === "]")
55
+ inLocator = false;
56
+ current += ch;
57
+ }
58
+ else if (ch === "[" && i > 0 && /\s/.test(value[i - 1])) {
59
+ inLocator = true;
60
+ current += ch;
61
+ }
62
+ else if (ch === ",") {
63
+ parts.push(current);
64
+ current = "";
65
+ }
66
+ else {
67
+ current += ch;
68
+ }
69
+ }
70
+ // An unclosed `[` never swallows commas: the rest splits on each comma.
71
+ if (inLocator)
72
+ parts.push(...current.split(","));
73
+ else
74
+ parts.push(current);
75
+ return parts.map((p) => p.trim()).filter((p) => p.length > 0);
76
+ }
77
+ /** `target 1*WSP "[" locator "]"` with escapes inside the locator. The
78
+ * locator may be empty (`A []`); an empty locator names no scenario. */
79
+ const LOCATOR_VALUE_RE = /^(\S+)\s+\[((?:\\[\s\S]|[^\]\\])*)\]$/;
80
+ /**
81
+ * Parse one value from {@linkcode splitTraceValues} into target and
82
+ * optional locator. A value without a closed locator after whitespace is
83
+ * kept whole as the target, as before scenario locators existed.
84
+ */
85
+ function parseTraceValue(raw) {
86
+ const value = raw.trim();
87
+ const match = LOCATOR_VALUE_RE.exec(value);
88
+ if (!match)
89
+ return { target: value };
90
+ const locatorRaw = match[2];
91
+ return {
92
+ target: match[1],
93
+ locator: normalizeLocator(locatorRaw.replace(/\\([\]\\])/g, "$1")),
94
+ locatorRaw,
95
+ };
96
+ }
97
+ /**
98
+ * `true` when a trace value has a `[` after whitespace that no unescaped
99
+ * `]` closes. Such a value has no locator.
100
+ */
101
+ function isUnterminatedLocator(raw) {
102
+ const value = raw.trim();
103
+ let inLocator = false;
104
+ for (let i = 0; i < value.length; i++) {
105
+ const ch = value[i];
106
+ if (inLocator) {
107
+ if (ch === "\\")
108
+ i++;
109
+ else if (ch === "]")
110
+ inLocator = false;
111
+ }
112
+ else if (ch === "[" && i > 0 && /\s/.test(value[i - 1])) {
113
+ inLocator = true;
114
+ }
115
+ }
116
+ return inLocator;
117
+ }
118
+ /**
119
+ * The target of a trace value for existence and value-type checks: the
120
+ * target before a closed bracket locator, else the trimmed value as
121
+ * written.
122
+ */
123
+ function traceTarget(raw) {
124
+ return parseTraceValue(raw).target;
125
+ }
126
+ /**
127
+ * The tokens of a trace value that can name another entry, for reference
128
+ * scans (find references, dependent counts). A closed locator is dropped,
129
+ * so an ID written inside a locator is not a reference. Any other part is
130
+ * split on whitespace and commas, as before scenario locators existed.
131
+ */
132
+ function referenceTokens(value) {
133
+ const out = [];
134
+ for (const part of splitTraceValues(value)) {
135
+ const parsed = parseTraceValue(part);
136
+ if (parsed.locator !== undefined) {
137
+ out.push(parsed.target);
138
+ continue;
139
+ }
140
+ for (const t of part.split(/[\s,]+/))
141
+ if (t.length > 0)
142
+ out.push(t);
143
+ }
144
+ return out;
145
+ }
@@ -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;AAQxD,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;CACtD;AAED;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,aAAa,GAAG,MAAM,CAY5E"}
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"}
@@ -7,6 +7,7 @@
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.report = report;
10
+ const scenarios_js_1 = require("../criteria/scenarios.js");
10
11
  const mod_js_1 = require("../model/mod.js");
11
12
  /**
12
13
  * Generate a report from compiled traceability graph.
@@ -20,7 +21,7 @@ function report(result, options) {
20
21
  if (options.kind === "traceability") {
21
22
  return formatTraceability(result, entries, options.format);
22
23
  }
23
- return formatCoverage(result, entries, options.format, options.dependencyUpstreamIds);
24
+ return formatCoverage(result, entries, options.format, options.dependencyUpstreamIds, options.profile);
24
25
  }
25
26
  // ---------------------------------------------------------------------------
26
27
  // Filtering
@@ -146,10 +147,13 @@ function computeCoverage(result, entries, opts = {}) {
146
147
  gaps: { orphans, unsatisfied },
147
148
  };
148
149
  }
149
- function formatCoverage(result, entries, format, dependencyUpstreamIds) {
150
+ function formatCoverage(result, entries, format, dependencyUpstreamIds, profile) {
150
151
  const stats = computeCoverage(result, entries, { dependencyUpstreamIds });
152
+ // Absent when no reported entry has criteria, so coverage output for a
153
+ // project without feature blocks stays unchanged.
154
+ const criteria = computeCriterionCoverage(result, entries, profile);
151
155
  if (format === "json") {
152
- return JSON.stringify(stats, null, 2);
156
+ return JSON.stringify(criteria ? { ...stats, criteria } : stats, null, 2);
153
157
  }
154
158
  if (format === "csv") {
155
159
  const lines = [
@@ -161,6 +165,9 @@ function formatCoverage(result, entries, format, dependencyUpstreamIds) {
161
165
  `Orphans,${stats.gaps.orphans.length}`,
162
166
  `Unsatisfied parents,${stats.gaps.unsatisfied.length}`,
163
167
  ];
168
+ if (criteria) {
169
+ lines.push(`Criteria total,${criteria.total}`, `Criteria verified,${criteria.verified}`);
170
+ }
164
171
  return lines.join("\n");
165
172
  }
166
173
  // Markdown
@@ -185,8 +192,111 @@ function formatCoverage(result, entries, format, dependencyUpstreamIds) {
185
192
  if (stats.gaps.unsatisfied.length > 0) {
186
193
  lines.push("## Unsatisfied parents (STK/SYS with no children)", "", ...stats.gaps.unsatisfied.map((id) => `- ${id}`), "");
187
194
  }
195
+ if (criteria)
196
+ lines.push(...formatCriteriaMarkdown(criteria));
188
197
  return lines.join("\n");
189
198
  }
199
+ /**
200
+ * Compute per-criterion verification for the reported entries that carry
201
+ * criteria. Returns `undefined` when none does.
202
+ *
203
+ * Only `verifies` links count, and only when the verifier's type is, or
204
+ * extends, the core `Test` type; an entry never verifies itself. A link
205
+ * without a locator verifies every criterion of its target. A link with a
206
+ * locator verifies the named criterion only when `locatorResolved` is
207
+ * `true`. A generated inverse runs from the target to the verifier; the
208
+ * verifier set removes the duplicate it makes of the authored link.
209
+ * Upstream (federated) entries are not reported.
210
+ */
211
+ function computeCriterionCoverage(result, entries, profile) {
212
+ const withCriteria = entries.filter((e) => (e.criteria?.length ?? 0) > 0 && !(0, mod_js_1.isUpstreamEntry)(e));
213
+ if (withCriteria.length === 0)
214
+ return undefined;
215
+ // A link end may be written as a ULID; report display IDs.
216
+ const byUlid = new Map();
217
+ for (const e of result.entries.values())
218
+ if (e.id)
219
+ byUlid.set(e.id, e);
220
+ const resolve = (id) => result.entries.get(id) ?? byUlid.get(id);
221
+ // Target display ID → criterion name ("" for whole entry) → verifiers.
222
+ const verifiers = new Map();
223
+ for (const link of result.links) {
224
+ if (link.kind !== "verifies")
225
+ continue;
226
+ if (link.locator !== undefined && link.locatorResolved !== true)
227
+ continue;
228
+ const generated = link.origin === "generated";
229
+ const targetEntry = resolve(generated ? link.from : link.to);
230
+ const verifierEntry = resolve(generated ? link.to : link.from);
231
+ if (!targetEntry || !verifierEntry)
232
+ continue;
233
+ if (targetEntry.displayId === verifierEntry.displayId)
234
+ continue;
235
+ if (!(0, scenarios_js_1.isTestEntry)(verifierEntry, profile))
236
+ continue;
237
+ const target = targetEntry.displayId;
238
+ const verifier = verifierEntry.displayId;
239
+ let byName = verifiers.get(target);
240
+ if (!byName) {
241
+ byName = new Map();
242
+ verifiers.set(target, byName);
243
+ }
244
+ const key = link.locator ?? "";
245
+ let set = byName.get(key);
246
+ if (!set) {
247
+ set = new Set();
248
+ byName.set(key, set);
249
+ }
250
+ set.add(verifier);
251
+ }
252
+ let total = 0;
253
+ let verified = 0;
254
+ const rows = withCriteria.map((entry) => {
255
+ const byName = verifiers.get(entry.displayId);
256
+ const whole = byName?.get("") ?? new Set();
257
+ const criteria = entry.criteria.map((c) => {
258
+ const named = c.addressable ? byName?.get(c.name) : undefined;
259
+ const all = new Set([...whole, ...(named ?? [])]);
260
+ return {
261
+ name: c.name,
262
+ addressable: c.addressable,
263
+ verifiedBy: [...all].sort(),
264
+ };
265
+ });
266
+ const entryVerified = criteria.filter((c) => c.verifiedBy.length > 0)
267
+ .length;
268
+ total += criteria.length;
269
+ verified += entryVerified;
270
+ return {
271
+ displayId: entry.displayId,
272
+ title: entry.title,
273
+ state: entryVerified === criteria.length
274
+ ? "full"
275
+ : entryVerified === 0
276
+ ? "none"
277
+ : "partial",
278
+ verified: entryVerified,
279
+ total: criteria.length,
280
+ criteria,
281
+ };
282
+ });
283
+ return { total, verified, entries: rows };
284
+ }
285
+ /** Render the `## Criteria` Markdown section, one text block per entry. */
286
+ function formatCriteriaMarkdown(criteria) {
287
+ const lines = ["## Criteria", ""];
288
+ for (const entry of criteria.entries) {
289
+ const width = Math.max(...entry.criteria.map((c) => c.name.length));
290
+ lines.push("```text", `${entry.displayId} ${entry.title} ${entry.verified}/${entry.total} criteria verified`, ...entry.criteria.map((c) => {
291
+ const mark = c.verifiedBy.length > 0 ? "\u2713" : "\u2717";
292
+ const by = c.verifiedBy.length > 0
293
+ ? c.verifiedBy.join(", ")
294
+ : "no verifier";
295
+ return ` ${mark} ${c.name.padEnd(width)} \u2190 ${by}`;
296
+ }), "```", "");
297
+ }
298
+ return lines;
299
+ }
190
300
  // ---------------------------------------------------------------------------
191
301
  // Helpers
192
302
  // ---------------------------------------------------------------------------
@@ -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;AAWzB;;;;;;;;;;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,CA4Ed"}
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"}
@@ -16,6 +16,7 @@ exports.effectiveScope = effectiveScope;
16
16
  exports.validateAttributesForEntry = validateAttributesForEntry;
17
17
  const mod_js_1 = require("../model/mod.js");
18
18
  const value_types_js_1 = require("./value_types.js");
19
+ const split_js_1 = require("../refs/split.js");
19
20
  /** Core-reserved attribute keys that are always permitted regardless of profile. */
20
21
  const CORE_RESERVED_KEYS = new Set([
21
22
  "Id",
@@ -136,8 +137,10 @@ function validateAttributesForEntry(entry, profile) {
136
137
  });
137
138
  }
138
139
  // MSL-A004: value-type conformance.
140
+ // A bracket locator (`A [x]`) is not part of an id value.
141
+ const isIdType = decl.type === "id" || decl.type === "id-list";
139
142
  for (const v of values) {
140
- const detail = (0, value_types_js_1.validateValue)(v, decl);
143
+ const detail = (0, value_types_js_1.validateValue)(isIdType ? (0, split_js_1.traceTarget)(v) : v, decl);
141
144
  if (detail !== null) {
142
145
  diagnostics.push({
143
146
  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,112 @@
1
+ "use strict";
2
+ /**
3
+ * @module core/validator/block_role
4
+ *
5
+ * Diagnostics for the role of a Gherkin block (epic #915, ADR-038).
6
+ *
7
+ * `MSL-B064` (warning): a scenario of a criteria block has no outcome step.
8
+ * A criteria block belongs to an entry that is, or extends, a Requirement
9
+ * or a Contract (see `blockRole`). The scenario has no `Then` step (or the
10
+ * keyword of the block language that means `Then`, including `And` and `But`
11
+ * after it), or no step at all. A scenario with `Given` and `Then` and no
12
+ * action is valid. `Scenario Outline` Examples are not considered.
13
+ *
14
+ * Each `feature` or `gherkin` block is checked in a top-level block or in a
15
+ * list item at any depth, as for `MSL-B062`. A block that has a `parseError`
16
+ * or no `feature` is skipped. Upstream entries are not checked
17
+ * (`emittableEntries`). An entry without a type after classification with
18
+ * the profile is not checked.
19
+ *
20
+ * The warning is reported at the file line of the `Scenario` keyword, in
21
+ * column 1.
22
+ *
23
+ * Four information diagnostics (severity `info`) complete the checks:
24
+ *
25
+ * - `MSL-B065`: in a procedure block (an entry that is, or extends, a Test),
26
+ * a step has an expected result and no action. Reported at the line of the
27
+ * first expected-result step.
28
+ * - `MSL-B066`: a scenario starts with `And` or `But`, which is read as an
29
+ * action. Reported at the line of that step. It applies to every role
30
+ * except an illustration.
31
+ * - `MSL-B067`: in a procedure block, a `# Step` label comment labels no
32
+ * step. Reported at the line of the comment.
33
+ * - `MSL-B068`: a feature block in a typed entry whose type has no role (an
34
+ * illustration). Reported at the first line of the block.
35
+ *
36
+ * The diagnostics of one entry are sorted by file line.
37
+ */
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.checkBlockRoles = checkBlockRoles;
40
+ const mod_js_1 = require("../model/mod.js");
41
+ const role_js_1 = require("../gherkin/role.js");
42
+ const procedure_js_1 = require("../gherkin/procedure.js");
43
+ const position_js_1 = require("../gherkin/position.js");
44
+ const feature_parse_js_1 = require("./feature_parse.js");
45
+ const locators_js_1 = require("./locators.js");
46
+ /** Report the block-role diagnostics for `entries`. */
47
+ function checkBlockRoles(entries, profile) {
48
+ const diagnostics = [];
49
+ for (const candidate of (0, mod_js_1.emittableEntries)(entries)) {
50
+ const nodes = [...(0, feature_parse_js_1.featureNodes)(candidate.bodyAst ?? [])];
51
+ if (nodes.length === 0)
52
+ continue;
53
+ // Classify an unclassified entry, as `validateLocators` does.
54
+ const entry = (0, locators_js_1.withType)(candidate, profile);
55
+ const role = (0, role_js_1.blockRole)(entry, profile);
56
+ if (role === undefined)
57
+ continue;
58
+ const found = [];
59
+ const report = (code, node, sourceLine, severity, message) => found.push({
60
+ code,
61
+ severity,
62
+ message: `${entry.displayId}: ${message}`,
63
+ location: {
64
+ file: entry.location.file,
65
+ line: (0, position_js_1.featureFileLine)(entry, node, sourceLine),
66
+ column: 1,
67
+ },
68
+ });
69
+ for (const node of nodes) {
70
+ if (node.parseError !== undefined || node.feature === undefined)
71
+ continue;
72
+ const feature = node.feature;
73
+ if (role === "illustration") {
74
+ report("MSL-B068", node, 1, "info", `Gherkin block in a ${entry.type} entry is an illustration; only ` +
75
+ "Requirement, Contract and Test entries give it a meaning");
76
+ continue;
77
+ }
78
+ for (const scenario of feature.scenarios) {
79
+ const first = scenario.steps[0];
80
+ if (first !== undefined &&
81
+ (first.normalized === "and" || first.normalized === "but")) {
82
+ report("MSL-B066", node, first.range.start.line, "info", `scenario "${scenario.name}" starts with "${first.keyword}"; ` +
83
+ "the step is read as an action; start with Given, When or Then");
84
+ }
85
+ if (role === "criteria") {
86
+ if ((0, procedure_js_1.stepRoles)(scenario.steps).includes("outcome"))
87
+ continue;
88
+ report("MSL-B064", node, scenario.range.start.line, "warning", `scenario "${scenario.name}" has no outcome (no Then step); a ` +
89
+ "criterion must state what has to hold; add a Then step");
90
+ continue;
91
+ }
92
+ const procedure = (0, procedure_js_1.scenarioProcedure)(scenario, feature.comments);
93
+ for (const step of procedure.steps) {
94
+ if (step.actions.length > 0 || step.expected.length === 0)
95
+ continue;
96
+ report("MSL-B065", node, step.expected[0].step.range.start.line, "info", `step ${step.n} of scenario "${scenario.name}" has an expected ` +
97
+ "result and no action; add a When step before the Then step");
98
+ }
99
+ }
100
+ if (role === "procedure") {
101
+ for (const comment of (0, procedure_js_1.unplacedStepLabels)(feature)) {
102
+ report("MSL-B067", node, comment.line, "info", `"${comment.text.trim()}" labels no procedure step; place it ` +
103
+ "on the first line of a procedure step");
104
+ }
105
+ }
106
+ }
107
+ // Stable sort: diagnostics of one entry follow the file order.
108
+ found.sort((a, b) => a.location.line - b.location.line);
109
+ diagnostics.push(...found);
110
+ }
111
+ return diagnostics;
112
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"feature_ac.d.ts","sourceRoot":"","sources":["../../src/validator/feature_ac.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AA2DzD;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,KAAK,GAAG,SAAS,UAAU,EAAE,CA2BrE"}
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"}
@@ -21,6 +21,7 @@
21
21
  */
22
22
  Object.defineProperty(exports, "__esModule", { value: true });
23
23
  exports.validateFeatureAc = validateFeatureAc;
24
+ const position_js_1 = require("../gherkin/position.js");
24
25
  /** Case-insensitive match for "acceptance criteria" anywhere in text. */
25
26
  const ACCEPTANCE_CRITERIA_RE = /acceptance\s+criteria/i;
26
27
  /**
@@ -87,7 +88,11 @@ function validateFeatureAc(entry) {
87
88
  // Now check for an "Acceptance criteria" list.
88
89
  if (!hasAcceptanceCriteriaList(blocks))
89
90
  return [];
90
- const fileLine = entry.location.line + featureBlock.range.start.line;
91
+ // A `.feature` entry's FeatureNode range is relative to the body start, so
92
+ // its first line comes from `featureFileLine`.
93
+ const fileLine = entry.source.kind === "feature-file"
94
+ ? (0, position_js_1.featureFileLine)(entry, featureBlock, 1)
95
+ : entry.location.line + featureBlock.range.start.line;
91
96
  return [
92
97
  {
93
98
  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,73 @@
1
+ "use strict";
2
+ /**
3
+ * @module core/validator/feature_parse
4
+ *
5
+ * `MSL-B062` (warning): a `gherkin` or `feature` block does not parse as
6
+ * Gherkin (epic #915). The warning is reported at the file line of the
7
+ * first parser error, for an entry of any type. A feature block is checked
8
+ * in a top-level block or in a list item at any depth. (Criteria
9
+ * are read from top-level blocks only; see `core/criteria/scenarios.ts`.)
10
+ * For a top-level block of a Requirement or Contract entry, the criteria of
11
+ * a block that does not parse come from the line scanner.
12
+ *
13
+ * The column is always 1. The parser column is relative to the block text,
14
+ * and the block indent (list-item and fence indent in Markdown, the comment
15
+ * prefix in source doc comments) is not recorded, so the file column cannot
16
+ * be derived reliably.
17
+ *
18
+ * A warning located in a delivered-corpus file is not published by the LSP
19
+ * (its corpus-file guard). In `check`, the corpus post-pass keeps it and
20
+ * prefixes the message with `delivered by <profile>@<version>: `
21
+ * (`attributeCorpusDiagnostics`). Upstream entries are not checked:
22
+ * `emittableEntries` skips them.
23
+ *
24
+ * Only a block that the Gherkin parser rejected carries `parseError`. When
25
+ * the parser was not loaded when the entry was built (a failed import, or
26
+ * the synchronous `parse()` before any load), no block has one and nothing
27
+ * is reported.
28
+ */
29
+ Object.defineProperty(exports, "__esModule", { value: true });
30
+ exports.checkFeatureParse = checkFeatureParse;
31
+ exports.featureNodes = featureNodes;
32
+ const mod_js_1 = require("../model/mod.js");
33
+ const position_js_1 = require("../gherkin/position.js");
34
+ /** Report one MSL-B062 warning per feature block that failed to parse. */
35
+ function checkFeatureParse(entries) {
36
+ const diagnostics = [];
37
+ for (const entry of (0, mod_js_1.emittableEntries)(entries)) {
38
+ for (const node of featureNodes(entry.bodyAst ?? [])) {
39
+ const error = node.parseError;
40
+ if (error === undefined)
41
+ continue;
42
+ // The parser message starts with a "(line:column): " position that
43
+ // is relative to the block, which would mislead; the location holds
44
+ // the file position.
45
+ const reason = error.message.split("\n")[0]
46
+ .replace(/^\(\d+:\d+\):\s*/, "").trim();
47
+ diagnostics.push({
48
+ code: "MSL-B062",
49
+ severity: "warning",
50
+ message: `${entry.displayId}: Gherkin block does not parse: ` +
51
+ `${reason}`,
52
+ location: {
53
+ file: entry.location.file,
54
+ line: (0, position_js_1.featureFileLine)(entry, node, error.line),
55
+ column: 1,
56
+ },
57
+ });
58
+ }
59
+ }
60
+ return diagnostics;
61
+ }
62
+ /** Every feature node in `blocks`, including those nested in list items,
63
+ * in source order. */
64
+ function* featureNodes(blocks) {
65
+ for (const block of blocks) {
66
+ if (block.kind === "feature")
67
+ yield block;
68
+ else if (block.kind === "list") {
69
+ for (const item of block.items)
70
+ yield* featureNodes(item.blocks);
71
+ }
72
+ }
73
+ }