@hydranium/core 1.0.0-next.11 → 1.0.0-next.111

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 (415) 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 +23 -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/completion/hydranium-completion-provider.d.ts +44 -2
  192. package/lib/lsp/completion/hydranium-completion-provider.d.ts.map +1 -1
  193. package/lib/lsp/completion/hydranium-completion-provider.js +68 -0
  194. package/lib/lsp/completion/hydranium-completion-provider.js.map +1 -1
  195. package/lib/lsp/connection-features.d.ts +23 -0
  196. package/lib/lsp/connection-features.d.ts.map +1 -0
  197. package/lib/lsp/connection-features.js +60 -0
  198. package/lib/lsp/connection-features.js.map +1 -0
  199. package/lib/lsp/diagnostics-connection.d.ts +27 -0
  200. package/lib/lsp/diagnostics-connection.d.ts.map +1 -0
  201. package/lib/lsp/diagnostics-connection.js +53 -0
  202. package/lib/lsp/diagnostics-connection.js.map +1 -0
  203. package/lib/lsp/hydranium-document-update-handler.d.ts.map +1 -1
  204. package/lib/lsp/hydranium-document-update-handler.js +10 -1
  205. package/lib/lsp/hydranium-document-update-handler.js.map +1 -1
  206. package/lib/lsp/index.d.ts +3 -1
  207. package/lib/lsp/index.d.ts.map +1 -1
  208. package/lib/lsp/index.js +3 -1
  209. package/lib/lsp/index.js.map +1 -1
  210. package/lib/lsp/lsp-latency.d.ts +39 -0
  211. package/lib/lsp/lsp-latency.d.ts.map +1 -0
  212. package/lib/lsp/lsp-latency.js +58 -0
  213. package/lib/lsp/lsp-latency.js.map +1 -0
  214. package/lib/lsp/semantic-token-provider.d.ts +34 -1
  215. package/lib/lsp/semantic-token-provider.d.ts.map +1 -1
  216. package/lib/lsp/semantic-token-provider.js +55 -8
  217. package/lib/lsp/semantic-token-provider.js.map +1 -1
  218. package/lib/lsp/start-language-server.d.ts +5 -3
  219. package/lib/lsp/start-language-server.d.ts.map +1 -1
  220. package/lib/lsp/start-language-server.js +10 -3
  221. package/lib/lsp/start-language-server.js.map +1 -1
  222. package/lib/messages/carriers.d.ts +54 -0
  223. package/lib/messages/carriers.d.ts.map +1 -0
  224. package/lib/messages/carriers.js +62 -0
  225. package/lib/messages/carriers.js.map +1 -0
  226. package/lib/messages/index.d.ts +25 -0
  227. package/lib/messages/index.d.ts.map +1 -0
  228. package/lib/messages/index.js +25 -0
  229. package/lib/messages/index.js.map +1 -0
  230. package/lib/messages/renderer.d.ts +136 -0
  231. package/lib/messages/renderer.d.ts.map +1 -0
  232. package/lib/messages/renderer.js +159 -0
  233. package/lib/messages/renderer.js.map +1 -0
  234. package/lib/node/heap-ceiling.d.ts +61 -0
  235. package/lib/node/heap-ceiling.d.ts.map +1 -0
  236. package/lib/node/heap-ceiling.js +72 -0
  237. package/lib/node/heap-ceiling.js.map +1 -0
  238. package/lib/node/index.d.ts +1 -0
  239. package/lib/node/index.d.ts.map +1 -1
  240. package/lib/node/index.js +1 -0
  241. package/lib/node/index.js.map +1 -1
  242. package/lib/node/latency-from-env.d.ts +1 -1
  243. package/lib/node/latency-from-env.js +1 -1
  244. package/lib/node/node-file-system-provider.d.ts +35 -1
  245. package/lib/node/node-file-system-provider.d.ts.map +1 -1
  246. package/lib/node/node-file-system-provider.js +140 -45
  247. package/lib/node/node-file-system-provider.js.map +1 -1
  248. package/lib/node/profile-capture.d.ts +8 -2
  249. package/lib/node/profile-capture.d.ts.map +1 -1
  250. package/lib/node/profile-capture.js.map +1 -1
  251. package/lib/node/profiling-run.d.ts +2 -2
  252. package/lib/node/profiling-run.js +1 -1
  253. package/lib/node/profiling-run.js.map +1 -1
  254. package/lib/node/rename-over-open-readers.d.ts +52 -0
  255. package/lib/node/rename-over-open-readers.d.ts.map +1 -0
  256. package/lib/node/rename-over-open-readers.js +66 -0
  257. package/lib/node/rename-over-open-readers.js.map +1 -0
  258. package/lib/node/socket-launcher.d.ts +15 -0
  259. package/lib/node/socket-launcher.d.ts.map +1 -1
  260. package/lib/node/socket-launcher.js +3 -2
  261. package/lib/node/socket-launcher.js.map +1 -1
  262. package/lib/testing/fake-document.d.ts +16 -4
  263. package/lib/testing/fake-document.d.ts.map +1 -1
  264. package/lib/testing/fake-document.js +18 -3
  265. package/lib/testing/fake-document.js.map +1 -1
  266. package/lib/testing/make-noop-shared-services.d.ts +14 -0
  267. package/lib/testing/make-noop-shared-services.d.ts.map +1 -1
  268. package/lib/testing/make-noop-shared-services.js +28 -2
  269. package/lib/testing/make-noop-shared-services.js.map +1 -1
  270. package/lib/testing/make-test-services.d.ts +45 -9
  271. package/lib/testing/make-test-services.d.ts.map +1 -1
  272. package/lib/testing/make-test-services.js +19 -3
  273. package/lib/testing/make-test-services.js.map +1 -1
  274. package/lib/testing/node/index.d.ts +1 -0
  275. package/lib/testing/node/index.d.ts.map +1 -1
  276. package/lib/testing/node/index.js +1 -0
  277. package/lib/testing/node/index.js.map +1 -1
  278. package/lib/testing/node/lsp-server-connection.d.ts.map +1 -1
  279. package/lib/testing/node/lsp-server-connection.js +5 -6
  280. package/lib/testing/node/lsp-server-connection.js.map +1 -1
  281. package/lib/testing/node/scratch-workspace.d.ts.map +1 -1
  282. package/lib/testing/node/scratch-workspace.js +9 -4
  283. package/lib/testing/node/scratch-workspace.js.map +1 -1
  284. package/lib/testing/node/spawned-server.d.ts +14 -0
  285. package/lib/testing/node/spawned-server.d.ts.map +1 -1
  286. package/lib/testing/node/spawned-server.js +33 -1
  287. package/lib/testing/node/spawned-server.js.map +1 -1
  288. package/lib/testing/node/unhandled-rejections.d.ts +20 -0
  289. package/lib/testing/node/unhandled-rejections.d.ts.map +1 -0
  290. package/lib/testing/node/unhandled-rejections.js +32 -0
  291. package/lib/testing/node/unhandled-rejections.js.map +1 -0
  292. package/lib/testing/playwright/flaky-network-proxy.d.ts +76 -0
  293. package/lib/testing/playwright/flaky-network-proxy.d.ts.map +1 -0
  294. package/lib/testing/playwright/flaky-network-proxy.js +164 -0
  295. package/lib/testing/playwright/flaky-network-proxy.js.map +1 -0
  296. package/lib/testing/playwright/index.d.ts +1 -0
  297. package/lib/testing/playwright/index.d.ts.map +1 -1
  298. package/lib/testing/playwright/index.js +1 -0
  299. package/lib/testing/playwright/index.js.map +1 -1
  300. package/lib/testing/playwright/server-log-capture.d.ts +14 -4
  301. package/lib/testing/playwright/server-log-capture.d.ts.map +1 -1
  302. package/lib/testing/playwright/server-log-capture.js +21 -4
  303. package/lib/testing/playwright/server-log-capture.js.map +1 -1
  304. package/lib/testing/playwright/server-log-rename-reporter.d.ts.map +1 -1
  305. package/lib/testing/playwright/server-log-rename-reporter.js +10 -1
  306. package/lib/testing/playwright/server-log-rename-reporter.js.map +1 -1
  307. package/lib/testing/stub-ast-document-manager.d.ts +5 -5
  308. package/lib/testing/stub-ast-document-manager.d.ts.map +1 -1
  309. package/lib/testing/stub-ast-document-manager.js +4 -6
  310. package/lib/testing/stub-ast-document-manager.js.map +1 -1
  311. package/lib/testing/stub-document-builder.d.ts +8 -0
  312. package/lib/testing/stub-document-builder.d.ts.map +1 -1
  313. package/lib/testing/stub-document-builder.js +22 -3
  314. package/lib/testing/stub-document-builder.js.map +1 -1
  315. package/lib/testing/stub-langium-documents.d.ts +3 -2
  316. package/lib/testing/stub-langium-documents.d.ts.map +1 -1
  317. package/lib/testing/stub-langium-documents.js.map +1 -1
  318. package/lib/testing/stub-model-service.d.ts +5 -4
  319. package/lib/testing/stub-model-service.d.ts.map +1 -1
  320. package/lib/testing/stub-model-service.js +2 -2
  321. package/lib/testing/stub-model-service.js.map +1 -1
  322. package/lib/util/connection-liveness.d.ts +7 -6
  323. package/lib/util/connection-liveness.d.ts.map +1 -1
  324. package/lib/util/connection-liveness.js +35 -14
  325. package/lib/util/connection-liveness.js.map +1 -1
  326. package/package.json +17 -8
  327. package/src/documents/ast-document-manager.ts +129 -36
  328. package/src/documents/client-ids.ts +5 -22
  329. package/src/documents/hydranium-text-documents.ts +248 -75
  330. package/src/documents/language-client-text-shadow.ts +59 -11
  331. package/src/documents/self-save-registry.ts +52 -13
  332. package/src/index.ts +6 -0
  333. package/src/langium/ast-extension/ast-node-builder.ts +66 -22
  334. package/src/langium/bootstrap.ts +16 -9
  335. package/src/langium/config/configuration-provider.ts +119 -0
  336. package/src/langium/config/index.ts +1 -0
  337. package/src/langium/diagnostics/lsp-logger.ts +41 -6
  338. package/src/langium/document-builder/build-pipeline-integration.ts +50 -5
  339. package/src/langium/document-builder/build-session.ts +87 -0
  340. package/src/langium/document-builder/document-builder.ts +339 -11
  341. package/src/langium/document-builder/index.ts +1 -0
  342. package/src/langium/integration-services.ts +67 -6
  343. package/src/langium/integrity/integrity-service.ts +116 -2
  344. package/src/langium/keys/containment.ts +87 -0
  345. package/src/langium/keys/index.ts +1 -0
  346. package/src/langium/keys/name-based-key-provider.ts +4 -0
  347. package/src/langium/language-module.ts +38 -0
  348. package/src/langium/model-service/model-service.ts +264 -32
  349. package/src/langium/module.ts +106 -21
  350. package/src/langium/naming/name-provider.ts +27 -5
  351. package/src/langium/naming/name-separator-validation.ts +34 -5
  352. package/src/langium/residency/cst-residency-service.ts +36 -14
  353. package/src/langium/scope/hydranium-scope-provider.ts +60 -22
  354. package/src/langium/serialization/abstract-serializer.ts +13 -32
  355. package/src/langium/service-registry.ts +19 -2
  356. package/src/langium/shared-services.ts +19 -2
  357. package/src/langium/transfer/transfer-encoder.ts +85 -24
  358. package/src/langium/trivia/comment-preserver.ts +1100 -0
  359. package/src/langium/trivia/document-ending-preserver.ts +55 -0
  360. package/src/langium/trivia/index.ts +14 -0
  361. package/src/langium/trivia/trivia-contribution.ts +39 -0
  362. package/src/langium/trivia/trivia-preserver.ts +54 -0
  363. package/src/langium/trivia/trivia-service.ts +99 -0
  364. package/src/langium/validation/document-validator.ts +537 -11
  365. package/src/langium/workspace/document-uri-policy.ts +3 -4
  366. package/src/langium/workspace/file-system-provider.ts +48 -8
  367. package/src/langium/workspace/hydranium-langium-document-factory.ts +34 -0
  368. package/src/langium/workspace/hydranium-workspace-manager.ts +30 -1
  369. package/src/langium/workspace/in-memory-file-system-provider.ts +53 -10
  370. package/src/langium/workspace/initialize-workspace.ts +35 -5
  371. package/src/langium/workspace/langium-documents.ts +106 -33
  372. package/src/langium/workspace/virtual-document.ts +21 -3
  373. package/src/locale/index.ts +10 -0
  374. package/src/locale/server-locale.ts +86 -0
  375. package/src/lsp/completion/hydranium-completion-provider.ts +82 -2
  376. package/src/lsp/connection-features.ts +67 -0
  377. package/src/lsp/diagnostics-connection.ts +56 -0
  378. package/src/lsp/hydranium-document-update-handler.ts +10 -1
  379. package/src/lsp/index.ts +3 -1
  380. package/src/lsp/lsp-latency.ts +62 -0
  381. package/src/lsp/semantic-token-provider.ts +74 -7
  382. package/src/lsp/start-language-server.ts +10 -3
  383. package/src/messages/carriers.ts +78 -0
  384. package/src/messages/index.ts +36 -0
  385. package/src/messages/renderer.ts +206 -0
  386. package/src/node/heap-ceiling.ts +108 -0
  387. package/src/node/index.ts +1 -0
  388. package/src/node/latency-from-env.ts +1 -1
  389. package/src/node/node-file-system-provider.ts +154 -47
  390. package/src/node/profile-capture.ts +8 -2
  391. package/src/node/profiling-run.ts +3 -3
  392. package/src/node/rename-over-open-readers.ts +78 -0
  393. package/src/node/socket-launcher.ts +18 -2
  394. package/src/testing/fake-document.ts +24 -5
  395. package/src/testing/make-noop-shared-services.ts +50 -2
  396. package/src/testing/make-test-services.ts +74 -18
  397. package/src/testing/node/index.ts +1 -0
  398. package/src/testing/node/lsp-server-connection.ts +5 -6
  399. package/src/testing/node/scratch-workspace.ts +9 -4
  400. package/src/testing/node/spawned-server.ts +35 -1
  401. package/src/testing/node/unhandled-rejections.ts +31 -0
  402. package/src/testing/playwright/flaky-network-proxy.ts +240 -0
  403. package/src/testing/playwright/index.ts +1 -0
  404. package/src/testing/playwright/server-log-capture.ts +24 -5
  405. package/src/testing/playwright/server-log-rename-reporter.ts +12 -1
  406. package/src/testing/stub-ast-document-manager.ts +10 -14
  407. package/src/testing/stub-document-builder.ts +32 -3
  408. package/src/testing/stub-langium-documents.ts +3 -2
  409. package/src/testing/stub-model-service.ts +7 -6
  410. package/src/util/connection-liveness.ts +37 -14
  411. package/lib/lsp/instrument-connection.d.ts +0 -36
  412. package/lib/lsp/instrument-connection.d.ts.map +0 -1
  413. package/lib/lsp/instrument-connection.js +0 -62
  414. package/lib/lsp/instrument-connection.js.map +0 -1
  415. package/src/lsp/instrument-connection.ts +0 -66
