@hydranium/core 1.0.0-next.19 → 1.0.0-next.193

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 (588) hide show
  1. package/README.md +6 -2
  2. package/lib/documents/ast-document-manager.d.ts +222 -63
  3. package/lib/documents/ast-document-manager.d.ts.map +1 -1
  4. package/lib/documents/ast-document-manager.js +250 -83
  5. package/lib/documents/ast-document-manager.js.map +1 -1
  6. package/lib/documents/client-ids.d.ts +5 -19
  7. package/lib/documents/client-ids.d.ts.map +1 -1
  8. package/lib/documents/client-ids.js +5 -19
  9. package/lib/documents/client-ids.js.map +1 -1
  10. package/lib/documents/client-session-errors.d.ts +15 -0
  11. package/lib/documents/client-session-errors.d.ts.map +1 -0
  12. package/lib/documents/client-session-errors.js +15 -0
  13. package/lib/documents/client-session-errors.js.map +1 -0
  14. package/lib/documents/client-session-registry.d.ts +138 -0
  15. package/lib/documents/client-session-registry.d.ts.map +1 -0
  16. package/lib/documents/client-session-registry.js +187 -0
  17. package/lib/documents/client-session-registry.js.map +1 -0
  18. package/lib/documents/file-system-task-queue.d.ts +49 -0
  19. package/lib/documents/file-system-task-queue.d.ts.map +1 -0
  20. package/lib/documents/file-system-task-queue.js +34 -0
  21. package/lib/documents/file-system-task-queue.js.map +1 -0
  22. package/lib/documents/hydranium-text-documents.d.ts +523 -101
  23. package/lib/documents/hydranium-text-documents.d.ts.map +1 -1
  24. package/lib/documents/hydranium-text-documents.js +961 -177
  25. package/lib/documents/hydranium-text-documents.js.map +1 -1
  26. package/lib/documents/index.d.ts +5 -0
  27. package/lib/documents/index.d.ts.map +1 -1
  28. package/lib/documents/index.js +5 -0
  29. package/lib/documents/index.js.map +1 -1
  30. package/lib/documents/language-client-text-shadow.d.ts +41 -9
  31. package/lib/documents/language-client-text-shadow.d.ts.map +1 -1
  32. package/lib/documents/language-client-text-shadow.js +56 -11
  33. package/lib/documents/language-client-text-shadow.js.map +1 -1
  34. package/lib/documents/model-ledger.d.ts +47 -0
  35. package/lib/documents/model-ledger.d.ts.map +1 -0
  36. package/lib/documents/model-ledger.js +30 -0
  37. package/lib/documents/model-ledger.js.map +1 -0
  38. package/lib/documents/self-save-registry.d.ts +37 -6
  39. package/lib/documents/self-save-registry.d.ts.map +1 -1
  40. package/lib/documents/self-save-registry.js +28 -15
  41. package/lib/documents/self-save-registry.js.map +1 -1
  42. package/lib/documents/version-sync-service.d.ts +134 -0
  43. package/lib/documents/version-sync-service.d.ts.map +1 -0
  44. package/lib/documents/version-sync-service.js +171 -0
  45. package/lib/documents/version-sync-service.js.map +1 -0
  46. package/lib/index.d.ts +3 -0
  47. package/lib/index.d.ts.map +1 -1
  48. package/lib/index.js +6 -0
  49. package/lib/index.js.map +1 -1
  50. package/lib/langium/ast-extension/ast-extension-service.d.ts.map +1 -1
  51. package/lib/langium/ast-extension/ast-extension-service.js.map +1 -1
  52. package/lib/langium/ast-extension/ast-node-builder.d.ts +32 -9
  53. package/lib/langium/ast-extension/ast-node-builder.d.ts.map +1 -1
  54. package/lib/langium/ast-extension/ast-node-builder.js +60 -22
  55. package/lib/langium/ast-extension/ast-node-builder.js.map +1 -1
  56. package/lib/langium/bootstrap.d.ts.map +1 -1
  57. package/lib/langium/bootstrap.js +32 -9
  58. package/lib/langium/bootstrap.js.map +1 -1
  59. package/lib/langium/build-phase-pass/build-phase-pass-service.d.ts.map +1 -1
  60. package/lib/langium/build-phase-pass/build-phase-pass-service.js.map +1 -1
  61. package/lib/langium/config/configuration-provider.d.ts +81 -0
  62. package/lib/langium/config/configuration-provider.d.ts.map +1 -0
  63. package/lib/langium/config/configuration-provider.js +112 -0
  64. package/lib/langium/config/configuration-provider.js.map +1 -0
  65. package/lib/langium/config/index.d.ts +1 -0
  66. package/lib/langium/config/index.d.ts.map +1 -1
  67. package/lib/langium/config/index.js +1 -0
  68. package/lib/langium/config/index.js.map +1 -1
  69. package/lib/langium/config/settings.js.map +1 -1
  70. package/lib/langium/diagnostics/hydranium-langium-profiler.d.ts.map +1 -1
  71. package/lib/langium/diagnostics/hydranium-langium-profiler.js.map +1 -1
  72. package/lib/langium/diagnostics/logger.d.ts +10 -3
  73. package/lib/langium/diagnostics/logger.d.ts.map +1 -1
  74. package/lib/langium/diagnostics/logger.js +12 -5
  75. package/lib/langium/diagnostics/logger.js.map +1 -1
  76. package/lib/langium/diagnostics/lsp-logger.d.ts +17 -0
  77. package/lib/langium/diagnostics/lsp-logger.d.ts.map +1 -1
  78. package/lib/langium/diagnostics/lsp-logger.js +56 -13
  79. package/lib/langium/diagnostics/lsp-logger.js.map +1 -1
  80. package/lib/langium/diagnostics/server-tracer.d.ts.map +1 -1
  81. package/lib/langium/diagnostics/server-tracer.js.map +1 -1
  82. package/lib/langium/document-builder/build-pipeline-integration.d.ts +21 -1
  83. package/lib/langium/document-builder/build-pipeline-integration.d.ts.map +1 -1
  84. package/lib/langium/document-builder/build-pipeline-integration.js +32 -5
  85. package/lib/langium/document-builder/build-pipeline-integration.js.map +1 -1
  86. package/lib/langium/document-builder/build-session.d.ts +93 -0
  87. package/lib/langium/document-builder/build-session.d.ts.map +1 -0
  88. package/lib/langium/document-builder/build-session.js +72 -0
  89. package/lib/langium/document-builder/build-session.js.map +1 -0
  90. package/lib/langium/document-builder/document-builder.d.ts +382 -29
  91. package/lib/langium/document-builder/document-builder.d.ts.map +1 -1
  92. package/lib/langium/document-builder/document-builder.js +659 -61
  93. package/lib/langium/document-builder/document-builder.js.map +1 -1
  94. package/lib/langium/document-builder/index.d.ts +1 -0
  95. package/lib/langium/document-builder/index.d.ts.map +1 -1
  96. package/lib/langium/document-builder/index.js +1 -0
  97. package/lib/langium/document-builder/index.js.map +1 -1
  98. package/lib/langium/documentation/comment-provider.d.ts.map +1 -1
  99. package/lib/langium/documentation/comment-provider.js.map +1 -1
  100. package/lib/langium/integration-services.d.ts +45 -1
  101. package/lib/langium/integration-services.d.ts.map +1 -1
  102. package/lib/langium/integration-services.js +10 -5
  103. package/lib/langium/integration-services.js.map +1 -1
  104. package/lib/langium/integrity/integrity-rule.d.ts +13 -5
  105. package/lib/langium/integrity/integrity-rule.d.ts.map +1 -1
  106. package/lib/langium/integrity/integrity-rule.js.map +1 -1
  107. package/lib/langium/integrity/integrity-service.d.ts +58 -13
  108. package/lib/langium/integrity/integrity-service.d.ts.map +1 -1
  109. package/lib/langium/integrity/integrity-service.js +204 -29
  110. package/lib/langium/integrity/integrity-service.js.map +1 -1
  111. package/lib/langium/keys/containment.d.ts +64 -0
  112. package/lib/langium/keys/containment.d.ts.map +1 -0
  113. package/lib/langium/keys/containment.js +53 -0
  114. package/lib/langium/keys/containment.js.map +1 -0
  115. package/lib/langium/keys/index.d.ts +1 -0
  116. package/lib/langium/keys/index.d.ts.map +1 -1
  117. package/lib/langium/keys/index.js +1 -0
  118. package/lib/langium/keys/index.js.map +1 -1
  119. package/lib/langium/keys/name-based-key-provider.d.ts +4 -0
  120. package/lib/langium/keys/name-based-key-provider.d.ts.map +1 -1
  121. package/lib/langium/keys/name-based-key-provider.js +4 -0
  122. package/lib/langium/keys/name-based-key-provider.js.map +1 -1
  123. package/lib/langium/keys/positional-key-provider.d.ts.map +1 -1
  124. package/lib/langium/keys/positional-key-provider.js.map +1 -1
  125. package/lib/langium/labeling/label-provider.d.ts.map +1 -1
  126. package/lib/langium/labeling/label-provider.js.map +1 -1
  127. package/lib/langium/language-module.d.ts +27 -2
  128. package/lib/langium/language-module.d.ts.map +1 -1
  129. package/lib/langium/language-module.js +16 -2
  130. package/lib/langium/language-module.js.map +1 -1
  131. package/lib/langium/model-service/client-session.d.ts +330 -0
  132. package/lib/langium/model-service/client-session.d.ts.map +1 -0
  133. package/lib/langium/model-service/client-session.js +418 -0
  134. package/lib/langium/model-service/client-session.js.map +1 -0
  135. package/lib/langium/model-service/index.d.ts +1 -0
  136. package/lib/langium/model-service/index.d.ts.map +1 -1
  137. package/lib/langium/model-service/index.js +1 -0
  138. package/lib/langium/model-service/index.js.map +1 -1
  139. package/lib/langium/model-service/model-service.d.ts +353 -253
  140. package/lib/langium/model-service/model-service.d.ts.map +1 -1
  141. package/lib/langium/model-service/model-service.js +361 -408
  142. package/lib/langium/model-service/model-service.js.map +1 -1
  143. package/lib/langium/module.d.ts +150 -35
  144. package/lib/langium/module.d.ts.map +1 -1
  145. package/lib/langium/module.js +50 -35
  146. package/lib/langium/module.js.map +1 -1
  147. package/lib/langium/naming/name-provider.d.ts +25 -4
  148. package/lib/langium/naming/name-provider.d.ts.map +1 -1
  149. package/lib/langium/naming/name-provider.js +2 -1
  150. package/lib/langium/naming/name-provider.js.map +1 -1
  151. package/lib/langium/naming/name-separator-validation.d.ts +23 -0
  152. package/lib/langium/naming/name-separator-validation.d.ts.map +1 -1
  153. package/lib/langium/naming/name-separator-validation.js +30 -1
  154. package/lib/langium/naming/name-separator-validation.js.map +1 -1
  155. package/lib/langium/project/abstract-project-manager.d.ts.map +1 -1
  156. package/lib/langium/project/abstract-project-manager.js +9 -2
  157. package/lib/langium/project/abstract-project-manager.js.map +1 -1
  158. package/lib/langium/project/project-change-event.d.ts +2 -2
  159. package/lib/langium/project/single-project-manager.d.ts.map +1 -1
  160. package/lib/langium/project/single-project-manager.js.map +1 -1
  161. package/lib/langium/residency/cst-residency-service.d.ts +31 -11
  162. package/lib/langium/residency/cst-residency-service.d.ts.map +1 -1
  163. package/lib/langium/residency/cst-residency-service.js +23 -57
  164. package/lib/langium/residency/cst-residency-service.js.map +1 -1
  165. package/lib/langium/scope/ast-node-description-provider.d.ts.map +1 -1
  166. package/lib/langium/scope/ast-node-description-provider.js.map +1 -1
  167. package/lib/langium/scope/hydranium-scope-computation.d.ts.map +1 -1
  168. package/lib/langium/scope/hydranium-scope-computation.js.map +1 -1
  169. package/lib/langium/scope/hydranium-scope-provider.d.ts +48 -13
  170. package/lib/langium/scope/hydranium-scope-provider.d.ts.map +1 -1
  171. package/lib/langium/scope/hydranium-scope-provider.js +56 -20
  172. package/lib/langium/scope/hydranium-scope-provider.js.map +1 -1
  173. package/lib/langium/scope/reference-builder.d.ts.map +1 -1
  174. package/lib/langium/scope/reference-builder.js.map +1 -1
  175. package/lib/langium/scope/reference-candidate-provider.d.ts.map +1 -1
  176. package/lib/langium/scope/reference-candidate-provider.js.map +1 -1
  177. package/lib/langium/scope/scope-extension-service.d.ts.map +1 -1
  178. package/lib/langium/scope/scope-extension-service.js.map +1 -1
  179. package/lib/langium/serialization/abstract-serializer.d.ts +11 -20
  180. package/lib/langium/serialization/abstract-serializer.d.ts.map +1 -1
  181. package/lib/langium/serialization/abstract-serializer.js +12 -21
  182. package/lib/langium/serialization/abstract-serializer.js.map +1 -1
  183. package/lib/langium/serialization/json-serializer.d.ts +1 -1
  184. package/lib/langium/serialization/json-serializer.d.ts.map +1 -1
  185. package/lib/langium/serialization/json-serializer.js.map +1 -1
  186. package/lib/langium/serialization/yaml-serializer.d.ts.map +1 -1
  187. package/lib/langium/serialization/yaml-serializer.js.map +1 -1
  188. package/lib/langium/service-registry.d.ts +15 -1
  189. package/lib/langium/service-registry.d.ts.map +1 -1
  190. package/lib/langium/service-registry.js +16 -0
  191. package/lib/langium/service-registry.js.map +1 -1
  192. package/lib/langium/shared-services.d.ts +21 -4
  193. package/lib/langium/shared-services.d.ts.map +1 -1
  194. package/lib/langium/shared-services.js.map +1 -1
  195. package/lib/langium/transfer/transfer-encoder.d.ts +75 -23
  196. package/lib/langium/transfer/transfer-encoder.d.ts.map +1 -1
  197. package/lib/langium/transfer/transfer-encoder.js +44 -21
  198. package/lib/langium/transfer/transfer-encoder.js.map +1 -1
  199. package/lib/langium/trivia/comment-preserver.d.ts +423 -0
  200. package/lib/langium/trivia/comment-preserver.d.ts.map +1 -0
  201. package/lib/langium/trivia/comment-preserver.js +906 -0
  202. package/lib/langium/trivia/comment-preserver.js.map +1 -0
  203. package/lib/langium/trivia/document-ending-preserver.d.ts +43 -0
  204. package/lib/langium/trivia/document-ending-preserver.d.ts.map +1 -0
  205. package/lib/langium/trivia/document-ending-preserver.js +48 -0
  206. package/lib/langium/trivia/document-ending-preserver.js.map +1 -0
  207. package/lib/langium/trivia/index.d.ts +14 -0
  208. package/lib/langium/trivia/index.d.ts.map +1 -0
  209. package/lib/langium/trivia/index.js +14 -0
  210. package/lib/langium/trivia/index.js.map +1 -0
  211. package/lib/langium/trivia/trivia-contribution.d.ts +37 -0
  212. package/lib/langium/trivia/trivia-contribution.d.ts.map +1 -0
  213. package/lib/langium/trivia/trivia-contribution.js +10 -0
  214. package/lib/langium/trivia/trivia-contribution.js.map +1 -0
  215. package/lib/langium/trivia/trivia-preserver.d.ts +50 -0
  216. package/lib/langium/trivia/trivia-preserver.d.ts.map +1 -0
  217. package/lib/langium/trivia/trivia-preserver.js +10 -0
  218. package/lib/langium/trivia/trivia-preserver.js.map +1 -0
  219. package/lib/langium/trivia/trivia-service.d.ts +70 -0
  220. package/lib/langium/trivia/trivia-service.d.ts.map +1 -0
  221. package/lib/langium/trivia/trivia-service.js +56 -0
  222. package/lib/langium/trivia/trivia-service.js.map +1 -0
  223. package/lib/langium/update-rewrite/normalize-empty-strings.d.ts.map +1 -1
  224. package/lib/langium/update-rewrite/update-rewrite-service.d.ts.map +1 -1
  225. package/lib/langium/update-rewrite/update-rewrite-service.js.map +1 -1
  226. package/lib/langium/update-rewrite/update-rewrite.d.ts +1 -1
  227. package/lib/langium/validation/document-validator.d.ts +294 -10
  228. package/lib/langium/validation/document-validator.d.ts.map +1 -1
  229. package/lib/langium/validation/document-validator.js +448 -5
  230. package/lib/langium/validation/document-validator.js.map +1 -1
  231. package/lib/langium/validation/validation-contribution-collector.d.ts.map +1 -1
  232. package/lib/langium/validation/validation-contribution-collector.js.map +1 -1
  233. package/lib/langium/workspace/document-uri-policy.d.ts +17 -12
  234. package/lib/langium/workspace/document-uri-policy.d.ts.map +1 -1
  235. package/lib/langium/workspace/document-uri-policy.js +10 -9
  236. package/lib/langium/workspace/document-uri-policy.js.map +1 -1
  237. package/lib/langium/workspace/file-not-found.d.ts +17 -0
  238. package/lib/langium/workspace/file-not-found.d.ts.map +1 -0
  239. package/lib/langium/workspace/file-not-found.js +20 -0
  240. package/lib/langium/workspace/file-not-found.js.map +1 -0
  241. package/lib/langium/workspace/file-system-provider.d.ts +84 -8
  242. package/lib/langium/workspace/file-system-provider.d.ts.map +1 -1
  243. package/lib/langium/workspace/file-system-provider.js +93 -14
  244. package/lib/langium/workspace/file-system-provider.js.map +1 -1
  245. package/lib/langium/workspace/hydranium-langium-document-factory.d.ts +56 -1
  246. package/lib/langium/workspace/hydranium-langium-document-factory.d.ts.map +1 -1
  247. package/lib/langium/workspace/hydranium-langium-document-factory.js +79 -0
  248. package/lib/langium/workspace/hydranium-langium-document-factory.js.map +1 -1
  249. package/lib/langium/workspace/hydranium-workspace-lock.d.ts +43 -1
  250. package/lib/langium/workspace/hydranium-workspace-lock.d.ts.map +1 -1
  251. package/lib/langium/workspace/hydranium-workspace-lock.js +58 -1
  252. package/lib/langium/workspace/hydranium-workspace-lock.js.map +1 -1
  253. package/lib/langium/workspace/hydranium-workspace-manager.d.ts +81 -8
  254. package/lib/langium/workspace/hydranium-workspace-manager.d.ts.map +1 -1
  255. package/lib/langium/workspace/hydranium-workspace-manager.js +128 -10
  256. package/lib/langium/workspace/hydranium-workspace-manager.js.map +1 -1
  257. package/lib/langium/workspace/in-memory-file-system-provider.d.ts +25 -2
  258. package/lib/langium/workspace/in-memory-file-system-provider.d.ts.map +1 -1
  259. package/lib/langium/workspace/in-memory-file-system-provider.js +41 -15
  260. package/lib/langium/workspace/in-memory-file-system-provider.js.map +1 -1
  261. package/lib/langium/workspace/index-manager.d.ts.map +1 -1
  262. package/lib/langium/workspace/index-manager.js.map +1 -1
  263. package/lib/langium/workspace/initialize-workspace.d.ts +31 -2
  264. package/lib/langium/workspace/initialize-workspace.d.ts.map +1 -1
  265. package/lib/langium/workspace/initialize-workspace.js +13 -5
  266. package/lib/langium/workspace/initialize-workspace.js.map +1 -1
  267. package/lib/langium/workspace/langium-documents.d.ts +86 -17
  268. package/lib/langium/workspace/langium-documents.d.ts.map +1 -1
  269. package/lib/langium/workspace/langium-documents.js +101 -29
  270. package/lib/langium/workspace/langium-documents.js.map +1 -1
  271. package/lib/langium/workspace/persistent-file-system-provider.d.ts +0 -7
  272. package/lib/langium/workspace/persistent-file-system-provider.d.ts.map +1 -1
  273. package/lib/langium/workspace/persistent-file-system-provider.js +0 -7
  274. package/lib/langium/workspace/persistent-file-system-provider.js.map +1 -1
  275. package/lib/langium/workspace/virtual-document.d.ts +48 -15
  276. package/lib/langium/workspace/virtual-document.d.ts.map +1 -1
  277. package/lib/langium/workspace/virtual-document.js +78 -18
  278. package/lib/langium/workspace/virtual-document.js.map +1 -1
  279. package/lib/langium/workspace/write-lock-scope.d.ts +20 -10
  280. package/lib/langium/workspace/write-lock-scope.d.ts.map +1 -1
  281. package/lib/langium/workspace/write-lock-scope.js +12 -4
  282. package/lib/langium/workspace/write-lock-scope.js.map +1 -1
  283. package/lib/locale/index.d.ts +10 -0
  284. package/lib/locale/index.d.ts.map +1 -0
  285. package/lib/locale/index.js +10 -0
  286. package/lib/locale/index.js.map +1 -0
  287. package/lib/locale/server-locale.d.ts +73 -0
  288. package/lib/locale/server-locale.d.ts.map +1 -0
  289. package/lib/locale/server-locale.js +61 -0
  290. package/lib/locale/server-locale.js.map +1 -0
  291. package/lib/lsp/completion/hydranium-completion-provider.d.ts +44 -2
  292. package/lib/lsp/completion/hydranium-completion-provider.d.ts.map +1 -1
  293. package/lib/lsp/completion/hydranium-completion-provider.js +68 -0
  294. package/lib/lsp/completion/hydranium-completion-provider.js.map +1 -1
  295. package/lib/lsp/connection-features.d.ts +23 -0
  296. package/lib/lsp/connection-features.d.ts.map +1 -0
  297. package/lib/lsp/connection-features.js +60 -0
  298. package/lib/lsp/connection-features.js.map +1 -0
  299. package/lib/lsp/diagnostics-connection.d.ts +27 -0
  300. package/lib/lsp/diagnostics-connection.d.ts.map +1 -0
  301. package/lib/lsp/diagnostics-connection.js +53 -0
  302. package/lib/lsp/diagnostics-connection.js.map +1 -0
  303. package/lib/lsp/hydranium-document-update-handler.d.ts +90 -79
  304. package/lib/lsp/hydranium-document-update-handler.d.ts.map +1 -1
  305. package/lib/lsp/hydranium-document-update-handler.js +153 -99
  306. package/lib/lsp/hydranium-document-update-handler.js.map +1 -1
  307. package/lib/lsp/index.d.ts +3 -1
  308. package/lib/lsp/index.d.ts.map +1 -1
  309. package/lib/lsp/index.js +3 -1
  310. package/lib/lsp/index.js.map +1 -1
  311. package/lib/lsp/lsp-latency.d.ts +39 -0
  312. package/lib/lsp/lsp-latency.d.ts.map +1 -0
  313. package/lib/lsp/lsp-latency.js +58 -0
  314. package/lib/lsp/lsp-latency.js.map +1 -0
  315. package/lib/lsp/semantic-token-provider.d.ts +34 -1
  316. package/lib/lsp/semantic-token-provider.d.ts.map +1 -1
  317. package/lib/lsp/semantic-token-provider.js +55 -8
  318. package/lib/lsp/semantic-token-provider.js.map +1 -1
  319. package/lib/lsp/shared-module.d.ts +4 -8
  320. package/lib/lsp/shared-module.d.ts.map +1 -1
  321. package/lib/lsp/shared-module.js.map +1 -1
  322. package/lib/lsp/start-language-server.d.ts +8 -7
  323. package/lib/lsp/start-language-server.d.ts.map +1 -1
  324. package/lib/lsp/start-language-server.js +13 -7
  325. package/lib/lsp/start-language-server.js.map +1 -1
  326. package/lib/messages/carriers.d.ts +54 -0
  327. package/lib/messages/carriers.d.ts.map +1 -0
  328. package/lib/messages/carriers.js +62 -0
  329. package/lib/messages/carriers.js.map +1 -0
  330. package/lib/messages/index.d.ts +25 -0
  331. package/lib/messages/index.d.ts.map +1 -0
  332. package/lib/messages/index.js +25 -0
  333. package/lib/messages/index.js.map +1 -0
  334. package/lib/messages/renderer.d.ts +142 -0
  335. package/lib/messages/renderer.d.ts.map +1 -0
  336. package/lib/messages/renderer.js +165 -0
  337. package/lib/messages/renderer.js.map +1 -0
  338. package/lib/node/event-loop-monitor.js.map +1 -1
  339. package/lib/node/heap-ceiling.d.ts +61 -0
  340. package/lib/node/heap-ceiling.d.ts.map +1 -0
  341. package/lib/node/heap-ceiling.js +72 -0
  342. package/lib/node/heap-ceiling.js.map +1 -0
  343. package/lib/node/index.d.ts +1 -0
  344. package/lib/node/index.d.ts.map +1 -1
  345. package/lib/node/index.js +1 -0
  346. package/lib/node/index.js.map +1 -1
  347. package/lib/node/latency-from-env.d.ts +1 -1
  348. package/lib/node/latency-from-env.js +1 -1
  349. package/lib/node/lint-grammar.js.map +1 -1
  350. package/lib/node/measure-memory.d.ts.map +1 -1
  351. package/lib/node/measure-memory.js +1 -0
  352. package/lib/node/measure-memory.js.map +1 -1
  353. package/lib/node/memory-monitor.js.map +1 -1
  354. package/lib/node/node-file-system-provider.d.ts +39 -4
  355. package/lib/node/node-file-system-provider.d.ts.map +1 -1
  356. package/lib/node/node-file-system-provider.js +109 -49
  357. package/lib/node/node-file-system-provider.js.map +1 -1
  358. package/lib/node/process-memory.js.map +1 -1
  359. package/lib/node/profile-capture.d.ts +8 -2
  360. package/lib/node/profile-capture.d.ts.map +1 -1
  361. package/lib/node/profile-capture.js.map +1 -1
  362. package/lib/node/profile-digest.js.map +1 -1
  363. package/lib/node/profiling-run.d.ts +13 -3
  364. package/lib/node/profiling-run.d.ts.map +1 -1
  365. package/lib/node/profiling-run.js +17 -8
  366. package/lib/node/profiling-run.js.map +1 -1
  367. package/lib/node/rename-over-open-readers.d.ts +52 -0
  368. package/lib/node/rename-over-open-readers.d.ts.map +1 -0
  369. package/lib/node/rename-over-open-readers.js +66 -0
  370. package/lib/node/rename-over-open-readers.js.map +1 -0
  371. package/lib/node/socket-launcher.d.ts +16 -1
  372. package/lib/node/socket-launcher.d.ts.map +1 -1
  373. package/lib/node/socket-launcher.js +4 -3
  374. package/lib/node/socket-launcher.js.map +1 -1
  375. package/lib/node/stdio-launcher.d.ts +1 -1
  376. package/lib/node/stdio-launcher.d.ts.map +1 -1
  377. package/lib/node/stdio-launcher.js +1 -1
  378. package/lib/node/stdio-launcher.js.map +1 -1
  379. package/lib/testing/document-uri-policy-conformance.js.map +1 -1
  380. package/lib/testing/fake-description.js.map +1 -1
  381. package/lib/testing/fake-document.d.ts +16 -4
  382. package/lib/testing/fake-document.d.ts.map +1 -1
  383. package/lib/testing/fake-document.js +18 -3
  384. package/lib/testing/fake-document.js.map +1 -1
  385. package/lib/testing/index.d.ts +1 -1
  386. package/lib/testing/index.d.ts.map +1 -1
  387. package/lib/testing/index.js +2 -1
  388. package/lib/testing/index.js.map +1 -1
  389. package/lib/testing/langium-test-helpers.d.ts.map +1 -1
  390. package/lib/testing/langium-test-helpers.js +1 -0
  391. package/lib/testing/langium-test-helpers.js.map +1 -1
  392. package/lib/testing/make-noop-language-services.js.map +1 -1
  393. package/lib/testing/make-noop-shared-services.d.ts +14 -0
  394. package/lib/testing/make-noop-shared-services.d.ts.map +1 -1
  395. package/lib/testing/make-noop-shared-services.js +28 -2
  396. package/lib/testing/make-noop-shared-services.js.map +1 -1
  397. package/lib/testing/make-test-services.d.ts +69 -14
  398. package/lib/testing/make-test-services.d.ts.map +1 -1
  399. package/lib/testing/make-test-services.js +39 -10
  400. package/lib/testing/make-test-services.js.map +1 -1
  401. package/lib/testing/make-test-tracer.js.map +1 -1
  402. package/lib/testing/node/golden-corpus.js.map +1 -1
  403. package/lib/testing/node/index.d.ts +1 -0
  404. package/lib/testing/node/index.d.ts.map +1 -1
  405. package/lib/testing/node/index.js +1 -0
  406. package/lib/testing/node/index.js.map +1 -1
  407. package/lib/testing/node/lsp-harness.d.ts.map +1 -1
  408. package/lib/testing/node/lsp-harness.js +2 -0
  409. package/lib/testing/node/lsp-harness.js.map +1 -1
  410. package/lib/testing/node/lsp-server-connection.d.ts +11 -3
  411. package/lib/testing/node/lsp-server-connection.d.ts.map +1 -1
  412. package/lib/testing/node/lsp-server-connection.js +42 -9
  413. package/lib/testing/node/lsp-server-connection.js.map +1 -1
  414. package/lib/testing/node/scratch-workspace.d.ts.map +1 -1
  415. package/lib/testing/node/scratch-workspace.js +10 -5
  416. package/lib/testing/node/scratch-workspace.js.map +1 -1
  417. package/lib/testing/node/spawned-server.d.ts +14 -0
  418. package/lib/testing/node/spawned-server.d.ts.map +1 -1
  419. package/lib/testing/node/spawned-server.js +33 -1
  420. package/lib/testing/node/spawned-server.js.map +1 -1
  421. package/lib/testing/node/unhandled-rejections.d.ts +20 -0
  422. package/lib/testing/node/unhandled-rejections.d.ts.map +1 -0
  423. package/lib/testing/node/unhandled-rejections.js +32 -0
  424. package/lib/testing/node/unhandled-rejections.js.map +1 -0
  425. package/lib/testing/playwright/browser-capture-bridge.js.map +1 -1
  426. package/lib/testing/playwright/e2e-profiling.js.map +1 -1
  427. package/lib/testing/playwright/flaky-network-proxy.d.ts +76 -0
  428. package/lib/testing/playwright/flaky-network-proxy.d.ts.map +1 -0
  429. package/lib/testing/playwright/flaky-network-proxy.js +164 -0
  430. package/lib/testing/playwright/flaky-network-proxy.js.map +1 -0
  431. package/lib/testing/playwright/index.d.ts +1 -0
  432. package/lib/testing/playwright/index.d.ts.map +1 -1
  433. package/lib/testing/playwright/index.js +1 -0
  434. package/lib/testing/playwright/index.js.map +1 -1
  435. package/lib/testing/playwright/server-log-capture.d.ts +24 -8
  436. package/lib/testing/playwright/server-log-capture.d.ts.map +1 -1
  437. package/lib/testing/playwright/server-log-capture.js +27 -6
  438. package/lib/testing/playwright/server-log-capture.js.map +1 -1
  439. package/lib/testing/playwright/server-log-rename-reporter.d.ts.map +1 -1
  440. package/lib/testing/playwright/server-log-rename-reporter.js +10 -1
  441. package/lib/testing/playwright/server-log-rename-reporter.js.map +1 -1
  442. package/lib/testing/run-update-pipeline.d.ts +4 -4
  443. package/lib/testing/run-update-pipeline.d.ts.map +1 -1
  444. package/lib/testing/stub-ast-document-manager.d.ts +11 -9
  445. package/lib/testing/stub-ast-document-manager.d.ts.map +1 -1
  446. package/lib/testing/stub-ast-document-manager.js +25 -9
  447. package/lib/testing/stub-ast-document-manager.js.map +1 -1
  448. package/lib/testing/stub-document-builder.d.ts +26 -11
  449. package/lib/testing/stub-document-builder.d.ts.map +1 -1
  450. package/lib/testing/stub-document-builder.js +57 -4
  451. package/lib/testing/stub-document-builder.js.map +1 -1
  452. package/lib/testing/stub-hydranium-text-documents.d.ts +22 -7
  453. package/lib/testing/stub-hydranium-text-documents.d.ts.map +1 -1
  454. package/lib/testing/stub-hydranium-text-documents.js +97 -15
  455. package/lib/testing/stub-hydranium-text-documents.js.map +1 -1
  456. package/lib/testing/stub-index-manager.js.map +1 -1
  457. package/lib/testing/stub-langium-documents.d.ts +3 -2
  458. package/lib/testing/stub-langium-documents.d.ts.map +1 -1
  459. package/lib/testing/stub-langium-documents.js.map +1 -1
  460. package/lib/testing/stub-model-service.d.ts +7 -6
  461. package/lib/testing/stub-model-service.d.ts.map +1 -1
  462. package/lib/testing/stub-model-service.js +4 -4
  463. package/lib/testing/stub-model-service.js.map +1 -1
  464. package/lib/testing/stub-project-manager.js.map +1 -1
  465. package/lib/testing/stub-service-registry.js.map +1 -1
  466. package/lib/util/connection-liveness.d.ts +7 -6
  467. package/lib/util/connection-liveness.d.ts.map +1 -1
  468. package/lib/util/connection-liveness.js +35 -14
  469. package/lib/util/connection-liveness.js.map +1 -1
  470. package/lib/util/environment.d.ts.map +1 -1
  471. package/lib/util/environment.js.map +1 -1
  472. package/lib/util/registry.d.ts.map +1 -1
  473. package/package.json +35 -26
  474. package/src/documents/ast-document-manager.ts +395 -126
  475. package/src/documents/client-ids.ts +5 -22
  476. package/src/documents/client-session-errors.ts +24 -0
  477. package/src/documents/client-session-registry.ts +240 -0
  478. package/src/documents/file-system-task-queue.ts +68 -0
  479. package/src/documents/hydranium-text-documents.ts +1175 -225
  480. package/src/documents/index.ts +5 -0
  481. package/src/documents/language-client-text-shadow.ts +59 -11
  482. package/src/documents/model-ledger.ts +66 -0
  483. package/src/documents/self-save-registry.ts +52 -13
  484. package/src/documents/version-sync-service.ts +267 -0
  485. package/src/index.ts +6 -0
  486. package/src/langium/ast-extension/ast-node-builder.ts +66 -22
  487. package/src/langium/bootstrap.ts +32 -9
  488. package/src/langium/config/configuration-provider.ts +119 -0
  489. package/src/langium/config/index.ts +1 -0
  490. package/src/langium/diagnostics/logger.ts +12 -5
  491. package/src/langium/diagnostics/lsp-logger.ts +58 -12
  492. package/src/langium/document-builder/build-pipeline-integration.ts +50 -5
  493. package/src/langium/document-builder/build-session.ts +87 -0
  494. package/src/langium/document-builder/document-builder.ts +776 -59
  495. package/src/langium/document-builder/index.ts +1 -0
  496. package/src/langium/integration-services.ts +67 -6
  497. package/src/langium/integrity/integrity-rule.ts +13 -5
  498. package/src/langium/integrity/integrity-service.ts +220 -30
  499. package/src/langium/keys/containment.ts +87 -0
  500. package/src/langium/keys/index.ts +1 -0
  501. package/src/langium/keys/name-based-key-provider.ts +4 -0
  502. package/src/langium/language-module.ts +42 -4
  503. package/src/langium/model-service/client-session.ts +649 -0
  504. package/src/langium/model-service/index.ts +1 -0
  505. package/src/langium/model-service/model-service.ts +570 -433
  506. package/src/langium/module.ts +201 -64
  507. package/src/langium/naming/name-provider.ts +27 -5
  508. package/src/langium/naming/name-separator-validation.ts +34 -5
  509. package/src/langium/project/abstract-project-manager.ts +9 -1
  510. package/src/langium/project/project-change-event.ts +2 -2
  511. package/src/langium/residency/cst-residency-service.ts +46 -15
  512. package/src/langium/scope/hydranium-scope-provider.ts +60 -22
  513. package/src/langium/serialization/abstract-serializer.ts +13 -32
  514. package/src/langium/service-registry.ts +19 -2
  515. package/src/langium/shared-services.ts +25 -4
  516. package/src/langium/transfer/transfer-encoder.ts +102 -34
  517. package/src/langium/trivia/comment-preserver.ts +1100 -0
  518. package/src/langium/trivia/document-ending-preserver.ts +55 -0
  519. package/src/langium/trivia/index.ts +14 -0
  520. package/src/langium/trivia/trivia-contribution.ts +39 -0
  521. package/src/langium/trivia/trivia-preserver.ts +54 -0
  522. package/src/langium/trivia/trivia-service.ts +99 -0
  523. package/src/langium/update-rewrite/update-rewrite.ts +1 -1
  524. package/src/langium/validation/document-validator.ts +537 -11
  525. package/src/langium/workspace/document-uri-policy.ts +17 -12
  526. package/src/langium/workspace/file-not-found.ts +23 -0
  527. package/src/langium/workspace/file-system-provider.ts +153 -16
  528. package/src/langium/workspace/hydranium-langium-document-factory.ts +117 -0
  529. package/src/langium/workspace/hydranium-workspace-lock.ts +86 -2
  530. package/src/langium/workspace/hydranium-workspace-manager.ts +153 -13
  531. package/src/langium/workspace/in-memory-file-system-provider.ts +47 -16
  532. package/src/langium/workspace/initialize-workspace.ts +43 -5
  533. package/src/langium/workspace/langium-documents.ts +124 -33
  534. package/src/langium/workspace/persistent-file-system-provider.ts +0 -7
  535. package/src/langium/workspace/virtual-document.ts +96 -19
  536. package/src/langium/workspace/write-lock-scope.ts +24 -11
  537. package/src/locale/index.ts +10 -0
  538. package/src/locale/server-locale.ts +86 -0
  539. package/src/lsp/completion/hydranium-completion-provider.ts +82 -2
  540. package/src/lsp/connection-features.ts +67 -0
  541. package/src/lsp/diagnostics-connection.ts +56 -0
  542. package/src/lsp/hydranium-document-update-handler.ts +185 -106
  543. package/src/lsp/index.ts +3 -1
  544. package/src/lsp/lsp-latency.ts +62 -0
  545. package/src/lsp/semantic-token-provider.ts +74 -7
  546. package/src/lsp/shared-module.ts +4 -8
  547. package/src/lsp/start-language-server.ts +13 -7
  548. package/src/messages/carriers.ts +78 -0
  549. package/src/messages/index.ts +36 -0
  550. package/src/messages/renderer.ts +212 -0
  551. package/src/node/heap-ceiling.ts +108 -0
  552. package/src/node/index.ts +1 -0
  553. package/src/node/latency-from-env.ts +1 -1
  554. package/src/node/measure-memory.ts +1 -0
  555. package/src/node/node-file-system-provider.ts +122 -51
  556. package/src/node/profile-capture.ts +8 -2
  557. package/src/node/profiling-run.ts +30 -8
  558. package/src/node/rename-over-open-readers.ts +78 -0
  559. package/src/node/socket-launcher.ts +19 -4
  560. package/src/node/stdio-launcher.ts +1 -2
  561. package/src/testing/fake-document.ts +24 -5
  562. package/src/testing/index.ts +2 -1
  563. package/src/testing/langium-test-helpers.ts +1 -0
  564. package/src/testing/make-noop-shared-services.ts +50 -2
  565. package/src/testing/make-test-services.ts +120 -31
  566. package/src/testing/node/index.ts +1 -0
  567. package/src/testing/node/lsp-harness.ts +2 -0
  568. package/src/testing/node/lsp-server-connection.ts +61 -11
  569. package/src/testing/node/scratch-workspace.ts +10 -5
  570. package/src/testing/node/spawned-server.ts +35 -1
  571. package/src/testing/node/unhandled-rejections.ts +31 -0
  572. package/src/testing/playwright/flaky-network-proxy.ts +240 -0
  573. package/src/testing/playwright/index.ts +1 -0
  574. package/src/testing/playwright/server-log-capture.ts +45 -11
  575. package/src/testing/playwright/server-log-rename-reporter.ts +12 -1
  576. package/src/testing/run-update-pipeline.ts +4 -4
  577. package/src/testing/stub-ast-document-manager.ts +40 -23
  578. package/src/testing/stub-document-builder.ts +83 -17
  579. package/src/testing/stub-hydranium-text-documents.ts +133 -23
  580. package/src/testing/stub-langium-documents.ts +3 -2
  581. package/src/testing/stub-model-service.ts +9 -8
  582. package/src/util/connection-liveness.ts +37 -14
  583. package/src/util/environment.ts +9 -1
  584. package/lib/lsp/instrument-connection.d.ts +0 -36
  585. package/lib/lsp/instrument-connection.d.ts.map +0 -1
  586. package/lib/lsp/instrument-connection.js +0 -62
  587. package/lib/lsp/instrument-connection.js.map +0 -1
  588. package/src/lsp/instrument-connection.ts +0 -66
