@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,124 @@
1
+ import { findCommentReferencesInText } from './reqlan-comment-resolver.js';
2
+ import { findEmbeddedFileReferencesInText } from './reqlan-embedded-file-references.js';
3
+ import { parseFileReferenceString } from './reqlan-file-references.js';
4
+ import { parseReqlanQuotedString, REQLAN_QUOTED_STRING_CAPTURE } from './reqlan-quoted-strings.js';
5
+ const IMPORT_PATH_PATTERN = new RegExp(`(?:\\bfrom|\\bimport)\\s+(${REQLAN_QUOTED_STRING_CAPTURE})`, 'g');
6
+ export function findImportPathReferencesInText(text, lineOffset = 0) {
7
+ const references = [];
8
+ const lines = text.split(/\r?\n/);
9
+ for (let lineIndex = 0; lineIndex < lines.length; lineIndex++) {
10
+ const line = lines[lineIndex];
11
+ for (const match of line.matchAll(IMPORT_PATH_PATTERN)) {
12
+ const quoted = match[1];
13
+ const path = parseReqlanQuotedString(quoted);
14
+ const start = match.index + match[0].indexOf(quoted);
15
+ references.push({
16
+ path,
17
+ range: {
18
+ start: { line: lineOffset + lineIndex, character: start },
19
+ end: { line: lineOffset + lineIndex, character: start + quoted.length }
20
+ }
21
+ });
22
+ }
23
+ }
24
+ return references;
25
+ }
26
+ export function findEmbeddedPathReferencesInText(text, lineOffset = 0) {
27
+ const references = [];
28
+ for (const embedded of findEmbeddedFileReferencesInText(text, lineOffset)) {
29
+ const parsed = parseFileReferenceString(embedded.file);
30
+ if (!parsed.filePath) {
31
+ continue;
32
+ }
33
+ const quotedPattern = new RegExp(REQLAN_QUOTED_STRING_CAPTURE);
34
+ const embeddedText = text.slice(textOffsetAtPosition(text, embedded.range.start), textOffsetAtPosition(text, embedded.range.end));
35
+ const quotedMatch = quotedPattern.exec(embeddedText);
36
+ if (!quotedMatch) {
37
+ continue;
38
+ }
39
+ const quoted = quotedMatch[0];
40
+ const pathIndex = quotedMatch.index ?? embeddedText.indexOf(quoted);
41
+ const absoluteStart = textOffsetAtPosition(text, embedded.range.start) + pathIndex;
42
+ const startPos = offsetToPosition(text, absoluteStart);
43
+ references.push({
44
+ path: parsed.filePath,
45
+ range: {
46
+ start: startPos,
47
+ end: { line: startPos.line, character: startPos.character + quoted.length }
48
+ }
49
+ });
50
+ }
51
+ return references;
52
+ }
53
+ export function findCommentPathReferencesInText(text, lineOffset = 0) {
54
+ const references = [];
55
+ for (const commentRef of findCommentReferencesInText(text, lineOffset)) {
56
+ if (!commentRef.path) {
57
+ continue;
58
+ }
59
+ const quotedPattern = new RegExp(REQLAN_QUOTED_STRING_CAPTURE);
60
+ const segmentStart = textOffsetAtPosition(text, commentRef.range.start);
61
+ const segmentEnd = textOffsetAtPosition(text, commentRef.range.end);
62
+ const segment = text.slice(segmentStart, segmentEnd);
63
+ const quotedMatch = quotedPattern.exec(segment);
64
+ if (!quotedMatch) {
65
+ continue;
66
+ }
67
+ const quoted = quotedMatch[0];
68
+ const pathIndex = quotedMatch.index ?? segment.indexOf(quoted);
69
+ const absoluteStart = segmentStart + pathIndex;
70
+ const startPos = offsetToPosition(text, absoluteStart);
71
+ references.push({
72
+ path: commentRef.path,
73
+ range: {
74
+ start: startPos,
75
+ end: { line: startPos.line, character: startPos.character + quoted.length }
76
+ }
77
+ });
78
+ }
79
+ return references;
80
+ }
81
+ export function findPathReferencesInMovedFile(text, isRqFile) {
82
+ const references = isRqFile
83
+ ? [...findImportPathReferencesInText(text), ...findEmbeddedPathReferencesInText(text)]
84
+ : findCommentPathReferencesInText(text);
85
+ return dedupePathReferences(references);
86
+ }
87
+ function dedupePathReferences(references) {
88
+ const seen = new Set();
89
+ const unique = [];
90
+ for (const reference of references) {
91
+ const key = [
92
+ reference.range.start.line,
93
+ reference.range.start.character,
94
+ reference.range.end.line,
95
+ reference.range.end.character
96
+ ].join(':');
97
+ if (seen.has(key)) {
98
+ continue;
99
+ }
100
+ seen.add(key);
101
+ unique.push(reference);
102
+ }
103
+ return unique;
104
+ }
105
+ function textOffsetAtLine(text, lineIndex) {
106
+ const lines = text.split(/\r?\n/);
107
+ let offset = 0;
108
+ for (let index = 0; index < lineIndex; index++) {
109
+ offset += lines[index].length + 1;
110
+ }
111
+ return offset;
112
+ }
113
+ function textOffsetAtPosition(text, position) {
114
+ return textOffsetAtLine(text, position.line) + position.character;
115
+ }
116
+ function offsetToPosition(text, offset) {
117
+ const before = text.slice(0, offset);
118
+ const lines = before.split(/\r?\n/);
119
+ return {
120
+ line: lines.length - 1,
121
+ character: lines[lines.length - 1].length
122
+ };
123
+ }
124
+ //# sourceMappingURL=reqlan-path-references.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reqlan-path-references.js","sourceRoot":"","sources":["../src/reqlan-path-references.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,2BAA2B,EAAE,MAAM,8BAA8B,CAAC;AAC3E,OAAO,EAAE,gCAAgC,EAAE,MAAM,sCAAsC,CAAC;AACxF,OAAO,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AAEvE,OAAO,EAAE,uBAAuB,EAAE,4BAA4B,EAAE,MAAM,4BAA4B,CAAC;AAEnG,MAAM,mBAAmB,GAAG,IAAI,MAAM,CAAC,6BAA6B,4BAA4B,GAAG,EAAE,GAAG,CAAC,CAAC;AAE1G,MAAM,UAAU,8BAA8B,CAAC,IAAY,EAAE,UAAU,GAAG,CAAC;IACvE,MAAM,UAAU,GAAoB,EAAE,CAAC;IACvC,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,MAAM,IAAI,GAAG,KAAK,CAAC,SAAS,CAAE,CAAC;QAC/B,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,QAAQ,CAAC,mBAAmB,CAAC,EAAE,CAAC;YACrD,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,CAAE,CAAC;YACzB,MAAM,IAAI,GAAG,uBAAuB,CAAC,MAAM,CAAC,CAAC;YAC7C,MAAM,KAAK,GAAG,KAAK,CAAC,KAAM,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YACtD,UAAU,CAAC,IAAI,CAAC;gBACZ,IAAI;gBACJ,KAAK,EAAE;oBACH,KAAK,EAAE,EAAE,IAAI,EAAE,UAAU,GAAG,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE;oBACzD,GAAG,EAA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,CAAC;AAClB,CAAC;AAED,SAAS,gBAAgB,CAAC,IAAY,EAAE,SAAiB;IACrD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAClC,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,SAAS,EAAE,KAAK,EAAE,EAAE,CAAC;QAC7C,MAAM,IAAI,KAAK,CAAC,KAAK,CAAE,CAAC,MAAM,GAAG,CAAC,CAAC;IACvC,CAAC;IACD,OAAO,MAAM,CAAC;AAClB,CAAC;AAED,SAAS,oBAAoB,CAAC,IAAY,EAAE,QAAwB;IAChE,OAAO,gBAAgB,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,SAAS,CAAC;AACtE,CAAC;AAED,SAAS,gBAAgB,CAAC,IAAY,EAAE,MAAc;IAClD,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;IACrC,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACpC,OAAO;QACH,IAAI,EAAE,KAAK,CAAC,MAAM,GAAG,CAAC;QACtB,SAAS,EAAE,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAE,CAAC,MAAM;KAC7C,CAAC;AACN,CAAC"}
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Resolves document-relative and import-root-aliased paths (default `@/`).
3
+ * rq:["../../../reqlan rq/extension/configuration.rq".configuration_location]
4
+ * rq:["../../../reqlan rq/extension/configuration.rq".configuration_import_roots]
5
+ * rq:["../../../reqlan rq/language/imports.rq".configuration_import_root_alias]
6
+ */
7
+ import type { FileSystemProvider, LangiumDocument, URI } from 'langium';
8
+ export declare const DEFAULT_IMPORT_ROOT_ALIAS = "@";
9
+ export declare const RQCONFIG_FILENAME = ".rqconfig.json";
10
+ export interface ImportRootMapping {
11
+ alias: string;
12
+ /** Absolute URI of that alias’s import-root directory, when set. */
13
+ rootUri?: URI;
14
+ }
15
+ export type RqExportScope = 'workspace' | 'currentFile';
16
+ export type RqExportRuntimeMode = 'interactive' | 'document' | 'print';
17
+ export type RqExportClusterStrategy = 'deterministic' | 'hybrid';
18
+ export interface RqHtmlExportConfig {
19
+ printEntryFileName?: string;
20
+ includeRequirementsPage?: boolean;
21
+ includeGraphPage?: boolean;
22
+ runtimeMode?: RqExportRuntimeMode;
23
+ clusterStrategy?: RqExportClusterStrategy;
24
+ includeIdeaPages?: boolean;
25
+ includeFilePages?: boolean;
26
+ includeCodeFilePages?: boolean;
27
+ includeClusterPages?: boolean;
28
+ includePrintPages?: boolean;
29
+ }
30
+ export interface RqExportConfig {
31
+ outputFolder?: string;
32
+ templateId?: string;
33
+ scope?: RqExportScope;
34
+ html?: RqHtmlExportConfig;
35
+ }
36
+ export interface RqConfig {
37
+ importRoots: ImportRootMapping[];
38
+ export?: RqExportConfig;
39
+ }
40
+ export interface PathResolveContext {
41
+ /** Workspace folders that contain documents (longest match wins). */
42
+ workspaceFolderUris?: readonly URI[];
43
+ /** Explicit workspace folder for tests; preferred over list lookup when set. */
44
+ workspaceFolderUri?: URI;
45
+ fileSystem?: FileSystemProvider;
46
+ /**
47
+ * Preloaded config. `undefined` loads nearest `.rqconfig.json` when fileSystem is set.
48
+ * `null` skips loading and uses defaults only.
49
+ */
50
+ config?: RqConfig | null;
51
+ }
52
+ export declare function defaultRqConfig(): RqConfig;
53
+ export declare function matchImportRootAlias(path: string, alias: string): string | undefined;
54
+ /** Longest matching alias wins when several mappings could apply. */
55
+ export declare function matchImportRootMapping(path: string, mappings: readonly ImportRootMapping[]): {
56
+ mapping: ImportRootMapping;
57
+ remainder: string;
58
+ } | undefined;
59
+ export declare function findWorkspaceFolderUri(documentUri: URI, folderUris: readonly URI[] | undefined): URI | undefined;
60
+ export declare function loadApplyingRqConfig(startDirUri: URI, fileSystem: FileSystemProvider): RqConfig | undefined;
61
+ export declare function resolveRqConfig(document: LangiumDocument, context?: PathResolveContext): RqConfig;
62
+ export declare function resolveImportRootUri(document: LangiumDocument, context: PathResolveContext | undefined, mapping: ImportRootMapping): URI | undefined;
63
+ /**
64
+ * Resolves a path string against the document directory, or against an import root when aliased.
65
+ */
66
+ export declare function resolveDocumentPathUri(path: string, document: LangiumDocument, context?: PathResolveContext): URI;
67
+ export declare function workspaceFolderUrisFromManager(folders: ReadonlyArray<{
68
+ uri: string;
69
+ }> | undefined): URI[];
70
+ export declare function pathResolveContextFromServices(services: {
71
+ shared: {
72
+ workspace: {
73
+ WorkspaceManager: {
74
+ workspaceFolders?: ReadonlyArray<{
75
+ uri: string;
76
+ }>;
77
+ };
78
+ FileSystemProvider: FileSystemProvider;
79
+ };
80
+ };
81
+ }): PathResolveContext;
@@ -0,0 +1,245 @@
1
+ import { URI as UriCtor, UriUtils } from 'langium';
2
+ export const DEFAULT_IMPORT_ROOT_ALIAS = '@';
3
+ export const RQCONFIG_FILENAME = '.rqconfig.json';
4
+ export function defaultRqConfig() {
5
+ return { importRoots: [{ alias: DEFAULT_IMPORT_ROOT_ALIAS }] };
6
+ }
7
+ export function matchImportRootAlias(path, alias) {
8
+ if (!alias || !path.startsWith(alias)) {
9
+ return undefined;
10
+ }
11
+ const afterAlias = path.slice(alias.length);
12
+ if (!afterAlias.startsWith('/')) {
13
+ return undefined;
14
+ }
15
+ return afterAlias.slice(1);
16
+ }
17
+ /** Longest matching alias wins when several mappings could apply. */
18
+ export function matchImportRootMapping(path, mappings) {
19
+ const ordered = [...mappings]
20
+ .filter(mapping => mapping.alias.length > 0)
21
+ .sort((left, right) => right.alias.length - left.alias.length);
22
+ for (const mapping of ordered) {
23
+ const remainder = matchImportRootAlias(path, mapping.alias);
24
+ if (remainder !== undefined) {
25
+ return { mapping, remainder };
26
+ }
27
+ }
28
+ return undefined;
29
+ }
30
+ export function findWorkspaceFolderUri(documentUri, folderUris) {
31
+ if (!folderUris || folderUris.length === 0) {
32
+ return undefined;
33
+ }
34
+ const documentPath = documentUri.toString();
35
+ let best;
36
+ let bestLength = -1;
37
+ for (const folder of folderUris) {
38
+ const folderPath = folder.path.endsWith('/')
39
+ ? folder.toString()
40
+ : `${folder.toString()}/`;
41
+ const folderBase = folder.toString();
42
+ if (documentPath === folderBase || documentPath.startsWith(folderPath)) {
43
+ const length = folderBase.length;
44
+ if (length > bestLength) {
45
+ best = folder;
46
+ bestLength = length;
47
+ }
48
+ }
49
+ }
50
+ return best;
51
+ }
52
+ export function loadApplyingRqConfig(startDirUri, fileSystem) {
53
+ let dir = startDirUri;
54
+ for (;;) {
55
+ const configUri = UriUtils.joinPath(dir, RQCONFIG_FILENAME);
56
+ if (fileSystem.existsSync(configUri) && !fileSystem.statSync(configUri).isDirectory) {
57
+ return parseRqConfig(configUri, fileSystem);
58
+ }
59
+ const parent = UriUtils.dirname(dir);
60
+ if (UriUtils.equals(parent, dir)) {
61
+ return undefined;
62
+ }
63
+ dir = parent;
64
+ }
65
+ }
66
+ function parseRqConfig(configUri, fileSystem) {
67
+ let raw;
68
+ try {
69
+ raw = JSON.parse(fileSystem.readFileSync(configUri));
70
+ }
71
+ catch {
72
+ return undefined;
73
+ }
74
+ if (!raw || typeof raw !== 'object' || Array.isArray(raw)) {
75
+ return undefined;
76
+ }
77
+ const record = raw;
78
+ const importRoots = parseImportRoots(record.importRoots, configUri);
79
+ if (record.importRoots !== undefined && importRoots === undefined) {
80
+ return undefined;
81
+ }
82
+ const parsedExport = parseExportConfig(record.export, UriUtils.dirname(configUri));
83
+ const config = {
84
+ importRoots: importRoots ?? defaultRqConfig().importRoots
85
+ };
86
+ if (parsedExport) {
87
+ config.export = parsedExport;
88
+ }
89
+ return config;
90
+ }
91
+ function parseImportRootEntry(entry, configDir) {
92
+ if (!entry || typeof entry !== 'object' || Array.isArray(entry)) {
93
+ return undefined;
94
+ }
95
+ const record = entry;
96
+ if (typeof record.alias !== 'string' || record.alias.length === 0) {
97
+ return undefined;
98
+ }
99
+ const mapping = { alias: record.alias };
100
+ if (typeof record.root === 'string' && record.root.length > 0) {
101
+ mapping.rootUri = isAbsoluteUriOrPath(record.root)
102
+ ? toDirectoryUri(record.root)
103
+ : UriUtils.resolvePath(configDir, record.root);
104
+ }
105
+ return mapping;
106
+ }
107
+ function parseImportRoots(raw, configUri) {
108
+ if (raw === undefined) {
109
+ return undefined;
110
+ }
111
+ if (!Array.isArray(raw)) {
112
+ return undefined;
113
+ }
114
+ const configDir = UriUtils.dirname(configUri);
115
+ const importRoots = [];
116
+ for (const entry of raw) {
117
+ const mapping = parseImportRootEntry(entry, configDir);
118
+ if (mapping) {
119
+ importRoots.push(mapping);
120
+ }
121
+ }
122
+ return importRoots.length > 0 ? importRoots : defaultRqConfig().importRoots;
123
+ }
124
+ function parseExportConfig(raw, configDir) {
125
+ if (!raw || typeof raw !== 'object' || Array.isArray(raw)) {
126
+ return undefined;
127
+ }
128
+ const record = raw;
129
+ const config = {};
130
+ if (typeof record.outputFolder === 'string' && record.outputFolder.trim().length > 0) {
131
+ config.outputFolder = isAbsoluteUriOrPath(record.outputFolder)
132
+ ? toDirectoryUri(record.outputFolder).fsPath
133
+ : UriUtils.resolvePath(configDir, record.outputFolder).fsPath;
134
+ }
135
+ if (typeof record.templateId === 'string' && record.templateId.trim().length > 0) {
136
+ config.templateId = record.templateId.trim();
137
+ }
138
+ if (record.scope === 'workspace' || record.scope === 'currentFile') {
139
+ config.scope = record.scope;
140
+ }
141
+ const html = parseHtmlExportConfig(record.html);
142
+ if (html) {
143
+ config.html = html;
144
+ }
145
+ return Object.keys(config).length > 0 ? config : undefined;
146
+ }
147
+ function parseHtmlExportConfig(raw) {
148
+ if (!raw || typeof raw !== 'object' || Array.isArray(raw)) {
149
+ return undefined;
150
+ }
151
+ const record = raw;
152
+ const config = {};
153
+ if (typeof record.printEntryFileName === 'string' && record.printEntryFileName.trim().length > 0) {
154
+ config.printEntryFileName = record.printEntryFileName.trim();
155
+ }
156
+ if (typeof record.includeRequirementsPage === 'boolean') {
157
+ config.includeRequirementsPage = record.includeRequirementsPage;
158
+ }
159
+ if (typeof record.includeGraphPage === 'boolean') {
160
+ config.includeGraphPage = record.includeGraphPage;
161
+ }
162
+ if (record.runtimeMode === 'interactive' || record.runtimeMode === 'document' || record.runtimeMode === 'print') {
163
+ config.runtimeMode = record.runtimeMode;
164
+ }
165
+ if (record.clusterStrategy === 'deterministic' || record.clusterStrategy === 'hybrid') {
166
+ config.clusterStrategy = record.clusterStrategy;
167
+ }
168
+ if (typeof record.includeIdeaPages === 'boolean') {
169
+ config.includeIdeaPages = record.includeIdeaPages;
170
+ }
171
+ if (typeof record.includeFilePages === 'boolean') {
172
+ config.includeFilePages = record.includeFilePages;
173
+ }
174
+ if (typeof record.includeCodeFilePages === 'boolean') {
175
+ config.includeCodeFilePages = record.includeCodeFilePages;
176
+ }
177
+ if (typeof record.includeClusterPages === 'boolean') {
178
+ config.includeClusterPages = record.includeClusterPages;
179
+ }
180
+ if (typeof record.includePrintPages === 'boolean') {
181
+ config.includePrintPages = record.includePrintPages;
182
+ }
183
+ return Object.keys(config).length > 0 ? config : undefined;
184
+ }
185
+ function isAbsoluteUriOrPath(value) {
186
+ return /^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(value) || value.startsWith('/');
187
+ }
188
+ function toDirectoryUri(value) {
189
+ if (/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(value)) {
190
+ return UriCtor.parse(value);
191
+ }
192
+ return UriCtor.file(value);
193
+ }
194
+ export function resolveRqConfig(document, context) {
195
+ if (context?.config === null) {
196
+ return defaultRqConfig();
197
+ }
198
+ if (context?.config) {
199
+ return context.config;
200
+ }
201
+ if (context?.fileSystem) {
202
+ const loaded = loadApplyingRqConfig(UriUtils.dirname(document.uri), context.fileSystem);
203
+ if (loaded) {
204
+ return loaded;
205
+ }
206
+ }
207
+ return defaultRqConfig();
208
+ }
209
+ export function resolveImportRootUri(document, context, mapping) {
210
+ if (mapping.rootUri) {
211
+ return mapping.rootUri;
212
+ }
213
+ if (context?.workspaceFolderUri) {
214
+ return context.workspaceFolderUri;
215
+ }
216
+ return findWorkspaceFolderUri(document.uri, context?.workspaceFolderUris);
217
+ }
218
+ /**
219
+ * Resolves a path string against the document directory, or against an import root when aliased.
220
+ */
221
+ export function resolveDocumentPathUri(path, document, context) {
222
+ const config = resolveRqConfig(document, context);
223
+ const matched = matchImportRootMapping(path, config.importRoots);
224
+ if (!matched) {
225
+ return UriUtils.resolvePath(UriUtils.dirname(document.uri), path);
226
+ }
227
+ const importRoot = resolveImportRootUri(document, context, matched.mapping);
228
+ if (!importRoot) {
229
+ return UriUtils.resolvePath(UriUtils.dirname(document.uri), path);
230
+ }
231
+ return UriUtils.resolvePath(importRoot, matched.remainder);
232
+ }
233
+ export function workspaceFolderUrisFromManager(folders) {
234
+ if (!folders) {
235
+ return [];
236
+ }
237
+ return folders.map(folder => UriCtor.parse(folder.uri));
238
+ }
239
+ export function pathResolveContextFromServices(services) {
240
+ return {
241
+ fileSystem: services.shared.workspace.FileSystemProvider,
242
+ workspaceFolderUris: workspaceFolderUrisFromManager(services.shared.workspace.WorkspaceManager.workspaceFolders)
243
+ };
244
+ }
245
+ //# sourceMappingURL=reqlan-path-resolve.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reqlan-path-resolve.js","sourceRoot":"","sources":["../src/reqlan-path-resolve.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,GAAG,IAAI,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnD,MAAM,CAAC,MAAM,yBAAyB,GAAG,GAAG,CAAC;AAC7C,MAAM,CAAC,MAAM,iBAAiB,GAAG,gBAAgB,CAAC;AAkDlD,MAAM,UAAU,eAAe;IAC3B,OAAO,EAAE,WAAW,EAAE,CAAC,EAAE,KAAK,EAAE,yBAAyB,EAAE,CAAC,EAAE,CAAC;AACnE,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,IAAY,EAAE,KAAa;IAC5D,IA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AAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,CAAC;IACtE,CAAC;IACD,OAAO,QAAQ,CAAC,WAAW,CAAC,UAAU,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;AAC/D,CAAC;AAED,MAAM,UAAU,8BAA8B,CAC1C,OAAmD;IAEnD,IAAI,CAAC,OAAO,EAAE,CAAC;QACX,OAAO,EAAE,CAAC;IACd,CAAC;IACD,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;AAC5D,CAAC;AAED,MAAM,UAAU,8BAA8B,CAAC,QAO9C;IACG,OAAO;QACH,UAAU,EAAE,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,kBAAkB;QACxD,mBAAmB,EAAE,8BAA8B,CAC/C,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,gBAAgB,CAAC,gBAAgB,CAC9D;KACJ,CAAC;AACN,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Shared helpers for reqlan double- and single-quoted string literals.
3
+ */
4
+ /** Capturing group for one quoted string (double or single). */
5
+ export declare const REQLAN_QUOTED_STRING_CAPTURE = "(?:\"(?:\\\\.|[^\"\\\\])*\"|'(?:\\\\.|[^'\\\\])*')";
6
+ export declare const REQLAN_QUOTED_STRING_PATTERN: RegExp;
7
+ export declare function reqlanStringDelimiter(text: string): '"' | "'" | undefined;
8
+ export declare function unquoteReqlanString(text: string): string;
9
+ export declare function parseReqlanQuotedString(quoted: string): string;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Shared helpers for reqlan double- and single-quoted string literals.
3
+ */
4
+ /** Capturing group for one quoted string (double or single). */
5
+ export const REQLAN_QUOTED_STRING_CAPTURE = '(?:"(?:\\\\.|[^"\\\\])*"|\'(?:\\\\.|[^\'\\\\])*\')';
6
+ export const REQLAN_QUOTED_STRING_PATTERN = new RegExp(REQLAN_QUOTED_STRING_CAPTURE, 'g');
7
+ export function reqlanStringDelimiter(text) {
8
+ if (text.startsWith('"')) {
9
+ return '"';
10
+ }
11
+ if (text.startsWith("'")) {
12
+ return "'";
13
+ }
14
+ return undefined;
15
+ }
16
+ export function unquoteReqlanString(text) {
17
+ const delimiter = reqlanStringDelimiter(text);
18
+ if (!delimiter || !text.endsWith(delimiter)) {
19
+ return text;
20
+ }
21
+ return text.slice(1, -1).replace(/\\(.)/g, '$1');
22
+ }
23
+ export function parseReqlanQuotedString(quoted) {
24
+ return unquoteReqlanString(quoted);
25
+ }
26
+ //# sourceMappingURL=reqlan-quoted-strings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reqlan-quoted-strings.js","sourceRoot":"","sources":["../src/reqlan-quoted-strings.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,gEAAgE;AAChE,MAAM,CAAC,MAAM,4BAA4B,GAAG,oDAAoD,CAAC;AAEjG,MAAM,CAAC,MAAM,4BAA4B,GAAG,IAAI,MAAM,CAAC,4BAA4B,EAAE,GAAG,CAAC,CAAC;AAE1F,MAAM,UAAU,qBAAqB,CAAC,IAAY;IAC9C,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QACvB,OAAO,GAAG,CAAC;IACf,CAAC;IACD,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QACvB,OAAO,GAAG,CAAC;IACf,CAAC;IACD,OAAO,SAAS,CAAC;AACrB,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,IAAY;IAC5C,MAAM,SAAS,GAAG,qBAAqB,CAAC,IAAI,CAAC,CAAC;IAC9C,IAAI,CAAC,SAAS,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;QAC1C,OAAO,IAAI,CAAC;IAChB,CAAC;IACD,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;AACrD,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,MAAc;IAClD,OAAO,mBAAmB,CAAC,MAAM,CAAC,CAAC;AACvC,CAAC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Locates file path references at a cursor position and resolves them to files, folders, or missing paths.
3
+ */
4
+ import type { FileSystemProvider, LangiumDocument, LangiumDocuments } from 'langium';
5
+ import type { Position, LocationLink } from 'vscode-languageserver';
6
+ import { type ReferenceResolution, type ResolvedFileLink } from './reqlan-file-link-resolver.js';
7
+ import type { PathResolveContext } from './reqlan-path-resolve.js';
8
+ export declare const REQLAN_OPEN_FOLDER_COMMAND = "reqlan.openFolderReference";
9
+ export declare const REQLAN_FILE_REFERENCE_AT_REQUEST = "reqlan/fileReferenceAt";
10
+ export declare const REQLAN_COMMENT_DEFINITION_REQUEST = "reqlan/commentDefinition";
11
+ export declare function folderReferenceCommandTarget(folderUri: string): string;
12
+ export declare function findFileReferenceAtPosition(document: LangiumDocument, position: Position, documents: LangiumDocuments, fileSystem: FileSystemProvider, context?: PathResolveContext): ResolvedFileLink | undefined;
13
+ export interface FileReferenceAtRequestResult {
14
+ sourceRange: ResolvedFileLink['sourceRange'];
15
+ targetUri: string;
16
+ resolution: ReferenceResolution;
17
+ folderFiles?: string[];
18
+ }
19
+ export declare function findCommentDefinitionAtPosition(document: LangiumDocument, position: Position, documents: LangiumDocuments, context?: PathResolveContext): LocationLink[] | undefined;
20
+ export declare function fileReferenceAtRequestResult(link: ResolvedFileLink): FileReferenceAtRequestResult;
@@ -0,0 +1,89 @@
1
+ import { CstUtils, GrammarUtils } from 'langium';
2
+ import { findCommentReferencePartAt, resolveCommentDefinitionLinks, resolveFileUri } from './reqlan-comment-resolver.js';
3
+ import { findEmbeddedFileReferenceAt } from './reqlan-embedded-file-references.js';
4
+ import { classifyReferenceUri, listFolderFileNames, resolveEmbeddedFileReferenceLink, resolveFileReferenceLink } from './reqlan-file-link-resolver.js';
5
+ import { isFileReference, isFileSymbolReference } from './generated/ast.js';
6
+ export const REQLAN_OPEN_FOLDER_COMMAND = 'reqlan.openFolderReference';
7
+ export const REQLAN_FILE_REFERENCE_AT_REQUEST = 'reqlan/fileReferenceAt';
8
+ export const REQLAN_COMMENT_DEFINITION_REQUEST = 'reqlan/commentDefinition';
9
+ export function folderReferenceCommandTarget(folderUri) {
10
+ return `command:${REQLAN_OPEN_FOLDER_COMMAND}?${encodeURIComponent(JSON.stringify([folderUri]))}`;
11
+ }
12
+ export function findFileReferenceAtPosition(document, position, documents, fileSystem, context) {
13
+ const pathContext = { ...context, fileSystem: context?.fileSystem ?? fileSystem };
14
+ const commentPart = findCommentReferencePartAt(document, position);
15
+ if (commentPart?.property === 'path' && commentPart.reference.path) {
16
+ return resolvePathReference(document, commentPart.reference.path, commentPart.reference.range, documents, fileSystem, pathContext);
17
+ }
18
+ const embeddedReference = findEmbeddedFileReferenceAt(document, position);
19
+ if (embeddedReference) {
20
+ return resolveEmbeddedFileReferenceLink(embeddedReference, document, documents, fileSystem, pathContext);
21
+ }
22
+ const fileReference = findFileReferenceNodeAtPosition(document, position);
23
+ if (fileReference) {
24
+ return resolveFileReferenceLink(fileReference.node, documents, fileSystem, pathContext);
25
+ }
26
+ return undefined;
27
+ }
28
+ function resolvePathReference(document, path, sourceRange, documents, fileSystem, context) {
29
+ const targetUri = resolveFileUri(path, document, context);
30
+ const resolution = classifyReferenceUri(targetUri, documents, fileSystem);
31
+ if (resolution === 'missing') {
32
+ return undefined;
33
+ }
34
+ if (resolution === 'folder') {
35
+ return {
36
+ sourceRange,
37
+ targetUri: targetUri.toString(),
38
+ resolution,
39
+ folderFiles: listFolderFileNames(fileSystem, targetUri)
40
+ };
41
+ }
42
+ const targetDocument = documents.getDocument(targetUri);
43
+ const target = targetDocument?.parseResult.value.$cstNode;
44
+ if (!targetDocument || !target) {
45
+ return undefined;
46
+ }
47
+ return {
48
+ sourceRange,
49
+ targetUri: targetDocument.textDocument.uri,
50
+ targetRange: target.range,
51
+ resolution: 'file'
52
+ };
53
+ }
54
+ function findFileReferenceNodeAtPosition(document, position) {
55
+ const root = document.parseResult.value.$cstNode;
56
+ if (!root) {
57
+ return undefined;
58
+ }
59
+ const offset = document.textDocument.offsetAt(position);
60
+ let current = CstUtils.findLeafNodeAtOffset(root, offset);
61
+ while (current) {
62
+ const assignment = GrammarUtils.findAssignment(current);
63
+ const container = current.astNode;
64
+ if ((isFileReference(container) || isFileSymbolReference(container)) && assignment?.feature === 'file') {
65
+ const pathNode = GrammarUtils.findNodeForProperty(container.$cstNode, 'file');
66
+ if (pathNode) {
67
+ return { node: container, pathNode };
68
+ }
69
+ }
70
+ current = current.container;
71
+ }
72
+ return undefined;
73
+ }
74
+ export function findCommentDefinitionAtPosition(document, position, documents, context) {
75
+ const commentPart = findCommentReferencePartAt(document, position);
76
+ if (commentPart?.property !== 'idea') {
77
+ return undefined;
78
+ }
79
+ return resolveCommentDefinitionLinks(commentPart.reference, document, documents, context);
80
+ }
81
+ export function fileReferenceAtRequestResult(link) {
82
+ return {
83
+ sourceRange: link.sourceRange,
84
+ targetUri: link.targetUri,
85
+ resolution: link.resolution ?? 'file',
86
+ folderFiles: link.folderFiles
87
+ };
88
+ }
89
+ //# sourceMappingURL=reqlan-reference-at-position.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reqlan-reference-at-position.js","sourceRoot":"","sources":["../src/reqlan-reference-at-position.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEjD,OAAO,EACH,0BAA0B,EAC1B,6BAA6B,EAC7B,cAAc,EACjB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,2BAA2B,EAAE,MAAM,sCAAsC,CAAC;AACnF,OAAO,EACH,oBAAoB,EACpB,mBAAmB,EACnB,gCAAgC,EAChC,wBAAwB,EAG3B,MAAM,gCAAgC,CAAC;A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