@hydranium/core 1.0.0-next.10 → 1.0.0-next.103

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 (375) hide show
  1. package/lib/documents/ast-document-manager.d.ts +75 -16
  2. package/lib/documents/ast-document-manager.d.ts.map +1 -1
  3. package/lib/documents/ast-document-manager.js +57 -19
  4. package/lib/documents/ast-document-manager.js.map +1 -1
  5. package/lib/documents/client-ids.d.ts +5 -19
  6. package/lib/documents/client-ids.d.ts.map +1 -1
  7. package/lib/documents/client-ids.js +5 -19
  8. package/lib/documents/client-ids.js.map +1 -1
  9. package/lib/documents/hydranium-text-documents.d.ts +124 -36
  10. package/lib/documents/hydranium-text-documents.d.ts.map +1 -1
  11. package/lib/documents/hydranium-text-documents.js +191 -51
  12. package/lib/documents/hydranium-text-documents.js.map +1 -1
  13. package/lib/documents/language-client-text-shadow.d.ts +41 -9
  14. package/lib/documents/language-client-text-shadow.d.ts.map +1 -1
  15. package/lib/documents/language-client-text-shadow.js +56 -11
  16. package/lib/documents/language-client-text-shadow.js.map +1 -1
  17. package/lib/documents/self-save-registry.d.ts +37 -6
  18. package/lib/documents/self-save-registry.d.ts.map +1 -1
  19. package/lib/documents/self-save-registry.js +28 -15
  20. package/lib/documents/self-save-registry.js.map +1 -1
  21. package/lib/index.d.ts +3 -0
  22. package/lib/index.d.ts.map +1 -1
  23. package/lib/index.js +6 -0
  24. package/lib/index.js.map +1 -1
  25. package/lib/langium/ast-extension/ast-node-builder.d.ts +32 -9
  26. package/lib/langium/ast-extension/ast-node-builder.d.ts.map +1 -1
  27. package/lib/langium/ast-extension/ast-node-builder.js +60 -22
  28. package/lib/langium/ast-extension/ast-node-builder.js.map +1 -1
  29. package/lib/langium/bootstrap.d.ts.map +1 -1
  30. package/lib/langium/bootstrap.js +16 -9
  31. package/lib/langium/bootstrap.js.map +1 -1
  32. package/lib/langium/config/configuration-provider.d.ts +81 -0
  33. package/lib/langium/config/configuration-provider.d.ts.map +1 -0
  34. package/lib/langium/config/configuration-provider.js +112 -0
  35. package/lib/langium/config/configuration-provider.js.map +1 -0
  36. package/lib/langium/config/index.d.ts +1 -0
  37. package/lib/langium/config/index.d.ts.map +1 -1
  38. package/lib/langium/config/index.js +1 -0
  39. package/lib/langium/config/index.js.map +1 -1
  40. package/lib/langium/diagnostics/lsp-logger.d.ts +17 -0
  41. package/lib/langium/diagnostics/lsp-logger.d.ts.map +1 -1
  42. package/lib/langium/diagnostics/lsp-logger.js +40 -6
  43. package/lib/langium/diagnostics/lsp-logger.js.map +1 -1
  44. package/lib/langium/document-builder/build-pipeline-integration.d.ts +21 -1
  45. package/lib/langium/document-builder/build-pipeline-integration.d.ts.map +1 -1
  46. package/lib/langium/document-builder/build-pipeline-integration.js +32 -5
  47. package/lib/langium/document-builder/build-pipeline-integration.js.map +1 -1
  48. package/lib/langium/document-builder/build-session.d.ts +93 -0
  49. package/lib/langium/document-builder/build-session.d.ts.map +1 -0
  50. package/lib/langium/document-builder/build-session.js +72 -0
  51. package/lib/langium/document-builder/build-session.js.map +1 -0
  52. package/lib/langium/document-builder/document-builder.d.ts +150 -7
  53. package/lib/langium/document-builder/document-builder.d.ts.map +1 -1
  54. package/lib/langium/document-builder/document-builder.js +298 -11
  55. package/lib/langium/document-builder/document-builder.js.map +1 -1
  56. package/lib/langium/document-builder/index.d.ts +1 -0
  57. package/lib/langium/document-builder/index.d.ts.map +1 -1
  58. package/lib/langium/document-builder/index.js +1 -0
  59. package/lib/langium/document-builder/index.js.map +1 -1
  60. package/lib/langium/integration-services.d.ts +45 -1
  61. package/lib/langium/integration-services.d.ts.map +1 -1
  62. package/lib/langium/integration-services.js +10 -5
  63. package/lib/langium/integration-services.js.map +1 -1
  64. package/lib/langium/integrity/integrity-service.d.ts +16 -0
  65. package/lib/langium/integrity/integrity-service.d.ts.map +1 -1
  66. package/lib/langium/integrity/integrity-service.js +110 -2
  67. package/lib/langium/integrity/integrity-service.js.map +1 -1
  68. package/lib/langium/keys/containment.d.ts +64 -0
  69. package/lib/langium/keys/containment.d.ts.map +1 -0
  70. package/lib/langium/keys/containment.js +53 -0
  71. package/lib/langium/keys/containment.js.map +1 -0
  72. package/lib/langium/keys/index.d.ts +1 -0
  73. package/lib/langium/keys/index.d.ts.map +1 -1
  74. package/lib/langium/keys/index.js +1 -0
  75. package/lib/langium/keys/index.js.map +1 -1
  76. package/lib/langium/keys/name-based-key-provider.d.ts +4 -0
  77. package/lib/langium/keys/name-based-key-provider.d.ts.map +1 -1
  78. package/lib/langium/keys/name-based-key-provider.js +4 -0
  79. package/lib/langium/keys/name-based-key-provider.js.map +1 -1
  80. package/lib/langium/language-module.d.ts +25 -0
  81. package/lib/langium/language-module.d.ts.map +1 -1
  82. package/lib/langium/language-module.js +14 -0
  83. package/lib/langium/language-module.js.map +1 -1
  84. package/lib/langium/model-service/model-service.d.ts +161 -10
  85. package/lib/langium/model-service/model-service.d.ts.map +1 -1
  86. package/lib/langium/model-service/model-service.js +174 -95
  87. package/lib/langium/model-service/model-service.js.map +1 -1
  88. package/lib/langium/module.d.ts +84 -15
  89. package/lib/langium/module.d.ts.map +1 -1
  90. package/lib/langium/module.js +26 -12
  91. package/lib/langium/module.js.map +1 -1
  92. package/lib/langium/naming/name-provider.d.ts +25 -4
  93. package/lib/langium/naming/name-provider.d.ts.map +1 -1
  94. package/lib/langium/naming/name-provider.js +2 -1
  95. package/lib/langium/naming/name-provider.js.map +1 -1
  96. package/lib/langium/naming/name-separator-validation.d.ts +23 -0
  97. package/lib/langium/naming/name-separator-validation.d.ts.map +1 -1
  98. package/lib/langium/naming/name-separator-validation.js +30 -1
  99. package/lib/langium/naming/name-separator-validation.js.map +1 -1
  100. package/lib/langium/residency/cst-residency-service.d.ts +31 -11
  101. package/lib/langium/residency/cst-residency-service.d.ts.map +1 -1
  102. package/lib/langium/residency/cst-residency-service.js +13 -56
  103. package/lib/langium/residency/cst-residency-service.js.map +1 -1
  104. package/lib/langium/scope/hydranium-scope-provider.d.ts +48 -13
  105. package/lib/langium/scope/hydranium-scope-provider.d.ts.map +1 -1
  106. package/lib/langium/scope/hydranium-scope-provider.js +56 -20
  107. package/lib/langium/scope/hydranium-scope-provider.js.map +1 -1
  108. package/lib/langium/serialization/abstract-serializer.d.ts +11 -20
  109. package/lib/langium/serialization/abstract-serializer.d.ts.map +1 -1
  110. package/lib/langium/serialization/abstract-serializer.js +12 -21
  111. package/lib/langium/serialization/abstract-serializer.js.map +1 -1
  112. package/lib/langium/service-registry.d.ts +15 -1
  113. package/lib/langium/service-registry.d.ts.map +1 -1
  114. package/lib/langium/service-registry.js +16 -0
  115. package/lib/langium/service-registry.js.map +1 -1
  116. package/lib/langium/shared-services.d.ts +15 -2
  117. package/lib/langium/shared-services.d.ts.map +1 -1
  118. package/lib/langium/shared-services.js.map +1 -1
  119. package/lib/langium/transfer/transfer-encoder.d.ts +60 -17
  120. package/lib/langium/transfer/transfer-encoder.d.ts.map +1 -1
  121. package/lib/langium/transfer/transfer-encoder.js +38 -16
  122. package/lib/langium/transfer/transfer-encoder.js.map +1 -1
  123. package/lib/langium/trivia/comment-preserver.d.ts +423 -0
  124. package/lib/langium/trivia/comment-preserver.d.ts.map +1 -0
  125. package/lib/langium/trivia/comment-preserver.js +906 -0
  126. package/lib/langium/trivia/comment-preserver.js.map +1 -0
  127. package/lib/langium/trivia/document-ending-preserver.d.ts +43 -0
  128. package/lib/langium/trivia/document-ending-preserver.d.ts.map +1 -0
  129. package/lib/langium/trivia/document-ending-preserver.js +48 -0
  130. package/lib/langium/trivia/document-ending-preserver.js.map +1 -0
  131. package/lib/langium/trivia/index.d.ts +14 -0
  132. package/lib/langium/trivia/index.d.ts.map +1 -0
  133. package/lib/langium/trivia/index.js +14 -0
  134. package/lib/langium/trivia/index.js.map +1 -0
  135. package/lib/langium/trivia/trivia-contribution.d.ts +37 -0
  136. package/lib/langium/trivia/trivia-contribution.d.ts.map +1 -0
  137. package/lib/langium/trivia/trivia-contribution.js +10 -0
  138. package/lib/langium/trivia/trivia-contribution.js.map +1 -0
  139. package/lib/langium/trivia/trivia-preserver.d.ts +50 -0
  140. package/lib/langium/trivia/trivia-preserver.d.ts.map +1 -0
  141. package/lib/langium/trivia/trivia-preserver.js +10 -0
  142. package/lib/langium/trivia/trivia-preserver.js.map +1 -0
  143. package/lib/langium/trivia/trivia-service.d.ts +70 -0
  144. package/lib/langium/trivia/trivia-service.d.ts.map +1 -0
  145. package/lib/langium/trivia/trivia-service.js +56 -0
  146. package/lib/langium/trivia/trivia-service.js.map +1 -0
  147. package/lib/langium/validation/document-validator.d.ts +294 -10
  148. package/lib/langium/validation/document-validator.d.ts.map +1 -1
  149. package/lib/langium/validation/document-validator.js +448 -5
  150. package/lib/langium/validation/document-validator.js.map +1 -1
  151. package/lib/langium/workspace/document-uri-policy.d.ts +3 -4
  152. package/lib/langium/workspace/document-uri-policy.d.ts.map +1 -1
  153. package/lib/langium/workspace/document-uri-policy.js +3 -4
  154. package/lib/langium/workspace/document-uri-policy.js.map +1 -1
  155. package/lib/langium/workspace/file-system-provider.d.ts +9 -1
  156. package/lib/langium/workspace/file-system-provider.d.ts.map +1 -1
  157. package/lib/langium/workspace/file-system-provider.js +40 -7
  158. package/lib/langium/workspace/file-system-provider.js.map +1 -1
  159. package/lib/langium/workspace/hydranium-langium-document-factory.d.ts +25 -0
  160. package/lib/langium/workspace/hydranium-langium-document-factory.d.ts.map +1 -1
  161. package/lib/langium/workspace/hydranium-langium-document-factory.js +25 -0
  162. package/lib/langium/workspace/hydranium-langium-document-factory.js.map +1 -1
  163. package/lib/langium/workspace/hydranium-workspace-manager.d.ts +21 -1
  164. package/lib/langium/workspace/hydranium-workspace-manager.d.ts.map +1 -1
  165. package/lib/langium/workspace/hydranium-workspace-manager.js +28 -0
  166. package/lib/langium/workspace/hydranium-workspace-manager.js.map +1 -1
  167. package/lib/langium/workspace/in-memory-file-system-provider.d.ts +23 -0
  168. package/lib/langium/workspace/in-memory-file-system-provider.d.ts.map +1 -1
  169. package/lib/langium/workspace/in-memory-file-system-provider.js +47 -9
  170. package/lib/langium/workspace/in-memory-file-system-provider.js.map +1 -1
  171. package/lib/langium/workspace/initialize-workspace.d.ts +22 -2
  172. package/lib/langium/workspace/initialize-workspace.d.ts.map +1 -1
  173. package/lib/langium/workspace/initialize-workspace.js +13 -5
  174. package/lib/langium/workspace/initialize-workspace.js.map +1 -1
  175. package/lib/langium/workspace/langium-documents.d.ts +79 -17
  176. package/lib/langium/workspace/langium-documents.d.ts.map +1 -1
  177. package/lib/langium/workspace/langium-documents.js +83 -28
  178. package/lib/langium/workspace/langium-documents.js.map +1 -1
  179. package/lib/langium/workspace/virtual-document.d.ts +18 -3
  180. package/lib/langium/workspace/virtual-document.d.ts.map +1 -1
  181. package/lib/langium/workspace/virtual-document.js +19 -2
  182. package/lib/langium/workspace/virtual-document.js.map +1 -1
  183. package/lib/locale/index.d.ts +10 -0
  184. package/lib/locale/index.d.ts.map +1 -0
  185. package/lib/locale/index.js +10 -0
  186. package/lib/locale/index.js.map +1 -0
  187. package/lib/locale/server-locale.d.ts +73 -0
  188. package/lib/locale/server-locale.d.ts.map +1 -0
  189. package/lib/locale/server-locale.js +61 -0
  190. package/lib/locale/server-locale.js.map +1 -0
  191. package/lib/lsp/hydranium-document-update-handler.js +1 -1
  192. package/lib/lsp/hydranium-document-update-handler.js.map +1 -1
  193. package/lib/lsp/index.d.ts +1 -1
  194. package/lib/lsp/index.d.ts.map +1 -1
  195. package/lib/lsp/index.js +1 -1
  196. package/lib/lsp/index.js.map +1 -1
  197. package/lib/lsp/lsp-latency.d.ts +39 -0
  198. package/lib/lsp/lsp-latency.d.ts.map +1 -0
  199. package/lib/lsp/lsp-latency.js +58 -0
  200. package/lib/lsp/lsp-latency.js.map +1 -0
  201. package/lib/lsp/semantic-token-provider.d.ts +34 -1
  202. package/lib/lsp/semantic-token-provider.d.ts.map +1 -1
  203. package/lib/lsp/semantic-token-provider.js +55 -8
  204. package/lib/lsp/semantic-token-provider.js.map +1 -1
  205. package/lib/messages/carriers.d.ts +54 -0
  206. package/lib/messages/carriers.d.ts.map +1 -0
  207. package/lib/messages/carriers.js +62 -0
  208. package/lib/messages/carriers.js.map +1 -0
  209. package/lib/messages/index.d.ts +25 -0
  210. package/lib/messages/index.d.ts.map +1 -0
  211. package/lib/messages/index.js +25 -0
  212. package/lib/messages/index.js.map +1 -0
  213. package/lib/messages/renderer.d.ts +136 -0
  214. package/lib/messages/renderer.d.ts.map +1 -0
  215. package/lib/messages/renderer.js +159 -0
  216. package/lib/messages/renderer.js.map +1 -0
  217. package/lib/node/heap-ceiling.d.ts +61 -0
  218. package/lib/node/heap-ceiling.d.ts.map +1 -0
  219. package/lib/node/heap-ceiling.js +72 -0
  220. package/lib/node/heap-ceiling.js.map +1 -0
  221. package/lib/node/index.d.ts +1 -0
  222. package/lib/node/index.d.ts.map +1 -1
  223. package/lib/node/index.js +1 -0
  224. package/lib/node/index.js.map +1 -1
  225. package/lib/node/latency-from-env.d.ts +1 -1
  226. package/lib/node/latency-from-env.js +1 -1
  227. package/lib/node/node-file-system-provider.d.ts +35 -1
  228. package/lib/node/node-file-system-provider.d.ts.map +1 -1
  229. package/lib/node/node-file-system-provider.js +140 -45
  230. package/lib/node/node-file-system-provider.js.map +1 -1
  231. package/lib/node/profile-capture.d.ts +8 -2
  232. package/lib/node/profile-capture.d.ts.map +1 -1
  233. package/lib/node/profile-capture.js.map +1 -1
  234. package/lib/node/profiling-run.d.ts +2 -2
  235. package/lib/node/profiling-run.js +1 -1
  236. package/lib/node/profiling-run.js.map +1 -1
  237. package/lib/node/rename-over-open-readers.d.ts +52 -0
  238. package/lib/node/rename-over-open-readers.d.ts.map +1 -0
  239. package/lib/node/rename-over-open-readers.js +66 -0
  240. package/lib/node/rename-over-open-readers.js.map +1 -0
  241. package/lib/node/socket-launcher.d.ts +15 -0
  242. package/lib/node/socket-launcher.d.ts.map +1 -1
  243. package/lib/node/socket-launcher.js +3 -2
  244. package/lib/node/socket-launcher.js.map +1 -1
  245. package/lib/testing/fake-document.d.ts +16 -4
  246. package/lib/testing/fake-document.d.ts.map +1 -1
  247. package/lib/testing/fake-document.js +18 -3
  248. package/lib/testing/fake-document.js.map +1 -1
  249. package/lib/testing/make-noop-shared-services.d.ts +14 -0
  250. package/lib/testing/make-noop-shared-services.d.ts.map +1 -1
  251. package/lib/testing/make-noop-shared-services.js +28 -2
  252. package/lib/testing/make-noop-shared-services.js.map +1 -1
  253. package/lib/testing/make-test-services.d.ts +44 -8
  254. package/lib/testing/make-test-services.d.ts.map +1 -1
  255. package/lib/testing/make-test-services.js +19 -3
  256. package/lib/testing/make-test-services.js.map +1 -1
  257. package/lib/testing/node/scratch-workspace.d.ts.map +1 -1
  258. package/lib/testing/node/scratch-workspace.js +9 -4
  259. package/lib/testing/node/scratch-workspace.js.map +1 -1
  260. package/lib/testing/node/spawned-server.d.ts +14 -0
  261. package/lib/testing/node/spawned-server.d.ts.map +1 -1
  262. package/lib/testing/node/spawned-server.js +33 -1
  263. package/lib/testing/node/spawned-server.js.map +1 -1
  264. package/lib/testing/playwright/flaky-network-proxy.d.ts +76 -0
  265. package/lib/testing/playwright/flaky-network-proxy.d.ts.map +1 -0
  266. package/lib/testing/playwright/flaky-network-proxy.js +164 -0
  267. package/lib/testing/playwright/flaky-network-proxy.js.map +1 -0
  268. package/lib/testing/playwright/index.d.ts +1 -0
  269. package/lib/testing/playwright/index.d.ts.map +1 -1
  270. package/lib/testing/playwright/index.js +1 -0
  271. package/lib/testing/playwright/index.js.map +1 -1
  272. package/lib/testing/playwright/server-log-capture.d.ts +14 -4
  273. package/lib/testing/playwright/server-log-capture.d.ts.map +1 -1
  274. package/lib/testing/playwright/server-log-capture.js +21 -4
  275. package/lib/testing/playwright/server-log-capture.js.map +1 -1
  276. package/lib/testing/playwright/server-log-rename-reporter.d.ts.map +1 -1
  277. package/lib/testing/playwright/server-log-rename-reporter.js +10 -1
  278. package/lib/testing/playwright/server-log-rename-reporter.js.map +1 -1
  279. package/lib/testing/stub-ast-document-manager.d.ts +5 -5
  280. package/lib/testing/stub-ast-document-manager.d.ts.map +1 -1
  281. package/lib/testing/stub-ast-document-manager.js +4 -6
  282. package/lib/testing/stub-ast-document-manager.js.map +1 -1
  283. package/lib/testing/stub-document-builder.d.ts +8 -0
  284. package/lib/testing/stub-document-builder.d.ts.map +1 -1
  285. package/lib/testing/stub-document-builder.js +22 -3
  286. package/lib/testing/stub-document-builder.js.map +1 -1
  287. package/lib/testing/stub-langium-documents.d.ts +3 -2
  288. package/lib/testing/stub-langium-documents.d.ts.map +1 -1
  289. package/lib/testing/stub-langium-documents.js.map +1 -1
  290. package/lib/testing/stub-model-service.d.ts +5 -4
  291. package/lib/testing/stub-model-service.d.ts.map +1 -1
  292. package/lib/testing/stub-model-service.js +2 -2
  293. package/lib/testing/stub-model-service.js.map +1 -1
  294. package/package.json +17 -8
  295. package/src/documents/ast-document-manager.ts +129 -36
  296. package/src/documents/client-ids.ts +5 -22
  297. package/src/documents/hydranium-text-documents.ts +248 -75
  298. package/src/documents/language-client-text-shadow.ts +59 -11
  299. package/src/documents/self-save-registry.ts +52 -13
  300. package/src/index.ts +6 -0
  301. package/src/langium/ast-extension/ast-node-builder.ts +66 -22
  302. package/src/langium/bootstrap.ts +16 -9
  303. package/src/langium/config/configuration-provider.ts +119 -0
  304. package/src/langium/config/index.ts +1 -0
  305. package/src/langium/diagnostics/lsp-logger.ts +41 -6
  306. package/src/langium/document-builder/build-pipeline-integration.ts +50 -5
  307. package/src/langium/document-builder/build-session.ts +87 -0
  308. package/src/langium/document-builder/document-builder.ts +339 -11
  309. package/src/langium/document-builder/index.ts +1 -0
  310. package/src/langium/integration-services.ts +67 -6
  311. package/src/langium/integrity/integrity-service.ts +116 -2
  312. package/src/langium/keys/containment.ts +87 -0
  313. package/src/langium/keys/index.ts +1 -0
  314. package/src/langium/keys/name-based-key-provider.ts +4 -0
  315. package/src/langium/language-module.ts +38 -0
  316. package/src/langium/model-service/model-service.ts +264 -32
  317. package/src/langium/module.ts +106 -21
  318. package/src/langium/naming/name-provider.ts +27 -5
  319. package/src/langium/naming/name-separator-validation.ts +34 -5
  320. package/src/langium/residency/cst-residency-service.ts +36 -14
  321. package/src/langium/scope/hydranium-scope-provider.ts +60 -22
  322. package/src/langium/serialization/abstract-serializer.ts +13 -32
  323. package/src/langium/service-registry.ts +19 -2
  324. package/src/langium/shared-services.ts +19 -2
  325. package/src/langium/transfer/transfer-encoder.ts +85 -24
  326. package/src/langium/trivia/comment-preserver.ts +1100 -0
  327. package/src/langium/trivia/document-ending-preserver.ts +55 -0
  328. package/src/langium/trivia/index.ts +14 -0
  329. package/src/langium/trivia/trivia-contribution.ts +39 -0
  330. package/src/langium/trivia/trivia-preserver.ts +54 -0
  331. package/src/langium/trivia/trivia-service.ts +99 -0
  332. package/src/langium/validation/document-validator.ts +537 -11
  333. package/src/langium/workspace/document-uri-policy.ts +3 -4
  334. package/src/langium/workspace/file-system-provider.ts +48 -8
  335. package/src/langium/workspace/hydranium-langium-document-factory.ts +34 -0
  336. package/src/langium/workspace/hydranium-workspace-manager.ts +30 -1
  337. package/src/langium/workspace/in-memory-file-system-provider.ts +53 -10
  338. package/src/langium/workspace/initialize-workspace.ts +34 -5
  339. package/src/langium/workspace/langium-documents.ts +106 -33
  340. package/src/langium/workspace/virtual-document.ts +21 -3
  341. package/src/locale/index.ts +10 -0
  342. package/src/locale/server-locale.ts +86 -0
  343. package/src/lsp/hydranium-document-update-handler.ts +1 -1
  344. package/src/lsp/index.ts +1 -1
  345. package/src/lsp/lsp-latency.ts +62 -0
  346. package/src/lsp/semantic-token-provider.ts +74 -7
  347. package/src/messages/carriers.ts +78 -0
  348. package/src/messages/index.ts +36 -0
  349. package/src/messages/renderer.ts +204 -0
  350. package/src/node/heap-ceiling.ts +108 -0
  351. package/src/node/index.ts +1 -0
  352. package/src/node/latency-from-env.ts +1 -1
  353. package/src/node/node-file-system-provider.ts +154 -47
  354. package/src/node/profile-capture.ts +8 -2
  355. package/src/node/profiling-run.ts +3 -3
  356. package/src/node/rename-over-open-readers.ts +78 -0
  357. package/src/node/socket-launcher.ts +18 -2
  358. package/src/testing/fake-document.ts +24 -5
  359. package/src/testing/make-noop-shared-services.ts +50 -2
  360. package/src/testing/make-test-services.ts +73 -18
  361. package/src/testing/node/scratch-workspace.ts +9 -4
  362. package/src/testing/node/spawned-server.ts +35 -1
  363. package/src/testing/playwright/flaky-network-proxy.ts +240 -0
  364. package/src/testing/playwright/index.ts +1 -0
  365. package/src/testing/playwright/server-log-capture.ts +24 -5
  366. package/src/testing/playwright/server-log-rename-reporter.ts +12 -1
  367. package/src/testing/stub-ast-document-manager.ts +10 -14
  368. package/src/testing/stub-document-builder.ts +32 -3
  369. package/src/testing/stub-langium-documents.ts +3 -2
  370. package/src/testing/stub-model-service.ts +7 -6
  371. package/lib/lsp/instrument-connection.d.ts +0 -36
  372. package/lib/lsp/instrument-connection.d.ts.map +0 -1
  373. package/lib/lsp/instrument-connection.js +0 -62
  374. package/lib/lsp/instrument-connection.js.map +0 -1
  375. package/src/lsp/instrument-connection.ts +0 -66
