@driftsys/markspec 0.12.0 → 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 (317) 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/config/markspec.d.ts +2 -2
  15. package/esm/config/mod.d.ts.map +1 -1
  16. package/esm/config/mod.js +47 -5
  17. package/esm/criteria/scenarios.d.ts +55 -0
  18. package/esm/criteria/scenarios.d.ts.map +1 -0
  19. package/esm/criteria/scenarios.js +133 -0
  20. package/esm/discovery/mod.d.ts +20 -1
  21. package/esm/discovery/mod.d.ts.map +1 -1
  22. package/esm/discovery/mod.js +105 -17
  23. package/esm/discovery/projects.d.ts +6 -4
  24. package/esm/discovery/projects.d.ts.map +1 -1
  25. package/esm/discovery/projects.js +27 -17
  26. package/esm/formatter/entry_body.d.ts +13 -12
  27. package/esm/formatter/entry_body.d.ts.map +1 -1
  28. package/esm/formatter/entry_body.js +25 -17
  29. package/esm/formatter/feature_file.d.ts +40 -0
  30. package/esm/formatter/feature_file.d.ts.map +1 -0
  31. package/esm/formatter/feature_file.js +88 -0
  32. package/esm/formatter/md_equiv.d.ts +6 -5
  33. package/esm/formatter/md_equiv.d.ts.map +1 -1
  34. package/esm/formatter/md_equiv.js +6 -5
  35. package/esm/formatter/mod.d.ts +25 -3
  36. package/esm/formatter/mod.d.ts.map +1 -1
  37. package/esm/formatter/mod.js +267 -27
  38. package/esm/formatter/tab_markers.d.ts +15 -0
  39. package/esm/formatter/tab_markers.d.ts.map +1 -0
  40. package/esm/formatter/tab_markers.js +133 -0
  41. package/esm/gates/mod.d.ts +2 -2
  42. package/esm/gates/mod.d.ts.map +1 -1
  43. package/esm/gates/mod.js +18 -3
  44. package/esm/gherkin/load.d.ts +35 -0
  45. package/esm/gherkin/load.d.ts.map +1 -0
  46. package/esm/gherkin/load.js +39 -0
  47. package/esm/gherkin/parse.d.ts +11 -0
  48. package/esm/gherkin/parse.d.ts.map +1 -0
  49. package/esm/gherkin/parse.js +311 -0
  50. package/esm/gherkin/position.d.ts +23 -0
  51. package/esm/gherkin/position.d.ts.map +1 -0
  52. package/esm/gherkin/position.js +21 -0
  53. package/esm/gherkin/procedure.d.ts +76 -0
  54. package/esm/gherkin/procedure.d.ts.map +1 -0
  55. package/esm/gherkin/procedure.js +164 -0
  56. package/esm/gherkin/project.d.ts +35 -0
  57. package/esm/gherkin/project.d.ts.map +1 -0
  58. package/esm/gherkin/project.js +64 -0
  59. package/esm/gherkin/role.d.ts +23 -0
  60. package/esm/gherkin/role.d.ts.map +1 -0
  61. package/esm/gherkin/role.js +28 -0
  62. package/esm/gherkin/types.d.ts +118 -0
  63. package/esm/gherkin/types.d.ts.map +1 -0
  64. package/esm/gherkin/types.js +12 -0
  65. package/esm/lock/acquire_compile.d.ts +12 -4
  66. package/esm/lock/acquire_compile.d.ts.map +1 -1
  67. package/esm/lock/acquire_compile.js +15 -5
  68. package/esm/lock/canonical_edges.d.ts +6 -2
  69. package/esm/lock/canonical_edges.d.ts.map +1 -1
  70. package/esm/lock/canonical_edges.js +10 -3
  71. package/esm/lock/model.d.ts +5 -0
  72. package/esm/lock/model.d.ts.map +1 -1
  73. package/esm/lock/parser.d.ts.map +1 -1
  74. package/esm/lock/parser.js +2 -0
  75. package/esm/lock/resolve.d.ts +6 -2
  76. package/esm/lock/resolve.d.ts.map +1 -1
  77. package/esm/lock/resolve.js +36 -4
  78. package/esm/lock/serializer.d.ts.map +1 -1
  79. package/esm/lock/serializer.js +7 -1
  80. package/esm/lock/upstream_deps.js +1 -1
  81. package/esm/mod.d.ts +24 -6
  82. package/esm/mod.d.ts.map +1 -1
  83. package/esm/mod.js +19 -5
  84. package/esm/model/mod.d.ts +43 -2
  85. package/esm/model/mod.d.ts.map +1 -1
  86. package/esm/model/mod.js +1 -1
  87. package/esm/model/relations.d.ts +9 -0
  88. package/esm/model/relations.d.ts.map +1 -1
  89. package/esm/model/relations.js +16 -1
  90. package/esm/parser/attributes.d.ts +82 -3
  91. package/esm/parser/attributes.d.ts.map +1 -1
  92. package/esm/parser/attributes.js +199 -32
  93. package/esm/parser/body_tokens.d.ts +1 -1
  94. package/esm/parser/body_tokens.d.ts.map +1 -1
  95. package/esm/parser/body_tokens.js +49 -35
  96. package/esm/parser/feature_file.d.ts +116 -0
  97. package/esm/parser/feature_file.d.ts.map +1 -0
  98. package/esm/parser/feature_file.js +540 -0
  99. package/esm/parser/markdown.d.ts +7 -0
  100. package/esm/parser/markdown.d.ts.map +1 -1
  101. package/esm/parser/markdown.js +129 -40
  102. package/esm/parser/mod.d.ts +18 -0
  103. package/esm/parser/mod.d.ts.map +1 -1
  104. package/esm/parser/mod.js +51 -0
  105. package/esm/parser/translate.d.ts.map +1 -1
  106. package/esm/parser/translate.js +5 -0
  107. package/esm/refs/mod.d.ts +8 -3
  108. package/esm/refs/mod.d.ts.map +1 -1
  109. package/esm/refs/mod.js +20 -7
  110. package/esm/refs/split.d.ts +58 -0
  111. package/esm/refs/split.d.ts.map +1 -0
  112. package/esm/refs/split.js +137 -0
  113. package/esm/reporter/mod.d.ts +7 -0
  114. package/esm/reporter/mod.d.ts.map +1 -1
  115. package/esm/reporter/mod.js +113 -3
  116. package/esm/sync/mapping.d.ts +4 -3
  117. package/esm/sync/mapping.d.ts.map +1 -1
  118. package/esm/sync/mapping.js +52 -9
  119. package/esm/util/display_id.d.ts +20 -0
  120. package/esm/util/display_id.d.ts.map +1 -0
  121. package/esm/util/display_id.js +19 -0
  122. package/esm/validator/attributes.d.ts.map +1 -1
  123. package/esm/validator/attributes.js +4 -1
  124. package/esm/validator/block_role.d.ts +40 -0
  125. package/esm/validator/block_role.d.ts.map +1 -0
  126. package/esm/validator/block_role.js +109 -0
  127. package/esm/validator/feature_ac.d.ts.map +1 -1
  128. package/esm/validator/feature_ac.js +6 -1
  129. package/esm/validator/feature_parse.d.ts +35 -0
  130. package/esm/validator/feature_parse.d.ts.map +1 -0
  131. package/esm/validator/feature_parse.js +69 -0
  132. package/esm/validator/locators.d.ts +36 -0
  133. package/esm/validator/locators.d.ts.map +1 -0
  134. package/esm/validator/locators.js +184 -0
  135. package/esm/validator/mod.d.ts +10 -1
  136. package/esm/validator/mod.d.ts.map +1 -1
  137. package/esm/validator/mod.js +38 -14
  138. package/esm/validator/normalize.d.ts.map +1 -1
  139. package/esm/validator/normalize.js +8 -3
  140. package/esm/validator/per_type_attrs.d.ts +3 -3
  141. package/esm/validator/per_type_attrs.js +3 -3
  142. package/esm/validator/pipeline.d.ts +10 -16
  143. package/esm/validator/pipeline.d.ts.map +1 -1
  144. package/esm/validator/pipeline.js +37 -16
  145. package/esm/validator/procedure.d.ts +22 -0
  146. package/esm/validator/procedure.d.ts.map +1 -0
  147. package/esm/validator/procedure.js +58 -0
  148. package/esm/validator/trace_types.d.ts.map +1 -1
  149. package/esm/validator/trace_types.js +4 -3
  150. package/esm/validator/traceability.d.ts.map +1 -1
  151. package/esm/validator/traceability.js +4 -1
  152. package/esm/validator/type_resolution.d.ts +5 -3
  153. package/esm/validator/type_resolution.d.ts.map +1 -1
  154. package/esm/validator/type_resolution.js +14 -2
  155. package/esm/validator/types.d.ts +11 -0
  156. package/esm/validator/types.d.ts.map +1 -1
  157. package/esm/validator/types.js +26 -4
  158. package/esm/validator/uxil_family.d.ts +1 -1
  159. package/package.json +3 -1
  160. package/script/ast/build.d.ts.map +1 -1
  161. package/script/ast/build.js +19 -5
  162. package/script/ast/equivalence.js +14 -2
  163. package/script/ast/nodes.d.ts +15 -3
  164. package/script/ast/nodes.d.ts.map +1 -1
  165. package/script/compiler/inverses.d.ts.map +1 -1
  166. package/script/compiler/inverses.js +18 -3
  167. package/script/compiler/mod.d.ts +34 -1
  168. package/script/compiler/mod.d.ts.map +1 -1
  169. package/script/compiler/mod.js +110 -46
  170. package/script/compiler/schema.d.ts +3 -2
  171. package/script/compiler/schema.d.ts.map +1 -1
  172. package/script/compiler/schema.js +6 -3
  173. package/script/config/markspec.d.ts +2 -2
  174. package/script/config/mod.d.ts.map +1 -1
  175. package/script/config/mod.js +47 -5
  176. package/script/criteria/scenarios.d.ts +55 -0
  177. package/script/criteria/scenarios.d.ts.map +1 -0
  178. package/script/criteria/scenarios.js +139 -0
  179. package/script/discovery/mod.d.ts +20 -1
  180. package/script/discovery/mod.d.ts.map +1 -1
  181. package/script/discovery/mod.js +106 -17
  182. package/script/discovery/projects.d.ts +6 -4
  183. package/script/discovery/projects.d.ts.map +1 -1
  184. package/script/discovery/projects.js +27 -17
  185. package/script/formatter/entry_body.d.ts +13 -12
  186. package/script/formatter/entry_body.d.ts.map +1 -1
  187. package/script/formatter/entry_body.js +25 -17
  188. package/script/formatter/feature_file.d.ts +40 -0
  189. package/script/formatter/feature_file.d.ts.map +1 -0
  190. package/script/formatter/feature_file.js +92 -0
  191. package/script/formatter/md_equiv.d.ts +6 -5
  192. package/script/formatter/md_equiv.d.ts.map +1 -1
  193. package/script/formatter/md_equiv.js +6 -5
  194. package/script/formatter/mod.d.ts +25 -3
  195. package/script/formatter/mod.d.ts.map +1 -1
  196. package/script/formatter/mod.js +266 -26
  197. package/script/formatter/tab_markers.d.ts +15 -0
  198. package/script/formatter/tab_markers.d.ts.map +1 -0
  199. package/script/formatter/tab_markers.js +141 -0
  200. package/script/gates/mod.d.ts +2 -2
  201. package/script/gates/mod.d.ts.map +1 -1
  202. package/script/gates/mod.js +18 -3
  203. package/script/gherkin/load.d.ts +35 -0
  204. package/script/gherkin/load.d.ts.map +1 -0
  205. package/script/gherkin/load.js +76 -0
  206. package/script/gherkin/parse.d.ts +11 -0
  207. package/script/gherkin/parse.d.ts.map +1 -0
  208. package/script/gherkin/parse.js +314 -0
  209. package/script/gherkin/position.d.ts +23 -0
  210. package/script/gherkin/position.d.ts.map +1 -0
  211. package/script/gherkin/position.js +24 -0
  212. package/script/gherkin/procedure.d.ts +76 -0
  213. package/script/gherkin/procedure.d.ts.map +1 -0
  214. package/script/gherkin/procedure.js +169 -0
  215. package/script/gherkin/project.d.ts +35 -0
  216. package/script/gherkin/project.d.ts.map +1 -0
  217. package/script/gherkin/project.js +67 -0
  218. package/script/gherkin/role.d.ts +23 -0
  219. package/script/gherkin/role.d.ts.map +1 -0
  220. package/script/gherkin/role.js +31 -0
  221. package/script/gherkin/types.d.ts +118 -0
  222. package/script/gherkin/types.d.ts.map +1 -0
  223. package/script/gherkin/types.js +13 -0
  224. package/script/lock/acquire_compile.d.ts +12 -4
  225. package/script/lock/acquire_compile.d.ts.map +1 -1
  226. package/script/lock/acquire_compile.js +15 -5
  227. package/script/lock/canonical_edges.d.ts +6 -2
  228. package/script/lock/canonical_edges.d.ts.map +1 -1
  229. package/script/lock/canonical_edges.js +10 -3
  230. package/script/lock/model.d.ts +5 -0
  231. package/script/lock/model.d.ts.map +1 -1
  232. package/script/lock/parser.d.ts.map +1 -1
  233. package/script/lock/parser.js +2 -0
  234. package/script/lock/resolve.d.ts +6 -2
  235. package/script/lock/resolve.d.ts.map +1 -1
  236. package/script/lock/resolve.js +36 -4
  237. package/script/lock/serializer.d.ts.map +1 -1
  238. package/script/lock/serializer.js +7 -1
  239. package/script/lock/upstream_deps.js +1 -1
  240. package/script/mod.d.ts +24 -6
  241. package/script/mod.d.ts.map +1 -1
  242. package/script/mod.js +48 -6
  243. package/script/model/mod.d.ts +43 -2
  244. package/script/model/mod.d.ts.map +1 -1
  245. package/script/model/mod.js +2 -1
  246. package/script/model/relations.d.ts +9 -0
  247. package/script/model/relations.d.ts.map +1 -1
  248. package/script/model/relations.js +17 -1
  249. package/script/parser/attributes.d.ts +82 -3
  250. package/script/parser/attributes.d.ts.map +1 -1
  251. package/script/parser/attributes.js +205 -33
  252. package/script/parser/body_tokens.d.ts +1 -1
  253. package/script/parser/body_tokens.d.ts.map +1 -1
  254. package/script/parser/body_tokens.js +49 -35
  255. package/script/parser/feature_file.d.ts +116 -0
  256. package/script/parser/feature_file.d.ts.map +1 -0
  257. package/script/parser/feature_file.js +548 -0
  258. package/script/parser/markdown.d.ts +7 -0
  259. package/script/parser/markdown.d.ts.map +1 -1
  260. package/script/parser/markdown.js +128 -39
  261. package/script/parser/mod.d.ts +18 -0
  262. package/script/parser/mod.d.ts.map +1 -1
  263. package/script/parser/mod.js +52 -1
  264. package/script/parser/translate.d.ts.map +1 -1
  265. package/script/parser/translate.js +5 -0
  266. package/script/refs/mod.d.ts +8 -3
  267. package/script/refs/mod.d.ts.map +1 -1
  268. package/script/refs/mod.js +20 -7
  269. package/script/refs/split.d.ts +58 -0
  270. package/script/refs/split.d.ts.map +1 -0
  271. package/script/refs/split.js +145 -0
  272. package/script/reporter/mod.d.ts +7 -0
  273. package/script/reporter/mod.d.ts.map +1 -1
  274. package/script/reporter/mod.js +113 -3
  275. package/script/sync/mapping.d.ts +4 -3
  276. package/script/sync/mapping.d.ts.map +1 -1
  277. package/script/sync/mapping.js +52 -9
  278. package/script/util/display_id.d.ts +20 -0
  279. package/script/util/display_id.d.ts.map +1 -0
  280. package/script/util/display_id.js +22 -0
  281. package/script/validator/attributes.d.ts.map +1 -1
  282. package/script/validator/attributes.js +4 -1
  283. package/script/validator/block_role.d.ts +40 -0
  284. package/script/validator/block_role.d.ts.map +1 -0
  285. package/script/validator/block_role.js +112 -0
  286. package/script/validator/feature_ac.d.ts.map +1 -1
  287. package/script/validator/feature_ac.js +6 -1
  288. package/script/validator/feature_parse.d.ts +35 -0
  289. package/script/validator/feature_parse.d.ts.map +1 -0
  290. package/script/validator/feature_parse.js +73 -0
  291. package/script/validator/locators.d.ts +36 -0
  292. package/script/validator/locators.d.ts.map +1 -0
  293. package/script/validator/locators.js +188 -0
  294. package/script/validator/mod.d.ts +10 -1
  295. package/script/validator/mod.d.ts.map +1 -1
  296. package/script/validator/mod.js +38 -14
  297. package/script/validator/normalize.d.ts.map +1 -1
  298. package/script/validator/normalize.js +8 -3
  299. package/script/validator/per_type_attrs.d.ts +3 -3
  300. package/script/validator/per_type_attrs.js +3 -3
  301. package/script/validator/pipeline.d.ts +10 -16
  302. package/script/validator/pipeline.d.ts.map +1 -1
  303. package/script/validator/pipeline.js +36 -16
  304. package/script/validator/procedure.d.ts +22 -0
  305. package/script/validator/procedure.d.ts.map +1 -0
  306. package/script/validator/procedure.js +61 -0
  307. package/script/validator/trace_types.d.ts.map +1 -1
  308. package/script/validator/trace_types.js +4 -3
  309. package/script/validator/traceability.d.ts.map +1 -1
  310. package/script/validator/traceability.js +4 -1
  311. package/script/validator/type_resolution.d.ts +5 -3
  312. package/script/validator/type_resolution.d.ts.map +1 -1
  313. package/script/validator/type_resolution.js +14 -2
  314. package/script/validator/types.d.ts +11 -0
  315. package/script/validator/types.d.ts.map +1 -1
  316. package/script/validator/types.js +27 -4
  317. package/script/validator/uxil_family.d.ts +1 -1
