@reqlan/language 1.4.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 (371) hide show
  1. package/README.md +24 -0
  2. package/out/file-path-rewrite.d.ts +25 -0
  3. package/out/file-path-rewrite.js +56 -0
  4. package/out/file-path-rewrite.js.map +1 -0
  5. package/out/generated/ast.d.ts +1157 -0
  6. package/out/generated/ast.js +980 -0
  7. package/out/generated/ast.js.map +1 -0
  8. package/out/generated/grammar.d.ts +7 -0
  9. package/out/generated/grammar.js +3071 -0
  10. package/out/generated/grammar.js.map +1 -0
  11. package/out/generated/module.d.ts +20 -0
  12. package/out/generated/module.js +32 -0
  13. package/out/generated/module.js.map +1 -0
  14. package/out/index.d.ts +34 -0
  15. package/out/index.js +35 -0
  16. package/out/index.js.map +1 -0
  17. package/out/reqlan-attribute-catalog.d.ts +19 -0
  18. package/out/reqlan-attribute-catalog.js +87 -0
  19. package/out/reqlan-attribute-catalog.js.map +1 -0
  20. package/out/reqlan-code-action-provider.d.ts +55 -0
  21. package/out/reqlan-code-action-provider.js +269 -0
  22. package/out/reqlan-code-action-provider.js.map +1 -0
  23. package/out/reqlan-code-lens-provider.d.ts +13 -0
  24. package/out/reqlan-code-lens-provider.js +27 -0
  25. package/out/reqlan-code-lens-provider.js.map +1 -0
  26. package/out/reqlan-code-lens-settings.d.ts +34 -0
  27. package/out/reqlan-code-lens-settings.js +12 -0
  28. package/out/reqlan-code-lens-settings.js.map +1 -0
  29. package/out/reqlan-comment-resolver.d.ts +35 -0
  30. package/out/reqlan-comment-resolver.js +308 -0
  31. package/out/reqlan-comment-resolver.js.map +1 -0
  32. package/out/reqlan-completion-context.d.ts +46 -0
  33. package/out/reqlan-completion-context.js +244 -0
  34. package/out/reqlan-completion-context.js.map +1 -0
  35. package/out/reqlan-completion-provider.d.ts +41 -0
  36. package/out/reqlan-completion-provider.js +317 -0
  37. package/out/reqlan-completion-provider.js.map +1 -0
  38. package/out/reqlan-definition-provider.d.ts +31 -0
  39. package/out/reqlan-definition-provider.js +240 -0
  40. package/out/reqlan-definition-provider.js.map +1 -0
  41. package/out/reqlan-document-highlight-provider.d.ts +10 -0
  42. package/out/reqlan-document-highlight-provider.js +11 -0
  43. package/out/reqlan-document-highlight-provider.js.map +1 -0
  44. package/out/reqlan-document-link-provider.d.ts +14 -0
  45. package/out/reqlan-document-link-provider.js +24 -0
  46. package/out/reqlan-document-link-provider.js.map +1 -0
  47. package/out/reqlan-embedded-file-references.d.ts +11 -0
  48. package/out/reqlan-embedded-file-references.js +50 -0
  49. package/out/reqlan-embedded-file-references.js.map +1 -0
  50. package/out/reqlan-file-link-resolver.d.ts +44 -0
  51. package/out/reqlan-file-link-resolver.js +347 -0
  52. package/out/reqlan-file-link-resolver.js.map +1 -0
  53. package/out/reqlan-file-references.d.ts +15 -0
  54. package/out/reqlan-file-references.js +72 -0
  55. package/out/reqlan-file-references.js.map +1 -0
  56. package/out/reqlan-grammar-config.d.ts +5 -0
  57. package/out/reqlan-grammar-config.js +9 -0
  58. package/out/reqlan-grammar-config.js.map +1 -0
  59. package/out/reqlan-idea-reference-site.d.ts +14 -0
  60. package/out/reqlan-idea-reference-site.js +47 -0
  61. package/out/reqlan-idea-reference-site.js.map +1 -0
  62. package/out/reqlan-idea-summary.d.ts +6 -0
  63. package/out/reqlan-idea-summary.js +134 -0
  64. package/out/reqlan-idea-summary.js.map +1 -0
  65. package/out/reqlan-ignore-error.d.ts +10 -0
  66. package/out/reqlan-ignore-error.js +42 -0
  67. package/out/reqlan-ignore-error.js.map +1 -0
  68. package/out/reqlan-import-bindings.d.ts +12 -0
  69. package/out/reqlan-import-bindings.js +65 -0
  70. package/out/reqlan-import-bindings.js.map +1 -0
  71. package/out/reqlan-import-edits.d.ts +17 -0
  72. package/out/reqlan-import-edits.js +96 -0
  73. package/out/reqlan-import-edits.js.map +1 -0
  74. package/out/reqlan-imports.d.ts +22 -0
  75. package/out/reqlan-imports.js +61 -0
  76. package/out/reqlan-imports.js.map +1 -0
  77. package/out/reqlan-inbound-reference-inlay-label.d.ts +27 -0
  78. package/out/reqlan-inbound-reference-inlay-label.js +142 -0
  79. package/out/reqlan-inbound-reference-inlay-label.js.map +1 -0
  80. package/out/reqlan-inlay-hint-provider.d.ts +15 -0
  81. package/out/reqlan-inlay-hint-provider.js +54 -0
  82. package/out/reqlan-inlay-hint-provider.js.map +1 -0
  83. package/out/reqlan-inlay-hint-settings.d.ts +10 -0
  84. package/out/reqlan-inlay-hint-settings.js +10 -0
  85. package/out/reqlan-inlay-hint-settings.js.map +1 -0
  86. package/out/reqlan-linker.d.ts +26 -0
  87. package/out/reqlan-linker.js +83 -0
  88. package/out/reqlan-linker.js.map +1 -0
  89. package/out/reqlan-markdown-links.d.ts +28 -0
  90. package/out/reqlan-markdown-links.js +113 -0
  91. package/out/reqlan-markdown-links.js.map +1 -0
  92. package/out/reqlan-module.d.ts +41 -0
  93. package/out/reqlan-module.js +78 -0
  94. package/out/reqlan-module.js.map +1 -0
  95. package/out/reqlan-name-catalog.d.ts +23 -0
  96. package/out/reqlan-name-catalog.js +63 -0
  97. package/out/reqlan-name-catalog.js.map +1 -0
  98. package/out/reqlan-name-provider.d.ts +10 -0
  99. package/out/reqlan-name-provider.js +38 -0
  100. package/out/reqlan-name-provider.js.map +1 -0
  101. package/out/reqlan-namespace-import-links.d.ts +10 -0
  102. package/out/reqlan-namespace-import-links.js +69 -0
  103. package/out/reqlan-namespace-import-links.js.map +1 -0
  104. package/out/reqlan-path-completion.d.ts +50 -0
  105. package/out/reqlan-path-completion.js +304 -0
  106. package/out/reqlan-path-completion.js.map +1 -0
  107. package/out/reqlan-path-references.d.ts +5 -0
  108. package/out/reqlan-path-references.js +124 -0
  109. package/out/reqlan-path-references.js.map +1 -0
  110. package/out/reqlan-path-resolve.d.ts +81 -0
  111. package/out/reqlan-path-resolve.js +245 -0
  112. package/out/reqlan-path-resolve.js.map +1 -0
  113. package/out/reqlan-quoted-strings.d.ts +9 -0
  114. package/out/reqlan-quoted-strings.js +26 -0
  115. package/out/reqlan-quoted-strings.js.map +1 -0
  116. package/out/reqlan-reference-at-position.d.ts +20 -0
  117. package/out/reqlan-reference-at-position.js +89 -0
  118. package/out/reqlan-reference-at-position.js.map +1 -0
  119. package/out/reqlan-reference-code-lens.d.ts +32 -0
  120. package/out/reqlan-reference-code-lens.js +240 -0
  121. package/out/reqlan-reference-code-lens.js.map +1 -0
  122. package/out/reqlan-reference-search-site.d.ts +34 -0
  123. package/out/reqlan-reference-search-site.js +136 -0
  124. package/out/reqlan-reference-search-site.js.map +1 -0
  125. package/out/reqlan-references.d.ts +16 -0
  126. package/out/reqlan-references.js +51 -0
  127. package/out/reqlan-references.js.map +1 -0
  128. package/out/reqlan-scope.d.ts +25 -0
  129. package/out/reqlan-scope.js +259 -0
  130. package/out/reqlan-scope.js.map +1 -0
  131. package/out/reqlan-semantic-token-provider.d.ts +8 -0
  132. package/out/reqlan-semantic-token-provider.js +91 -0
  133. package/out/reqlan-semantic-token-provider.js.map +1 -0
  134. package/out/reqlan-token-builder.d.ts +12 -0
  135. package/out/reqlan-token-builder.js +459 -0
  136. package/out/reqlan-token-builder.js.map +1 -0
  137. package/out/reqlan-validator.d.ts +25 -0
  138. package/out/reqlan-validator.js +119 -0
  139. package/out/reqlan-validator.js.map +1 -0
  140. package/out/reqlan-workspace-attribute-catalog.d.ts +6 -0
  141. package/out/reqlan-workspace-attribute-catalog.js +54 -0
  142. package/out/reqlan-workspace-attribute-catalog.js.map +1 -0
  143. package/out/src/file-path-rewrite.d.ts +25 -0
  144. package/out/src/file-path-rewrite.js +56 -0
  145. package/out/src/file-path-rewrite.js.map +1 -0
  146. package/out/src/generated/ast.d.ts +1173 -0
  147. package/out/src/generated/ast.js +994 -0
  148. package/out/src/generated/ast.js.map +1 -0
  149. package/out/src/generated/grammar.d.ts +7 -0
  150. package/out/src/generated/grammar.js +3045 -0
  151. package/out/src/generated/grammar.js.map +1 -0
  152. package/out/src/generated/module.d.ts +20 -0
  153. package/out/src/generated/module.js +32 -0
  154. package/out/src/generated/module.js.map +1 -0
  155. package/out/src/index.d.ts +29 -0
  156. package/out/src/index.js +30 -0
  157. package/out/src/index.js.map +1 -0
  158. package/out/src/reqlan-attribute-catalog.d.ts +19 -0
  159. package/out/src/reqlan-attribute-catalog.js +87 -0
  160. package/out/src/reqlan-attribute-catalog.js.map +1 -0
  161. package/out/src/reqlan-code-action-provider.d.ts +34 -0
  162. package/out/src/reqlan-code-action-provider.js +206 -0
  163. package/out/src/reqlan-code-action-provider.js.map +1 -0
  164. package/out/src/reqlan-comment-resolver.d.ts +35 -0
  165. package/out/src/reqlan-comment-resolver.js +308 -0
  166. package/out/src/reqlan-comment-resolver.js.map +1 -0
  167. package/out/src/reqlan-completion-context.d.ts +46 -0
  168. package/out/src/reqlan-completion-context.js +244 -0
  169. package/out/src/reqlan-completion-context.js.map +1 -0
  170. package/out/src/reqlan-completion-provider.d.ts +41 -0
  171. package/out/src/reqlan-completion-provider.js +320 -0
  172. package/out/src/reqlan-completion-provider.js.map +1 -0
  173. package/out/src/reqlan-definition-provider.d.ts +31 -0
  174. package/out/src/reqlan-definition-provider.js +240 -0
  175. package/out/src/reqlan-definition-provider.js.map +1 -0
  176. package/out/src/reqlan-document-highlight-provider.d.ts +10 -0
  177. package/out/src/reqlan-document-highlight-provider.js +11 -0
  178. package/out/src/reqlan-document-highlight-provider.js.map +1 -0
  179. package/out/src/reqlan-document-link-provider.d.ts +14 -0
  180. package/out/src/reqlan-document-link-provider.js +24 -0
  181. package/out/src/reqlan-document-link-provider.js.map +1 -0
  182. package/out/src/reqlan-embedded-file-references.d.ts +11 -0
  183. package/out/src/reqlan-embedded-file-references.js +50 -0
  184. package/out/src/reqlan-embedded-file-references.js.map +1 -0
  185. package/out/src/reqlan-file-link-resolver.d.ts +44 -0
  186. package/out/src/reqlan-file-link-resolver.js +347 -0
  187. package/out/src/reqlan-file-link-resolver.js.map +1 -0
  188. package/out/src/reqlan-file-references.d.ts +15 -0
  189. package/out/src/reqlan-file-references.js +72 -0
  190. package/out/src/reqlan-file-references.js.map +1 -0
  191. package/out/src/reqlan-grammar-config.d.ts +5 -0
  192. package/out/src/reqlan-grammar-config.js +9 -0
  193. package/out/src/reqlan-grammar-config.js.map +1 -0
  194. package/out/src/reqlan-idea-summary.d.ts +6 -0
  195. package/out/src/reqlan-idea-summary.js +78 -0
  196. package/out/src/reqlan-idea-summary.js.map +1 -0
  197. package/out/src/reqlan-ignore-error.d.ts +10 -0
  198. package/out/src/reqlan-ignore-error.js +42 -0
  199. package/out/src/reqlan-ignore-error.js.map +1 -0
  200. package/out/src/reqlan-import-bindings.d.ts +12 -0
  201. package/out/src/reqlan-import-bindings.js +65 -0
  202. package/out/src/reqlan-import-bindings.js.map +1 -0
  203. package/out/src/reqlan-import-edits.d.ts +17 -0
  204. package/out/src/reqlan-import-edits.js +96 -0
  205. package/out/src/reqlan-import-edits.js.map +1 -0
  206. package/out/src/reqlan-imports.d.ts +22 -0
  207. package/out/src/reqlan-imports.js +61 -0
  208. package/out/src/reqlan-imports.js.map +1 -0
  209. package/out/src/reqlan-inbound-reference-inlay-label.d.ts +23 -0
  210. package/out/src/reqlan-inbound-reference-inlay-label.js +128 -0
  211. package/out/src/reqlan-inbound-reference-inlay-label.js.map +1 -0
  212. package/out/src/reqlan-inlay-hint-provider.d.ts +15 -0
  213. package/out/src/reqlan-inlay-hint-provider.js +54 -0
  214. package/out/src/reqlan-inlay-hint-provider.js.map +1 -0
  215. package/out/src/reqlan-inlay-hint-settings.d.ts +10 -0
  216. package/out/src/reqlan-inlay-hint-settings.js +10 -0
  217. package/out/src/reqlan-inlay-hint-settings.js.map +1 -0
  218. package/out/src/reqlan-linker.d.ts +26 -0
  219. package/out/src/reqlan-linker.js +86 -0
  220. package/out/src/reqlan-linker.js.map +1 -0
  221. package/out/src/reqlan-markdown-links.d.ts +28 -0
  222. package/out/src/reqlan-markdown-links.js +113 -0
  223. package/out/src/reqlan-markdown-links.js.map +1 -0
  224. package/out/src/reqlan-module.d.ts +41 -0
  225. package/out/src/reqlan-module.js +76 -0
  226. package/out/src/reqlan-module.js.map +1 -0
  227. package/out/src/reqlan-name-catalog.d.ts +23 -0
  228. package/out/src/reqlan-name-catalog.js +63 -0
  229. package/out/src/reqlan-name-catalog.js.map +1 -0
  230. package/out/src/reqlan-name-provider.d.ts +10 -0
  231. package/out/src/reqlan-name-provider.js +38 -0
  232. package/out/src/reqlan-name-provider.js.map +1 -0
  233. package/out/src/reqlan-namespace-import-links.d.ts +10 -0
  234. package/out/src/reqlan-namespace-import-links.js +81 -0
  235. package/out/src/reqlan-namespace-import-links.js.map +1 -0
  236. package/out/src/reqlan-path-completion.d.ts +50 -0
  237. package/out/src/reqlan-path-completion.js +304 -0
  238. package/out/src/reqlan-path-completion.js.map +1 -0
  239. package/out/src/reqlan-path-references.d.ts +5 -0
  240. package/out/src/reqlan-path-references.js +124 -0
  241. package/out/src/reqlan-path-references.js.map +1 -0
  242. package/out/src/reqlan-path-resolve.d.ts +59 -0
  243. package/out/src/reqlan-path-resolve.js +173 -0
  244. package/out/src/reqlan-path-resolve.js.map +1 -0
  245. package/out/src/reqlan-quoted-strings.d.ts +9 -0
  246. package/out/src/reqlan-quoted-strings.js +26 -0
  247. package/out/src/reqlan-quoted-strings.js.map +1 -0
  248. package/out/src/reqlan-reference-at-position.d.ts +20 -0
  249. package/out/src/reqlan-reference-at-position.js +89 -0
  250. package/out/src/reqlan-reference-at-position.js.map +1 -0
  251. package/out/src/reqlan-references.d.ts +16 -0
  252. package/out/src/reqlan-references.js +51 -0
  253. package/out/src/reqlan-references.js.map +1 -0
  254. package/out/src/reqlan-scope.d.ts +25 -0
  255. package/out/src/reqlan-scope.js +266 -0
  256. package/out/src/reqlan-scope.js.map +1 -0
  257. package/out/src/reqlan-semantic-token-provider.d.ts +8 -0
  258. package/out/src/reqlan-semantic-token-provider.js +97 -0
  259. package/out/src/reqlan-semantic-token-provider.js.map +1 -0
  260. package/out/src/reqlan-token-builder.d.ts +12 -0
  261. package/out/src/reqlan-token-builder.js +459 -0
  262. package/out/src/reqlan-token-builder.js.map +1 -0
  263. package/out/src/reqlan-validator.d.ts +25 -0
  264. package/out/src/reqlan-validator.js +119 -0
  265. package/out/src/reqlan-validator.js.map +1 -0
  266. package/out/src/reqlan-workspace-attribute-catalog.d.ts +6 -0
  267. package/out/src/reqlan-workspace-attribute-catalog.js +54 -0
  268. package/out/src/reqlan-workspace-attribute-catalog.js.map +1 -0
  269. package/out/test/code-actions.test.d.ts +1 -0
  270. package/out/test/code-actions.test.js +126 -0
  271. package/out/test/code-actions.test.js.map +1 -0
  272. package/out/test/comment-in-string.test.d.ts +1 -0
  273. package/out/test/comment-in-string.test.js +100 -0
  274. package/out/test/comment-in-string.test.js.map +1 -0
  275. package/out/test/completion.test.d.ts +1 -0
  276. package/out/test/completion.test.js +467 -0
  277. package/out/test/completion.test.js.map +1 -0
  278. package/out/test/file-path-rewrite.test.d.ts +1 -0
  279. package/out/test/file-path-rewrite.test.js +64 -0
  280. package/out/test/file-path-rewrite.test.js.map +1 -0
  281. package/out/test/ignore-error.test.d.ts +1 -0
  282. package/out/test/ignore-error.test.js +87 -0
  283. package/out/test/ignore-error.test.js.map +1 -0
  284. package/out/test/implicit-import-extension.test.d.ts +1 -0
  285. package/out/test/implicit-import-extension.test.js +203 -0
  286. package/out/test/implicit-import-extension.test.js.map +1 -0
  287. package/out/test/import-edits.test.d.ts +1 -0
  288. package/out/test/import-edits.test.js +20 -0
  289. package/out/test/import-edits.test.js.map +1 -0
  290. package/out/test/inlay-hints.test.d.ts +1 -0
  291. package/out/test/inlay-hints.test.js +238 -0
  292. package/out/test/inlay-hints.test.js.map +1 -0
  293. package/out/test/linking.test.d.ts +1 -0
  294. package/out/test/linking.test.js +754 -0
  295. package/out/test/linking.test.js.map +1 -0
  296. package/out/test/naked-strings.test.d.ts +1 -0
  297. package/out/test/naked-strings.test.js +50 -0
  298. package/out/test/naked-strings.test.js.map +1 -0
  299. package/out/test/parsing.test.d.ts +1 -0
  300. package/out/test/parsing.test.js +773 -0
  301. package/out/test/parsing.test.js.map +1 -0
  302. package/out/test/path-resolve.test.d.ts +1 -0
  303. package/out/test/path-resolve.test.js +88 -0
  304. package/out/test/path-resolve.test.js.map +1 -0
  305. package/out/test/references.test.d.ts +1 -0
  306. package/out/test/references.test.js +168 -0
  307. package/out/test/references.test.js.map +1 -0
  308. package/out/test/rqconfig.test.d.ts +1 -0
  309. package/out/test/rqconfig.test.js +275 -0
  310. package/out/test/rqconfig.test.js.map +1 -0
  311. package/out/test/test-requirement-refs.d.ts +8 -0
  312. package/out/test/test-requirement-refs.js +35 -0
  313. package/out/test/test-requirement-refs.js.map +1 -0
  314. package/out/test/testing.test.d.ts +1 -0
  315. package/out/test/testing.test.js +23 -0
  316. package/out/test/testing.test.js.map +1 -0
  317. package/out/test/validating.test.d.ts +1 -0
  318. package/out/test/validating.test.js +117 -0
  319. package/out/test/validating.test.js.map +1 -0
  320. package/out/tsconfig.tsbuildinfo +1 -0
  321. package/package.json +54 -0
  322. package/src/chevrotain.d.ts +8 -0
  323. package/src/file-path-rewrite.ts +96 -0
  324. package/src/generated/ast.ts +1481 -0
  325. package/src/generated/grammar.ts +3074 -0
  326. package/src/generated/module.ts +38 -0
  327. package/src/index.ts +34 -0
  328. package/src/reqlan-attribute-catalog.ts +100 -0
  329. package/src/reqlan-code-action-provider.ts +385 -0
  330. package/src/reqlan-code-lens-provider.ts +54 -0
  331. package/src/reqlan-code-lens-settings.ts +42 -0
  332. package/src/reqlan-comment-resolver.ts +372 -0
  333. package/src/reqlan-comment.langium +23 -0
  334. package/src/reqlan-completion-context.ts +330 -0
  335. package/src/reqlan-completion-provider.ts +400 -0
  336. package/src/reqlan-definition-provider.ts +319 -0
  337. package/src/reqlan-document-highlight-provider.ts +21 -0
  338. package/src/reqlan-document-link-provider.ts +45 -0
  339. package/src/reqlan-embedded-file-references.ts +72 -0
  340. package/src/reqlan-file-link-resolver.ts +485 -0
  341. package/src/reqlan-file-references.ts +84 -0
  342. package/src/reqlan-grammar-config.ts +14 -0
  343. package/src/reqlan-idea-reference-site.ts +74 -0
  344. package/src/reqlan-idea-summary.ts +162 -0
  345. package/src/reqlan-ignore-error.ts +50 -0
  346. package/src/reqlan-import-bindings.ts +87 -0
  347. package/src/reqlan-import-edits.ts +124 -0
  348. package/src/reqlan-imports.ts +115 -0
  349. package/src/reqlan-inbound-reference-inlay-label.ts +194 -0
  350. package/src/reqlan-inlay-hint-provider.ts +88 -0
  351. package/src/reqlan-inlay-hint-settings.ts +15 -0
  352. package/src/reqlan-linker.ts +108 -0
  353. package/src/reqlan-markdown-links.ts +136 -0
  354. package/src/reqlan-module.ts +104 -0
  355. package/src/reqlan-name-catalog.ts +81 -0
  356. package/src/reqlan-name-provider.ts +56 -0
  357. package/src/reqlan-namespace-import-links.ts +92 -0
  358. package/src/reqlan-path-completion.ts +420 -0
  359. package/src/reqlan-path-references.ts +140 -0
  360. package/src/reqlan-path-resolve.ts +346 -0
  361. package/src/reqlan-quoted-strings.ts +30 -0
  362. package/src/reqlan-reference-at-position.ts +154 -0
  363. package/src/reqlan-reference-code-lens.ts +323 -0
  364. package/src/reqlan-reference-search-site.ts +202 -0
  365. package/src/reqlan-references.ts +76 -0
  366. package/src/reqlan-scope.ts +312 -0
  367. package/src/reqlan-semantic-token-provider.ts +113 -0
  368. package/src/reqlan-token-builder.ts +492 -0
  369. package/src/reqlan-validator.ts +149 -0
  370. package/src/reqlan-workspace-attribute-catalog.ts +62 -0
  371. package/src/reqlan.langium +236 -0
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Parses file path strings from bracket references, including L# line suffixes and :test name suffixes.
3
+ */
4
+ const LINE_SUFFIX_PATTERN = /^(.*?)L#(\d+)(?:-(\d+))?$/;
5
+ export function parseFileReferenceString(file) {
6
+ const lineMatch = LINE_SUFFIX_PATTERN.exec(file);
7
+ const lineParsed = lineMatch
8
+ ? {
9
+ filePath: lineMatch[1],
10
+ lineStart: Number.parseInt(lineMatch[2], 10),
11
+ lineEnd: lineMatch[3] ? Number.parseInt(lineMatch[3], 10) : Number.parseInt(lineMatch[2], 10)
12
+ }
13
+ : { filePath: file };
14
+ const testParsed = parseTestNameSuffix(lineParsed.filePath);
15
+ return {
16
+ filePath: testParsed.filePath,
17
+ lineStart: lineParsed.lineStart,
18
+ lineEnd: lineParsed.lineEnd,
19
+ testName: testParsed.testName
20
+ };
21
+ }
22
+ function parseTestNameSuffix(file) {
23
+ let colonIndex = -1;
24
+ for (let index = file.length - 1; index >= 0; index--) {
25
+ if (file[index] !== ':') {
26
+ continue;
27
+ }
28
+ if (index > 0 && file[index - 1] === '/' && index > 1 && file[index - 2] === '/') {
29
+ continue;
30
+ }
31
+ colonIndex = index;
32
+ break;
33
+ }
34
+ if (colonIndex < 0) {
35
+ return { filePath: file };
36
+ }
37
+ const testName = file.slice(colonIndex + 1);
38
+ if (!testName) {
39
+ return { filePath: file };
40
+ }
41
+ return {
42
+ filePath: file.slice(0, colonIndex),
43
+ testName
44
+ };
45
+ }
46
+ const NON_RQ_FILE_EXTENSION = /\.[^./\\]+$/;
47
+ /**
48
+ * True when a bracketed quoted path is an arbitrary file reference, not an inline .rq import path.
49
+ */
50
+ export function isOpaqueFileReferencePath(path) {
51
+ const parsed = parseFileReferenceString(path);
52
+ if (parsed.testName !== undefined || parsed.lineStart !== undefined) {
53
+ return true;
54
+ }
55
+ const filePath = parsed.filePath;
56
+ if (/\.rq$/i.test(filePath)) {
57
+ return false;
58
+ }
59
+ return NON_RQ_FILE_EXTENSION.test(filePath);
60
+ }
61
+ export function findTestLineInText(text, testName) {
62
+ const escaped = testName.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
63
+ const pattern = new RegExp(`\\b(?:test|it)\\(\\s*['\`]${escaped}['\`]`);
64
+ const lines = text.split(/\r?\n/);
65
+ for (let lineIndex = 0; lineIndex < lines.length; lineIndex++) {
66
+ if (pattern.test(lines[lineIndex])) {
67
+ return lineIndex;
68
+ }
69
+ }
70
+ return undefined;
71
+ }
72
+ //# sourceMappingURL=reqlan-file-references.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reqlan-file-references.js","sourceRoot":"","sources":["../../src/reqlan-file-references.ts"],"names":[],"mappings":"AAAA;;GAEG;AASH,MAAM,mBAAmB,GAAG,2BAA2B,CAAC;AAExD,MAAM,UAAU,wBAAwB,CAAC,IAAY;IACjD,MAAM,SAAS,GAAG,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACjD,MAAM,UAAU,GAAG,SAAS;QACxB,CAAC,CAAC;YACE,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC;YACtB,SAAS,EAAE,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;YAC5C,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;SAChG;QACD,CAAC,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACzB,MAAM,UAAU,GAAG,mBAAmB,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;IAC5D,OAAO;QACH,QAAQ,EAAE,UAAU,CAAC,QAAQ;QAC7B,SAAS,EAAE,UAAU,CAAC,SAAS;QAC/B,OAAO,EAAE,UAAU,CAAC,OAAO;QAC3B,QAAQ,EAAE,UAAU,CAAC,QAAQ;KAChC,CAAC;AACN,CAAC;AAED,SAAS,mBAAmB,CAAC,IAAY;IACrC,IAAI,UAAU,GAAG,CAAC,CAAC,CAAC;IACpB,KAAK,IAAI,KAAK,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC;QACpD,IAAI,IAA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C,IAAY,EAAE,QAAgB;IAC7D,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC;IAChE,MAAM,OAAO,GAAG,IAAI,MAAM,CAAC,6BAA6B,OAAO,OAAO,CAAC,CAAC;IACxE,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAClC,KAAK,IAAI,SAAS,GAAG,CAAC,EAAE,SAAS,GAAG,KAAK,CAAC,MAAM,EAAE,SAAS,EAAE,EAAE,CAAC;QAC5D,IAAI,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC;YACjC,OAAO,SAAS,CAAC;QACrB,CAAC;IACL,CAAC;IACD,OAAO,SAAS,CAAC;AACrB,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Grammar configuration for rename and comment handling in requirement documents.
3
+ */
4
+ import type { GrammarConfig, LangiumCoreServices } from 'langium';
5
+ export declare function createReqlanGrammarConfig(services: LangiumCoreServices): GrammarConfig;
@@ -0,0 +1,9 @@
1
+ import { createGrammarConfig } from 'langium';
2
+ const ReqlanNameRegexp = /"[^"]*"|'[^']*'|\w[\w_]*/;
3
+ export function createReqlanGrammarConfig(services) {
4
+ return {
5
+ ...createGrammarConfig(services),
6
+ nameRegexp: ReqlanNameRegexp
7
+ };
8
+ }
9
+ //# sourceMappingURL=reqlan-grammar-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reqlan-grammar-config.js","sourceRoot":"","sources":["../../src/reqlan-grammar-config.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAE9C,MAAM,gBAAgB,GAAG,0BAA0B,CAAC;AAEpD,MAAM,UAAU,yBAAyB,CAAC,QAA6B;IACnE,OAAO;QACH,GAAG,mBAAmB,CAAC,QAAQ,CAAC;QAChC,UAAU,EAAE,gBAAgB;KAC/B,CAAC;AACN,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Compact idea body summaries for inline editor hints.
3
+ */
4
+ import { type IdeaDeclaration } from './generated/ast.js';
5
+ export declare function summarizeIdeaDeclaration(idea: IdeaDeclaration): string;
6
+ export declare function truncateSummary(text: string, maxLength?: number): string;
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Compact idea body summaries for inline editor hints.
3
+ */
4
+ import { isBodyLine, isBracketReference, isIdea, isMarkdownLink, isOneLinerIdea, isRichTextPart, isWikiLink } from './generated/ast.js';
5
+ import { parseMarkdownLink } from './reqlan-references.js';
6
+ function summarizeOneLinerPart(part) {
7
+ if (typeof part === 'string') {
8
+ return part;
9
+ }
10
+ if (isMarkdownLink(part)) {
11
+ return parseMarkdownLink(part.raw)?.label ?? part.raw;
12
+ }
13
+ if (isWikiLink(part) || isBracketReference(part)) {
14
+ return '[ref]';
15
+ }
16
+ return '';
17
+ }
18
+ function summarizeRichTextPart(part) {
19
+ if (typeof part === 'string') {
20
+ return part;
21
+ }
22
+ if (isRichTextPart(part) && part.$type === 'RichTextPart') {
23
+ return part.text ?? part.inlineCode ?? part.punct ?? part.lparen ?? part.rparen ?? '';
24
+ }
25
+ if (isMarkdownLink(part)) {
26
+ return parseMarkdownLink(part.raw)?.label ?? part.raw;
27
+ }
28
+ if (isWikiLink(part) || isBracketReference(part)) {
29
+ return '[ref]';
30
+ }
31
+ return '';
32
+ }
33
+ function summarizeOneLinerBody(idea) {
34
+ return idea.body.content
35
+ .map(summarizeOneLinerPart)
36
+ .join(' ')
37
+ .replace(/\s+/g, ' ')
38
+ .trim();
39
+ }
40
+ function summarizeBlockIdeaBody(idea) {
41
+ if (!isIdea(idea)) {
42
+ return '';
43
+ }
44
+ const lines = [];
45
+ for (const element of idea.elements) {
46
+ if (!isBodyLine(element)) {
47
+ continue;
48
+ }
49
+ const line = element.parts
50
+ .map(summarizeRichTextPart)
51
+ .filter(part => part.length > 0)
52
+ .join(' ')
53
+ .replace(/\s+([.,!?;:])/g, '$1')
54
+ .replace(/\s+/g, ' ')
55
+ .trim();
56
+ if (line) {
57
+ lines.push(line);
58
+ }
59
+ }
60
+ return lines.join('\n');
61
+ }
62
+ export function summarizeIdeaDeclaration(idea) {
63
+ if (isOneLinerIdea(idea)) {
64
+ return summarizeOneLinerBody(idea);
65
+ }
66
+ if (isIdea(idea)) {
67
+ return summarizeBlockIdeaBody(idea);
68
+ }
69
+ return '';
70
+ }
71
+ export function truncateSummary(text, maxLength = 80) {
72
+ const normalized = text.replace(/\s+/g, ' ').trim();
73
+ if (normalized.length <= maxLength) {
74
+ return normalized;
75
+ }
76
+ return `${normalized.slice(0, maxLength - 1).trimEnd()}…`;
77
+ }
78
+ //# sourceMappingURL=reqlan-idea-summary.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reqlan-idea-summary.js","sourceRoot":"","sources":["../../src/reqlan-idea-summary.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EACH,UAAU,EACV,kBAAkB,EAClB,MAAM,EACN,cAAc,EACd,cAAc,EACd,cAAc,EACd,UAAU,EAIb,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,SAAS,qBAAqB,CAAC,IAA6C;IACxE,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC3B,OAAO,IAAI,CAAC;IAChB,CAAC;IACD,IAAI,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC;QACvB,OAAO,iBAAiB,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,KAAK,IAAI,IAAI,CAAC,GAAG,CAAC;IAC1D,CAAC;IACD,IAAI,UAAU,CAAC,IAAI,CAAC,IAAI,kBAAkB,CAAC,IAAI,CAAC,EAAE,CAAC;QAC/C,OAAO,OAAO,CAAC;IACnB,CAAC;IACD,OAAO,EAAE,CAAC;AACd,CAAC;AAED,SAAS,qBAAqB,CAAC,IAA+B;IAC1D,IAAI,OAAO,I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E,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;aAC/B,IAAI,CAAC,GAAG,CAAC;aACT,OAAO,CAAC,gBAAgB,EAAE,IAAI,CAAC;aAC/B,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC;aACpB,IAAI,EAAE,CAAC;QACZ,IAAI,IAAI,EAAE,CAAC;YACP,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACrB,CAAC;IACL,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC5B,CAAC;AAED,MAAM,UAAU,wBAAwB,CAAC,IAAqB;IAC1D,IAAI,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC;QACvB,OAAO,qBAAqB,CAAC,IAAI,CAAC,CAAC;IACvC,CAAC;IACD,IAAI,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;QACf,OAAO,sBAAsB,CAAC,IAAI,CAAC,CAAC;IACxC,CAAC;IACD,OAAO,EAAE,CAAC;AACd,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,IAAY,EAAE,SAAS,GAAG,EAAE;IACxD,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;IACpD,IAAI,UAAU,CAAC,MAAM,IAAI,SAAS,EAAE,CAAC;QACjC,OAAO,UAAU,CAAC;IACtB,CAAC;IACD,OAAO,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,GAAG,CAAC,CAAC,CAAC,OAAO,EAAE,GAAG,CAAC;AAC9D,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Suppresses diagnostics on lines immediately following `//rq-ignore-error`.
3
+ * rq:["../../../reqlan rq/language/syntax.rq".comment_reference_ignore]
4
+ */
5
+ import { type LangiumDocument, type LangiumSharedCoreServices } from 'langium';
6
+ import type { Diagnostic } from 'vscode-languageserver';
7
+ export declare function findRqIgnoreErrorTargetLines(text: string): Set<number>;
8
+ export declare function filterRqIgnoredDiagnostics(text: string, diagnostics: Diagnostic[]): Diagnostic[];
9
+ export declare function applyRqIgnoreErrorFiltering(document: LangiumDocument): void;
10
+ export declare function registerRqIgnoreErrorFiltering(shared: LangiumSharedCoreServices): void;
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Suppresses diagnostics on lines immediately following `//rq-ignore-error`.
3
+ * rq:["../../../reqlan rq/language/syntax.rq".comment_reference_ignore]
4
+ */
5
+ import { DocumentState } from 'langium';
6
+ import { findLineCommentStart } from './reqlan-comment-resolver.js';
7
+ const RQ_IGNORE_ERROR = /\/\/\s*rq-ignore-error\b/;
8
+ export function findRqIgnoreErrorTargetLines(text) {
9
+ const lines = text.split(/\r?\n/);
10
+ const targetLines = new Set();
11
+ for (let lineIndex = 0; lineIndex < lines.length; lineIndex++) {
12
+ const line = lines[lineIndex];
13
+ const commentStart = findLineCommentStart(line);
14
+ if (commentStart < 0) {
15
+ continue;
16
+ }
17
+ const commentText = line.slice(commentStart);
18
+ if (RQ_IGNORE_ERROR.test(commentText) && lineIndex + 1 < lines.length) {
19
+ targetLines.add(lineIndex + 1);
20
+ }
21
+ }
22
+ return targetLines;
23
+ }
24
+ export function filterRqIgnoredDiagnostics(text, diagnostics) {
25
+ const ignoredLines = findRqIgnoreErrorTargetLines(text);
26
+ if (ignoredLines.size === 0) {
27
+ return diagnostics;
28
+ }
29
+ return diagnostics.filter(diagnostic => !ignoredLines.has(diagnostic.range.start.line));
30
+ }
31
+ export function applyRqIgnoreErrorFiltering(document) {
32
+ if (!document.diagnostics?.length) {
33
+ return;
34
+ }
35
+ document.diagnostics = filterRqIgnoredDiagnostics(document.textDocument.getText(), document.diagnostics);
36
+ }
37
+ export function registerRqIgnoreErrorFiltering(shared) {
38
+ shared.workspace.DocumentBuilder.onDocumentPhase(DocumentState.Validated, (document) => {
39
+ applyRqIgnoreErrorFiltering(document);
40
+ });
41
+ }
42
+ //# sourceMappingURL=reqlan-ignore-error.js.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,EAAE,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;AAC5F,CAAC;AAED,MAAM,UAAU,2BAA2B,CAAC,QAAyB;IACjE,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE,MAAM,EAAE,CAAC;QAChC,OAAO;IACX,CAAC;IACD,QAAQ,CAAC,WAAW,GAAG,0BAA0B,CAC7C,QAAQ,CAAC,YAAY,CAAC,OAAO,EAAE,EAC/B,QAAQ,CAAC,WAAW,CACvB,CAAC;AACN,CAAC;AAED,MAAM,UAAU,8BAA8B,CAAC,MAAiC;IAC5E,MAAM,CAAC,SAAS,CAAC,eAAe,CAAC,eAAe,CAAC,aAAa,CAAC,SAAS,EAAE,CAAC,QAAyB,EAAE,EAAE;QACpG,2BAA2B,CAAC,QAAQ,CAAC,CAAC;IAC1C,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -0,0 +1,12 @@
1
+ import type { AstNode } from 'langium';
2
+ import { type FromImportSpecifier, type Import } from './generated/ast.js';
3
+ export interface ImportBinding {
4
+ name: string;
5
+ node: AstNode;
6
+ property: 'alias' | 'idea';
7
+ }
8
+ export declare function specifierBindingName(specifier: FromImportSpecifier): string | undefined;
9
+ export declare function importBindings(importDecl: Import): ImportBinding[];
10
+ export declare function importedIdeaNames(importDecl: Import): string[];
11
+ export declare function findNamespaceImportByAlias(imports: Import[], alias: string): Import | undefined;
12
+ export declare function findFromImportSpecifierByBinding(imports: Import[], bindingName: string): FromImportSpecifier | undefined;
@@ -0,0 +1,65 @@
1
+ import { isFromImport, isNamespaceImport, isQualifiedImport } from './generated/ast.js';
2
+ export function specifierBindingName(specifier) {
3
+ return specifier.alias ?? specifier.idea.$refText;
4
+ }
5
+ export function importBindings(importDecl) {
6
+ if (isFromImport(importDecl)) {
7
+ return importDecl.specifiers.flatMap(specifier => {
8
+ const name = specifierBindingName(specifier);
9
+ if (!name) {
10
+ return [];
11
+ }
12
+ return [{
13
+ name,
14
+ node: specifier,
15
+ property: specifier.alias ? 'alias' : 'idea'
16
+ }];
17
+ });
18
+ }
19
+ if (isQualifiedImport(importDecl)) {
20
+ const name = importDecl.alias ?? importDecl.idea.$refText;
21
+ if (!name) {
22
+ return [];
23
+ }
24
+ return [{
25
+ name,
26
+ node: importDecl,
27
+ property: importDecl.alias ? 'alias' : 'idea'
28
+ }];
29
+ }
30
+ if (importDecl.alias) {
31
+ return [{ name: importDecl.alias, node: importDecl, property: 'alias' }];
32
+ }
33
+ return [];
34
+ }
35
+ export function importedIdeaNames(importDecl) {
36
+ if (isFromImport(importDecl)) {
37
+ return importDecl.specifiers.map(specifier => specifier.idea.$refText);
38
+ }
39
+ if (isQualifiedImport(importDecl)) {
40
+ return [importDecl.idea.$refText];
41
+ }
42
+ return [];
43
+ }
44
+ export function findNamespaceImportByAlias(imports, alias) {
45
+ for (const importDecl of imports) {
46
+ if (!isNamespaceImport(importDecl) || importDecl.alias !== alias) {
47
+ continue;
48
+ }
49
+ return importDecl;
50
+ }
51
+ return undefined;
52
+ }
53
+ export function findFromImportSpecifierByBinding(imports, bindingName) {
54
+ for (const importDecl of imports) {
55
+ if (!isFromImport(importDecl)) {
56
+ continue;
57
+ }
58
+ const specifier = importDecl.specifiers.find(entry => specifierBindingName(entry) === bindingName);
59
+ if (specifier) {
60
+ return specifier;
61
+ }
62
+ }
63
+ return undefined;
64
+ }
65
+ //# sourceMappingURL=reqlan-import-bindings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reqlan-import-bindings.js","sourceRoot":"","sources":["../../src/reqlan-import-bindings.ts"],"names":[],"mappings":"AACA,OAAO,EACH,YAAY,EACZ,iBAAiB,EACjB,iBAAiB,EAGpB,MAAM,oBAAoB,CAAC;AAQ5B,MAAM,UAAU,oBAAoB,CAAC,SAA8B;IAC/D,OAAO,SAAS,CAAC,KAAK,IAAI,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC;AACtD,CAAC;AAED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IAAI,CAAC,QAAQ,CAAC,CAAC;IAC3E,CAAC;IACD,IAAI,iBAAiB,CAAC,UAAU,CAAC,EAAE,CAAC;QAChC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACtC,CAAC;IACD,OAAO,EAAE,CAAC;AACd,CAAC;AAED,MAAM,UAAU,0BAA0B,CAAC,OAAiB,EAAE,KAAa;IACvE,KAAK,MAAM,UAAU,IAAI,OAAO,EAAE,CAAC;QAC/B,IAAI,CAAC,iBAAiB,CAAC,UAAU,CAAC,IAAI,UAAU,CAAC,KAAK,KAAK,KAAK,EAAE,CAAC;YAC/D,SAAS;QACb,CAAC;QACD,OAAO,UAAU,CAAC;IACtB,CAAC;IACD,OAAO,SAAS,CAAC;AACrB,CAAC;AAED,MAAM,UAAU,gCAAgC,CAC5C,OAAiB,EACjB,WAAmB;IAEnB,KAAK,MAAM,UAAU,IAAI,OAAO,EAAE,CAAC;QAC/B,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,EAAE,CAAC;YAC5B,SAAS;QACb,CAAC;QACD,MAAM,SAAS,GAAG,UAAU,CAAC,UAAU,CAAC,IAAI,CACxC,KAAK,CAAC,EAAE,CAAC,oBAAoB,CAAC,KAAK,CAAC,KAAK,WAAW,CACvD,CAAC;QACF,IAAI,SAAS,EAAE,CAAC;YACZ,OAAO,SAAS,CAAC;QACrB,CAAC;IACL,CAAC;IACD,OAAO,SAAS,CAAC;AACrB,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Shared WorkspaceEdit helpers for import insertion used by unresolved-reference quick fixes.
3
+ * rq:["../../../reqlan rq/extension/language-support/features-imports.rq".import_error]
4
+ */
5
+ import type { LangiumDocument, URI } from 'langium';
6
+ import type { Position, TextEdit } from 'vscode-languageserver';
7
+ import { type FromImport, type Model } from './generated/ast.js';
8
+ export declare function relativeRqImportPath(fromUri: URI, toUri: URI): string;
9
+ export declare function findImportInsertPosition(model: Model): {
10
+ position: Position;
11
+ trailingNewline: boolean;
12
+ };
13
+ export declare function findExistingFromImport(model: Model, importPath: string): FromImport | undefined;
14
+ export declare function hasNamespaceImport(model: Model, importPath: string): boolean;
15
+ export declare function buildFromImportEdit(document: LangiumDocument, importPath: string, symbolName: string): TextEdit | undefined;
16
+ export declare function buildNamespaceImportEdit(document: LangiumDocument, importPath: string, alias: string): TextEdit | undefined;
17
+ export declare function fileBasenameAlias(fileUri: string | URI): string;
@@ -0,0 +1,96 @@
1
+ import { UriUtils } from 'langium';
2
+ import { isFromImport, isModel, isNamespaceImport } from './generated/ast.js';
3
+ import { unquoteReqlanString } from './reqlan-references.js';
4
+ export function relativeRqImportPath(fromUri, toUri) {
5
+ const sourceDir = UriUtils.dirname(fromUri);
6
+ let relativePath = UriUtils.relative(sourceDir, toUri);
7
+ if (!relativePath.startsWith('./') && !relativePath.startsWith('../')) {
8
+ relativePath = `./${relativePath}`;
9
+ }
10
+ return relativePath;
11
+ }
12
+ export function findImportInsertPosition(model) {
13
+ if (model.imports.length > 0) {
14
+ const last = model.imports[model.imports.length - 1];
15
+ const end = last.$cstNode?.range.end;
16
+ if (end) {
17
+ return {
18
+ position: { line: end.line + 1, character: 0 },
19
+ trailingNewline: false
20
+ };
21
+ }
22
+ }
23
+ const firstElement = model.elements[0];
24
+ if (firstElement?.$cstNode) {
25
+ return {
26
+ position: firstElement.$cstNode.range.start,
27
+ trailingNewline: true
28
+ };
29
+ }
30
+ return { position: { line: 0, character: 0 }, trailingNewline: true };
31
+ }
32
+ export function findExistingFromImport(model, importPath) {
33
+ return model.imports.find((decl) => {
34
+ if (!isFromImport(decl)) {
35
+ return false;
36
+ }
37
+ return unquoteReqlanString(decl.path) === importPath;
38
+ });
39
+ }
40
+ export function hasNamespaceImport(model, importPath) {
41
+ return model.imports.some(decl => isNamespaceImport(decl) && unquoteReqlanString(decl.path) === importPath);
42
+ }
43
+ export function buildFromImportEdit(document, importPath, symbolName) {
44
+ const model = document.parseResult.value;
45
+ if (!isModel(model)) {
46
+ return undefined;
47
+ }
48
+ const existing = findExistingFromImport(model, importPath);
49
+ if (existing) {
50
+ const alreadyImported = existing.specifiers.some(specifier => {
51
+ const binding = specifier.alias ?? specifier.idea.$refText;
52
+ return binding === symbolName || specifier.idea.$refText === symbolName;
53
+ });
54
+ if (alreadyImported) {
55
+ return undefined;
56
+ }
57
+ const lastSpecifier = existing.specifiers[existing.specifiers.length - 1];
58
+ const insertAt = lastSpecifier?.$cstNode?.range.end ?? existing.$cstNode?.range.end;
59
+ if (!insertAt) {
60
+ return undefined;
61
+ }
62
+ return {
63
+ range: { start: insertAt, end: insertAt },
64
+ newText: `, ${symbolName}`
65
+ };
66
+ }
67
+ const insert = findImportInsertPosition(model);
68
+ const line = `from "${importPath}" import ${symbolName}`;
69
+ return {
70
+ range: { start: insert.position, end: insert.position },
71
+ newText: insert.trailingNewline ? `${line}\n\n` : `${line}\n`
72
+ };
73
+ }
74
+ export function buildNamespaceImportEdit(document, importPath, alias) {
75
+ const model = document.parseResult.value;
76
+ if (!isModel(model)) {
77
+ return undefined;
78
+ }
79
+ if (hasNamespaceImport(model, importPath)) {
80
+ return undefined;
81
+ }
82
+ const insert = findImportInsertPosition(model);
83
+ const line = `import "${importPath}" as ${alias}`;
84
+ return {
85
+ range: { start: insert.position, end: insert.position },
86
+ newText: insert.trailingNewline ? `${line}\n\n` : `${line}\n`
87
+ };
88
+ }
89
+ export function fileBasenameAlias(fileUri) {
90
+ const uriString = typeof fileUri === 'string' ? fileUri : fileUri.toString();
91
+ const base = uriString.split('/').pop() ?? uriString;
92
+ const withoutExt = base.replace(/\.rq$/i, '');
93
+ const cleaned = withoutExt.replace(/[^A-Za-z0-9_]+/g, '_').replace(/^(\d)/, '_$1');
94
+ return cleaned || 'imported';
95
+ }
96
+ //# sourceMappingURL=reqlan-import-edits.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reqlan-import-edits.js","sourceRoot":"","sources":["../../src/reqlan-import-edits.ts"],"names":[],"mappings":"AAKA,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AC,EAAE,CAAC;QACxC,OAAO,SAAS,CAAC;IACrB,CAAC;IACD,MAAM,MAAM,GAAG,wBAAwB,CAAC,KAAK,CAAC,CAAC;IAC/C,MAAM,IAAI,GAAG,WAAW,UAAU,QAAQ,KAAK,EAAE,CAAC;IAClD,OAAO;QACH,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,QAAQ,EAAE,GAAG,EAAE,MAAM,CAAC,QAAQ,EAAE;QACvD,OAAO,EAAE,MAAM,CAAC,eAAe,CAAC,CAAC,CAAC,GAAG,IAAI,MAAM,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI;KAChE,CAAC;AACN,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,OAAqB;IACnD,MAAM,SAAS,GAAG,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;IAC7E,MAAM,IAAI,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,IAAI,SAAS,CAAC;IACrD,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;IAC9C,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC,iBAAiB,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IACnF,OAAO,OAAO,IAAI,UAAU,CAAC;AACjC,CAAC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Resolves imported requirement documents from relative and import-root-aliased paths.
3
+ * Interacts with scope linking and go-to-definition for import paths.
4
+ * rq:["../../../reqlan rq/extension/language-support/features-imports.rq".implicit_file_extension]
5
+ */
6
+ import type { FileSystemProvider, LangiumDocument, LangiumDocuments, URI } from 'langium';
7
+ import { type PathResolveContext } from './reqlan-path-resolve.js';
8
+ export type { PathResolveContext };
9
+ export declare const IMPLICIT_IMPORT_EXTENSION = ".rq";
10
+ /**
11
+ * Import paths written without an extension mean `.rq`; the literal path stays a fallback so
12
+ * extensionless files on disk keep resolving.
13
+ */
14
+ export declare function importPathCandidates(path: string): string[];
15
+ export declare function importPathWithImplicitExtension(path: string): string | undefined;
16
+ export declare function resolveImportUri(path: string, document: LangiumDocument, context?: PathResolveContext): URI;
17
+ /** Candidate URIs in preference order: implicit `.rq` first, then the path as written. */
18
+ export declare function resolveImportCandidateUris(path: string, document: LangiumDocument, context?: PathResolveContext): URI[];
19
+ export declare function isResolvableImportPath(path: string, document: LangiumDocument, documents: LangiumDocuments, fileSystem?: FileSystemProvider, context?: PathResolveContext): boolean;
20
+ export declare function findImportedDocument(path: string, document: LangiumDocument, documents: LangiumDocuments, context?: PathResolveContext): LangiumDocument | undefined;
21
+ /** First candidate that exists, falling back to the path as written when none do. */
22
+ export declare function resolveExistingImportUri(path: string, document: LangiumDocument, documents: LangiumDocuments, fileSystem?: FileSystemProvider, context?: PathResolveContext): URI;
@@ -0,0 +1,61 @@
1
+ import { resolveDocumentPathUri } from './reqlan-path-resolve.js';
2
+ export const IMPLICIT_IMPORT_EXTENSION = '.rq';
3
+ /**
4
+ * Import paths written without an extension mean `.rq`; the literal path stays a fallback so
5
+ * extensionless files on disk keep resolving.
6
+ */
7
+ export function importPathCandidates(path) {
8
+ const implicit = importPathWithImplicitExtension(path);
9
+ return implicit ? [implicit, path] : [path];
10
+ }
11
+ export function importPathWithImplicitExtension(path) {
12
+ const basename = path.slice(path.lastIndexOf('/') + 1);
13
+ if (basename.length === 0 || basename === '.' || basename === '..') {
14
+ return undefined;
15
+ }
16
+ if (basename.includes('.', 1)) {
17
+ return undefined;
18
+ }
19
+ return `${path}${IMPLICIT_IMPORT_EXTENSION}`;
20
+ }
21
+ export function resolveImportUri(path, document, context) {
22
+ return resolveDocumentPathUri(path, document, context);
23
+ }
24
+ /** Candidate URIs in preference order: implicit `.rq` first, then the path as written. */
25
+ export function resolveImportCandidateUris(path, document, context) {
26
+ return importPathCandidates(path).map(candidate => resolveDocumentPathUri(candidate, document, context));
27
+ }
28
+ export function isResolvableImportPath(path, document, documents, fileSystem, context) {
29
+ return resolveImportCandidateUris(path, document, withFileSystem(context, fileSystem))
30
+ .some(uri => isImportTarget(uri, documents, fileSystem));
31
+ }
32
+ export function findImportedDocument(path, document, documents, context) {
33
+ for (const uri of resolveImportCandidateUris(path, document, context)) {
34
+ const imported = documents.getDocument(uri);
35
+ if (imported) {
36
+ return imported;
37
+ }
38
+ }
39
+ return undefined;
40
+ }
41
+ /** First candidate that exists, falling back to the path as written when none do. */
42
+ export function resolveExistingImportUri(path, document, documents, fileSystem, context) {
43
+ const uris = resolveImportCandidateUris(path, document, withFileSystem(context, fileSystem));
44
+ return uris.find(uri => isImportTarget(uri, documents, fileSystem)) ?? uris[uris.length - 1];
45
+ }
46
+ function isImportTarget(uri, documents, fileSystem) {
47
+ if (documents.getDocument(uri)) {
48
+ return true;
49
+ }
50
+ if (!fileSystem?.existsSync(uri)) {
51
+ return false;
52
+ }
53
+ return !fileSystem.statSync(uri).isDirectory;
54
+ }
55
+ function withFileSystem(context, fileSystem) {
56
+ if (!fileSystem && !context) {
57
+ return undefined;
58
+ }
59
+ return { ...context, fileSystem: fileSystem ?? context?.fileSystem };
60
+ }
61
+ //# sourceMappingURL=reqlan-imports.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reqlan-imports.js","sourceRoot":"","sources":["../../src/reqlan-imports.ts"],"names":[],"mappings":"AAMA,OAAO,EACH,sBAAsB,EAEzB,MAAM,0BAA0B,CAAC;AAIlC,MAAM,CAAC,MAAM,yBAAyB,GAAG,KAAK,CAAC;AAE/C;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAC,IAAY;IAC7C,MAAM,QAAQ,GAAG,+BAA+B,CAAC,IAAI,CAAC,CAAC;IACvD,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;A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,EAAE,UAAU,EAAE,CAAC;AACzE,CAAC"}
@@ -0,0 +1,23 @@
1
+ import { Location, type InlayHintLabelPart as InlayHintLabelPartType, type MarkupContent } from 'vscode-languageserver';
2
+ import { type IdeaDeclaration, type IdeaSet } from './generated/ast.js';
3
+ import type { ReqlanServices } from './reqlan-module.js';
4
+ export interface InboundReferenceInlayLabel {
5
+ labelParts: InlayHintLabelPartType[];
6
+ tooltip?: MarkupContent;
7
+ }
8
+ export interface InboundReferencer {
9
+ name: string;
10
+ location: Location;
11
+ }
12
+ export type ReferencedDeclaration = IdeaDeclaration | IdeaSet;
13
+ export declare function collectInboundReferencers(services: ReqlanServices, declaration: ReferencedDeclaration): InboundReferencer[];
14
+ /** @deprecated Use {@link collectInboundReferencers} */
15
+ export declare function collectInboundReferencingNames(services: ReqlanServices, declaration: ReferencedDeclaration): string[];
16
+ export declare function referencerMarkdownLink(referrer: InboundReferencer): string;
17
+ export declare function buildReferencersTooltipMarkup(referencers: InboundReferencer[]): MarkupContent;
18
+ export declare function buildInboundReferencesInlayLabel(referencers: InboundReferencer[], targetDocumentUri: string, targetName: string): InboundReferenceInlayLabel | undefined;
19
+ /** @deprecated Use {@link buildInboundReferencesInlayLabel} */
20
+ export declare function formatInboundReferencesInlayLabel(referencers: string[]): {
21
+ label: string;
22
+ tooltip?: string;
23
+ } | undefined;