package/lib/lsp/index.js CHANGED
@@ -7,7 +7,7 @@
7
7
  * SPDX-License-Identifier: MIT
8
8
  ********************************************************************************/
9
9
  export * from './completion/hydranium-completion-provider.js';
10
- export * from './instrument-connection.js';
10
+ export * from './lsp-latency.js';
11
11
  export * from './semantic-token-provider.js';
12
12
  export * from './language-module.js';
13
13
  export * from './shared-module.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/lsp/index.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,cAAc,+CAA+C,CAAC;AAC9D,cAAc,4BAA4B,CAAC;AAC3C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wCAAwC,CAAC;AAEvD;;;;;;GAMG;AACH,cAAc,4BAA4B,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/lsp/index.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,cAAc,+CAA+C,CAAC;AAC9D,cAAc,kBAAkB,CAAC;AACjC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wCAAwC,CAAC;AAEvD;;;;;;GAMG;AACH,cAAc,4BAA4B,CAAC"}
@@ -0,0 +1,39 @@
1
+ /********************************************************************************
2
+ * Copyright (c) 2026 CrossBreeze, EclipseSource and others.
3
+ *
4
+ * This program and the accompanying materials are made available under the
5
+ * terms of the MIT License which is available in the project root.
6
+ *
7
+ * SPDX-License-Identifier: MIT
8
+ ********************************************************************************/
9
+ import type { LatencyCollector } from '@hydranium/protocol';
10
+ import type { ConnectionOptions } from 'vscode-jsonrpc';
11
+ /**
12
+ * Connection options that time every inbound LSP message into `latency` under
13
+ * its method name — the LSP analog of the data-server RPC chokepoint.
14
+ *
15
+ * Pass the result to `createConnection` where the head builds its connection:
16
+ * `createConnection(ProposedFeatures.all, lspLatencyOptions(latency))`. The
17
+ * transport is untouched, so a head keeps whatever `--stdio` / `--socket`
18
+ * selection its arguments make.
19
+ *
20
+ * **`messageStrategy` is the seam because it is the only one the handlers
21
+ * actually pass through.** `vscode-languageserver` builds its `Connection` as an
22
+ * object whose `onHover`, `onCompletion` and every other named helper register
23
+ * against the inner protocol connection captured in their closure — not against
24
+ * the returned object's own `onRequest`. Langium registers exclusively through
25
+ * those helpers, so decorating the `Connection` reaches none of them and reports
26
+ * an empty LSP half no matter how much traffic ran. `handleMessage` sits on the
27
+ * dispatch path itself, which every request and notification crosses, so it also
28
+ * catches `initialize` — special-cased into `onInitialize` and invisible to any
29
+ * `onRequest` decoration.
30
+ *
31
+ * What it measures is **dispatch plus handler**, not handler alone: the wait a
32
+ * client actually experiences, including time queued behind other work.
33
+ *
34
+ * When `latency` is `undefined` the seam is off and this returns `undefined`, so
35
+ * a head can pass the result of an env-gated factory (`latencyFromEnv()`)
36
+ * straight through and pay nothing when timing is not enabled.
37
+ */
38
+ export declare function lspLatencyOptions(latency: LatencyCollector | undefined): ConnectionOptions | undefined;
39
+ //# sourceMappingURL=lsp-latency.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lsp-latency.d.ts","sourceRoot":"","sources":["../../src/lsp/lsp-latency.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,KAAK,EAAE,iBAAiB,EAAW,MAAM,gBAAgB,CAAC;AAEjE;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,gBAAgB,GAAG,SAAS,GAAG,iBAAiB,GAAG,SAAS,CAiBtG"}
@@ -0,0 +1,58 @@
1
+ /********************************************************************************
2
+ * Copyright (c) 2026 CrossBreeze, EclipseSource and others.
3
+ *
4
+ * This program and the accompanying materials are made available under the
5
+ * terms of the MIT License which is available in the project root.
6
+ *
7
+ * SPDX-License-Identifier: MIT
8
+ ********************************************************************************/
9
+ /**
10
+ * Connection options that time every inbound LSP message into `latency` under
11
+ * its method name — the LSP analog of the data-server RPC chokepoint.
12
+ *
13
+ * Pass the result to `createConnection` where the head builds its connection:
14
+ * `createConnection(ProposedFeatures.all, lspLatencyOptions(latency))`. The
15
+ * transport is untouched, so a head keeps whatever `--stdio` / `--socket`
16
+ * selection its arguments make.
17
+ *
18
+ * **`messageStrategy` is the seam because it is the only one the handlers
19
+ * actually pass through.** `vscode-languageserver` builds its `Connection` as an
20
+ * object whose `onHover`, `onCompletion` and every other named helper register
21
+ * against the inner protocol connection captured in their closure — not against
22
+ * the returned object's own `onRequest`. Langium registers exclusively through
23
+ * those helpers, so decorating the `Connection` reaches none of them and reports
24
+ * an empty LSP half no matter how much traffic ran. `handleMessage` sits on the
25
+ * dispatch path itself, which every request and notification crosses, so it also
26
+ * catches `initialize` — special-cased into `onInitialize` and invisible to any
27
+ * `onRequest` decoration.
28
+ *
29
+ * What it measures is **dispatch plus handler**, not handler alone: the wait a
30
+ * client actually experiences, including time queued behind other work.
31
+ *
32
+ * When `latency` is `undefined` the seam is off and this returns `undefined`, so
33
+ * a head can pass the result of an env-gated factory (`latencyFromEnv()`)
34
+ * straight through and pay nothing when timing is not enabled.
35
+ */
36
+ export function lspLatencyOptions(latency) {
37
+ if (!latency) {
38
+ return undefined;
39
+ }
40
+ return {
41
+ messageStrategy: {
42
+ handleMessage: (message, next) => {
43
+ // Responses to requests the SERVER sent carry no method and are not
44
+ // work this head performed; timing them would report the client's
45
+ // latency under a name this collector cannot supply.
46
+ if (!hasMethod(message)) {
47
+ return next(message);
48
+ }
49
+ return latency.time(message.method, () => next(message));
50
+ }
51
+ }
52
+ };
53
+ }
54
+ /** Narrow to the messages that name an operation — requests and notifications. */
55
+ function hasMethod(message) {
56
+ return typeof message.method === 'string';
57
+ }
58
+ //# sourceMappingURL=lsp-latency.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lsp-latency.js","sourceRoot":"","sources":["../../src/lsp/lsp-latency.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAKlF;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,UAAU,iBAAiB,CAAC,OAAqC;IACpE,IAAI,CAAC,OAAO,EAAE,CAAC;QACZ,OAAO,SAAS,CAAC;IACpB,CAAC;IACD,OAAO;QACJ,eAAe,EAAE;YACd,aAAa,EAAE,CAAC,OAAgB,EAAE,IAAgD,EAAE,EAAE;gBACnF,oEAAoE;gBACpE,kEAAkE;gBAClE,qDAAqD;gBACrD,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC;oBACvB,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;gBACxB,CAAC;gBACD,OAAO,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;YAC5D,CAAC;SACH;KACH,CAAC;AACL,CAAC;AAED,kFAAkF;AAClF,SAAS,SAAS,CAAC,OAAgB;IAChC,OAAO,OAAQ,OAAgC,CAAC,MAAM,KAAK,QAAQ,CAAC;AACvE,CAAC"}
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * SPDX-License-Identifier: MIT
8
8
  ********************************************************************************/