@@ -8,5 +8,6 @@
8
8
  ********************************************************************************/
9
9
 
10
10
  export * from './build-pipeline-integration.js';
11
+ export * from './build-session.js';
11
12
  export * from './document-builder.js';
12
13
  export * from './labeled-phase-listener.js';
@@ -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
 
@@ -49,14 +49,22 @@ export namespace IntegrityPhase {
49
49
  }
50
50
 
51
51
  /**
52
- * Controls how integrity corrections are persisted for *closed* files. The
53
- * mode does not reach open files: their corrected text is delivered by the
54
- * model service's settled-state sync, whatever the mode says.
52
+ * Controls how integrity corrections are persisted for files no editor holds.
53
+ * The mode does not reach a file open in the language client: the correction
54
+ * is delivered to the editor, which shows it as an unsaved change.
55
55
  *
56
- * - `silent`: write to disk immediately; no editor involvement.
56
+ * - `silent`: write to disk immediately; no editor involvement. For a file
57
+ * held only through the data or GLSP head, only while disk still holds the
58
+ * text the correction was computed from and the text store still holds the
59
+ * correction. Otherwise — the holder has unsaved edits, disk changed behind
60
+ * the server, or disk cannot be read — the correction waits in the text
61
+ * store for the next save.
57
62
  * - `editor`: open the file dirty via `applyEdit`. If the user closes without
58
63
  * saving, the correction is suppressed until the file changes or the
59
- * workspace reloads.
64
+ * workspace reloads. A file held only through the data or GLSP head gets
65
+ * neither: the correction stays in the text store, and since those heads
66
+ * mark only their own edits unsaved, nothing shows that store and disk
67
+ * differ until a save or the last close.
60
68
  */
