@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,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
+ }
@@ -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,188 @@
1
+ "use strict";
2
+ /**
3
+ * @module core/validator/locators
4
+ *
5
+ * Locator and scenario-name diagnostics (epic #915, scenario-locator
6
+ * slice):
7
+ *
8
+ * - `MSL-L007` (warning): a locator on a `"criterion"` relation
9
+ * (`Satisfies`, `Verifies`) names no addressable scenario of a resolved,
10
+ * criteria-bearing target. The edge to the target is kept.
11
+ * - `MSL-L008` (warning): a locator on a trace relation that does not
12
+ * accept one (every relation without a locator mode, including
13
+ * profile-declared relations and a hand-written `Verified-by`). The
14
+ * edge to the target is kept.
15
+ * - `MSL-L009` (warning): a trace value has a `[` after whitespace that
16
+ * no `]` closes. The value has no locator and is read as it was before
17
+ * scenario locators existed.
18
+ * - `MSL-B060` (warning): a scenario name occurs more than once in one
19
+ * entry; reported on the second and later occurrences.
20
+ * - `MSL-B061` (info): a scenario has an empty name.
21
+ *
22
+ * A locator on an unresolved target raises only `MSL-L006`, and a locator
23
+ * on a target that carries no criteria (not a Requirement or Contract, or a
24
+ * Reference entry) is free text: neither raises `MSL-L007`.
25
+ */
26
+ Object.defineProperty(exports, "__esModule", { value: true });
27
+ exports.validateLocators = validateLocators;
28
+ exports.withType = withType;
29
+ const mod_js_1 = require("../model/mod.js");
30
+ const scenarios_js_1 = require("../criteria/scenarios.js");
31
+ const split_js_1 = require("../refs/split.js");
32
+ const types_js_1 = require("./types.js");
33
+ /** Value types whose values reference other entries. */
34
+ const REFERENCE_VALUE_TYPES = new Set([
35
+ "id",
36
+ "id-list",
37
+ "citation",
38
+ ]);
39
+ /** Core relations that accept a locator, for the MSL-L008 message. */
40
+ const LOCATOR_RELATIONS = (() => {
41
+ const names = mod_js_1.CORE_RELATIONS.filter((r) => r.locator !== undefined).map((r) => r.attr);
42
+ return `${names.slice(0, -1).join(", ")} and ${names[names.length - 1]}`;
43
+ })();
44
+ /**
45
+ * Report the locator and scenario-name diagnostics for `entries`.
46
+ * Targets resolve against every entry (upstream entries included);
47
+ * diagnostics are emitted for emittable entries only. When `profile` is
48
+ * given, an entry without a `type` is classified against it first.
49
+ */
50
+ function validateLocators(entries, profile) {
51
+ const typed = entries.map((e) => withType(e, profile));
52
+ const byKey = new Map();
53
+ for (const e of typed) {
54
+ if (!byKey.has(e.displayId))
55
+ byKey.set(e.displayId, e);
56
+ if (e.id && !byKey.has(e.id))
57
+ byKey.set(e.id, e);
58
+ }
59
+ const relations = relationKeys(profile);
60
+ const diagnostics = [];
61
+ for (const entry of (0, mod_js_1.emittableEntries)(typed)) {
62
+ if ((0, scenarios_js_1.isCriteriaBearing)(entry, profile)) {
63
+ diagnostics.push(...scenarioNameDiagnostics(entry));
64
+ }
65
+ entry.rawAttributes.forEach((attr, index) => {
66
+ if (!relations.has(attr.key))
67
+ return;
68
+ const location = attributeLocation(entry, index);
69
+ for (const part of (0, split_js_1.splitTraceValues)(attr.value)) {
70
+ if ((0, split_js_1.isUnterminatedLocator)(part)) {
71
+ diagnostics.push({
72
+ code: "MSL-L009",
73
+ severity: "warning",
74
+ message: `${entry.displayId}: '${attr.key}' value '${part}' has ` +
75
+ "a '[' with no closing ']'. Add the closing ']'",
76
+ location,
77
+ });
78
+ continue;
79
+ }
80
+ const parsed = (0, split_js_1.parseTraceValue)(part);
81
+ if (parsed.locator === undefined)
82
+ continue;
83
+ const mode = (0, mod_js_1.relationLocatorMode)(attr.key);
84
+ if (mode === undefined) {
85
+ diagnostics.push({
86
+ code: "MSL-L008",
87
+ severity: "warning",
88
+ message: `${entry.displayId}: '${attr.key}' does not accept a ` +
89
+ `locator ('${parsed.locator}'); only ${LOCATOR_RELATIONS} do. ` +
90
+ `The link to ${parsed.target} is kept`,
91
+ location,
92
+ });
93
+ continue;
94
+ }
95
+ if (mode !== "criterion")
96
+ continue;
97
+ const target = byKey.get(parsed.target);
98
+ // An upstream target carries no criteria (as in the compiler).
99
+ if (!target || (0, mod_js_1.isUpstreamEntry)(target))
100
+ continue;
101
+ if (!(0, scenarios_js_1.isCriteriaBearing)(target, profile))
102
+ continue;
103
+ const resolved = (0, scenarios_js_1.buildCriteria)(target).some((c) => c.addressable && c.name === parsed.locator);
104
+ if (resolved)
105
+ continue;
106
+ diagnostics.push({
107
+ code: "MSL-L007",
108
+ severity: "warning",
109
+ message: `${entry.displayId}: locator '${parsed.locator}' matches ` +
110
+ `no scenario of ${target.displayId}`,
111
+ location,
112
+ });
113
+ }
114
+ });
115
+ }
116
+ return diagnostics;
117
+ }
118
+ /** MSL-B060 and MSL-B061 for the scenarios of one entry. */
119
+ function scenarioNameDiagnostics(entry) {
120
+ const diagnostics = [];
121
+ const seen = new Set();
122
+ for (const criterion of (0, scenarios_js_1.buildCriteria)(entry)) {
123
+ if (criterion.name === "") {
124
+ diagnostics.push({
125
+ code: "MSL-B061",
126
+ severity: "info",
127
+ message: `${entry.displayId}: scenario has no name; ` +
128
+ "a locator cannot address it",
129
+ location: criterion.location,
130
+ });
131
+ continue;
132
+ }
133
+ if (seen.has(criterion.name)) {
134
+ diagnostics.push({
135
+ code: "MSL-B060",
136
+ severity: "warning",
137
+ message: `${entry.displayId}: scenario name '${criterion.name}' ` +
138
+ "is used more than once; a locator cannot address it",
139
+ location: criterion.location,
140
+ });
141
+ }
142
+ seen.add(criterion.name);
143
+ }
144
+ return diagnostics;
145
+ }
146
+ /** `entry` with its type classified against `profile` when unset. Without a
147
+ * profile, a `.feature` header entry still gets its step-6a core type. */
148
+ function withType(entry, profile) {
149
+ if (entry.type !== undefined)
150
+ return entry;
151
+ // Without a profile only step 6a (a `.feature` header entry) can type it.
152
+ const type = profile === null
153
+ ? (0, types_js_1.featureFileCoreType)(entry)
154
+ : (0, types_js_1.classifyEntry)(entry, profile).type;
155
+ return type === undefined ? entry : { ...entry, type };
156
+ }
157
+ /**
158
+ * Trailer keys that are trace relations: the core relations, core
159
+ * attributes whose values reference entries (such as `Verified-by`), and
160
+ * the profile's reference-valued attributes and traceability links.
161
+ */
162
+ function relationKeys(profile) {
163
+ const keys = new Set(mod_js_1.CORE_RELATIONS.map((r) => r.attr));
164
+ const isRelation = (key, type) => type !== undefined && REFERENCE_VALUE_TYPES.has(type) && keys.add(key);
165
+ for (const spec of mod_js_1.ATTRIBUTE_CATALOG)
166
+ isRelation(spec.key, spec.type);
167
+ if (profile === null)
168
+ return keys;
169
+ for (const [, a] of profile.attributes) {
170
+ isRelation(a.value.name, a.value.type);
171
+ }
172
+ for (const [, t] of profile.types) {
173
+ for (const [, a] of t.value.attributes) {
174
+ isRelation(a.value.name, a.value.type);
175
+ }
176
+ for (const name of t.value.traceability.keys())
177
+ keys.add(name);
178
+ }
179
+ return keys;
180
+ }
181
+ /** The location of the trailer line of `entry.rawAttributes[index]`. */
182
+ function attributeLocation(entry, index) {
183
+ const lines = entry.attributeLines;
184
+ if (!lines || lines.length !== entry.rawAttributes.length) {
185
+ return entry.location;
186
+ }
187
+ return { file: entry.location.file, line: lines[index], column: 1 };
188
+ }
@@ -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"}
@@ -15,15 +15,20 @@
15
15
  * a profile-aware validator layer (not in the core).
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.detectCorpusCollisions = exports.attributeCorpusDiagnostics = exports.applyCorpusPostPass = exports.validateTraceabilityForEntry = exports.matchesAnyTarget = exports.effectiveTraceRules = exports.normalizeListValues = exports.validateValue = exports.validateAttributesForEntry = exports.effectiveScope = exports.compileDisplayIdPattern = exports.classifyEntry = exports.classifyEntriesStage = exports.validateListingDocuments = exports.suppressDeclaredAttrR010 = exports.runPipeline = void 0;
18
+ exports.detectCorpusCollisions = exports.attributeCorpusDiagnostics = exports.applyCorpusPostPass = exports.validateTraceabilityForEntry = exports.matchesAnyTarget = exports.effectiveTraceRules = exports.normalizeListValues = exports.validateValue = exports.validateAttributesForEntry = exports.effectiveScope = exports.compileDisplayIdPattern = exports.classifyEntry = exports.classifyEntriesStage = exports.validateListingDocuments = exports.runPipeline = void 0;
19
+ exports.repeatableAttributeValues = repeatableAttributeValues;
19
20
  exports.validate = validate;