9
- import { type AstNode, type AstReflection, type LangiumDocument, type ReferenceInfo } from '@hydranium/langium';
9
+ import { type AstNode, type AstReflection, type LangiumDocument, type LeafCstNode, type ReferenceInfo } from '@hydranium/langium';
10
10
  import { AbstractSemanticTokenProvider, type SemanticTokenAcceptor } from '@hydranium/langium/lsp';
11
11
  import { type CancellationToken } from 'vscode-languageserver';
12
12
  import { type NameProvider } from '../langium/naming/name-provider.js';
@@ -37,6 +37,22 @@ export interface HydraniumSemanticTokenProviderOptions {
37
37
  * render in the editor's default foreground.
38
38
  */
39
39
  readonly highlightKeywords?: boolean;
40
+ /**
41
+ * Also emit a `comment` token for every comment leaf of the CST.
42
+ *
43
+ * OFF by default for the same reason as {@link highlightKeywords}, and the
44
+ * loss is larger: a TextMate grammar distinguishes `comment.line` from
45
+ * `comment.block` and scopes the delimiters separately, where a semantic
46
+ * token carries one flat `comment` that overrides all of them. It exists
47
+ * for the host that ships no client-side grammar, where a comment otherwise
48
+ * renders in the editor's default foreground.
49
+ *
50
+ * What counts as a comment is every hidden terminal the lexer retains,
51
+ * which is every hidden terminal whose pattern is not whitespace. A grammar
52
+ * whose hidden non-whitespace terminal means something other than a comment
53
+ * is miscoloured, and this option is the place to say no.
54
+ */
55
+ readonly highlightComments?: boolean;
40
56
  }