61
69
  export type IntegritySyncMode = 'silent' | 'editor';
62
70
 
@@ -8,8 +8,16 @@
8
8
  ********************************************************************************/
9
9
 
10
10
  import { isPromiseLike, Logger, type ProfileSession, type Tracer } from '@hydranium/protocol';
11
- import { type AstNode, AstUtils, DocumentState, interruptAndCheck, type LangiumDocument, UriUtils } from '@hydranium/langium';
12
- import { type CancellationToken, type Disposable } from 'vscode-languageserver';
11
+ import {
12
+ type AstNode,
13
+ AstUtils,
14
+ DocumentState,
15
+ interruptAndCheck,
16
+ isOperationCancelled,
17
+ type LangiumDocument,
18
+ UriUtils
19
+ } from '@hydranium/langium';
20
+ import { CancellationToken, type Disposable } from 'vscode-languageserver';
13
21
  import { type HydraniumDocumentBuilder } from '../document-builder/document-builder.js';
14
22
  import { type TextDocument } from 'vscode-languageserver-textdocument';
15
23
  import { type WritableFileSystemProvider } from '../../documents/ast-document-manager.js';
@@ -17,6 +25,7 @@ import { type LogNameOptions } from '../diagnostics/logger.js';
17
25
  import { type HydraniumTextDocuments } from '../../documents/hydranium-text-documents.js';