@@ -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;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"}
@@ -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
- const fileLine = entry.location.line + featureBlock.range.start.line;
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"}
@@ -0,0 +1,184 @@
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 { ATTRIBUTE_CATALOG, CORE_RELATIONS, emittableEntries, isUpstreamEntry, relationLocatorMode, } from "../model/mod.js";
26
+ import { buildCriteria, isCriteriaBearing } from "../criteria/scenarios.js";
27
+ import { isUnterminatedLocator, parseTraceValue, splitTraceValues, } from "../refs/split.js";
28
+ import { classifyEntry, featureFileCoreType } from "./types.js";
29
+ /** Value types whose values reference other entries. */
30
+ const REFERENCE_VALUE_TYPES = new Set([
31
+ "id",
32
+ "id-list",
33
+ "citation",
34
+ ]);
35
+ /** Core relations that accept a locator, for the MSL-L008 message. */
36
+ const LOCATOR_RELATIONS = (() => {
37
+ const names = CORE_RELATIONS.filter((r) => r.locator !== undefined).map((r) => r.attr);
38
+ return `${names.slice(0, -1).join(", ")} and ${names[names.length - 1]}`;
39
+ })();
40
+ /**
41
+ * Report the locator and scenario-name diagnostics for `entries`.
42
+ * Targets resolve against every entry (upstream entries included);
43
+ * diagnostics are emitted for emittable entries only. When `profile` is
44
+ * given, an entry without a `type` is classified against it first.
45
+ */
46
+ export function validateLocators(entries, profile) {
47
+ const typed = entries.map((e) => withType(e, profile));
48
+ const byKey = new Map();
49
+ for (const e of typed) {
50
+ if (!byKey.has(e.displayId))
51
+ byKey.set(e.displayId, e);
52
+ if (e.id && !byKey.has(e.id))
53
+ byKey.set(e.id, e);
54
+ }
55
+ const relations = relationKeys(profile);
56
+ const diagnostics = [];
57
+ for (const entry of emittableEntries(typed)) {
58
+ if (isCriteriaBearing(entry, profile)) {
59
+ diagnostics.push(...scenarioNameDiagnostics(entry));
60
+ }
61
+ entry.rawAttributes.forEach((attr, index) => {
62
+ if (!relations.has(attr.key))
63
+ return;
64
+ const location = attributeLocation(entry, index);
65
+ for (const part of splitTraceValues(attr.value)) {
66
+ if (isUnterminatedLocator(part)) {
67
+ diagnostics.push({
68
+ code: "MSL-L009",
69
+ severity: "warning",
70
+ message: `${entry.displayId}: '${attr.key}' value '${part}' has ` +
71
+ "a '[' with no closing ']'. Add the closing ']'",
72
+ location,
73
+ });
74
+ continue;
75
+ }
76
+ const parsed = parseTraceValue(part);
77
+ if (parsed.locator === undefined)
78
+ continue;
79
+ const mode = relationLocatorMode(attr.key);
80
+ if (mode === undefined) {
81
+ diagnostics.push({
82
+ code: "MSL-L008",
83
+ severity: "warning",
84
+ message: `${entry.displayId}: '${attr.key}' does not accept a ` +
85
+ `locator ('${parsed.locator}'); only ${LOCATOR_RELATIONS} do. ` +
86
+ `The link to ${parsed.target} is kept`,
87
+ location,
88
+ });
89
+ continue;
90
+ }
91
+ if (mode !== "criterion")
92
+ continue;
93
+ const target = byKey.get(parsed.target);
94
+ // An upstream target carries no criteria (as in the compiler).
95
+ if (!target || isUpstreamEntry(target))
96
+ continue;
97
+ if (!isCriteriaBearing(target, profile))
98
+ continue;
99
+ const resolved = buildCriteria(target).some((c) => c.addressable && c.name === parsed.locator);
100
+ if (resolved)
101
+ continue;
102
+ diagnostics.push({
103
+ code: "MSL-L007",
104
+ severity: "warning",
105
+ message: `${entry.displayId}: locator '${parsed.locator}' matches ` +
106
+ `no scenario of ${target.displayId}`,
107
+ location,
108
+ });
109
+ }
110
+ });
111
+ }
112
+ return diagnostics;
113
+ }
114
+ /** MSL-B060 and MSL-B061 for the scenarios of one entry. */
115
+ function scenarioNameDiagnostics(entry) {
116
+ const diagnostics = [];
117
+ const seen = new Set();
118
+ for (const criterion of buildCriteria(entry)) {
119
+ if (criterion.name === "") {
120
+ diagnostics.push({
121
+ code: "MSL-B061",
122
+ severity: "info",
123
+ message: `${entry.displayId}: scenario has no name; ` +
124
+ "a locator cannot address it",
125
+ location: criterion.location,
126
+ });
127
+ continue;
128
+ }
129
+ if (seen.has(criterion.name)) {
130
+ diagnostics.push({
131
+ code: "MSL-B060",
132
+ severity: "warning",
133
+ message: `${entry.displayId}: scenario name '${criterion.name}' ` +
134
+ "is used more than once; a locator cannot address it",
135
+ location: criterion.location,
136
+ });
137
+ }
138
+ seen.add(criterion.name);
139
+ }
140
+ return diagnostics;
141
+ }
142
+ /** `entry` with its type classified against `profile` when unset. Without a
143
+ * profile, a `.feature` header entry still gets its step-6a core type. */
144
+ export function withType(entry, profile) {
145
+ if (entry.type !== undefined)
146
+ return entry;
147
+ // Without a profile only step 6a (a `.feature` header entry) can type it.
148
+ const type = profile === null
149
+ ? featureFileCoreType(entry)
150
+ : classifyEntry(entry, profile).type;
151
+ return type === undefined ? entry : { ...entry, type };
152
+ }
153
+ /**
154
+ * Trailer keys that are trace relations: the core relations, core
155
+ * attributes whose values reference entries (such as `Verified-by`), and
156
+ * the profile's reference-valued attributes and traceability links.
157
+ */
158
+ function relationKeys(profile) {
159
+ const keys = new Set(CORE_RELATIONS.map((r) => r.attr));
160
+ const isRelation = (key, type) => type !== undefined && REFERENCE_VALUE_TYPES.has(type) && keys.add(key);
161
+ for (const spec of ATTRIBUTE_CATALOG)
162
+ isRelation(spec.key, spec.type);
163
+ if (profile === null)
164
+ return keys;
165
+ for (const [, a] of profile.attributes) {
166
+ isRelation(a.value.name, a.value.type);
167
+ }
168
+ for (const [, t] of profile.types) {
169
+ for (const [, a] of t.value.attributes) {
170
+ isRelation(a.value.name, a.value.type);
171
+ }
172
+ for (const name of t.value.traceability.keys())
173
+ keys.add(name);
174
+ }
175
+ return keys;
176
+ }
177
+ /** The location of the trailer line of `entry.rawAttributes[index]`. */
178
+ function attributeLocation(entry, index) {
179
+ const lines = entry.attributeLines;
180
+ if (!lines || lines.length !== entry.rawAttributes.length) {
181
+ return entry.location;
182
+ }
183
+ return { file: entry.location.file, line: lines[index], column: 1 };
184
+ }
@@ -14,6 +14,15 @@
14
14
  * a profile-aware validator layer (not in the core).