41
57
  /**
42
58
  * Semantic-token provider that derives highlighting from ONE adopter-supplied
@@ -102,6 +118,23 @@ export declare abstract class AbstractHydraniumSemanticTokenProvider extends Abs
102
118
  * drops anything outside `currentRange` on its own.
103
119
  */
104
120
  protected computeHighlighting(document: LangiumDocument, acceptor: SemanticTokenAcceptor, cancelToken: CancellationToken): Promise<void>;
121
+ /**
122
+ * Emit a comment as ONE TOKEN PER LINE, never as one multi-line range.
123
+ *
124
+ * A block comment is the first token this provider emits that can span
125
+ * lines, and the upstream encoder mishandles that for a client which does
126
+ * not advertise `multilineTokenSupport` — the split path computes the first
127
+ * line's length as `nextLineOffset - range.start.character - 1`, subtracting
128
+ * a COLUMN from a document OFFSET, so the length is right only for a token
129
+ * starting on line 0 and overruns its line everywhere else. No client in
130
+ * this repository advertises that capability, so the broken path is the one
131
+ * taken. Splitting here means every range handed over starts and ends on one
132
+ * line and the arithmetic is never reached.
133
+ *
134
+ * Lines come from the leaf's own text rather than from the document, so
135
+ * nothing has to re-derive where the comment ends.
136
+ */
137
+ protected acceptComment(cst: LeafCstNode, acceptor: SemanticTokenAcceptor): void;
105
138
  protected highlightElement(node: AstNode, acceptor: SemanticTokenAcceptor): void | undefined | 'prune';
