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

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 (424) 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 +132 -42
  10. package/lib/documents/hydranium-text-documents.d.ts.map +1 -1
  11. package/lib/documents/hydranium-text-documents.js +199 -57
  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 +176 -97
  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/measure-memory.d.ts.map +1 -1
  245. package/lib/node/measure-memory.js +1 -0
  246. package/lib/node/measure-memory.js.map +1 -1
  247. package/lib/node/node-file-system-provider.d.ts +35 -1
  248. package/lib/node/node-file-system-provider.d.ts.map +1 -1
  249. package/lib/node/node-file-system-provider.js +140 -45
  250. package/lib/node/node-file-system-provider.js.map +1 -1
  251. package/lib/node/profile-capture.d.ts +8 -2
  252. package/lib/node/profile-capture.d.ts.map +1 -1
  253. package/lib/node/profile-capture.js.map +1 -1
  254. package/lib/node/profiling-run.d.ts +2 -2
  255. package/lib/node/profiling-run.js +1 -1
  256. package/lib/node/profiling-run.js.map +1 -1
  257. package/lib/node/rename-over-open-readers.d.ts +52 -0
  258. package/lib/node/rename-over-open-readers.d.ts.map +1 -0
  259. package/lib/node/rename-over-open-readers.js +66 -0
  260. package/lib/node/rename-over-open-readers.js.map +1 -0
  261. package/lib/node/socket-launcher.d.ts +15 -0
  262. package/lib/node/socket-launcher.d.ts.map +1 -1
  263. package/lib/node/socket-launcher.js +3 -2
  264. package/lib/node/socket-launcher.js.map +1 -1
  265. package/lib/testing/fake-document.d.ts +16 -4
  266. package/lib/testing/fake-document.d.ts.map +1 -1
  267. package/lib/testing/fake-document.js +18 -3
  268. package/lib/testing/fake-document.js.map +1 -1
  269. package/lib/testing/make-noop-shared-services.d.ts +14 -0
  270. package/lib/testing/make-noop-shared-services.d.ts.map +1 -1
  271. package/lib/testing/make-noop-shared-services.js +28 -2
  272. package/lib/testing/make-noop-shared-services.js.map +1 -1
  273. package/lib/testing/make-test-services.d.ts +45 -9
  274. package/lib/testing/make-test-services.d.ts.map +1 -1
  275. package/lib/testing/make-test-services.js +19 -3
  276. package/lib/testing/make-test-services.js.map +1 -1
  277. package/lib/testing/node/index.d.ts +1 -0
  278. package/lib/testing/node/index.d.ts.map +1 -1
  279. package/lib/testing/node/index.js +1 -0
  280. package/lib/testing/node/index.js.map +1 -1
  281. package/lib/testing/node/lsp-harness.d.ts.map +1 -1
  282. package/lib/testing/node/lsp-harness.js +2 -0
  283. package/lib/testing/node/lsp-harness.js.map +1 -1
  284. package/lib/testing/node/lsp-server-connection.d.ts +10 -2
  285. package/lib/testing/node/lsp-server-connection.d.ts.map +1 -1
  286. package/lib/testing/node/lsp-server-connection.js +42 -9
  287. package/lib/testing/node/lsp-server-connection.js.map +1 -1
  288. package/lib/testing/node/scratch-workspace.d.ts.map +1 -1
  289. package/lib/testing/node/scratch-workspace.js +9 -4
  290. package/lib/testing/node/scratch-workspace.js.map +1 -1
  291. package/lib/testing/node/spawned-server.d.ts +14 -0
  292. package/lib/testing/node/spawned-server.d.ts.map +1 -1
  293. package/lib/testing/node/spawned-server.js +33 -1
  294. package/lib/testing/node/spawned-server.js.map +1 -1
  295. package/lib/testing/node/unhandled-rejections.d.ts +20 -0
  296. package/lib/testing/node/unhandled-rejections.d.ts.map +1 -0
  297. package/lib/testing/node/unhandled-rejections.js +32 -0
  298. package/lib/testing/node/unhandled-rejections.js.map +1 -0
  299. package/lib/testing/playwright/flaky-network-proxy.d.ts +76 -0
  300. package/lib/testing/playwright/flaky-network-proxy.d.ts.map +1 -0
  301. package/lib/testing/playwright/flaky-network-proxy.js +164 -0
  302. package/lib/testing/playwright/flaky-network-proxy.js.map +1 -0
  303. package/lib/testing/playwright/index.d.ts +1 -0
  304. package/lib/testing/playwright/index.d.ts.map +1 -1
  305. package/lib/testing/playwright/index.js +1 -0
  306. package/lib/testing/playwright/index.js.map +1 -1
  307. package/lib/testing/playwright/server-log-capture.d.ts +14 -4
  308. package/lib/testing/playwright/server-log-capture.d.ts.map +1 -1
  309. package/lib/testing/playwright/server-log-capture.js +21 -4
  310. package/lib/testing/playwright/server-log-capture.js.map +1 -1
  311. package/lib/testing/playwright/server-log-rename-reporter.d.ts.map +1 -1
  312. package/lib/testing/playwright/server-log-rename-reporter.js +10 -1
  313. package/lib/testing/playwright/server-log-rename-reporter.js.map +1 -1
  314. package/lib/testing/stub-ast-document-manager.d.ts +5 -5
  315. package/lib/testing/stub-ast-document-manager.d.ts.map +1 -1
  316. package/lib/testing/stub-ast-document-manager.js +4 -6
  317. package/lib/testing/stub-ast-document-manager.js.map +1 -1
  318. package/lib/testing/stub-document-builder.d.ts +8 -0
  319. package/lib/testing/stub-document-builder.d.ts.map +1 -1
  320. package/lib/testing/stub-document-builder.js +22 -3
  321. package/lib/testing/stub-document-builder.js.map +1 -1
  322. package/lib/testing/stub-langium-documents.d.ts +3 -2
  323. package/lib/testing/stub-langium-documents.d.ts.map +1 -1
  324. package/lib/testing/stub-langium-documents.js.map +1 -1
  325. package/lib/testing/stub-model-service.d.ts +5 -4
  326. package/lib/testing/stub-model-service.d.ts.map +1 -1
  327. package/lib/testing/stub-model-service.js +2 -2
  328. package/lib/testing/stub-model-service.js.map +1 -1
  329. package/lib/util/connection-liveness.d.ts +7 -6
  330. package/lib/util/connection-liveness.d.ts.map +1 -1
  331. package/lib/util/connection-liveness.js +35 -14
  332. package/lib/util/connection-liveness.js.map +1 -1
  333. package/package.json +17 -8
  334. package/src/documents/ast-document-manager.ts +129 -36
  335. package/src/documents/client-ids.ts +5 -22
  336. package/src/documents/hydranium-text-documents.ts +256 -81
  337. package/src/documents/language-client-text-shadow.ts +59 -11
  338. package/src/documents/self-save-registry.ts +52 -13
  339. package/src/index.ts +6 -0
  340. package/src/langium/ast-extension/ast-node-builder.ts +66 -22
  341. package/src/langium/bootstrap.ts +16 -9
  342. package/src/langium/config/configuration-provider.ts +119 -0
  343. package/src/langium/config/index.ts +1 -0
  344. package/src/langium/diagnostics/lsp-logger.ts +41 -6
  345. package/src/langium/document-builder/build-pipeline-integration.ts +50 -5
  346. package/src/langium/document-builder/build-session.ts +87 -0
  347. package/src/langium/document-builder/document-builder.ts +339 -11
  348. package/src/langium/document-builder/index.ts +1 -0
  349. package/src/langium/integration-services.ts +67 -6
  350. package/src/langium/integrity/integrity-service.ts +116 -2
  351. package/src/langium/keys/containment.ts +87 -0
  352. package/src/langium/keys/index.ts +1 -0
  353. package/src/langium/keys/name-based-key-provider.ts +4 -0
  354. package/src/langium/language-module.ts +38 -0
  355. package/src/langium/model-service/model-service.ts +266 -34
  356. package/src/langium/module.ts +106 -21
  357. package/src/langium/naming/name-provider.ts +27 -5
  358. package/src/langium/naming/name-separator-validation.ts +34 -5
  359. package/src/langium/residency/cst-residency-service.ts +36 -14
  360. package/src/langium/scope/hydranium-scope-provider.ts +60 -22
  361. package/src/langium/serialization/abstract-serializer.ts +13 -32
  362. package/src/langium/service-registry.ts +19 -2
  363. package/src/langium/shared-services.ts +19 -2
  364. package/src/langium/transfer/transfer-encoder.ts +85 -24
  365. package/src/langium/trivia/comment-preserver.ts +1100 -0
  366. package/src/langium/trivia/document-ending-preserver.ts +55 -0
  367. package/src/langium/trivia/index.ts +14 -0
  368. package/src/langium/trivia/trivia-contribution.ts +39 -0
  369. package/src/langium/trivia/trivia-preserver.ts +54 -0
  370. package/src/langium/trivia/trivia-service.ts +99 -0
  371. package/src/langium/validation/document-validator.ts +537 -11
  372. package/src/langium/workspace/document-uri-policy.ts +3 -4
  373. package/src/langium/workspace/file-system-provider.ts +48 -8
  374. package/src/langium/workspace/hydranium-langium-document-factory.ts +34 -0
  375. package/src/langium/workspace/hydranium-workspace-manager.ts +30 -1
  376. package/src/langium/workspace/in-memory-file-system-provider.ts +53 -10
  377. package/src/langium/workspace/initialize-workspace.ts +35 -5
  378. package/src/langium/workspace/langium-documents.ts +106 -33
  379. package/src/langium/workspace/virtual-document.ts +21 -3
  380. package/src/locale/index.ts +10 -0
  381. package/src/locale/server-locale.ts +86 -0
  382. package/src/lsp/completion/hydranium-completion-provider.ts +82 -2
  383. package/src/lsp/connection-features.ts +67 -0
  384. package/src/lsp/diagnostics-connection.ts +56 -0
  385. package/src/lsp/hydranium-document-update-handler.ts +10 -1
  386. package/src/lsp/index.ts +3 -1
  387. package/src/lsp/lsp-latency.ts +62 -0
  388. package/src/lsp/semantic-token-provider.ts +74 -7
  389. package/src/lsp/start-language-server.ts +10 -3
  390. package/src/messages/carriers.ts +78 -0
  391. package/src/messages/index.ts +36 -0
  392. package/src/messages/renderer.ts +206 -0
  393. package/src/node/heap-ceiling.ts +108 -0
  394. package/src/node/index.ts +1 -0
  395. package/src/node/latency-from-env.ts +1 -1
  396. package/src/node/measure-memory.ts +1 -0
  397. package/src/node/node-file-system-provider.ts +154 -47
  398. package/src/node/profile-capture.ts +8 -2
  399. package/src/node/profiling-run.ts +3 -3
  400. package/src/node/rename-over-open-readers.ts +78 -0
  401. package/src/node/socket-launcher.ts +18 -2
  402. package/src/testing/fake-document.ts +24 -5
  403. package/src/testing/make-noop-shared-services.ts +50 -2
  404. package/src/testing/make-test-services.ts +74 -18
  405. package/src/testing/node/index.ts +1 -0
  406. package/src/testing/node/lsp-harness.ts +2 -0
  407. package/src/testing/node/lsp-server-connection.ts +60 -10
  408. package/src/testing/node/scratch-workspace.ts +9 -4
  409. package/src/testing/node/spawned-server.ts +35 -1
  410. package/src/testing/node/unhandled-rejections.ts +31 -0
  411. package/src/testing/playwright/flaky-network-proxy.ts +240 -0
  412. package/src/testing/playwright/index.ts +1 -0
  413. package/src/testing/playwright/server-log-capture.ts +24 -5
  414. package/src/testing/playwright/server-log-rename-reporter.ts +12 -1
  415. package/src/testing/stub-ast-document-manager.ts +10 -14
  416. package/src/testing/stub-document-builder.ts +32 -3
  417. package/src/testing/stub-langium-documents.ts +3 -2
  418. package/src/testing/stub-model-service.ts +7 -6
  419. package/src/util/connection-liveness.ts +37 -14
  420. package/lib/lsp/instrument-connection.d.ts +0 -36
  421. package/lib/lsp/instrument-connection.d.ts.map +0 -1
  422. package/lib/lsp/instrument-connection.js +0 -62
  423. package/lib/lsp/instrument-connection.js.map +0 -1
  424. package/src/lsp/instrument-connection.ts +0 -66