18
26
  import { Registry } from '../../util/registry.js';
19
27
  import { type ServerLanguageServices } from '../language-module.js';
28
+ import { isVirtualUri } from '../workspace/virtual-document.js';
20
29
  import { type IntegrityRuleRegistry } from './integrity-contribution.js';
21
30
  import { IntegrityPhase, type IntegrityRule, type IntegritySyncMode } from './integrity-rule.js';
22
31
 
@@ -75,6 +84,11 @@ export namespace IntegrityService {
75
84
  * at `DocumentState.Validated` and delivered separately via `publishDiagnostics`
76
85
  * or the `onModelUpdated` event.
77
86
  *
87
+ * The AST is what this guarantees, not the text. For a closed document whose
88
+ * repair was STAGED rather than written (`'editor'` sync mode),
89
+ * `textDocument` still mirrors disk — read the repair off the AST, or from
90
+ * the staged content the next open consumes.
91
+ *
78
92
  * Invariant: integrity rules only register at Parsed or Linked, so the build
79
93
  * is guaranteed post-integrity once it advances past `onBuildPhase(Linked)`
80
94
  * into `IndexedReferences`. {@link IntegrityService.register} enforces this at
@@ -194,7 +208,8 @@ export class DefaultIntegrityService<TRoot extends AstNode = AstNode> implements
194
208
  const changed = await this.enforceIntegrity(document, phase, cancelToken, session);
195
209
  if (changed) {
196
210
  mutatedCount++;
197
- await this.resyncDocument(document, cancelToken);
211
+ // Not cancellable: see `resyncDocument`.
212
+ await this.resyncDocument(document, CancellationToken.None);
198
213
  }
199
214
  await interruptAndCheck(cancelToken);
200
215
  }