106
139
  /** Colour the node's own name, at whichever property the NameProvider reads it from. */
107
140
  protected highlightDeclaration(node: AstNode, acceptor: SemanticTokenAcceptor): void;
@@ -1 +1 @@
1
- {"version":3,"file":"semantic-token-provider.d.ts","sourceRoot":"","sources":["../../src/lsp/semantic-token-provider.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EACJ,KAAK,OAAO,EACZ,KAAK,aAAa,EAKlB,KAAK,eAAe,EACpB,KAAK,aAAa,EACpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,6BAA6B,EAAE,KAAK,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AACnG,OAAO,EAAE,KAAK,iBAAiB,EAA8C,MAAM,uBAAuB,CAAC;AAC3G,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,oCAAoC,CAAC;AACvE,OAAO,EAAE,KAAK,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAE5E;;;;;GAKG;AACH,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG;IAAE,QAAQ,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uF;IACvF,SAAS,CAAC,eAAe,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS;CAG9D"}
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * SPDX-License-Identifier: MIT
8
8
  ********************************************************************************/
9
- import { AstUtils, CstUtils, GrammarAST, interruptAndCheck } from '@hydranium/langium';
9
+ import { AstUtils, CstUtils, GrammarAST, interruptAndCheck, isLeafCstNode } from '@hydranium/langium';
10
10
  import { AbstractSemanticTokenProvider } from '@hydranium/langium/lsp';
11
11
  import { SemanticTokenModifiers, SemanticTokenTypes } from 'vscode-languageserver';
12
12
  /** Normalise both {@link SemanticTokenKind} forms to the acceptor's shape. */
@@ -86,7 +86,9 @@ export class AbstractHydraniumSemanticTokenProvider extends AbstractSemanticToke
86
86
  */
87
87
  async computeHighlighting(document, acceptor, cancelToken) {
88
88
  await super.computeHighlighting(document, acceptor, cancelToken);
89
- if (this.options.highlightKeywords !== true) {
89
+ const keywords = this.options.highlightKeywords === true;
90
+ const comments = this.options.highlightComments === true;
91
+ if (!keywords && !comments) {
90
92
  return;
91
93
  }
92
94
  const root = document.parseResult.value.$cstNode;
@@ -95,14 +97,59 @@ export class AbstractHydraniumSemanticTokenProvider extends AbstractSemanticToke
95
97
  }
96
98
  for (const cst of CstUtils.streamCst(root)) {
97
99
  await interruptAndCheck(cancelToken);
98
- // The grammar source is the whole filter. A keyword is always a leaf,
99
- // and the hidden leaves a comment or a run of whitespace contributes
100
- // are sourced from a terminal rule rather than a `Keyword` — so
101
- // neither a composite-node check nor a hidden-token check adds
102
- // anything here.
103
- if (GrammarAST.isKeyword(cst.grammarSource)) {
100
+ // A keyword is always a leaf with a `Keyword` grammar source, so that
101
+ // check alone separates it from everything else in the walk.
102
+ if (keywords && GrammarAST.isKeyword(cst.grammarSource)) {
104
103
  acceptor({ cst, type: SemanticTokenTypes.keyword });
105
104
  }
105
+ // A comment leaf cannot be recognised the same way — the CST builder
106
+ // adds hidden nodes from the token alone, so `grammarSource` is
107
+ // undefined, which is also why the keyword filter never matches one.
108
+ //
109
+ // `hidden` alone IS the comment test, and nothing narrower is needed:
110
+ // the token builder groups a hidden terminal as `Lexer.SKIPPED` when
111
+ // its pattern matches whitespace and as `hidden` otherwise, so the
112
+ // lexer discards whitespace before a CST node is ever built and every
113
+ // hidden leaf that survives is a comment. Classifying the terminal
114
+ // again here would be a second guard for the same property, which no
115
+ // test could then distinguish. An adopter whose token builder RETAINS
116
+ // whitespace breaks that equivalence and would colour its gaps.
117
+ if (comments && isLeafCstNode(cst) && cst.hidden) {
118
+ this.acceptComment(cst, acceptor);
119
+ }
120
+ }
121
+ }
122
+ /**
123
+ * Emit a comment as ONE TOKEN PER LINE, never as one multi-line range.
124
+ *
125
+ * A block comment is the first token this provider emits that can span
126
+ * lines, and the upstream encoder mishandles that for a client which does
127
+ * not advertise `multilineTokenSupport` — the split path computes the first
128
+ * line's length as `nextLineOffset - range.start.character - 1`, subtracting
129
+ * a COLUMN from a document OFFSET, so the length is right only for a token
130
+ * starting on line 0 and overruns its line everywhere else. No client in
131
+ * this repository advertises that capability, so the broken path is the one
132
+ * taken. Splitting here means every range handed over starts and ends on one
133
+ * line and the arithmetic is never reached.
134
+ *
135
+ * Lines come from the leaf's own text rather than from the document, so
136
+ * nothing has to re-derive where the comment ends.
137
+ */
138
+ acceptComment(cst, acceptor) {
139
+ const lines = cst.text.split('\n');
140
+ for (let index = 0; index < lines.length; index++) {
141
+ // A `\r\n` document leaves the carriage return on the line's end;
142
+ // colouring it would extend the token past the visible text.
143
+ const length = lines[index].replace(/\r$/, '').length;
144
+ const character = index === 0 ? cst.range.start.character : 0;
145
+ if (length === 0) {
146
+ continue;
147
+ }
148
+ const line = cst.range.start.line + index;
149
+ acceptor({
150
+ range: { start: { line, character }, end: { line, character: character + length } },
151
+ type: SemanticTokenTypes.comment
152
+ });
106
153
  }
107
154
  }
108
155
  highlightElement(node, acceptor) {
@@ -1 +1 @@
1
- {"version":3,"file":"semantic-token-provider.js","sourceR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CAAC,IAAI,CAAC,CAAC;IAClD,CAAC;CACH"}
@@ -0,0 +1,54 @@
1
+ /********************************************************************************
2
+ * Copyright (c) 2026 CrossBreeze, EclipseSource and others.
3
+ *
4
+ * This program and the accompanying materials are made available under the
5
+ * terms of the MIT License which is available in the project root.
6
+ *
7
+ * SPDX-License-Identifier: MIT
8
+ ********************************************************************************/
9
+ import { type MessageDefinition, type ParamsArg, type ResolvedMessage } from '@hydranium/protocol';
10
+ import type { AstNode, DiagnosticData, DiagnosticInfo, Properties, ValidationAcceptor } from '@hydranium/langium';
11
+ import { Diagnostic } from 'vscode-languageserver-protocol';
12
+ /**
13
+ * Raise a validation diagnostic from a declaration, so the call site never
14
+ * restates the code or the sentence.
15
+ *
16
+ * `code` is omitted from `info` because this owns it — the framework claims LSP
17
+ * `Diagnostic.code` for framework codes, which collides with no adopter today
18
+ * and is a stated rule rather than an accident. `data` is deliberately NOT
19
+ * omitted: Langium owns `data.code` for code-action dispatch, so a caller has to
20
+ * be able to request a quick fix. The identity is merged OVER whatever they
21
+ * pass, which makes the two conventions co-exist rather than compete.
22
+ *
23
+ * `data` admits adopter-owned keys beside Langium's, which is why the index
24
+ * signature is there rather than a bare `Partial<DiagnosticData>`. Langium's
25
+ * shape is closed, and a diagnostic that carries a COMPANION payload for its own
26
+ * surface to read — the field a form must highlight, say — has nowhere else to
27
+ * put it: an encoder projecting that payload reads `diagnostic.data`, so the
28
+ * narrower type made the identity and the companion mutually exclusive.
29
+ *
30
+ * The identity lands in both `code` and `data.hydranium` on purpose. `code` is
31
+ * what survives to the editor surface; Theia's converter drops `data` before the
32
+ * squiggle, so a parameterised diagnostic falls back to the server's English
33
+ * there while any adopter-owned surface can still render the parameterised form
34
+ * from the marker store.
35
+ *
36
+ * `DiagnosticInfo` must be Langium's own type: a `Parameters<ValidationAcceptor>[2]`
37
+ * shortcut compiles but loses the `property?: Properties<N>` relation. The `data`
38
+ * re-type has to be an intersection rather than an `Omit` alone, because Langium
39
+ * declares `data?: unknown` and an `unknown` cannot be spread.
40
+ */
41
+ export declare function acceptMessage<S extends string, N extends AstNode, P extends Properties<N> = Properties<N>>(accept: ValidationAcceptor, severity: 'error' | 'warning' | 'info' | 'hint', message: MessageDefinition<S>, info: Omit<DiagnosticInfo<N, P>, 'code' | 'data'> & {
42
+ data?: Partial<DiagnosticData> & Record<string, unknown>;
43
+ }, ...params: ParamsArg<S>): void;
44
+ /**
45
+ * Recover the identity from a published diagnostic, for a surface that
46
+ * identifies or renders diagnostics itself.
47
+ *
48
+ * `Diagnostic.message` is `string | MarkupContent` in LSP 3.17+, so the text
49
+ * comes from upstream's own `Diagnostic.getMessageString` rather than a
50
+ * hand-rolled narrowing — consuming the library in its style, and one fewer
51
+ * place restating the union.
52
+ */
53
+ export declare function resolvedFromDiagnostic(diagnostic: Diagnostic): ResolvedMessage | undefined;
54
+ //# sourceMappingURL=carriers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"carriers.d.ts","sourceRoot":"","sources":["../../src/messages/carriers.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAIJ,KAAK,iBAAiB,EACtB,KAAK,SAAS,EACd,KAAK,eAAe,EACtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAClH,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAE5D;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,OAAO,EAAE,CAAC,SAAS,UAAU,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,EACvG,MAAM,EAAE,kBAAkB,EAC1B,QAAQ,EAAE,OAAO,GAAG,SAAS,GAAG,MAAM,GAAG,MAAM,EAC/C,OAAO,EAAE,iBAAiB,CAAC,CAAC,CAAC,EAC7B,IAAI,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,GAAG;IAAE,IAAI,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,EAChH,GAAG,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC,GACvB,IAAI,CAMN;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,UAAU,GAAG,eAAe,GAAG,SAAS,CAK1F"}
@@ -0,0 +1,62 @@
1
+ /********************************************************************************
2
+ * Copyright (c) 2026 CrossBreeze, EclipseSource and others.
3
+ *
4
+ * This program and the accompanying materials are made available under the
5
+ * terms of the MIT License which is available in the project root.
6
+ *
7
+ * SPDX-License-Identifier: MIT
8
+ ********************************************************************************/
9
+ import { hasMessageIdentity, messageData } from '@hydranium/protocol';
10
+ import { Diagnostic } from 'vscode-languageserver-protocol';
11
+ /**
12
+ * Raise a validation diagnostic from a declaration, so the call site never
13
+ * restates the code or the sentence.
14
+ *
15
+ * `code` is omitted from `info` because this owns it — the framework claims LSP
16
+ * `Diagnostic.code` for framework codes, which collides with no adopter today
17
+ * and is a stated rule rather than an accident. `data` is deliberately NOT
18
+ * omitted: Langium owns `data.code` for code-action dispatch, so a caller has to
19
+ * be able to request a quick fix. The identity is merged OVER whatever they
20
+ * pass, which makes the two conventions co-exist rather than compete.
21
+ *
22
+ * `data` admits adopter-owned keys beside Langium's, which is why the index
23
+ * signature is there rather than a bare `Partial<DiagnosticData>`. Langium's
24
+ * shape is closed, and a diagnostic that carries a COMPANION payload for its own
25
+ * surface to read — the field a form must highlight, say — has nowhere else to
26
+ * put it: an encoder projecting that payload reads `diagnostic.data`, so the
27
+ * narrower type made the identity and the companion mutually exclusive.
28
+ *
29
+ * The identity lands in both `code` and `data.hydranium` on purpose. `code` is
30
+ * what survives to the editor surface; Theia's converter drops `data` before the
31
+ * squiggle, so a parameterised diagnostic falls back to the server's English
32
+ * there while any adopter-owned surface can still render the parameterised form
33
+ * from the marker store.
34
+ *
35
+ * `DiagnosticInfo` must be Langium's own type: a `Parameters<ValidationAcceptor>[2]`
36
+ * shortcut compiles but loses the `property?: Properties<N>` relation. The `data`
37
+ * re-type has to be an intersection rather than an `Omit` alone, because Langium
38
+ * declares `data?: unknown` and an `unknown` cannot be spread.
39
+ */
40
+ export function acceptMessage(accept, severity, message, info, ...params) {
41
+ const data = {
42
+ ...info.data,
43
+ ...messageData(message, ...params)
44
+ };
45
+ accept(severity, message.format(...params), { ...info, code: message.code, data });
46
+ }
47
+ /**
48
+ * Recover the identity from a published diagnostic, for a surface that
49
+ * identifies or renders diagnostics itself.
50
+ *
51
+ * `Diagnostic.message` is `string | MarkupContent` in LSP 3.17+, so the text
52
+ * comes from upstream's own `Diagnostic.getMessageString` rather than a
53
+ * hand-rolled narrowing — consuming the library in its style, and one fewer
54
+ * place restating the union.
55
+ */
56
+ export function resolvedFromDiagnostic(diagnostic) {
57
+ if (!hasMessageIdentity(diagnostic.data)) {
58
+ return undefined;
59
+ }
60
+ return { ...diagnostic.data.hydranium, text: Diagnostic.getMessageString(diagnostic) };
61
+ }
62
+ //# sourceMappingURL=carriers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"carriers.js","sourceRoot":"","sources":["../../src/messages/carriers.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EACJ,kBAAkB,EAClB,WAAW,EAKb,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAE5D;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,UAAU,aAAa,CAC1B,MAA0B,EAC1B,QAA+C,EAC/C,OAA6B,EAC7B,IAAgH,EAChH,GAAG,MAAoB;IAEvB,MAAM,IAAI,GAA6E;QACpF,GAAG,IAAI,CAAC,IAAI;QACZ,GAAG,WAAW,CAAC,OAAO,EAAE,GAAG,MAAM,CAAC;KACpC,CAAC;IACF,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,EAAE,EAAE,GAAG,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;AACtF,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,sBAAsB,CAAC,UAAsB;IAC1D,IAAI,CAAC,kBAAkB,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QACxC,OAAO,SAAS,CAAC;IACpB,CAAC;IACD,OAAO,EAAE,GAAG,UAAU,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,UAAU,CAAC,gBAAgB,CAAC,UAAU,CAAC,EAAE,CAAC;AAC1F,CAAC"}
@@ -0,0 +1,25 @@
1
+ /********************************************************************************
2
+ * Copyright (c) 2026 CrossBreeze, EclipseSource and others.
3
+ *
4
+ * This program and the accompanying materials are made available under the
5
+ * terms of the MIT License which is available in the project root.
6
+ *
7
+ * SPDX-License-Identifier: MIT
8
+ ********************************************************************************/
9
+ /**
10
+ * Every user-facing message `@hydranium/core` raises, plus the carrier helpers
11
+ * that attach an identity to one.
12
+ *
13
+ * Declarations stay beside their call sites and are re-exported here, so this is
14
+ * enumeration rather than centralization: a code's package segment has to name
15
+ * the package that raises it. The English is a fallback, not a contract; the
16
+ * code is the contract, and renaming one is a breaking change.
17
+ */
18
+ export * from './carriers.js';
19
+ export * from './renderer.js';
20
+ export { MODEL_UPDATE_EDIT } from '../langium/model-service/model-service.js';
21
+ export { SEPARATOR_IN_NAME } from '../langium/naming/name-separator-validation.js';
22
+ export { INVALID_DEDENT, UNEXPECTED_CHARACTER, MISSING_ITERATION, NO_VIABLE_ALTERNATIVE, TRAILING_INPUT, UNEXPECTED_TOKEN, UNPOPPABLE_LEXER_MODE, UNRESOLVED_REFERENCE } from '../langium/validation/document-validator.js';
23
+ export { NO_LOADABLE_CONTENT } from '../langium/workspace/langium-documents.js';
24
+ export { NO_SUCH_FILE, NO_SUCH_PATH, UNSUPPORTED_WRITE } from '../langium/workspace/in-memory-file-system-provider.js';
25
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/messages/index.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF;;;;;;;;GAQG;AAEH,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAE9B,OAAO,EAAE,iBAAiB,EAAE,MAAM,2CAA2C,CAAC;AAC9E,OAAO,EAAE,iBAAiB,EAAE,MAAM,gDAAgD,CAAC;AACnF,OAAO,EACJ,cAAc,EACd,oBAAoB,EACpB,iBAAiB,EACjB,qBAAqB,EACrB,cAAc,EACd,gBAAgB,EAChB,qBAAqB,EACrB,oBAAoB,EACtB,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AAChF,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,wDAAwD,CAAC"}
@@ -0,0 +1,25 @@
1
+ /********************************************************************************
2
+ * Copyright (c) 2026 CrossBreeze, EclipseSource and others.
3
+ *
4
+ * This program and the accompanying materials are made available under the
5
+ * terms of the MIT License which is available in the project root.
6
+ *
7
+ * SPDX-License-Identifier: MIT
8
+ ********************************************************************************/
9
+ /**
10
+ * Every user-facing message `@hydranium/core` raises, plus the carrier helpers
11
+ * that attach an identity to one.
12
+ *
13
+ * Declarations stay beside their call sites and are re-exported here, so this is
14
+ * enumeration rather than centralization: a code's package segment has to name
15
+ * the package that raises it. The English is a fallback, not a contract; the
16
+ * code is the contract, and renaming one is a breaking change.
17
+ */
18
+ export * from './carriers.js';
19
+ export * from './renderer.js';
20
+ export { MODEL_UPDATE_EDIT } from '../langium/model-service/model-service.js';
21
+ export { SEPARATOR_IN_NAME } from '../langium/naming/name-separator-validation.js';
22
+ export { INVALID_DEDENT, UNEXPECTED_CHARACTER, MISSING_ITERATION, NO_VIABLE_ALTERNATIVE, TRAILING_INPUT, UNEXPECTED_TOKEN, UNPOPPABLE_LEXER_MODE, UNRESOLVED_REFERENCE } from '../langium/validation/document-validator.js';
23
+ export { NO_LOADABLE_CONTENT } from '../langium/workspace/langium-documents.js';
24
+ export { NO_SUCH_FILE, NO_SUCH_PATH, UNSUPPORTED_WRITE } from '../langium/workspace/in-memory-file-system-provider.js';
25
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/messages/index.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF;;;;;;;;GAQG;AAEH,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAE9B,OAAO,EAAE,iBAAiB,EAAE,MAAM,2CAA2C,CAAC;AAC9E,OAAO,EAAE,iBAAiB,EAAE,MAAM,gDAAgD,CAAC;AACnF,OAAO,EACJ,cAAc,EACd,oBAAoB,EACpB,iBAAiB,EACjB,qBAAqB,EACrB,cAAc,EACd,gBAAgB,EAChB,qBAAqB,EACrB,oBAAoB,EACtB,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AAChF,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,wDAAwD,CAAC"}
@@ -0,0 +1,136 @@
1
+ /********************************************************************************
2
+ * Copyright (c) 2026 CrossBreeze, EclipseSource and others.
3
+ *
4
+ * This program and the accompanying materials are made available under the
5
+ * terms of the MIT License which is available in the project root.
6
+ *
7
+ * SPDX-License-Identifier: MIT
8
+ ********************************************************************************/
9
+ import { type MessageDefinition, type ParamsArg, type ResolvedMessage, type Tracer } from '@hydranium/protocol';
10
+ import { SimpleCache } from '@hydranium/langium';
11
+ import type { ResponseError } from 'vscode-jsonrpc';
12
+ import { Diagnostic } from 'vscode-languageserver-protocol';
13
+ import { type LogNameOptions } from '../langium/diagnostics/logger.js';
14
+ import type { ServerSharedServicesMinimal } from '../langium/shared-services.js';
15
+ import type { ServerLocale } from '../locale/server-locale.js';
16
+ /** Construction options for {@link DefaultMessageRenderer}. */
17
+ export type MessageRendererOptions = LogNameOptions;
18
+ /**
19
+ * The render contract the `MessageRenderer` slot holds, implemented by
20
+ * {@link DefaultMessageRenderer}.
21
+ *
22
+ * An interface rather than the class, so the slot is compared STRUCTURALLY. A
23
+ * class-typed slot carries its `protected` members into every assignability
24
+ * check and TypeScript compares those nominally — which makes the slot
25
+ * unsatisfiable by a subclass declared against a second physical copy of this
26
+ * package, which any duplicated install produces. It also
27
+ * lets an adopter REPLACE this declaration rather than intersect with it, so
28
+ * slot resolution does not depend on the order a services type is written in.
29
+ *
30
+ * Every method carries a no-throw contract; see the implementation.
31
+ */
32
+ export interface MessageRenderer {
33
+ renderDiagnostic(diagnostic: Diagnostic): string;
34
+ renderError(error: ResponseError<unknown>): string;
35
+ renderMessage<S extends string>(message: MessageDefinition<S>, ...params: ParamsArg<S>): string;
36
+ }
37
+ /**
38
+ * Renders every user-facing message the server sends, in the locale the server
39
+ * was handed at init. The framework ships no catalogue, so its own behaviour is
40
+ * a pass-through.
41
+ *
42
+ * Adopters override {@link translationsFor}: the public render methods carry
43
+ * the no-throw contract, and the catalogue lookup they wrap is what can fail.
44
+ *
45
+ * Two render methods rather than one, because what is useful to an adopter is
46
+ * the carrier's structured fields and the two carriers have different ones. A
47
+ * single `render(text)` would force an adopter to match English prose, which
48
+ * breaks on the first Langium reword.
49
+ */
50
+ export declare class DefaultMessageRenderer implements MessageRenderer {
51
+ protected readonly tracer: Tracer;
52
+ protected readonly serverLocale: ServerLocale;
53
+ /**
54
+ * {@link translationsFor}'s answer per locale, `undefined` answers included —
55
+ * a `SimpleCache` distinguishes "absent" from "cached as none", which matters
56
+ * because shipping no catalogue is the framework's own hot path.
57
+ *
58
+ * `SimpleCache` rather than Langium's `WorkspaceCache`: the eviction axis
59
+ * there is document change, and a catalogue does not depend on documents, so
60
+ * it would evict on every build AND put a `DocumentBuilder` dependency on a
61
+ * service the shared tier declares free of one. Nothing evicts this: the
62
+ * locale arrives once per process. A subclass whose catalogue can change
63
+ * clears it.
64
+ */
65
+ protected readonly catalogues: SimpleCache<string | undefined, Record<string, string> | undefined>;
66
+ constructor(services: ServerSharedServicesMinimal, options?: MessageRendererOptions);
67
+ /**
68
+ * The sentence to publish for `diagnostic`, replacing its current `message`.
69
+ * Sees lexer and parser errors too, which Langium pushes onto the document
70
+ * without routing them through `toDiagnostic`.
71
+ *
72
+ * **Must not throw**, which is why the guard is here and not at the call
73
+ * site: this runs inside the `Validated` phase, and Langium's
74
+ * `notifyDocumentPhase` rethrows anything that is not a cancellation — so an
75
+ * escaping error leaves the document AT `Validated` with the phase's
76
+ * listeners never run, and the client receives no diagnostics for that file.
77
+ * A subclass overriding this method takes that contract on itself.
78
+ */
79
+ renderDiagnostic(diagnostic: Diagnostic): string;
80
+ /**
81
+ * The sentence to send for `error`, replacing its current `message`. Same
82
+ * no-throw contract as {@link renderDiagnostic}: an escaping error replaces a
83
+ * typed rejection the caller can handle with one it cannot.
84
+ */
85
+ renderError(error: ResponseError<unknown>): string;
86
+ /**
87
+ * The sentence for a declaration the caller holds directly, for a carrier
88
+ * with no slot to put an identity in.
89
+ *
90
+ * GLSP's action protocol is the case: every member of its message, status
91
+ * and reject actions is prose or an enum, so a code cannot travel and the
92
+ * raise site is the last place that still knows which message this is.
93
+ * Prefer {@link renderDiagnostic} / {@link renderError} wherever a carrier
94
+ * does hold the identity — they keep the render off the raise site, so an
95
+ * adopter's own messages ride the same one binding.
96
+ *
97
+ * Same no-throw contract as the carrier methods.
98
+ */
99
+ renderMessage<S extends string>(message: MessageDefinition<S>, ...params: ParamsArg<S>): string;
100
+ /**
101
+ * The catalogue for the current locale, or `undefined` for none — the
102
+ * framework's answer, shipping none. Overriding this leaves every identity
103
+ * decision, every pass-through and the no-throw guard in place.
104
+ *
105
+ * **Called once per locale, not once per message**, so an override may load
106
+ * a file or build a map without that cost landing per diagnostic. The
107
+ * corollary is that a catalogue mutated in place afterwards is not seen;
108
+ * clear {@link catalogues} to invalidate.
109
+ *
110
+ * An adopter wanting Langium's own uncoded sentences instead matches
111
+ * `Diagnostic.data.code` from an overridden {@link renderDiagnostic}, never
112
+ * the sentence.
113
+ */
114
+ protected translationsFor(_locale: string | undefined): Record<string, string> | undefined;
115
+ /**
116
+ * Resolve one identity against the current locale's catalogue.
117
+ *
118
+ * Reads the locale per call. Copying it into a field at construction pins
119
+ * whatever was there before init ran, which is always `undefined` — services
120
+ * compose first.
121
+ *
122
+ * The catalogue behind it is memoized, because a workspace-wide validation
123
+ * renders once per diagnostic and the naive override — parse a JSON file,
124
+ * build a map — then pays that per diagnostic rather than per locale.
125
+ */
126
+ protected render(message: ResolvedMessage): string;
127
+ /**
128
+ * Emit a failed render. Logged rather than swallowed: the fallback output is
129
+ * byte-identical to a correctly-configured default, so a throwing catalogue
130
+ * is otherwise invisible.
131
+ */
132
+ protected reportFailure(err: unknown, carrier: string): void;
133
+ /** Format the failed-render line. Override to name the adopter's catalogue entry. */
134
+ protected formatRenderFailure(err: unknown, carrier: string): string;
135
+ }
136
+ //# sourceMappingURL=renderer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../../src/messages/renderer.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAKJ,KAAK,iBAAiB,EACtB,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,KAAK,MAAM,EACb,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,KA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