@@ -7,7 +7,7 @@
7
7
  * SPDX-License-Identifier: MIT
8
8
  ********************************************************************************/
9
9
 
10
- import { inject, type Module } from '@hydranium/langium';
10
+ import { type DeepPartial, inject, type Module } from '@hydranium/langium';
11
11
  import {
12
12
  createDefaultModule,
13
13
  createDefaultSharedModule,
@@ -98,6 +98,31 @@ export interface IntegrationServicesOptions<
98
98
  * it is silently inert.
99
99
  */
100
100
  extra?: ReadonlyArray<Module<TShared, PartialLangiumSharedServices>>;
101
+ /**
102
+ * Shared modules composed LAST — after `adopter` — and partial over
103
+ * `TShared` rather than over Langium's shared services.
104
+ *
105
+ * Both differences are the point, and neither is served by
106
+ * {@link extra}. Most framework shared services are constructed with
107
+ * no options (`ModelService: services => new DefaultModelService(services)`),
108
+ * so rebinding the slot is the only way to boot one configured
109
+ * differently; a caller that needs that is usually a test, and the slot
110
+ * it needs is as often a framework ADDITION (`Clock`, `Tracer`,
111
+ * `ProjectManager`) as a Langium one. `extra` can express neither: it
112
+ * is typed `DeepPartial<LangiumSharedServices>`, and it loses to
113
+ * `adopter` on every slot the adopter binds.
114
+ *
115
+ * Kept separate rather than widening `extra` because `extra` is the
116
+ * protocol-head tier, and a head must NOT outrank the adopter. Widening
117
+ * it also does not typecheck — `Module<I, T>` puts `T` in factory
118
+ * return position, so a head module declaring Langium slot types stops
119
+ * being assignable once `T` becomes `DeepPartial<TShared>`.
120
+ *
121
+ * Composing last means an override wins over everything, including the
122
+ * adopter. That is what makes it usable for the slots an adopter binds
123
+ * itself, and why production code should not reach for it.
124
+ */
125
+ overrides?: ReadonlyArray<Module<TShared, DeepPartial<TShared>>>;
101
126
  };