@@ -0,0 +1,240 @@
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
+ import { createServer as createHttpServer, type Server as HttpServer } from 'node:http';
11
+ import { connect, createServer as createTcpServer, type Server as TcpServer, type Socket } from 'node:net';
12
+
13
+ /**
14
+ * A TCP proxy that can half-close a connection, so an e2e suite can reproduce a
15
+ * flaky network against a real browser session.
16
+ *
17
+ * Toggling the browser offline is not enough. On localhost the server sees the
18
+ * close immediately and reaps the socket before the browser reconnects, so the
19
+ * window where both sides disagree about the session — the one where reconnect
20
+ * defects live — never opens. Reaching it needs the browser's socket to die
21
+ * while the server still believes it is alive, and nothing inside the app or in
22
+ * Playwright's offline emulation can produce that asymmetry: both close cleanly
23
+ * at both ends.
24
+ *
25
+ * The proxy holds both halves of every connection and lets a test kill them
26
+ * independently:
27
+ *
28
+ * `break` destroy the BROWSER-side sockets, keep the server-side ones open.
29
+ * The browser reconnects through a fresh pair while the server
30
+ * still holds the old one.
31
+ * `release` destroy the orphaned server-side sockets `break` left. The
32
+ * server's disconnect handler fires at once, rather than whenever
33
+ * its next heartbeat write would have failed.
34
+ */
35
+
36
+ /** Where the proxy listens, and the application it fronts. */
37
+ export interface FlakyNetworkProxyOptions {
38
+ /** Port the browser connects to. */
39
+ readonly listenPort: number;
40
+ /** Port of the application being proxied. */
41
+ readonly targetPort: number;
42
+ /** Host of the application being proxied. Defaults to loopback. */
43
+ readonly targetHost?: string;
44
+ /** Port the HTTP control channel listens on. Defaults to `listenPort + 1000`. */
45
+ readonly controlPort?: number;
46
+ }
47
+
48
+ /** The commands the control channel accepts, and the proxy's own vocabulary. */
49
+ export type FlakyNetworkCommand = 'break' | 'release' | 'status';
50
+
51
+ /** Drives a running proxy. Implemented both in-process and over HTTP. */
52
+ export interface FlakyNetworkControl {
53
+ /** Kill the browser side of every live connection; leave the server side up. */
54
+ break(): Promise<string>;
55
+ /** Kill the server side of every connection `break` orphaned. */
56
+ release(): Promise<string>;
57
+ /** How many connections are live and how many are orphaned. */
58
+ status(): Promise<string>;
59
+ }
60
+
61
+ export interface FlakyNetworkProxy extends FlakyNetworkControl {
62
+ /** Base URL a browser should be pointed at, i.e. Playwright's `baseURL`. */
63
+ readonly url: string;
64
+ /** Control channel, for workers that cannot reach this object directly. */
65
+ readonly controlUrl: string;
66
+ close(): Promise<void>;
67
+ }
68
+
69
+ interface ConnectionPair {
70
+ readonly id: number;
71
+ readonly browserSocket: Socket;
72
+ readonly targetSocket: Socket;
73
+ orphaned: boolean;
74
+ }
75
+
76
+ /**
77
+ * Starts the proxy in the calling process.
78
+ *
79
+ * Call it from a Playwright config, which runs in the main process before any
80
+ * worker forks. Workers are separate processes and cannot reach the returned
81
+ * object, which is what {@link controlUrl} and {@link flakyNetworkControlClient}
82
+ * are for.
83
+ */
84
+ export async function startFlakyNetworkProxy(options: FlakyNetworkProxyOptions): Promise<FlakyNetworkProxy> {
85
+ const targetHost = options.targetHost ?? '127.0.0.1';
86
+ const controlPort = options.controlPort ?? options.listenPort + 1000;
87
+ const pairs = new Set<ConnectionPair>();
88
+ let sequence = 0;
89
+ let transcript: string[] = [];
90
+
91
+ const log = (message: string): void => {
92
+ transcript.push(message);
93
+ console.log(`[flaky-network] ${message}`);
94
+ };
95
+
96
+ const proxyServer: TcpServer = createTcpServer(browserSocket => {
97
+ const id = ++sequence;
98
+ const targetSocket = connect(options.targetPort, targetHost);
99
+ const pair: ConnectionPair = { id, browserSocket, targetSocket, orphaned: false };
100
+ pairs.add(pair);
101
+
102
+ // Forwarded by hand rather than with `pipe()`, so killing one side does not
103
+ // tear the other down — which is the entire point of the proxy.
104
+ browserSocket.on('data', chunk => {
105
+ if (!targetSocket.destroyed) {
106
+ targetSocket.write(chunk);
107
+ }
108
+ });
109
+ targetSocket.on('data', chunk => {
110
+ if (!pair.orphaned && !browserSocket.destroyed) {
111
+ browserSocket.write(chunk);
112
+ }
113
+ });
114
+
115
+ const teardown = (origin: 'browser' | 'target'): void => {
116
+ if (pair.orphaned && origin === 'browser') {
117
+ // Expected: `break` killed this side deliberately. The server side
118
+ // stays up until `release`.
119
+ return;
120
+ }
121
+ pairs.delete(pair);
122
+ browserSocket.destroy();
123
+ targetSocket.destroy();
124
+ };
125
+
126
+ browserSocket.on('close', () => teardown('browser'));
127
+ targetSocket.on('close', () => teardown('target'));
128
+ // A half-killed pair reliably raises ECONNRESET on the surviving side; an
129
+ // unhandled 'error' would take the whole runner down with it.
130
+ browserSocket.on('error', () => undefined);
131
+ targetSocket.on('error', () => undefined);
132
+ });
133
+
134
+ const commands: Record<FlakyNetworkCommand, () => void> = {
135
+ break: () => {
136
+ const live = [...pairs].filter(pair => !pair.orphaned);
137
+ if (live.length === 0) {
138
+ log('nothing to break');
139
+ return;
140
+ }
141
+ for (const pair of live) {
142
+ pair.orphaned = true;
143
+ pair.browserSocket.destroy();
144
+ }
145
+ log(`${live.length} connection(s) broken; the browser should reconnect shortly`);
146
+ },
147
+ release: () => {
148
+ const orphans = [...pairs].filter(pair => pair.orphaned);
149
+ if (orphans.length === 0) {
150
+ log('no orphaned connections; run `break` first');
151
+ return;
152
+ }
153
+ for (const pair of orphans) {
154
+ pairs.delete(pair);
155
+ pair.targetSocket.destroy();
156
+ }
157
+ log(`${orphans.length} orphaned connection(s) destroyed; their late disconnect fires now`);
158
+ },
159
+ status: () => {
160
+ const live = [...pairs].filter(pair => !pair.orphaned).length;
161
+ const orphaned = pairs.size - live;
162
+ log(`${live} live, ${orphaned} orphaned`);
163
+ }
164
+ };
165
+
166
+ const run = (name: string): string => {
167
+ transcript = [];
168
+ const command = commands[name as FlakyNetworkCommand];
169
+ if (command) {
170
+ command();
171
+ } else {
172
+ log(`unknown command '${name}'; use: ${Object.keys(commands).join(' | ')}`);
173
+ }
174
+ return transcript.join('\n');
175
+ };
176
+
177
+ const controlServer: HttpServer = createHttpServer((request, response) => {
178
+ const output = run((request.url ?? '').replace(/^\//, '').split('?')[0]);
179
+ response.writeHead(200, { 'content-type': 'text/plain' });
180
+ response.end(`${output}\n`);
181
+ });
182
+
183
+ await Promise.all([listen(proxyServer, options.listenPort), listen(controlServer, controlPort)]);
184
+ // Neither server keeps the process alive, so a runner that starts one from a
185
+ // config does not need a teardown hook to exit — and a caller that wants a
186
+ // deterministic shutdown still has `close()`.
187
+ proxyServer.unref();
188
+ controlServer.unref();
189
+
190
+ return {
191
+ url: `http://localhost:${options.listenPort}`,
192
+ controlUrl: `http://localhost:${controlPort}`,
193
+ break: async () => run('break'),
194
+ release: async () => run('release'),
195
+ status: async () => run('status'),
196
+ close: async () => {
197
+ for (const pair of pairs) {
198
+ pair.browserSocket.destroy();
199
+ pair.targetSocket.destroy();
200
+ }
201
+ pairs.clear();
202
+ await Promise.all([close(proxyServer), close(controlServer)]);
203
+ }
204
+ };
205
+ }
206
+
207
+ /**
208
+ * Drives a proxy running in another process, over its control channel.
209
+ *
210
+ * This is what a spec uses: Playwright workers are separate processes from the
211
+ * config that started the proxy.
212
+ */
213
+ export function flakyNetworkControlClient(controlUrl: string): FlakyNetworkControl {
214
+ const send = async (command: FlakyNetworkCommand): Promise<string> => {
215
+ const response = await fetch(`${controlUrl}/${command}`);
216
+ if (!response.ok) {
217
+ throw new Error(`flaky-network proxy rejected '${command}': ${response.status}`);
218
+ }
219
+ return (await response.text()).trim();
220
+ };
221
+ return {
222
+ break: () => send('break'),
223
+ release: () => send('release'),
224
+ status: () => send('status')
225
+ };
226
+ }
227
+
228
+ function listen(server: TcpServer | HttpServer, port: number): Promise<void> {
229
+ return new Promise((resolve, reject) => {
230
+ server.once('error', reject);
231
+ server.listen(port, () => {
232
+ server.off('error', reject);
233
+ resolve();
234
+ });
235
+ });
236
+ }
237
+
238
+ function close(server: TcpServer | HttpServer): Promise<void> {
239
+ return new Promise(resolve => server.close(() => resolve()));
240
+ }
@@ -11,6 +11,7 @@
11
11
  // `@hydranium/core/testing` barrel) so importing the framework's unit-test
12
12
  // helpers never pulls in `@playwright/test` — which is an OPTIONAL peer here.
13
13
  export * from './e2e-profiling.js';
14
+ export * from './flaky-network-proxy.js';
14
15
  export * from './browser-capture-bridge.js';
15
16
  export * from './server-log-capture.js';
16
17
  export * from './server-log-fixture.js';
@@ -160,16 +160,28 @@ export function serverLogSpecName(file: string): string {
160
160
  * Rename each `<token>.log` (backend) and `<token>.browser.log` (forwarded
161
161
  * browser console) to the spec name recorded in its `<token>.spec` sidecar
162
162
  * (written by {@link markServerLog}), then delete the sidecar. Colliding names —
163
- * a spec that opened more than one workspace — get a `-2`, `-3`, … suffix. Token
164
- * logs without a sidecar are left untouched. Run once, after all server processes
165
- * have exited (e.g. a reporter's `onEnd`). Best-effort.
163
+ * a spec that opened more than one workspace — get a `-2`, `-3`, … suffix. Run
164
+ * once, after all server processes have exited (e.g. a reporter's `onEnd`).
165
+ * Best-effort.
166
+ *
167
+ * Returns the workspace tokens left UNATTRIBUTED — a log the capture wrote that
168
+ * no test claimed, because that spec never reached
169
+ * {@link markServerLog} (no `serverLog` fixture, no `beforeEach` call).
170
+ *
171
+ * **Returned rather than ignored, because the unattributed state is the
172
+ * misleading one.** Such a log still exists, still has content, and is named by
173
+ * an opaque token with no test boundaries in it — so a capture run that covered
174
+ * nothing looks exactly like one that covered everything, and the logs are
175
+ * there to be read. A caller that can warn should warn.
166
176
  */
167
- export function renameServerLogs(dir: string): void {
177
+ export function renameServerLogs(dir: string): string[] {
168
178
  let entries: string[];
169
179
  try {
170
180
  entries = readdirSync(dir);
171
181
  } catch {
172
- return;
182
+ // An unreadable capture dir has nothing to report — including nothing
183
+ // unattributed, since no log was observed at all.
184
+ return [];
173
185
  }
174
186
  // Per suffix (`.log`, `.browser.log`) a `taken` set guards collisions, so the
175
187
  // backend and browser logs for one spec share the same friendly base name.
@@ -190,6 +202,11 @@ export function renameServerLogs(dir: string): void {
190
202
  // ignore
191
203
  }
192
204
  };
205
+ // Every token the capture produced a backend log for, so the ones no sidecar
206
+ // claims can be reported rather than silently left behind.
207
+ const unattributed = new Set(
208
+ entries.filter(entry => entry.endsWith('.log') && !entry.endsWith('.browser.log')).map(entry => entry.slice(0, -'.log'.length))
209
+ );
193
210
  for (const entry of entries) {
194
211
  if (!entry.endsWith('.spec')) {
195
212
  continue;
@@ -210,9 +227,11 @@ export function renameServerLogs(dir: string): void {
210
227
  if (!name) {
211
228
  continue;
212
229
  }
230
+ unattributed.delete(token);
213
231
  rename(token, name, '.log');
214
232
  rename(token, name, '.browser.log');
215
233
  }
234
+ return [...unattributed];
216
235
  }
217
236
 
218
237
  /**
@@ -24,6 +24,17 @@ export default class ServerLogRenameReporter {
24
24
  }
25
25
 
26
26
  onEnd(): void {
27
- renameServerLogs(this.dir);
27
+ const unattributed = renameServerLogs(this.dir);
28
+ if (unattributed.length > 0) {
29
+ // Loud, because the alternative is a capture run that reads as
30
+ // complete: these logs exist and have content, but are named by an
31
+ // opaque workspace token and carry no test boundaries, so nothing
32
+ // about them says which spec they belong to.
33
+ console.warn(
34
+ `[server-log] ${unattributed.length} captured log(s) belong to no test: ${unattributed.join(', ')}.\n` +
35
+ '[server-log] Those specs never marked a boundary — apply the `serverLog` fixture, ' +
36
+ 'or call `markServerLog`/`attachServerLog` from the suite, or their logs cannot be read per test.'
37
+ );
38
+ }
28
39
  }
29
40
  }
@@ -9,8 +9,9 @@
9
9
 
10
10
  import { type AstNode, type LangiumDocument, UriUtils } from '@hydranium/langium';
11
11
  import { Disposable } from 'vscode-languageserver';
12
+ import { type AstDiagnostic } from '../langium/validation/document-validator.js';
12
13
  import {
13
- type AstDocument,
14
+ AstDocument,
14
15
  type AstDocumentManager,
15
16
  type AstDocumentUpdatedEvent,
16
17
  type WritableFileSystemProvider
@@ -27,9 +28,8 @@ import type { StubLangiumDocuments } from './stub-langium-documents.js';
27
28
  * underlying stub text-document manager, `onUpdate` is driven explicitly
28
29
  * through {@link StubAstDocumentManager.emitUpdate} because the stub tree runs
29
30
  * no build phases to emit from, and the remaining read helpers
30
- * (`isDirectChange`, `getAuthor`, `readFile`) throw if invoked — tests that
31
- * need them should wire a richer stub or use the real
32
- * {@link AstDocumentManager}.
31
+ * (`isTriggeringEdit`, `getAuthor`) throw if invoked — tests that need them
32
+ * should wire a richer stub or use the real {@link AstDocumentManager}.
33
33
  *
34
34
  * Open state is tracked per URI as the set of holding client ids, so a
35
35
  * document stays open until its last client closes. The stub forwards
@@ -45,7 +45,7 @@ import type { StubLangiumDocuments } from './stub-langium-documents.js';
45
45
  * are still picked so signature drift on them produces a compile
46
46
  * error rather than silent divergence.
47
47
  */
48
- export interface StubAstDocumentManager<TAst extends AstNode, TDiagnostic = unknown> extends Pick<
48
+ export interface StubAstDocumentManager<TAst extends AstNode, TDiagnostic extends AstDiagnostic = AstDiagnostic> extends Pick<
49
49
  AstDocumentManager<TAst, TDiagnostic>,
50
50
  | 'open'
51
51
  | 'close'
@@ -57,8 +57,7 @@ export interface StubAstDocumentManager<TAst extends AstNode, TDiagnostic = unkn
57
57
  | 'onClientClosed'
58
58
  | 'getAuthor'
59
59
  | 'getDocument'
60
- | 'isDirectChange'
61
- | 'readFile'
60
+ | 'isTriggeringEdit'
62
61
  > {
63
62
  readonly openClients: Map<string, Set<string>>;
64
63
 
@@ -104,7 +103,7 @@ export interface StubAstDocumentManager<TAst extends AstNode, TDiagnostic = unkn
104
103
  updateSubscriptions(uri?: string): number;
105
104
  }
106
105
 
107
- export function makeStubAstDocumentManager<TAst extends AstNode, TDiagnostic = unknown>(
106
+ export function makeStubAstDocumentManager<TAst extends AstNode, TDiagnostic extends AstDiagnostic = AstDiagnostic>(
108
107
  textDocuments: StubHydraniumTextDocuments,
109
108
  fileSystem: Pick<WritableFileSystemProvider, 'writeFile'>,
110
109
  documents?: StubLangiumDocuments<TAst, TDiagnostic>
@@ -193,7 +192,7 @@ export function makeStubAstDocumentManager<TAst extends AstNode, TDiagnostic = u
193
192
  return;
194
193
  }
195
194
  listener({
196
- document: { uri, version: textDocuments.version(uri), root: undefined as unknown as TAst, diagnostics: [] as TDiagnostic[] },
195
+ document: AstDocument.create<TAst, TDiagnostic>(uri, textDocuments.version(uri), undefined as unknown as TAst),
197
196
  sourceClientId: event.clientId
198
197
  });
199
198
  });
@@ -214,11 +213,8 @@ export function makeStubAstDocumentManager<TAst extends AstNode, TDiagnostic = u
214
213
  getDocument(uri: string): LangiumDocument | undefined {
215
214
  return documents?.getDocument(UriUtils.toUri(uri));
216
215
  },
217
- isDirectChange(): boolean {
218
- return notSupported('isDirectChange');
219
- },
220
- async readFile(uri: string): Promise<string> {
221
- return notSupported(`readFile(${uri})`);
216
+ isTriggeringEdit(): boolean {
217
+ return notSupported('isTriggeringEdit');
222
218
  }
223
219
  };
224
220
  }
@@ -9,6 +9,7 @@
9
9
 
10
10
  import {
11
11
  type DocumentBuilder,
12
+ type DocumentBuildListener,
12
13
  type DocumentPhaseListener,
13
14
  type DocumentState,
14
15
  type DocumentUpdateListener,
@@ -94,6 +95,14 @@ export interface StubDocumentBuilder extends Pick<
94
95
  firePhase(state: DocumentState, document: LangiumDocument, cancelToken?: CancellationToken): void;
95
96
  /** Synchronously fire every registered `onUpdate` listener. */
96
97
  fireOnUpdate(changed: URI[], deleted: URI[]): void;
98
+ /**
99
+ * Synchronously fire the BUILD-phase listener(s) for `state` with the whole
100
+ * batch. The per-build counterpart of {@link firePhase}: a subject that
101
+ * reports once per build rather than once per document subscribes here, and
102
+ * a stub that only fired {@link firePhase} would leave it silent while
103
+ * looking wired.
104
+ */
105
+ fireBuildPhase(state: DocumentState, built: LangiumDocument[], cancelToken?: CancellationToken): void;
97
106
  /**
98
107
  * Hold the next {@link waitUntil} call. The returned handle releases it;
99
108
  * the call's return value resolves on the next tick after `resolve` runs.
@@ -131,6 +140,7 @@ function reraise(result: unknown): void {
131
140
  */
132
141
  export function makeStubDocumentBuilder(): StubDocumentBuilder {
133
142
  const phaseListeners = new Map<DocumentState, DocumentPhaseListener[]>();
143
+ const buildPhaseListeners = new Map<DocumentState, DocumentBuildListener[]>();
134
144
  const onUpdateListeners: DocumentUpdateListener[] = [];
135
145
  const gates: Array<{ take(release: () => void): void }> = [];
136
146
  const updateCalls: RecordedBuilderCall<[URI[], URI[]]>[] = [];
@@ -194,6 +204,28 @@ export function makeStubDocumentBuilder(): StubDocumentBuilder {
194
204
  reraise(listener(changed, deleted));
195
205
  }
196
206
  },
207
+ onBuildPhase(state: DocumentState, listener: DocumentBuildListener) {
208
+ const list = buildPhaseListeners.get(state) ?? [];
209
+ list.push(listener);
210
+ buildPhaseListeners.set(state, list);
211
+ return Disposable.create(() => {
212
+ const idx = list.indexOf(listener);
213
+ if (idx >= 0) {
214
+ list.splice(idx, 1);
215
+ }
216
+ });
217
+ },
218
+ fireBuildPhase(state: DocumentState, built: LangiumDocument[], cancelToken?: CancellationToken) {
219
+ const token =
220
+ cancelToken ??
221
+ ({
222
+ isCancellationRequested: false,
223
+ onCancellationRequested: () => Disposable.create(() => undefined)
224
+ } as CancellationToken);
225
+ for (const listener of buildPhaseListeners.get(state) ?? []) {
226
+ reraise(listener(built, token));
227
+ }
228
+ },
197
229
  gateNextWaitUntil(): StubWaitUntilGate {
198
230
  let release: (() => void) | undefined;
199
231
  const entry = {
@@ -224,9 +256,6 @@ export function makeStubDocumentBuilder(): StubDocumentBuilder {
224
256
  build() {
225
257
  return notSupported('build');
226
258
  },
227
- onBuildPhase() {
228
- return notSupported('onBuildPhase');
229
- },
230
259
  resetToState() {
231
260
  return notSupported('resetToState');
232
261
  },
@@ -9,6 +9,7 @@
9
9
 
10
10
  import { type AstNode, type LangiumDocument, type LangiumDocuments, stream, type URI } from '@hydranium/langium';
11
11
  import { makeFakeAstNode, makeFakeDocument, type FakeDocumentOptions } from './fake-document.js';
12
+ import { type AstDiagnostic } from '../langium/validation/document-validator.js';
12
13
 
13
14
  /**
14
15
  * Map-backed stub for Langium's {@link LangiumDocuments} registry. Implements
@@ -31,7 +32,7 @@ import { makeFakeAstNode, makeFakeDocument, type FakeDocumentOptions } from './f
31
32
  * production code reads the slot value through the `LangiumDocuments`
32
33
  * interface and a narrowing cast bridges the stub at the binding site.
33
34
  */
34
- export interface StubLangiumDocuments<TAst extends AstNode = AstNode, TDiagnostic = unknown> extends Pick<
35
+ export interface StubLangiumDocuments<TAst extends AstNode = AstNode, TDiagnostic extends AstDiagnostic = AstDiagnostic> extends Pick<
35
36
  LangiumDocuments,
36
37
  'getDocument' | 'hasDocument' | 'getOrCreateDocument' | 'all'
37
38
  > {
@@ -51,7 +52,7 @@ export interface StubLangiumDocuments<TAst extends AstNode = AstNode, TDiagnosti
51
52
  * Build a {@link StubLangiumDocuments}. Seed entries via the optional
52
53
  * `seeds` parameter so simple tests don't need a separate `set` call.
53
54
  */
54
- export function makeStubLangiumDocuments<TAst extends AstNode = AstNode, TDiagnostic = unknown>(
55
+ export function makeStubLangiumDocuments<TAst extends AstNode = AstNode, TDiagnostic extends AstDiagnostic = AstDiagnostic>(
55
56
  seeds: ReadonlyArray<{ uri: string | URI; root: TAst; options?: FakeDocumentOptions<TAst, TDiagnostic> }> = []
56
57
  ): StubLangiumDocuments<TAst, TDiagnostic> {
57
58
  const docs = new Map<string, LangiumDocument<TAst>>();
@@ -7,9 +7,10 @@
7
7
  * SPDX-License-Identifier: MIT
8
8
  ********************************************************************************/
9
9
 
10
- import type { TransferDiagnostic, TransferElement } from '@hydranium/protocol';
10
+ import type { TransferElement } from '@hydranium/protocol';
11
+ import type { AstDiagnostic } from '../langium/validation/document-validator.js';
11
12
  import type { AstNode } from '@hydranium/langium';
12
- import { ModelService, type ModelServiceOptions } from '../langium/model-service/model-service.js';
13
+ import { DefaultModelService, type ModelService, type ModelServiceOptions } from '../langium/model-service/model-service.js';
13
14
  import type { ServerSharedServices } from '../langium/module.js';
14
15
 
15
16
  /**
@@ -21,9 +22,9 @@ import type { ServerSharedServices } from '../langium/module.js';
21
22
  */
22
23
  class StubModelServiceImpl<
23
24
  TAst extends AstNode,
24
- TDiagnostic extends TransferDiagnostic = TransferDiagnostic,
25
+ TDiagnostic extends AstDiagnostic = AstDiagnostic,
25
26
  TTransfer extends TransferElement = TransferElement
26
- > extends ModelService<TAst, TDiagnostic, TTransfer> {
27
+ > extends DefaultModelService<TAst, TDiagnostic, TTransfer> {
27
28
  constructor(
28
29
  services: ServerSharedServices,
29
30
  protected readonly serializeFn: (uri: string, root: TTransfer) => string,
@@ -40,7 +41,7 @@ class StubModelServiceImpl<
40
41
  /** The type of the model-service test double produced by {@link makeStubModelService}. */
41
42
  export type StubModelService<
42
43
  TAst extends AstNode,
43
- TDiagnostic extends TransferDiagnostic = TransferDiagnostic,
44
+ TDiagnostic extends AstDiagnostic = AstDiagnostic,
44
45
  TTransfer extends TransferElement = TransferElement
45
46
  > = ModelService<TAst, TDiagnostic, TTransfer>;
46
47
 
@@ -61,7 +62,7 @@ export type StubModelService<
61
62
  */
62
63
  export function makeStubModelService<
63
64
  TAst extends AstNode,
64
- TDiagnostic extends TransferDiagnostic = TransferDiagnostic,
65
+ TDiagnostic extends AstDiagnostic = AstDiagnostic,
65
66
  TTransfer extends TransferElement = TransferElement
66
67
  >(
67
68
  services: ServerSharedServices,
@@ -8,39 +8,62 @@
8
8
  ********************************************************************************/
9
9
 
10
10
  /**
11
- * Phrases `vscode-jsonrpc` uses when a call loses its connection. Matched on the
12
- * message because the condition surfaces in two different shapes:
11
+ * Phrases that mean a call lost its connection. Matched on the message because
12
+ * the condition surfaces in shapes that share no discriminator:
13
13
  *
14
14
  * - a **throw** from `throwIfClosedOrDisposed` (`Connection is disposed.` /
15
15
  * `Connection is closed.`), a `ConnectionError` raised synchronously by
16
16
  * `sendRequest` / `sendNotification` and by `RemoteConsole.send`;
17
17
  * - a **rejection** of an already-issued request (`Pending response rejected
18
18
  * since connection got disposed`), a `ResponseError` produced when the
19
- * pending-response map is drained on teardown.
19
+ * pending-response map is drained on teardown;
20
+ * - a **write into a destroyed transport** (`Cannot call write after a stream
21
+ * was destroyed`), Node's own error for a message the writer queued before
22
+ * the connection was disposed and flushed after its stream was destroyed.
23
+ * A notification rejects with Node's error itself, which
24
+ * {@link isDestroyedStreamError} catches by its code; a request rejects with
25
+ * a `ResponseError` that copies only the message, so the phrase is needed
26
+ * too.
20
27
  *
21
- * Both are typed, but they are different error classes carrying codes from
22
- * different enums, so no single code check covers both. Kept
23
- * lowercase-normalised and anchored on `connection` so an unrelated "disposed"
24
- * message cannot match.
28
+ * The typed errors come from different classes carrying codes from different
29
+ * enums, so no single code check covers them. Kept lowercase-normalised and
30
+ * anchored on `connection` or `stream` so an unrelated "disposed" message
31
+ * cannot match.
25
32
  */
26
- const CONNECTION_GONE_PATTERNS = [/connection is disposed/, /connection is closed/, /connection got disposed/, /connection got closed/];
33
+ const CONNECTION_GONE_PATTERNS = [
34
+ /connection is disposed/,
35
+ /connection is closed/,
36
+ /connection got disposed/,
37
+ /connection got closed/,
38
+ /after a stream was destroyed/
39
+ ];
40
+
41
+ const DESTROYED_STREAM_CODE = 'ERR_STREAM_DESTROYED';
42
+
43
+ function isDestroyedStreamError(err: unknown): boolean {
44
+ return err instanceof Error && 'code' in err && err.code === DESTROYED_STREAM_CODE;
45
+ }
27
46
 
28
47
  /**
29
48
  * Whether `err` means "the peer is gone", as opposed to a genuine failure of
30
49
  * the operation.
31
50
  *
32
- * The distinction is a **log-severity** one, and it matters because the two are
33
- * indistinguishable at the call site otherwise. Pushing an edit to a language
34
- * client that has already disconnected is a no-op, not a fault — it happens on
35
- * every ordinary shutdown, and reporting it at `error` turns routine teardown
36
- * into something that looks like it needs investigation. A real `applyEdit`
37
- * failure (the client refused, the request malformed) still deserves `error`.
51
+ * The two are indistinguishable at the call site otherwise, and callers act on
52
+ * the answer: a gone peer is logged at `debug` or dropped, a genuine failure is
53
+ * logged at `error` or re-raised as an unhandled rejection. Pushing an edit to
54
+ * a language client that has already disconnected is a no-op, not a fault — it
55
+ * happens on every ordinary shutdown — so a `false` here turns routine teardown
56
+ * into errors that look like they need investigation. A `true` for a real
57
+ * `applyEdit` failure (the client refused, the request malformed) hides it.
38
58
  *
39
59
  * Callers that only need to *survive* a dead connection rather than classify it
40
60
  * should just catch — see `LspLogger.emit`, whose fallback path does exactly
41
61
  * that, since a logger has nowhere to report a logging failure anyway.
42
62
  */
43
63
  export function isConnectionGoneError(err: unknown): boolean {
64
+ if (isDestroyedStreamError(err)) {
65
+ return true;
66
+ }
44
67
  const message = err instanceof Error ? err.message : String(err);
45
68
  const normalized = message.toLowerCase();
46
69
  return CONNECTION_GONE_PATTERNS.some(pattern => pattern.test(normalized));
@@ -1,36 +0,0 @@
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
- /**
11
- * Wrap an LSP `Connection` so every request handler registered through
12
- * `onRequest` is timed into `latency` under its method name — the LSP analog of
13
- * the data-server RPC chokepoint. Langium's `startLanguageServer` registers
14
- * `onCompletion`/`onHover`/… one handler at a time, so there is no single
15
- * dispatch point; but every registration funnels through the ONE `onRequest`
16
- * on the shared `Connection`, so decorating it catches every method with no
17
- * Langium fork and no per-handler code.
18
- *
19
- * Opt in where the head creates the connection, before it hands it to the
20
- * services factory — wrapping it afterwards is too late, because Langium has
21
- * already registered its handlers against the raw connection.
22
- *
23
- * `onRequest` has several overloads: most register a handler for a specific
24
- * method (a string, or a typed request whose `.method` names it) and one is the
25
- * `StarRequestHandler` catch-all `onRequest(handler)`. The star form fires only
26
- * for methods with no registered handler, so timing it would be misleading — it
27
- * is passed through untouched. Every other member of the connection is
28
- * forwarded unchanged.
29
- *
30
- * When `latency` is `undefined` the seam is off: the connection is returned
31
- * unchanged (no Proxy, no per-request timing), so a head can pass the result of
32
- * an env-gated factory (`latencyFromEnv()`) straight through and pay nothing
33
- * when latency is not enabled.
34
- */
35
- export declare function instrumentLspConnection<C extends object>(connection: C, latency: LatencyCollector | undefined): C;
36
- //# sourceMappingURL=instrument-connection.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"instrument-connection.d.ts","sourceRoot":"","sources":["../../src/lsp/instrument-connection.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAI5D;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,uBAAuB,CAAC,CAAC,SAAS,MAAM,EAAE,UAAU,EAAE,CAAC,EAAE,OAAO,EAAE,gBAAgB,GAAG,SAAS,GAAG,CAAC,CA2BjH"}