@@ -255,8 +270,10 @@ export class DefaultIntegrityService<TRoot extends AstNode = AstNode> implements
255
270
  * full rule sweep) — coarser than per (node × rule) to avoid a microtask
256
271
  * per inner iteration, finer than per-document so a long-running rule set
257
272
  * on a large file can still interrupt mid-stream. Throws
258
- * `OperationCancelled` when the token is cancelled; Langium's build
259
- * pipeline absorbs the throw at the lock-holder.
273
+ * `OperationCancelled` when the token is cancelled before any rule mutated
274
+ * the AST; Langium's build pipeline absorbs the throw at the lock-holder.
275
+ * After a mutation it stops the sweep and returns `true` instead, so the
276
+ * caller can resync what was mutated before the cancellation unwinds.
260
277
  */
261
278
  async enforceIntegrity(
262
279
  document: LangiumDocument,
@@ -290,7 +307,14 @@ export class DefaultIntegrityService<TRoot extends AstNode = AstNode> implements
290
307
  }
291
308
  }
292
309
  if (cancelToken !== undefined) {
293
- await interruptAndCheck(cancelToken);
310
+ try {
311
+ await interruptAndCheck(cancelToken);
312
+ } catch (err: unknown) {
313
+ if (changed && isOperationCancelled(err)) {
314
+ return true;
315
+ }
316
+ throw err;
317
+ }
294
318
  }