102
127
 
103
128
  /**
@@ -134,6 +159,23 @@ export interface IntegrationServicesOptions<
134
159
  * still win over heads.
135
160
  */
136
161
  extra?: ReadonlyArray<Module<TLanguage, PartialLangiumServices>>;
162
+ /**
163
+ * Modules composed LAST, after `adopter`, and partial over `TLanguage`
164
+ * rather than over Langium's per-language services. The language-tier
165
+ * twin of {@link IntegrationServicesOptions.sharedModules}'s
166
+ * `overrides`, and both differences carry the same weight they do
167
+ * there.
168
+ *
169
+ * A per-language framework service is constructed by the framework's
170
+ * own module with no options
171
+ * (`IntegrityService: services => new DefaultIntegrityService(services)`),
172
+ * so booting one configured differently means rebinding the slot.
173
+ * {@link extra} serves neither half of that: it composes BEFORE
174
+ * `adopter` and so loses every slot the adopter binds, and it is typed
175
+ * `PartialLangiumServices`, which cannot express a framework ADDITION
176
+ * like `IntegrityService` or `AstExtensionService` at all.
177
+ */
178
+ overrides?: ReadonlyArray<Module<TLanguage, DeepPartial<TLanguage>>>;
137
179
  };
138
180
 
139
181
  /**
@@ -197,6 +239,8 @@ export interface AdditionalLanguageModules<
197
239
  adopter?: (shared: TShared) => Module<TLanguage, PartialLangiumServices>;
198
240
  /** Protocol-head modules for this language. Defaults to the primary language's. */
