@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,319 @@
1
+ /**
2
+ * Go-to-definition for imports, file references, symbols, and embedded comment references.
3
+ */
4
+ import type { CstNode, FileSystemProvider, LangiumDocument, MaybePromise } from 'langium';
5
+ import { AstUtils, CstUtils, GrammarUtils, URI } from 'langium';
6
+ import { DefaultDefinitionProvider, type GoToLink } from 'langium/lsp';
7
+ import type { DefinitionParams, Position } from 'vscode-languageserver';
8
+ import { LocationLink } from 'vscode-languageserver';
9
+ import {
10
+ findCommentReferencePartAt,
11
+ resolveCommentDefinitionLinks,
12
+ type EmbeddedCommentReference
13
+ } from './reqlan-comment-resolver.js';
14
+ import {
15
+ resolveFileReferenceLink,
16
+ resolveImportPathLink,
17
+ resolveQualifiedReferencePathLink,
18
+ resolvedFileLinkToGoToTarget,
19
+ resolvedFileLinkToGoToTargetFromFilesystem,
20
+ type ResolvedFileLink
21
+ } from './reqlan-file-link-resolver.js';
22
+ import {
23
+ isNamespaceImportOnlyReference,
24
+ resolveNamespaceImportReferenceLink
25
+ } from './reqlan-namespace-import-links.js';
26
+ import { findFileReferenceAtPosition } from './reqlan-reference-at-position.js';
27
+ import { isMarkdownLinkLabelPosition } from './reqlan-markdown-links.js';
28
+ import {
29
+ isFileReference,
30
+ isFileSymbolReference,
31
+ isFromImport,
32
+ isImport,
33
+ isLocalReference,
34
+ isQualifiedReference,
35
+ type FileReference,
36
+ type FileSymbolReference,
37
+ type Import,
38
+ type LocalReference,
39
+ type QualifiedReference
40
+ } from './generated/ast.js';
41
+ import type { ReqlanServices } from './reqlan-module.js';
42
+ import { pathResolveContextFromServices } from './reqlan-path-resolve.js';
43
+
44
+ export class ReqlanDefinitionProvider extends DefaultDefinitionProvider {
45
+
46
+ private readonly documents: ReqlanServices['shared']['workspace']['LangiumDocuments'];
47
+ private readonly fileSystem: FileSystemProvider;
48
+ private readonly services: ReqlanServices;
49
+
50
+ constructor(services: ReqlanServices) {
51
+ super(services);
52
+ this.documents = services.shared.workspace.LangiumDocuments;
53
+ this.fileSystem = services.shared.workspace.FileSystemProvider;
54
+ this.services = services;
55
+ }
56
+
57
+ private pathContext() {
58
+ return pathResolveContextFromServices(this.services);
59
+ }
60
+
61
+ override getDefinition(document: LangiumDocument, params: DefinitionParams): MaybePromise<LocationLink[] | undefined> {
62
+ if (isMarkdownLinkLabelPosition(document, params.position)) {
63
+ return undefined;
64
+ }
65
+ const commentPart = findCommentReferencePartAt(document, params.position);
66
+ if (commentPart?.property === 'idea') {
67
+ return this.createCommentIdeaReferenceLinks(document, commentPart.reference);
68
+ }
69
+ const fileReference = findFileReferenceAtPosition(
70
+ document,
71
+ params.position,
72
+ this.documents,
73
+ this.fileSystem,
74
+ this.pathContext()
75
+ );
76
+ if (fileReference) {
77
+ if (fileReference.resolution === 'folder' || fileReference.resolution === 'missing') {
78
+ return undefined;
79
+ }
80
+ return [this.resolvedFileLinkToLocationLink(fileReference)];
81
+ }
82
+ const fileLink = this.findFileReferenceLinkAtPosition(document, params.position);
83
+ if (fileLink) {
84
+ return [this.toLocationLink(fileLink)];
85
+ }
86
+ const anonymousImportPathLink = this.findAnonymousImportPathLinkAtPosition(document, params.position);
87
+ if (anonymousImportPathLink) {
88
+ return [this.toLocationLink(anonymousImportPathLink)];
89
+ }
90
+ const importPathLink = this.findImportPathLinkAtPosition(document, params.position);
91
+ if (importPathLink) {
92
+ return [this.toLocationLink(importPathLink)];
93
+ }
94
+ return super.getDefinition(document, params);
95
+ }
96
+
97
+ protected override findLinks(source: CstNode): GoToLink[] {
98
+ const fileLink = this.linkForFileReference(source) ?? this.linkForNamespaceImportReference(source);
99
+ if (fileLink) {
100
+ return [fileLink];
101
+ }
102
+ const importPathLink = this.linkForImportPath(source);
103
+ if (importPathLink) {
104
+ return [importPathLink];
105
+ }
106
+ return super.findLinks(source).map(link => this.redirectImportPathLink(link) ?? link);
107
+ }
108
+
109
+ private linkForFileReference(source: CstNode): GoToLink | undefined {
110
+ const assignment = GrammarUtils.findAssignment(source);
111
+ if (!assignment) {
112
+ return undefined;
113
+ }
114
+ const container = source.astNode;
115
+ if ((isFileReference(container) || isFileSymbolReference(container)) && assignment.feature === 'file') {
116
+ return this.createFileLink(source, container);
117
+ }
118
+ return undefined;
119
+ }
120
+
121
+ private createNamespaceImportLink(source: CstNode, reference: LocalReference | QualifiedReference): GoToLink | undefined {
122
+ const resolved = resolveNamespaceImportReferenceLink(
123
+ reference,
124
+ this.documents,
125
+ this.fileSystem,
126
+ this.pathContext()
127
+ );
128
+ if (!resolved) {
129
+ return undefined;
130
+ }
131
+ const targetDocument = this.documents.getDocument(URI.parse(resolved.targetUri));
132
+ if (targetDocument) {
133
+ return resolvedFileLinkToGoToTarget(resolved, source, targetDocument);
134
+ }
135
+ return resolvedFileLinkToGoToTargetFromFilesystem(resolved, source);
136
+ }
137
+
138
+ private linkForNamespaceImportReference(source: CstNode): GoToLink | undefined {
139
+ const assignment = GrammarUtils.findAssignment(source);
140
+ if (!assignment) {
141
+ return undefined;
142
+ }
143
+ const container = source.astNode;
144
+ if (!(isLocalReference(container) || isQualifiedReference(container))) {
145
+ return undefined;
146
+ }
147
+ if (!isNamespaceImportOnlyReference(container)) {
148
+ return undefined;
149
+ }
150
+ const property = assignment.feature;
151
+ if (property !== 'idea' && property !== 'ideaset' && property !== 'qualifier') {
152
+ return undefined;
153
+ }
154
+ return this.createNamespaceImportLink(source, container);
155
+ }
156
+
157
+ private linkForImportPath(source: CstNode): GoToLink | undefined {
158
+ let current: CstNode | undefined = source;
159
+ while (current) {
160
+ const container = current.astNode;
161
+ const assignment = GrammarUtils.findAssignment(current);
162
+ if (isImport(container) && assignment?.feature === 'path') {
163
+ return this.createImportedFileLink(current, container);
164
+ }
165
+ if (isQualifiedReference(container) && this.isOnQualifiedReferencePath(current, container)) {
166
+ const importDecl = container.path?.ref;
167
+ if (importDecl) {
168
+ return this.createImportedFileLink(current, importDecl);
169
+ }
170
+ const resolved = resolveQualifiedReferencePathLink(container, this.documents, this.pathContext());
171
+ if (resolved) {
172
+ const targetDocument = this.documents.getDocument(URI.parse(resolved.targetUri.split('#')[0]));
173
+ if (targetDocument) {
174
+ return resolvedFileLinkToGoToTarget(resolved, current, targetDocument);
175
+ }
176
+ }
177
+ }
178
+ current = current.container;
179
+ }
180
+ return undefined;
181
+ }
182
+
183
+ private isOnQualifiedReferencePath(source: CstNode, reference: QualifiedReference): boolean {
184
+ const pathNode = reference.path?.$refNode ?? GrammarUtils.findNodeForProperty(reference.$cstNode, 'path');
185
+ if (!pathNode) {
186
+ return false;
187
+ }
188
+ return source.offset >= pathNode.offset && source.end <= pathNode.end;
189
+ }
190
+
191
+ private redirectImportPathLink(link: GoToLink): GoToLink | undefined {
192
+ const importDecl = link.target.astNode;
193
+ if (!isImportPathTarget(importDecl, link.target)) {
194
+ return undefined;
195
+ }
196
+ return this.createImportedFileLink(link.source, importDecl);
197
+ }
198
+
199
+ private createImportedFileLink(source: CstNode, importDecl: Import): GoToLink | undefined {
200
+ const resolved = resolveImportPathLink(importDecl, this.documents, this.pathContext());
201
+ if (!resolved) {
202
+ return undefined;
203
+ }
204
+ const targetDocument = this.documents.getDocument(URI.parse(resolved.targetUri.split('#')[0]));
205
+ if (!targetDocument) {
206
+ return undefined;
207
+ }
208
+ return resolvedFileLinkToGoToTarget(resolved, source, targetDocument);
209
+ }
210
+
211
+ private createFileLink(source: CstNode, reference: FileReference | FileSymbolReference): GoToLink | undefined {
212
+ const resolved = resolveFileReferenceLink(reference, this.documents, this.fileSystem, this.pathContext());
213
+ if (!resolved) {
214
+ return undefined;
215
+ }
216
+ const targetDocument = this.documents.getDocument(URI.parse(resolved.targetUri));
217
+ if (targetDocument) {
218
+ return resolvedFileLinkToGoToTarget(resolved, source, targetDocument);
219
+ }
220
+ return resolvedFileLinkToGoToTargetFromFilesystem(resolved, source);
221
+ }
222
+
223
+ private createCommentIdeaReferenceLinks(
224
+ document: LangiumDocument,
225
+ reference: EmbeddedCommentReference
226
+ ): LocationLink[] | undefined {
227
+ return resolveCommentDefinitionLinks(reference, document, this.documents, this.pathContext());
228
+ }
229
+
230
+ private findAnonymousImportPathLinkAtPosition(document: LangiumDocument, position: Position): GoToLink | undefined {
231
+ const offset = document.textDocument.offsetAt(position);
232
+ for (const node of AstUtils.streamAst(document.parseResult.value)) {
233
+ if (!isQualifiedReference(node) || node.path?.ref) {
234
+ continue;
235
+ }
236
+ const pathNode = node.path?.$refNode ?? GrammarUtils.findNodeForProperty(node.$cstNode, 'path');
237
+ if (!pathNode || offset < pathNode.offset || offset >= pathNode.end) {
238
+ continue;
239
+ }
240
+ const resolved = resolveQualifiedReferencePathLink(node, this.documents, this.pathContext());
241
+ if (!resolved) {
242
+ continue;
243
+ }
244
+ const targetDocument = this.documents.getDocument(URI.parse(resolved.targetUri.split('#')[0]));
245
+ if (!targetDocument) {
246
+ continue;
247
+ }
248
+ return resolvedFileLinkToGoToTarget(resolved, pathNode, targetDocument);
249
+ }
250
+ return undefined;
251
+ }
252
+
253
+ private findImportPathLinkAtPosition(document: LangiumDocument, position: Position): GoToLink | undefined {
254
+ const root = document.parseResult.value.$cstNode;
255
+ if (!root) {
256
+ return undefined;
257
+ }
258
+ const offset = document.textDocument.offsetAt(position);
259
+ let current: CstNode | undefined = CstUtils.findLeafNodeAtOffset(root, offset);
260
+ while (current) {
261
+ const link = this.linkForImportPath(current) ?? this.linkForFileReference(current) ?? this.linkForNamespaceImportReference(current);
262
+ if (link) {
263
+ return link;
264
+ }
265
+ current = current.container;
266
+ }
267
+ return undefined;
268
+ }
269
+
270
+ private findFileReferenceLinkAtPosition(document: LangiumDocument, position: Position): GoToLink | undefined {
271
+ const root = document.parseResult.value.$cstNode;
272
+ if (!root) {
273
+ return undefined;
274
+ }
275
+ const offset = document.textDocument.offsetAt(position);
276
+ let current: CstNode | undefined = CstUtils.findLeafNodeAtOffset(root, offset);
277
+ while (current) {
278
+ const link = this.linkForFileReference(current) ?? this.linkForNamespaceImportReference(current);
279
+ if (link) {
280
+ return link;
281
+ }
282
+ current = current.container;
283
+ }
284
+ return undefined;
285
+ }
286
+
287
+ private toLocationLink(link: GoToLink): LocationLink {
288
+ return LocationLink.create(
289
+ link.targetDocument.textDocument.uri,
290
+ (link.target.astNode?.$cstNode ?? link.target).range,
291
+ link.target.range,
292
+ link.source.range
293
+ );
294
+ }
295
+
296
+ private resolvedFileLinkToLocationLink(link: ResolvedFileLink): LocationLink {
297
+ const targetRange = link.targetRange ?? {
298
+ start: { line: 0, character: 0 },
299
+ end: { line: 0, character: 0 }
300
+ };
301
+ return LocationLink.create(
302
+ link.targetUri,
303
+ targetRange,
304
+ targetRange,
305
+ link.sourceRange
306
+ );
307
+ }
308
+ }
309
+
310
+ function isImportPathTarget(node: unknown, targetCst: CstNode): node is Import {
311
+ if (!isImport(node)) {
312
+ return false;
313
+ }
314
+ if (isFromImport(node) || !node.alias) {
315
+ return true;
316
+ }
317
+ const pathNode = GrammarUtils.findNodeForProperty(node.$cstNode, 'path');
318
+ return pathNode === targetCst || (pathNode !== undefined && targetCst.offset >= pathNode.offset && targetCst.end <= pathNode.end);
319
+ }
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Document highlights for requirement references, excluding markdown link labels.
3
+ */
4
+ import type { LangiumDocument } from 'langium';
5
+ import { DefaultDocumentHighlightProvider } from 'langium/lsp';
6
+ import type { MaybePromise } from 'langium';
7
+ import type { DocumentHighlight, DocumentHighlightParams } from 'vscode-languageserver';
8
+ import { isMarkdownLinkLabelPosition } from './reqlan-markdown-links.js';
9
+
10
+ export class ReqlanDocumentHighlightProvider extends DefaultDocumentHighlightProvider {
11
+
12
+ override getDocumentHighlight(
13
+ document: LangiumDocument,
14
+ params: DocumentHighlightParams
15
+ ): MaybePromise<DocumentHighlight[] | undefined> {
16
+ if (isMarkdownLinkLabelPosition(document, params.position)) {
17
+ return undefined;
18
+ }
19
+ return super.getDocumentHighlight(document, params);
20
+ }
21
+ }
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Clickable document links for file references and import paths.
3
+ */
4
+ import type { LangiumDocument } from 'langium';
5
+ import type { DocumentLinkProvider } from 'langium/lsp';
6
+ import type { DocumentLink, DocumentLinkParams } from 'vscode-languageserver';
7
+ import { DocumentLink as LspDocumentLink } from 'vscode-languageserver';
8
+ import { collectFileLinks, resolvedFileLinkTargetUri } from './reqlan-file-link-resolver.js';
9
+ import { folderReferenceCommandTarget } from './reqlan-reference-at-position.js';
10
+ import type { ReqlanServices } from './reqlan-module.js';
11
+ import { pathResolveContextFromServices } from './reqlan-path-resolve.js';
12
+
13
+ export class ReqlanDocumentLinkProvider implements DocumentLinkProvider {
14
+
15
+ private readonly documents: ReqlanServices['shared']['workspace']['LangiumDocuments'];
16
+ private readonly fileSystem: ReqlanServices['shared']['workspace']['FileSystemProvider'];
17
+ private readonly services: ReqlanServices;
18
+
19
+ constructor(services: ReqlanServices) {
20
+ this.documents = services.shared.workspace.LangiumDocuments;
21
+ this.fileSystem = services.shared.workspace.FileSystemProvider;
22
+ this.services = services;
23
+ }
24
+
25
+ getDocumentLinks(document: LangiumDocument, _params: DocumentLinkParams): DocumentLink[] {
26
+ return collectFileLinks(
27
+ document,
28
+ this.documents,
29
+ this.fileSystem,
30
+ pathResolveContextFromServices(this.services)
31
+ ).flatMap(link => {
32
+ if (link.resolution === 'folder') {
33
+ return [LspDocumentLink.create(
34
+ link.sourceRange,
35
+ folderReferenceCommandTarget(link.targetUri)
36
+ )];
37
+ }
38
+ const target = resolvedFileLinkTargetUri(link);
39
+ if (!target) {
40
+ return [];
41
+ }
42
+ return [LspDocumentLink.create(link.sourceRange, target)];
43
+ });
44
+ }
45
+ }
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Locates quoted file paths embedded in .rq source text, including @tests list entries.
3
+ */
4
+ import type { LangiumDocument } from 'langium';
5
+ import type { Position, Range } from 'vscode-languageserver';
6
+ import { isRangeInsideMarkdownLinkLabel } from './reqlan-markdown-links.js';
7
+ import { parseReqlanQuotedString, REQLAN_QUOTED_STRING_CAPTURE } from './reqlan-quoted-strings.js';
8
+
9
+ export interface EmbeddedFileReference {
10
+ file: string;
11
+ range: Range;
12
+ }
13
+
14
+ const BRACKETED_FILE_REFERENCE_PATTERN = new RegExp(`\\[\\s*(${REQLAN_QUOTED_STRING_CAPTURE})\\s*\\]`, 'g');
15
+ const QUOTED_FILE_REFERENCE_PATTERN = new RegExp(`(${REQLAN_QUOTED_STRING_CAPTURE})`, 'g');
16
+ const FILE_REFERENCE_LIKE = /(?:\.\w[\w.]*|\/)/;
17
+
18
+ export function findEmbeddedFileReferencesInText(text: string, lineOffset = 0): EmbeddedFileReference[] {
19
+ const references: EmbeddedFileReference[] = [];
20
+ const lines = text.split(/\r?\n/);
21
+ for (let lineIndex = 0; lineIndex < lines.length; lineIndex++) {
22
+ const line = lines[lineIndex];
23
+ for (const match of line.matchAll(BRACKETED_FILE_REFERENCE_PATTERN)) {
24
+ pushEmbeddedReference(references, match, lineIndex, lineOffset, line);
25
+ }
26
+ for (const match of line.matchAll(QUOTED_FILE_REFERENCE_PATTERN)) {
27
+ if (line.slice(Math.max(0, (match.index ?? 0) - 1), match.index).includes('[')) {
28
+ continue;
29
+ }
30
+ pushEmbeddedReference(references, match, lineIndex, lineOffset, line);
31
+ }
32
+ }
33
+ return references;
34
+ }
35
+
36
+ function pushEmbeddedReference(
37
+ references: EmbeddedFileReference[],
38
+ match: RegExpMatchArray,
39
+ lineIndex: number,
40
+ lineOffset: number,
41
+ line: string
42
+ ): void {
43
+ const quoted = match[1];
44
+ const file = parseReqlanQuotedString(quoted);
45
+ if (!FILE_REFERENCE_LIKE.test(file)) {
46
+ return;
47
+ }
48
+ const start = match.index ?? 0;
49
+ if (isRangeInsideMarkdownLinkLabel(line, start, start + match[0].length)) {
50
+ return;
51
+ }
52
+ references.push({
53
+ file,
54
+ range: {
55
+ start: { line: lineOffset + lineIndex, character: start },
56
+ end: { line: lineOffset + lineIndex, character: start + match[0].length }
57
+ }
58
+ });
59
+ }
60
+
61
+ export function findEmbeddedFileReferenceAt(
62
+ document: LangiumDocument,
63
+ position: Position
64
+ ): EmbeddedFileReference | undefined {
65
+ const offset = document.textDocument.offsetAt(position);
66
+ return findEmbeddedFileReferencesInText(document.textDocument.getText())
67
+ .find(reference => {
68
+ const start = document.textDocument.offsetAt(reference.range.start);
69
+ const end = document.textDocument.offsetAt(reference.range.end);
70
+ return offset >= start && offset <= end;
71
+ });
72
+ }