20
21
  exports.indexByDisplayId = indexByDisplayId;
21
22
  exports.findAttr = findAttr;
22
23
  const mod_js_1 = require("../model/mod.js");
23
24
  const value_types_js_1 = require("./value_types.js");
25
+ const split_js_1 = require("../refs/split.js");
24
26
  const mod_js_2 = require("../typl/mod.js");
25
27
  /** Universal attribute keys the core recognizes. */
26
28
  const UNIVERSAL_KEYS = new Set(mod_js_1.UNIVERSAL_ATTRIBUTE_KEYS);
29
+ /** Trailer keys of the core relations. Core recognizes them without a
30
+ * profile, so MSL-R010 never applies to them. */
31
+ const CORE_RELATION_KEYS = new Set(mod_js_1.CORE_RELATIONS.map((r) => r.attr));
27
32
  /**
28
33
  * Value-type set that's repeatable per spec §1.8 — these attributes
29
34
  * accept multiple lines for distinct values, so multiple trailers with
@@ -36,6 +41,24 @@ const REPEATABLE_VALUE_TYPES = new Set([
36
41
  "citation",
37
42
  "external-id",
38
43
  ]);
44
+ /**
45
+ * The values of a repeatable attribute (id-list, tag-list, citation or
46
+ * external-id) after trimming and splitting, by the value type's rule: a
47
+ * citation is not split, an id-list uses `splitTraceValues`, the other types
48
+ * split on commas. Empty values are dropped. `undefined` when `key` is not a
49
+ * repeatable attribute. MSL-A012 fires when the list is empty; the LSP quick
50
+ * fix for it uses the same function.
51
+ */
52
+ function repeatableAttributeValues(key, raw) {
53
+ const spec = (0, mod_js_1.attributeSpec)(key);
54
+ if (!spec || !REPEATABLE_VALUE_TYPES.has(spec.type))
55
+ return undefined;
56
+ if (spec.type === "citation")
57
+ return [raw.trim()].filter((v) => v.length > 0);
58
+ if (spec.type === "id-list")
59
+ return (0, split_js_1.splitTraceValues)(raw);
60
+ return raw.split(",").map((v) => v.trim()).filter((v) => v.length > 0);
61
+ }
39
62
  /**
40
63
  * Slug pattern for Reference-shape display IDs (spec §1.7, ADR-002 §Part 3).
41
64
  * Pandoc/BibTeX cite-key convention, restricted to a portable character
@@ -247,8 +270,13 @@ function checkStructural(emittable, diagnostics) {
247
270
  continue;
248
271
  let depth = 0;
249
272
  let sawTopLevelComma = false;
250
- for (const ch of attr.value) {
251
- if (ch === "[")
273
+ const value = attr.value;
274
+ for (let i = 0; i < value.length; i++) {
275
+ const ch = value[i];
276
+ // Inside a locator, `\]` and `\\` are escapes (#915).
277
+ if (ch === "\\" && depth > 0)
278
+ i++;
279
+ else if (ch === "[")
252
280
  depth++;
253
281
  else if (ch === "]" && depth > 0)
254
282
  depth--;
@@ -279,11 +307,7 @@ function checkStructural(emittable, diagnostics) {
279
307
  continue;
280
308
  if (!REPEATABLE_VALUE_TYPES.has(spec.type))
281
309
  continue;
282
- const raw = attr.value;
283
- const isCitation = spec.type === "citation";
284
- const values = isCitation
285
- ? [raw.trim()].filter((s) => s.length > 0)
286
- : raw.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
310
+ const values = repeatableAttributeValues(attr.key, attr.value) ?? [];
287
311
  if (values.length === 0) {
288
312
  diagnostics.push({
289
313
  code: "MSL-A012",
@@ -371,17 +395,18 @@ function checkStructural(emittable, diagnostics) {
371
395
  }
372
396
  // MSL-R010: Unknown attributes are warnings in the core. A
373
397
  // profile-aware validator widens this check to include profile-declared
374
- // attributes; until then, anything outside the universal set is
375
- // unrecognized. Core-typed attributes (per ADR-003 §Part 2) are
376
- // suppressed here — the per-type validator emits a more specific
377
- // MSL-T022 when they appear on the "wrong" type.
398
+ // attributes; until then, anything outside the universal set and the
399
+ // core relation keys is unrecognized. Core-typed attributes (per
400
+ // ADR-003 §Part 2) are suppressed here — the per-type validator emits
401
+ // a more specific MSL-T022 when they appear on the "wrong" type.
378
402
  if (!UNIVERSAL_KEYS.has(attr.key) &&
403
+ !CORE_RELATION_KEYS.has(attr.key) &&
379
404
  attr.key !== "Type" &&
380
405
  !mod_js_1.CORE_TYPE_SCOPED_ATTRS.has(attr.key)) {
381
406
  diagnostics.push({
382
407
  code: "MSL-R010",
383
408
  severity: "warning",
384
- message: `${entry.displayId}: unknown attribute '${attr.key}' (not in core universal set; profile-declared attributes are permitted when a profile is loaded)`,
409
+ 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)`,
385
410
  location: entry.location,
386
411
  });
387
412
  }
@@ -487,7 +512,6 @@ function findAttr(attrs, key) {
487
512
  }
488
513
  var pipeline_js_1 = require("./pipeline.js");
489
514
  Object.defineProperty(exports, "runPipeline", { enumerable: true, get: function () { return pipeline_js_1.runPipeline; } });
490
- Object.defineProperty(exports, "suppressDeclaredAttrR010", { enumerable: true, get: function () { return pipeline_js_1.suppressDeclaredAttrR010; } });
491
515
  var listing_js_1 = require("./listing.js");
492
516
  Object.defineProperty(exports, "validateListingDocuments", { enumerable: true, get: function () { return listing_js_1.validateListingDocuments; } });
493
517
  var types_js_1 = require("./types.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"}