199
241
  extra?: ReadonlyArray<Module<TLanguage, PartialLangiumServices>>;
242
+ /** Last-composed overrides for this language. Defaults to the primary language's. */
243
+ overrides?: ReadonlyArray<Module<TLanguage, DeepPartial<TLanguage>>>;
200
244
  }
201
245
 
202
246
  /**
@@ -247,7 +291,9 @@ export function createIntegrationServices<
247
291
  sharedModules.generated,
248
292
  sharedModule,
249
293
  ...(sharedModules.extra ?? []),
250
- sharedModules.adopter
294
+ sharedModules.adopter,
295
+ // Last, so an override outranks the adopter too — see `overrides`.
296
+ ...((sharedModules.overrides ?? []) as ReadonlyArray<Module<TShared, PartialLangiumSharedServices>>)
251
297
  ) as unknown as TShared;
252
298
 
253
299
  // Each language gets its OWN `createDefaultModule({ shared })` — the
@@ -256,19 +302,34 @@ export function createIntegrationServices<
256
302
  const composeLanguage = (
257
303
  generated: Module<TLanguage, PartialLangiumServices>,
258
304
  adopter: (shared: TShared) => Module<TLanguage, PartialLangiumServices>,
259
- extra: ReadonlyArray<Module<TLanguage, PartialLangiumServices>>
305
+ extra: ReadonlyArray<Module<TLanguage, PartialLangiumServices>>,
306
+ overrides: ReadonlyArray<Module<TLanguage, DeepPartial<TLanguage>>>
260
307
  ): TLanguage => {
261
308
  const defaultLanguageModule = createDefaultModule({ shared }) as unknown as Module<TLanguage, PartialLangiumServices>;
262
309
  const serverLanguageModule = createServerLanguageModule(context) as unknown as Module<TLanguage, PartialLangiumServices>;
263
- return inject(defaultLanguageModule, generated, serverLanguageModule, ...extra, adopter(shared)) as unknown as TLanguage;
310
+ return inject(
311
+ defaultLanguageModule,
312
+ generated,
313
+ serverLanguageModule,
314
+ ...extra,
315
+ adopter(shared),
316
+ // Last, so an override outranks the adopter too — see `overrides`.
317
+ ...(overrides as ReadonlyArray<Module<TLanguage, PartialLangiumServices>>)
318
+ ) as unknown as TLanguage;
264
319
  };
265
320
 
266
321
  const primaryExtra = (languageModules.extra ?? []) as ReadonlyArray<Module<TLanguage, PartialLangiumServices>>;
267
- const language = composeLanguage(languageModules.generated, languageModules.adopter, primaryExtra);
322
+ const primaryOverrides = languageModules.overrides ?? [];
323
+ const language = composeLanguage(languageModules.generated, languageModules.adopter, primaryExtra, primaryOverrides);
268
324
  const languages = [
269
325
  language,
270
326
  ...additionalLanguages.map(additional =>
271
- composeLanguage(additional.generated, additional.adopter ?? languageModules.adopter, additional.extra ?? primaryExtra)
327
+ composeLanguage(
328
+ additional.generated,
329
+ additional.adopter ?? languageModules.adopter,
330
+ additional.extra ?? primaryExtra,
331
+ additional.overrides ?? primaryOverrides
332
+ )
272
333
  )
273
334
  ];
274
335
 
@@ -17,6 +17,7 @@ import { type LogNameOptions } from '../diagnostics/logger.js';
17
17
  import { type HydraniumTextDocuments } from '../../documents/hydranium-text-documents.js';
18
18
  import { Registry } from '../../util/registry.js';
19
19
  import { type ServerLanguageServices } from '../language-module.js';
20
+ import { isVirtualUri } from '../workspace/virtual-document.js';
20
21
  import { type IntegrityRuleRegistry } from './integrity-contribution.js';
21
22
  import { IntegrityPhase, type IntegrityRule, type IntegritySyncMode } from './integrity-rule.js';
22
23
 
@@ -75,6 +76,11 @@ export namespace IntegrityService {
75
76
  * at `DocumentState.Validated` and delivered separately via `publishDiagnostics`
76
77
  * or the `onModelUpdated` event.
77
78
  *
79
+ * The AST is what this guarantees, not the text. For a closed document whose
80
+ * repair was STAGED rather than written (`'editor'` sync mode),
81
+ * `textDocument` still mirrors disk — read the repair off the AST, or from
82
+ * the staged content the next open consumes.
83
+ *
78
84
  * Invariant: integrity rules only register at Parsed or Linked, so the build
79
85
  * is guaranteed post-integrity once it advances past `onBuildPhase(Linked)`
80
86
  * into `IndexedReferences`. {@link IntegrityService.register} enforces this at
@@ -310,24 +316,119 @@ export class DefaultIntegrityService<TRoot extends AstNode = AstNode> implements
310
316
  return;
311
317
  }
312
318
  const root = document.parseResult.value as TRoot;
313
- const newText = await this.services.serializer.Serializer.serializeAst(root);
319
+ // Extracted while `document` still holds the text being replaced — the
320
+ // resync that follows overwrites it with `newText`. Absent on a test
321
+ // stub that binds no trivia group; `createServerLanguageModule` always
322
+ // provides it, and an empty registry is already the no-op.
323
+ const trivia = this.services.trivia?.TriviaService;
324
+ const extracted = trivia?.extract(document);
325
+ const serialized = await this.services.serializer.Serializer.serializeAst(root);
326
+ const newText =
327
+ extracted === undefined ? serialized : trivia!.apply(serialized, extracted, UriUtils.toUri(document.textDocument.uri));
314
328
 
315
329
  const oldText = document.textDocument.getText();
316
330
  if (oldText === newText) {
317
331
  return;
318
332
  }
319
333
 
334
+ const version = document.textDocument.version;
335
+ // Commit into the store's own document when the URI is open there, rather
336
+ // than into whichever text-document object this build is holding. The two
337
+ // are the same on the LSP path and are NOT when the document was built for
338
+ // an already-open URI through `fromString`: repairing only the build's copy
339
+ // leaves the store — the server's authority on what an open document says —
340
+ // on the unrepaired text, and the reconciling re-parse then redefines
341
+ // `textDocument` onto the store's object and discards the repair with it.
342
+ //
343
+ // Compared against the CST's own text, not against `document.textDocument`.
344
+ // That object IS the store's on the LSP path, so asking it whether the
345
+ // store still agrees compares the store with itself and can only ever say
346
+ // yes — the guard would be vacuous exactly where an editor race can happen.
347
+ // The CST's `fullText` is the text that actually produced this AST, which
348
+ // is the only thing a repair derived from it is valid against. A document
349
+ // with no CST (built from a model rather than parsed) has no better answer
350
+ // than the text it is carrying.
351
+ const parsedFrom = document.parseResult.value.$cstNode?.root.fullText ?? oldText;
352
+ const commit = this.textDocuments.commitRepair(document.textDocument.uri, parsedFrom, newText);
353
+ if (commit.status === 'stale') {
354
+ // An edit landed after the parse this repair came from, so the repair
355
+ // describes text the store has already replaced. Abandon it rather than
356
+ // persist or stage it: that edit drives a build of its own, which
357
+ // re-runs these rules against what the document actually says.
358
+ //
359
+ // Abandoning the WRITE is only half of it. The build carries on to its
360
+ // settled phase with whatever AST is registered, and every settled
361
+ // consumer reads that AST rather than the store — so leaving the rule's
362
+ // mutation in place would answer questions about this document from a
363
+ // parse of text nobody has. Reconciling discards it by re-reading the
364
+ // store, which is what the document now has to agree with.
365
+ await this.reconcileDocument(document, cancelToken);
366
+ return;
367
+ }
368
+
320
369
  // Keep the same version so HydraniumTextDocuments doesn't reject subsequent client edits.
321
370
  // Use manager.update so the `instanceof FullTextDocument` gate in the bare
322
371
  // `TextDocument.update` doesn't trip on adopter-custom text-document types.
323
- const textDocument = this.textDocuments.update(document.textDocument, [{ text: newText }], document.textDocument.version);
372
+ const textDocument =
373
+ commit.status === 'committed' ? commit.document : this.textDocuments.update(document.textDocument, [{ text: newText }], version);
324
374
 
325
375
  await this.syncCorrections(textDocument);
326
376
 
377
+ await this.reconcileDocument(document, cancelToken);
378
+
379
+ // Re-version against the REPAIRED text, after either branch. The repair is
380
+ // a content change the store has not seen: whatever reconciliation ran
381
+ // during the re-parse saw the text on disk, which in `'editor'` sync mode
382
+ // is the PRE-repair text. Leave the sequence describing that and the next
383
+ // open hashes the repair, finds a mismatch and steps the version again, so
384
+ // every based-on version taken from this build is stale before it is used.
385
+ // Falls back to the pre-re-parse number for a URI the store never tracked,
386
+ // where there is no sequence to advance; an OPEN document answers
387
+ // `undefined` and keeps the store's own version, which is not this
388
+ // method's to move.
389
+ //
390
+ // Deliberately NOT gated on cancellation, unlike the entry to this method:
391
+ // `syncCorrections` has already written or staged the repair by now, so a
392
+ // preempted build that skipped this would leave the sequence describing
393
+ // text that is no longer there.
394
+ //
395
+ // Gated on the document being closed, because the fallback restores a
396
+ // number this method captured off whatever object it started with — and
397
+ // for a separately created document that is its own seeded numbering, not
398
+ // the store's. Applying it to the store's document (which the re-parse has
399
+ // by then made `textDocument`) would roll the shared version backwards.
400
+ // The store's own answer for an open document is `undefined` either way.
401
+ if (!this.textDocuments.isOpen(document.textDocument.uri)) {
402
+ const reconciled = this.textDocuments.reconcileExternalContent(document.textDocument.uri, newText) ?? version;
403
+ if (document.textDocument.version !== reconciled) {
404
+ this.textDocuments.update(document.textDocument, [], reconciled);
405
+ }
406
+ }
407
+ }
408
+
409
+ /**
410
+ * Bring `document` back into agreement with the text it is supposed to
411
+ * describe, after a rule has mutated its AST.
412
+ *
413
+ * Used for a correction that was applied and for one that was abandoned,
414
+ * because the document is left inconsistent either way: applied, the text
415
+ * moved under the CST; abandoned, the AST carries a mutation the text never
416
+ * had. Both are the same question — re-read and re-derive — and the phase is
417
+ * what decides how far that has to go.
418
+ */
419
+ protected async reconcileDocument(document: LangiumDocument, cancelToken?: CancellationToken): Promise<void> {
327
420
  if (document.state <= DocumentState.Parsed) {
328
421
  // Parsed-phase correction: re-parse only. The build pipeline still runs
329
422
  // IndexedContent → ComputedScopes → Linked → … on the fresh AST afterwards,
330
423
  // so the document reconciles naturally with no extra work here.
424
+ //
425
+ // Except for a closed document whose repair did not reach disk — `'editor'`
426
+ // sync mode stages it instead of writing it — where the re-parse is SKIPPED:
427
+ // Langium's factory gates the parse on the CST's `fullText`, which still
428
+ // equals the disk text the same call re-reads and redefines `textDocument`
429
+ // over. So `document.textDocument` is NOT post-integrity for such a
430
+ // document — it mirrors disk, and the AST is the only place the repair is
431
+ // legible, until an open consumes the staging.
331
432
  await this.documentBuilder.reparse(document, cancelToken);
332
433
  } else {
333
434
  // Linked-phase (or later) correction. The rule mutated the AST in place but
@@ -364,6 +465,19 @@ export class DefaultIntegrityService<TRoot extends AstNode = AstNode> implements
364
465
  return;
365
466
  }
366
467
 
468
+ // A virtual document has no disk backing, so neither persisting nor
469
+ // staging applies: there is no file to write and no editor that could open
470
+ // one. `URI.fsPath` yields a path for any scheme, so handing this to the
471
+ // provider would address `<cwd>/<contributor>/<name>` — an unrelated
472
+ // location a disk-backed provider refuses outright, turning a repair that
473
+ // was never persistable into a build failure. The correction is already on
474
+ // the AST and in the text store, which is the whole of where a virtual
475
+ // document lives, so there is nothing further to propagate.
476
+ if (isVirtualUri(document.uri)) {
477
+ this.tracer.with(document.uri).debug('Virtual document: correction kept in memory, nothing to persist');
478
+ return;
479
+ }
480
+
367
481
  // Closed files, silent mode: write to disk directly.
368
482
  if (this.syncMode === 'silent') {
369
483
  // Async write so the integrity pass does not block the event loop on a slow filesystem.
@@ -0,0 +1,87 @@
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
+ /**
11
+ * Containment-array maintenance for callers that build or delete AST nodes
12
+ * programmatically — a GLSP operation handler being the usual one.
13
+ *
14
+ * **These live beside the key provider because the constraint is the key
15
+ * provider's.** `NameBasedKeyProvider` keys a node the `NameProvider` gives no
16
+ * name from its position, as `` `${$containerProperty}@${$containerIndex}` ``,
17
+ * so a node appended with a bare `array.push` carries neither and
18
+ * `getElementKey` answers `undefined` — the element has no key at all, and the
19
+ * GLSP index cannot address it. Deleting from the middle of such a list must
20
+ * renumber the survivors, or an id derived later in the same command names the
21
+ * wrong node. Shipping the constraint's statement without the code that
22
+ * discharges it leaves every adopter in that position re-deriving thirty lines
23
+ * from prose, and both failures are silent.
24
+ *
25
+ * The population is narrower than "anyone creating elements from a diagram": it
26
+ * takes a grammar with UNNAMED element types, programmatic creation or deletion
27
+ * of them, and this key provider. A grammar whose diagram elements are all
28
+ * named never reaches it, and the two ways out are named on the provider —
29
+ * give the type a name, or bind a provider whose fallback is content-derived.
30
+ *
31
+ * **Free functions, and deliberately not a step on the AST builder.** Building a
32
+ * node detached and appending it later is legitimate, so a containment step
33
+ * cannot be mandatory; and an optional fluent step could not check the index
34
+ * against the array unless it were handed the array, at which point it is these
35
+ * signatures with more ceremony. `AstNodeInit` already accepts the three fields
36
+ * for a caller who has them, which is the case these cover: it is the INDEX that
37
+ * cannot be known without reading the array.
38
+ */
39
+
40
+ import type { AstNode } from '@hydranium/langium';
41
+ import type { Mutable } from '@hydranium/protocol';
42
+
43
+ /**
44
+ * Append `child` to `children`, stamping the Langium containment plumbing
45
+ * (`$container`, `$containerProperty`, `$containerIndex`) so a positional key
46
+ * can address it.
47
+ *
48
+ * `property` and `children` are separate parameters rather than one property
49
+ * name the function dereferences: the array is what the index is derived from,
50
+ * so taking it directly is what makes the two agree by construction instead of
51
+ * by a lookup that a typo could point elsewhere.
52
+ *
53
+ * @returns `child`, so a caller can append and use it in one expression.
54
+ */
55
+ export function appendChild<TChild extends AstNode>(container: AstNode, property: string, children: TChild[], child: TChild): TChild {
56
+ const mutable = child as Mutable<TChild>;
57
+ mutable.$container = container;
58
+ mutable.$containerProperty = property;
59
+ mutable.$containerIndex = children.length;
60
+ children.push(child);
61
+ return child;
62
+ }
63
+
64
+ /**
65
+ * Remove every entry of `children` that is in `toRemove`, then renumber the
66
+ * survivors' `$containerIndex`.
67
+ *
68
+ * Mutates `children` in place rather than returning a new array, because the
69
+ * caller's array IS the AST's containment list — replacing the reference would
70
+ * leave the parent pointing at the old one.
71
+ *
72
+ * @returns how many entries were removed, so a caller can tell a no-op delete
73
+ * from one that changed the model without comparing lengths itself.
74
+ */
75
+ export function removeChildren<TChild extends AstNode>(children: TChild[], toRemove: ReadonlySet<TChild>): number {
76
+ if (toRemove.size === 0) {
77
+ return 0;
78
+ }
79
+ const survivors = children.filter(child => !toRemove.has(child));
80
+ const removed = children.length - survivors.length;
81
+ children.length = 0;
82
+ for (const [index, child] of survivors.entries()) {
83
+ (child as Mutable<TChild>).$containerIndex = index;
84
+ children.push(child);
85
+ }
86
+ return removed;
87
+ }
@@ -7,6 +7,7 @@
7
7
  * SPDX-License-Identifier: MIT
8
8
  ********************************************************************************/
9
9
 
10
+ export * from './containment.js';
10
11
  export * from './element-key-provider.js';
11
12
  export * from './name-based-key-provider.js';
12
13
  export * from './positional-key-provider.js';
@@ -55,6 +55,10 @@ import { type NameProvider } from '../naming/name-provider.js';
55
55
  * - After a removal, surviving siblings need their `$containerIndex`
56
56
  * renumbered, or a key derived afterwards addresses the wrong node.
57
57
  *
58
+ * {@link appendChild} and {@link removeChildren} discharge both, and ship
59
+ * beside this provider because the constraint is this provider's rather than
60
+ * any caller's.
61
+ *
58
62
  * Adopters that need insert / delete stability for unnamed types should
59
63
  * give those types a name in the grammar, or bind a key provider whose
60
64
  * fallback is content-derived rather than positional.
@@ -28,6 +28,10 @@ import { DefaultReferenceBuilder, type ReferenceBuilder } from './scope/referenc
28
28
  import { type ScopeExtensionContribution } from './scope/scope-extension-contribution.js';
29
29
  import { DefaultScopeExtensionService, type ScopeExtensionService } from './scope/scope-extension-service.js';
30
30
  import { type Serializer } from './serialization/serializer.js';
31
+ import { type TriviaContribution } from './trivia/trivia-contribution.js';
32
+ import { type TriviaService, DefaultTriviaService } from './trivia/trivia-service.js';
33
+ import { CommentPreserverContribution } from './trivia/comment-preserver.js';
34
+ import { DocumentEndingPreserverContribution } from './trivia/document-ending-preserver.js';
31
35
  import { type UpdateRewriteContribution } from './update-rewrite/update-rewrite-contribution.js';
32
36
  import { DefaultUpdateRewriteService, type UpdateRewriteService } from './update-rewrite/update-rewrite-service.js';
33
37
  import { HydraniumDocumentValidator } from './validation/document-validator.js';
@@ -181,6 +185,29 @@ export interface ServerAddedServices {
181
185
  */
182
186
  rules: Record<string, IntegrityRuleContribution>;
183
187
  };
188
+ trivia: {
189
+ /**
190
+ * Runs the registered trivia preservers around a write, so what a
191
+ * document carries that its model does not — its comments, the whitespace
192
+ * it ended with — survives being re-serialized from that model.
193
+ *
194
+ * A separate group from {@link Serializer} because a preserver needs the
195
+ * document being overwritten, which a serializer is never given:
196
+ * `serializeAst` could reach one through its model, but
197
+ * `serializeTransfer` receives a plain wire object with no document at
198
+ * all, so folding this in would carry trivia on one write path and
199
+ * silently not on the other.
200
+ */
201
+ TriviaService: TriviaService;
202
+ /**
203
+ * Declarative {@link TriviaContribution} group. Distinct sub-keys
204
+ * accumulate across framework + adopter modules via Langium's deep-merge;
205
+ * binding one the framework already uses REPLACES it. The framework ships
206
+ * a sub-key per preserver, so an adopter replacing `comments` keeps
207
+ * `documentEnding` and whatever else ships beside it.
208
+ */
209
+ preservers: Record<string, TriviaContribution>;
210
+ };
184
211
  updateRewrite: {
185
212
  /**
186
213
  * Per-language runner for transfer-model rewrites applied on the
@@ -334,6 +361,17 @@ export function createServerLanguageModule(
334
361
  serializer: {
335
362
  Serializer: () => new UnboundSerializer()
336
363
  },
364
+ // Bound with a sub-key per preserver so an adopter can replace one and
365
+ // keep the other. Adopters MUST avoid these two keys for their own
366
+ // contributions unless replacement is what they mean — Langium's
367
+ // deep-merge is last-wins on same-key leaves.
368
+ trivia: {
369
+ TriviaService: services => new DefaultTriviaService(services),
370
+ preservers: {
371
+ comments: services => new CommentPreserverContribution(services),
372
+ documentEnding: () => new DocumentEndingPreserverContribution()
373
+ }
374
+ },
337
375
  // The per-URI serialise / re-parse path only fires when a rule mutates,
338
376
  // so the no-op default is safe even before adopters bind a real
339
377
  // serializer / parser.