295
319
  }
296
320
  return changed;
@@ -300,34 +324,120 @@ export class DefaultIntegrityService<TRoot extends AstNode = AstNode> implements
300
324
  * Re-serialise the document text after AST mutations, propagate corrections,
301
325
  * and re-parse at Parsed phase (safe because linking hasn't occurred yet).
302
326
  *
303
- * `cancelToken` is checked at entry so a preempted build skips the
304
- * serialise / disk-write atomic; the steps inside resync are not further
305
- * subdivided because each is a single fast operation that does not yield
306
- * a natural interruption point.
327
+ * Runs to the end whatever `cancelToken` says: the AST is already mutated,
328
+ * and skipping the resync leaves it against unchanged text that the next
329
+ * build does not re-parse. `cancelToken` reaches only the re-parse.
307
330
  */
308
331
  protected async resyncDocument(document: LangiumDocument, cancelToken?: CancellationToken): Promise<void> {
309
- if (cancelToken?.isCancellationRequested) {
310
- return;
311
- }
312
332
  const root = document.parseResult.value as TRoot;
313
- const newText = await this.services.serializer.Serializer.serializeAst(root);
333
+ // Extracted while `document` still holds the text being replaced — the
334
+ // resync that follows overwrites it with `newText`. Absent on a test
335
+ // stub that binds no trivia group; `createServerLanguageModule` always
336
+ // provides it, and an empty registry is already the no-op.
337
+ const trivia = this.services.trivia?.TriviaService;
338
+ const extracted = trivia?.extract(document);
339
+ const serialized = await this.services.serializer.Serializer.serializeAst(root);
340
+ const newText =
341
+ extracted === undefined ? serialized : trivia!.apply(serialized, extracted, UriUtils.toUri(document.textDocument.uri));
314
342
 
315
343
  const oldText = document.textDocument.getText();
316
344
  if (oldText === newText) {
317
345
  return;
318
346
  }
319
347
 
320
- // Keep the same version so HydraniumTextDocuments doesn't reject subsequent client edits.
321
- // Use manager.update so the `instanceof FullTextDocument` gate in the bare
322
- // `TextDocument.update` doesn't trip on adopter-custom text-document types.
323
- const textDocument = this.textDocuments.update(document.textDocument, [{ text: newText }], document.textDocument.version);
348
+ const version = document.textDocument.version;
349
+ // Commit into the store's own document when the URI is open there, rather
350
+ // than into whichever text-document object this build is holding. The two
351
+ // are the same on the LSP path and are NOT when the document was built for
352
+ // an already-open URI through `fromString`: repairing only the build's copy
353
+ // leaves the store — the server's authority on what an open document says —
354
+ // on the unrepaired text, and the reconciling re-parse then redefines
355
+ // `textDocument` onto the store's object and discards the repair with it.
356
+ //
357
+ // Compared against the CST's own text, not against `document.textDocument`.
358
+ // That object IS the store's on the LSP path, so asking it whether the
359
+ // store still agrees compares the store with itself and can only ever say
360
+ // yes — the guard would be vacuous exactly where an editor race can happen.
361
+ // The CST's `fullText` is the text that actually produced this AST, which
362
+ // is the only thing a repair derived from it is valid against. A document
363
+ // with no CST (built from a model rather than parsed) has no better answer
364
+ // than the text it is carrying.
365
+ const parsedFrom = document.parseResult.value.$cstNode?.root.fullText ?? oldText;
366
+ const commit = this.textDocuments.commitRepair(document.textDocument.uri, parsedFrom, newText);
367
+ if (commit.status === 'stale') {
368
+ // An edit landed after the parse this repair came from, so the repair
369
+ // describes text the store has already replaced. Abandon it rather than
370
+ // hand it to `syncCorrections`: an override that persists from there
371
+ // would write a correction over the edit that superseded it. That edit
372
+ // drives a build of its own, which re-runs these rules against what the
373
+ // document actually says.
374
+ //
375
+ // Abandoning the WRITE is only half of it. The build carries on to its
376
+ // settled phase with whatever AST is registered, and every settled
377
+ // consumer reads that AST rather than the store — so leaving the rule's
378
+ // mutation in place would answer questions about this document from a
379
+ // parse of text nobody has. Reconciling discards it by re-reading the
380
+ // store, which is what the document now has to agree with.
381
+ await this.reconcileDocument(document, cancelToken);
382
+ return;
383
+ }
384
+
385
+ // A committed repair is a new version; a document no client has open keeps
386
+ // its number here, and the re-versioning below moves it once the build
387
+ // has reconciled. Through the store's `update`, so the `instanceof
388
+ // FullTextDocument` gate in the bare `TextDocument.update` does not trip
389
+ // on adopter-custom text-document types.
390
+ const textDocument =
391
+ commit.status === 'committed' ? commit.document : this.textDocuments.update(document.textDocument, [{ text: newText }], version);
324
392
 
325
- await this.syncCorrections(textDocument);
393
+ await this.syncCorrections(textDocument, parsedFrom);
326
394
 
395
+ await this.reconcileDocument(document, cancelToken);
396
+
397
+ // Re-version against the REPAIRED text, after either branch. The repair is
398
+ // a content change the store has not seen: whatever reconciliation ran
399
+ // during the re-parse saw the text on disk, which in `'editor'` sync mode
400
+ // is the PRE-repair text. Leave the sequence describing that and the next
401
+ // open hashes the repair, finds a mismatch and steps the version again, so
402
+ // every base version taken from this build is stale before it is used.
403
+ // An open document keeps the store's own version, which is not this
404
+ // method's to move.
405
+ //
406
+ // Deliberately NOT gated on cancellation, unlike the entry to this method:
407
+ // `syncCorrections` has already written or staged the repair by now, so a
408
+ // preempted build that skipped this would leave the sequence describing
409
+ // text that is no longer there.
410
+ if (!this.textDocuments.isOpen(document.textDocument.uri)) {
411
+ // The root describes the repair too; left at the re-parse's number, a
412
+ // syncing read waits for a build nothing requests. The CST is still
413
+ // the unrepaired text, so the repair is reported as the parsed text.
414
+ this.services.shared.workspace.VersionSyncService.modelProduced(document, { text: newText });
415
+ }
416
+ }
417
+
418
+ /**
419
+ * Bring `document` back into agreement with the text it is supposed to
420
+ * describe, after a rule has mutated its AST.
421
+ *
422
+ * Used for a correction that was applied and for one that was abandoned,
423
+ * because the document is left inconsistent either way: applied, the text
424
+ * moved under the CST; abandoned, the AST carries a mutation the text never
425
+ * had. Both are the same question — re-read and re-derive — and the phase is
426
+ * what decides how far that has to go.
427
+ */
428
+ protected async reconcileDocument(document: LangiumDocument, cancelToken?: CancellationToken): Promise<void> {
327
429
  if (document.state <= DocumentState.Parsed) {
328
430
  // Parsed-phase correction: re-parse only. The build pipeline still runs
329
431
  // IndexedContent → ComputedScopes → Linked → … on the fresh AST afterwards,
330
432
  // so the document reconciles naturally with no extra work here.
433
+ //
434
+ // Except for a closed document whose repair did not reach disk — `'editor'`
435
+ // sync mode stages it instead of writing it — where the re-parse is SKIPPED:
436
+ // Langium's factory gates the parse on the CST's `fullText`, which still
437
+ // equals the disk text the same call re-reads and redefines `textDocument`
438
+ // over. So `document.textDocument` is NOT post-integrity for such a
439
+ // document — it mirrors disk, and the AST is the only place the repair is
440
+ // legible, until an open consumes the staging.
331
441
  await this.documentBuilder.reparse(document, cancelToken);
332
442
  } else {
333
443
  // Linked-phase (or later) correction. The rule mutated the AST in place but
@@ -347,27 +457,66 @@ export class DefaultIntegrityService<TRoot extends AstNode = AstNode> implements
347
457
  * already in the synced store (in-place in {@link resyncDocument}); this
348
458
  * method routes the out-of-band part by document registration:
349
459
  *
350
- * - **Open in the language client** → nothing to push here. The AST mutation
351
- * rode the current build, so `ModelService.syncToLanguageClient` (the
352
- * persistent integrity-settled listener) mirrors the corrected text to the
353
- * client by *content* (shadow diff) — no authorship rewrite, no second
354
- * rebuild.
460
+ * - **Open in the language client** → nothing to push here. The AST
461
+ * mutation rode the current build, so `ModelService.syncToLanguageClient`
462
+ * (the persistent integrity-settled listener) mirrors it to the client by
463
+ * *content* (shadow diff), and the editor shows it as an unsaved change.
464
+ * - **Held only through the data or GLSP head**, or waiting out the revert
465
+ * grace after its last client's connection was lost → the store is the
466
+ * authority, and those heads read the correction from the settled build.
467
+ * In silent mode it is also written to disk when the text it was computed
468
+ * from is what disk holds, since the repair is then the only difference;
469
+ * otherwise it waits for the next save. Editor mode always waits, and the
470
+ * repair leaves the document dirty until a save.
355
471
  * - **Closed, silent mode** → write to disk directly (disk is authoritative).
356
472
  * - **Closed, editor mode** → stage so the next open picks it up via applyEdit.
473
+ *
474
+ * A held URI is not closed. Writing it as one persists the holder's unsaved
475
+ * edits with the repair, and staging it leaves text no open reads, because
476
+ * only a first open consumes the stage.
477
+ *
478
+ * `parsedFrom` is the text the repaired AST was parsed from. Without it a
479
+ * held URI's repair is left to the next save.
357
480
  */
358
- protected async syncCorrections(document: TextDocument): Promise<void> {
359
- // Open files: delivery is the ModelService settled listener's job (by
360
- // content, via the shadow) — nothing to do here. Only the open/closed
361
- // question is asked, so no reverse address resolution is needed: a file
362
- // open under a symlinked path still answers `true`.
481
+ protected async syncCorrections(document: TextDocument, parsedFrom?: string): Promise<void> {
482
+ // Only the open/closed question is asked, so no reverse address
483
+ // resolution is needed: a file open under a symlinked path still answers
484
+ // `true`.
363
485
  if (this.textDocuments.isOpenInLanguageClient(document.uri)) {
364
486
  return;
365
487
  }
366
488
 
489
+ // A virtual document has no disk backing, so neither persisting nor
490
+ // staging applies: there is no file to write and no editor that could open
491
+ // one. `URI.fsPath` yields a path for any scheme, so handing this to the
492
+ // provider would address `<cwd>/<contributor>/<name>` — an unrelated
493
+ // location a disk-backed provider refuses outright, turning a repair that
494
+ // was never persistable into a build failure. The correction is already on
495
+ // the AST and in the text store, which is the whole of where a virtual
496
+ // document lives, so there is nothing further to propagate.
497
+ if (isVirtualUri(document.uri)) {
498
+ this.tracer.with(document.uri).debug('Virtual document: correction kept in memory, nothing to persist');
499
+ return;
500
+ }
501
+
502
+ // A document waiting out the revert grace still holds its lost client's
503
+ // unsaved text, so writing it as a closed file would persist that text.
504
+ if (this.textDocuments.isOpenInAnyClient(document.uri) || this.textDocuments.isRevertPending(document.uri)) {
505
+ if (this.syncMode === 'silent' && parsedFrom !== undefined) {
506
+ await this.persistIfDiskMatches(document, parsedFrom);
507
+ }
508
+ return;
509
+ }
510
+
367
511
  // Closed files, silent mode: write to disk directly.
368
512
  if (this.syncMode === 'silent') {
513
+ const repaired = document.getText();
369
514
  // Async write so the integrity pass does not block the event loop on a slow filesystem.
370
- await this.fileSystemProvider.writeFile(UriUtils.toUri(document.uri), document.getText());
515
+ // In the file's task queue, behind any save already queued: written
516
+ // beside one, the older repair can land last and stay on disk.
517
+ await this.services.shared.workspace.FileSystemTaskQueue.enqueue(document.uri, () =>
518
+ this.fileSystemProvider.writeFile(UriUtils.toUri(document.uri), repaired)
519
+ );
371
520
  return;
372
521
  }
373
522
 
@@ -375,6 +524,47 @@ export class DefaultIntegrityService<TRoot extends AstNode = AstNode> implements
375
524
  this.textDocuments.stagePendingContent(document.uri, document.getText());
376
525
  }
377
526
 
527
+ /**
528
+ * Write the repair in `document` to disk when disk still holds `parsedFrom`,
529
+ * the text the repair was computed from — so the write carries the repair
530
+ * and nothing a holder could still discard.
531
+ *
532
+ * The read, the compare and the write run as one task in the file's task
533
+ * queue, so no save of the file lands between them. The store is compared
534
+ * again once the read returns, and the write is skipped if it no longer
535
+ * holds the repair: an edit does not wait for the queue, and writing the
536
+ * older repair then puts text on disk that no participant holds. The
537
+ * skipped repair loses nothing: the edit drives a build of its own, and a
538
+ * save writes the store's text. A file that cannot be read is left alone
539
+ * too: there is no evidence it matches.
540
+ */
541
+ protected async persistIfDiskMatches(document: TextDocument, parsedFrom: string): Promise<void> {
542
+ const uri = UriUtils.toUri(document.uri);
543
+ const repaired = document.getText();
544
+ await this.services.shared.workspace.FileSystemTaskQueue.enqueue(document.uri, async () => {
545
+ let onDisk: string;
546
+ try {
547
+ onDisk = await this.fileSystemProvider.readFile(uri);
548
+ } catch (error: unknown) {
549
+ this.tracer.with(document.uri).debug(`Held document unreadable on disk, repair left to the next save: ${String(error)}`);
550
+ return;
551
+ }
552
+ // The file itself, not the store's disk baseline: the baseline moves
553
+ // only when the server hears of a change, so it can still hold the
554
+ // parsed text after another process rewrote the file and before the
555
+ // watcher reports it, and this write would then replace that change.
556
+ if (onDisk !== parsedFrom) {
557
+ return;
558
+ }
559
+ if (this.textDocuments.get(document.uri)?.getText() !== repaired) {
560
+ this.tracer.with(document.uri).debug('Held document changed while disk was read, repair left to that change');
561
+ return;
562
+ }
563
+ await this.fileSystemProvider.writeFile(uri, repaired);
564
+ this.textDocuments.updateDiskBaseline(document.uri, repaired);
565
+ });
566
+ }
567
+
378
568
  /**
379
569
  * Format a rule's name for inclusion in user-facing diagnostic strings
380
570
  * (error messages thrown during registration). Defaults to
@@ -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.