15
15
  */
16
16
  import type { Attribute, Diagnostic, Entry } from "../model/mod.js";
17
+ /**
18
+ * The values of a repeatable attribute (id-list, tag-list, citation or
19
+ * external-id) after trimming and splitting, by the value type's rule: a
20
+ * citation is not split, an id-list uses `splitTraceValues`, the other types
21
+ * split on commas. Empty values are dropped. `undefined` when `key` is not a
22
+ * repeatable attribute. MSL-A012 fires when the list is empty; the LSP quick
23
+ * fix for it uses the same function.
24
+ */
25
+ export declare function repeatableAttributeValues(key: string, raw: string): string[] | undefined;
17
26
  /** Result of a validation pass. */
18
27
  export interface ValidateResult {
19
28
  /** Diagnostics found during validation. */
@@ -30,7 +39,7 @@ export interface ValidateResult {
30
39
  export declare function validate(entries: readonly Entry[]): ValidateResult;
31
40
  export declare function indexByDisplayId(entries: readonly Entry[]): ReadonlyMap<string, Entry>;
32
41
  export declare function findAttr(attrs: readonly Attribute[], key: string): Attribute | undefined;
33
- export { runPipeline, suppressDeclaredAttrR010 } from "./pipeline.js";
42
+ export { runPipeline } from "./pipeline.js";
34
43
  export type { PipelineOptions, PipelineResult } from "./pipeline.js";
35
44
  export { validateListingDocuments } from "./listing.js";
36
45
  export type { ListingFileContext, ListingKind } from "./listing.js";
@@ -1 +1 @@
1
- {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/validator/mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAsCpE,mCAAmC;AACnC,MAAM,WAAW,cAAc;IAC7B,2CAA2C;IAC3C,QAAQ,CAAC,WAAW,EAAE,SAAS,UAAU,EAAE,CAAC;IAC5C,gDAAgD;IAChD,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;CACzB;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,SAAS,KAAK,EAAE,GAAG,cAAc,CAuBlE;AAibD,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,SAAS,KAAK,EAAE,GACxB,WAAW,CAAC,MAAM,EAAE,KAAK,CAAC,CAM5B;AAGD,wBAAgB,QAAQ,CACtB,KAAK,EAAE,SAAS,SAAS,EAAE,EAC3B,GAAG,EAAE,MAAM,GACV,SAAS,GAAG,SAAS,CAEvB;AAED,OAAO,EAAE,WAAW,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AACtE,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAErE,OAAO,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AACxD,YAAY,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEpE,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AACjE,YAAY,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEtE,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAEvD,OAAO,EAAE,cAAc,EAAE,0BAA0B,EAAE,MAAM,iBAAiB,CAAC;AAC7E,YAAY,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAE1D,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,YAAY,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAErD,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,4BAA4B,GAC7B,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,mBAAmB,EACnB,0BAA0B,EAC1B,sBAAsB,GACvB,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/validator/mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAsCpE;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CACvC,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,GACV,MAAM,EAAE,GAAG,SAAS,CAMtB;AAUD,mCAAmC;AACnC,MAAM,WAAW,cAAc;IAC7B,2CAA2C;IAC3C,QAAQ,CAAC,WAAW,EAAE,SAAS,UAAU,EAAE,CAAC;IAC5C,gDAAgD;IAChD,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;CACzB;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,SAAS,KAAK,EAAE,GAAG,cAAc,CAuBlE;AAkbD,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,SAAS,KAAK,EAAE,GACxB,WAAW,CAAC,MAAM,EAAE,KAAK,CAAC,CAM5B;AAGD,wBAAgB,QAAQ,CACtB,KAAK,EAAE,SAAS,SAAS,EAAE,EAC3B,GAAG,EAAE,MAAM,GACV,SAAS,GAAG,SAAS,CAEvB;AAED,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAErE,OAAO,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AACxD,YAAY,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEpE,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AACjE,YAAY,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEtE,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAEvD,OAAO,EAAE,cAAc,EAAE,0BAA0B,EAAE,MAAM,iBAAiB,CAAC;AAC7E,YAAY,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAE1D,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,YAAY,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAErD,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,4BAA4B,GAC7B,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,mBAAmB,EACnB,0BAA0B,EAC1B,sBAAsB,GACvB,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC"}
@@ -13,11 +13,15 @@
13
13
  * constraints, enum vocabularies) are profile-declared and evaluated by
14
14
  * a profile-aware validator layer (not in the core).
15
15
  */
16
- import { attributeSpec, CORE_TYPE_SCOPED_ATTRS, CSV_SPLITTABLE_TYPES, emittableEntries, IDENTITY_KEY, ULID_RE, UNIVERSAL_ATTRIBUTE_KEYS, URI_SCHEME_RE, } from "../model/mod.js";
16
+ import { attributeSpec, CORE_RELATIONS, CORE_TYPE_SCOPED_ATTRS, CSV_SPLITTABLE_TYPES, emittableEntries, IDENTITY_KEY, ULID_RE, UNIVERSAL_ATTRIBUTE_KEYS, URI_SCHEME_RE, } from "../model/mod.js";
17
17
  import { HTTP_URL_RE } from "./value_types.js";
18
+ import { splitTraceValues } from "../refs/split.js";
18
19
  import { validateTypl } from "../typl/mod.js";
19
20
  /** Universal attribute keys the core recognizes. */
20
21
  const UNIVERSAL_KEYS = new Set(UNIVERSAL_ATTRIBUTE_KEYS);
22
+ /** Trailer keys of the core relations. Core recognizes them without a
23
+ * profile, so MSL-R010 never applies to them. */
24
+ const CORE_RELATION_KEYS = new Set(CORE_RELATIONS.map((r) => r.attr));
21
25
  /**
22
26
  * Value-type set that's repeatable per spec §1.8 — these attributes
23
27
  * accept multiple lines for distinct values, so multiple trailers with
@@ -30,6 +34,24 @@ const REPEATABLE_VALUE_TYPES = new Set([
30
34
  "citation",
31
35
  "external-id",
32
36
  ]);
37
+ /**
38
+ * The values of a repeatable attribute (id-list, tag-list, citation or
39
+ * external-id) after trimming and splitting, by the value type's rule: a
40
+ * citation is not split, an id-list uses `splitTraceValues`, the other types
41
+ * split on commas. Empty values are dropped. `undefined` when `key` is not a
42
+ * repeatable attribute. MSL-A012 fires when the list is empty; the LSP quick
43
+ * fix for it uses the same function.
44
+ */
45
+ export function repeatableAttributeValues(key, raw) {
46
+ const spec = attributeSpec(key);
47
+ if (!spec || !REPEATABLE_VALUE_TYPES.has(spec.type))
48
+ return undefined;
49
+ if (spec.type === "citation")
50
+ return [raw.trim()].filter((v) => v.length > 0);
51
+ if (spec.type === "id-list")
52
+ return splitTraceValues(raw);
53
+ return raw.split(",").map((v) => v.trim()).filter((v) => v.length > 0);
54
+ }
33
55
  /**
34
56
  * Slug pattern for Reference-shape display IDs (spec §1.7, ADR-002 §Part 3).
35
57
  * Pandoc/BibTeX cite-key convention, restricted to a portable character
@@ -241,8 +263,13 @@ function checkStructural(emittable, diagnostics) {
241
263
  continue;
242
264
  let depth = 0;
243
265
  let sawTopLevelComma = false;
244
- for (const ch of attr.value) {
245
- if (ch === "[")
266
+ const value = attr.value;
267
+ for (let i = 0; i < value.length; i++) {
268
+ const ch = value[i];
269
+ // Inside a locator, `\]` and `\\` are escapes (#915).
270
+ if (ch === "\\" && depth > 0)
271
+ i++;
272
+ else if (ch === "[")
246
273
  depth++;
247
274
  else if (ch === "]" && depth > 0)
248
275
  depth--;
@@ -273,11 +300,7 @@ function checkStructural(emittable, diagnostics) {
273
300
  continue;
274
301
  if (!REPEATABLE_VALUE_TYPES.has(spec.type))
275
302
  continue;
276
- const raw = attr.value;
277
- const isCitation = spec.type === "citation";
278
- const values = isCitation
279
- ? [raw.trim()].filter((s) => s.length > 0)
280
- : raw.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
303
+ const values = repeatableAttributeValues(attr.key, attr.value) ?? [];
281
304
  if (values.length === 0) {
282
305
  diagnostics.push({
283
306
  code: "MSL-A012",
@@ -365,17 +388,18 @@ function checkStructural(emittable, diagnostics) {
365
388
  }
366
389
  // MSL-R010: Unknown attributes are warnings in the core. A
367
390
  // profile-aware validator widens this check to include profile-declared
368
- // attributes; until then, anything outside the universal set is
369
- // unrecognized. Core-typed attributes (per ADR-003 §Part 2) are
370
- // suppressed here — the per-type validator emits a more specific
371
- // MSL-T022 when they appear on the "wrong" type.
391
+ // attributes; until then, anything outside the universal set and the
392
+ // core relation keys is unrecognized. Core-typed attributes (per
393
+ // ADR-003 §Part 2) are suppressed here — the per-type validator emits
394
+ // a more specific MSL-T022 when they appear on the "wrong" type.
372
395
  if (!UNIVERSAL_KEYS.has(attr.key) &&
396
+ !CORE_RELATION_KEYS.has(attr.key) &&
373
397
  attr.key !== "Type" &&
374
398
  !CORE_TYPE_SCOPED_ATTRS.has(attr.key)) {
375
399
  diagnostics.push({
376
400
  code: "MSL-R010",
377
401
  severity: "warning",
378
- message: `${entry.displayId}: unknown attribute '${attr.key}' (not in core universal set; profile-declared attributes are permitted when a profile is loaded)`,
402
+ message: `${entry.displayId}: unknown attribute '${attr.key}' (not in core universal set or core relation keys; profile-declared attributes are permitted when a profile is loaded)`,
379
403
  location: entry.location,
380
404
  });
381
405
  }
@@ -479,7 +503,7 @@ export function indexByDisplayId(entries) {
479
503
  export function findAttr(attrs, key) {
480
504
  return attrs.find((a) => a.key === key);
481
505
  }
482
- export { runPipeline, suppressDeclaredAttrR010 } from "./pipeline.js";
506
+ export { runPipeline } from "./pipeline.js";
483
507
  export { validateListingDocuments } from "./listing.js";
484
508
  export { classifyEntriesStage, classifyEntry } from "./types.js";
485
509
  export { compileDisplayIdPattern } from "./pattern.js";
@@ -1 +1 @@
1
- {"version":3,"file":"normalize.d.ts","sourceRoot":"","sources":["../../src/validator/normalize.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAa,MAAM,iBAAiB,CAAC;AAK1E;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,gBAAgB,GACxB,KAAK,CAoBP"}
1
+ {"version":3,"file":"normalize.d.ts","sourceRoot":"","sources":["../../src/validator/normalize.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAa,MAAM,iBAAiB,CAAC;AAM1E;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,gBAAgB,GACxB,KAAK,CAoBP"}
@@ -13,6 +13,7 @@
13
13
  * whitespace is trimmed.
14
14
  */
15
15
  import { effectiveScope } from "./attributes.js";
16
+ import { splitTraceValues } from "../refs/split.js";
16
17
  const LIST_TYPES = new Set(["id-list", "tag-list"]);
17
18
  /**
18
19
  * Return a new Entry with list-typed attribute values split on commas. If no
@@ -25,7 +26,7 @@ export function normalizeListValues(entry, profile) {
25
26
  for (const [name, values] of entry.typedAttributes) {
26
27
  const decl = scope.attributes.get(name);
27
28
  if (decl !== undefined && LIST_TYPES.has(decl.type)) {
28
- const split = splitListValues(values);
29
+ const split = splitListValues(values, decl.type === "id-list");
29
30
  if (!arraysEqual(split, values)) {
30
31
  rewritten.set(name, split);
31
32
  anyChange = true;
@@ -38,10 +39,14 @@ export function normalizeListValues(entry, profile) {
38
39
  return entry;
39
40
  return { ...entry, typedAttributes: rewritten };
40
41
  }
41
- function splitListValues(values) {
42
+ function splitListValues(values, isTraceList) {
42
43
  const out = [];
43
44
  for (const v of values) {
44
- const parts = v.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
45
+ // In a trace list, commas inside a bracket locator (`A [x, y]`) do not
46
+ // split. Other lists (tag-list) split on every comma.
47
+ const parts = isTraceList
48
+ ? splitTraceValues(v)
49
+ : v.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
45
50
  if (parts.length === 0)
46
51
  continue;
47
52
  out.push(...parts);