@hydranium/core 1.0.0-next.8 → 1.0.0-next.85

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 (306) 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 +55 -21
  10. package/lib/documents/hydranium-text-documents.d.ts.map +1 -1
  11. package/lib/documents/hydranium-text-documents.js +142 -46
  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 +2 -0
  22. package/lib/index.d.ts.map +1 -1
  23. package/lib/index.js +5 -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 +13 -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 +1 -1
  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 +5 -0
  65. package/lib/langium/integrity/integrity-service.d.ts.map +1 -1
  66. package/lib/langium/integrity/integrity-service.js +34 -1
  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/model-service/model-service.d.ts +149 -10
  81. package/lib/langium/model-service/model-service.d.ts.map +1 -1
  82. package/lib/langium/model-service/model-service.js +120 -93
  83. package/lib/langium/model-service/model-service.js.map +1 -1
  84. package/lib/langium/module.d.ts +84 -15
  85. package/lib/langium/module.d.ts.map +1 -1
  86. package/lib/langium/module.js +26 -12
  87. package/lib/langium/module.js.map +1 -1
  88. package/lib/langium/naming/name-provider.d.ts +25 -4
  89. package/lib/langium/naming/name-provider.d.ts.map +1 -1
  90. package/lib/langium/naming/name-provider.js +2 -1
  91. package/lib/langium/naming/name-provider.js.map +1 -1
  92. package/lib/langium/naming/name-separator-validation.d.ts +23 -0
  93. package/lib/langium/naming/name-separator-validation.d.ts.map +1 -1
  94. package/lib/langium/naming/name-separator-validation.js +30 -1
  95. package/lib/langium/naming/name-separator-validation.js.map +1 -1
  96. package/lib/langium/residency/cst-residency-service.d.ts +31 -9
  97. package/lib/langium/residency/cst-residency-service.d.ts.map +1 -1
  98. package/lib/langium/residency/cst-residency-service.js +13 -56
  99. package/lib/langium/residency/cst-residency-service.js.map +1 -1
  100. package/lib/langium/scope/hydranium-scope-provider.d.ts +32 -13
  101. package/lib/langium/scope/hydranium-scope-provider.d.ts.map +1 -1
  102. package/lib/langium/scope/hydranium-scope-provider.js +37 -20
  103. package/lib/langium/scope/hydranium-scope-provider.js.map +1 -1
  104. package/lib/langium/shared-services.d.ts +15 -2
  105. package/lib/langium/shared-services.d.ts.map +1 -1
  106. package/lib/langium/shared-services.js.map +1 -1
  107. package/lib/langium/transfer/transfer-encoder.d.ts +60 -17
  108. package/lib/langium/transfer/transfer-encoder.d.ts.map +1 -1
  109. package/lib/langium/transfer/transfer-encoder.js +38 -16
  110. package/lib/langium/transfer/transfer-encoder.js.map +1 -1
  111. package/lib/langium/validation/document-validator.d.ts +294 -10
  112. package/lib/langium/validation/document-validator.d.ts.map +1 -1
  113. package/lib/langium/validation/document-validator.js +448 -5
  114. package/lib/langium/validation/document-validator.js.map +1 -1
  115. package/lib/langium/workspace/document-uri-policy.d.ts +3 -4
  116. package/lib/langium/workspace/document-uri-policy.d.ts.map +1 -1
  117. package/lib/langium/workspace/document-uri-policy.js +3 -4
  118. package/lib/langium/workspace/document-uri-policy.js.map +1 -1
  119. package/lib/langium/workspace/hydranium-langium-document-factory.d.ts +25 -0
  120. package/lib/langium/workspace/hydranium-langium-document-factory.d.ts.map +1 -1
  121. package/lib/langium/workspace/hydranium-langium-document-factory.js +25 -0
  122. package/lib/langium/workspace/hydranium-langium-document-factory.js.map +1 -1
  123. package/lib/langium/workspace/hydranium-workspace-manager.d.ts +21 -1
  124. package/lib/langium/workspace/hydranium-workspace-manager.d.ts.map +1 -1
  125. package/lib/langium/workspace/hydranium-workspace-manager.js +28 -0
  126. package/lib/langium/workspace/hydranium-workspace-manager.js.map +1 -1
  127. package/lib/langium/workspace/in-memory-file-system-provider.d.ts +8 -0
  128. package/lib/langium/workspace/in-memory-file-system-provider.d.ts.map +1 -1
  129. package/lib/langium/workspace/in-memory-file-system-provider.js +11 -2
  130. package/lib/langium/workspace/in-memory-file-system-provider.js.map +1 -1
  131. package/lib/langium/workspace/initialize-workspace.d.ts +22 -2
  132. package/lib/langium/workspace/initialize-workspace.d.ts.map +1 -1
  133. package/lib/langium/workspace/initialize-workspace.js +13 -5
  134. package/lib/langium/workspace/initialize-workspace.js.map +1 -1
  135. package/lib/langium/workspace/langium-documents.d.ts +79 -17
  136. package/lib/langium/workspace/langium-documents.d.ts.map +1 -1
  137. package/lib/langium/workspace/langium-documents.js +83 -28
  138. package/lib/langium/workspace/langium-documents.js.map +1 -1
  139. package/lib/locale/index.d.ts +10 -0
  140. package/lib/locale/index.d.ts.map +1 -0
  141. package/lib/locale/index.js +10 -0
  142. package/lib/locale/index.js.map +1 -0
  143. package/lib/locale/server-locale.d.ts +73 -0
  144. package/lib/locale/server-locale.d.ts.map +1 -0
  145. package/lib/locale/server-locale.js +61 -0
  146. package/lib/locale/server-locale.js.map +1 -0
  147. package/lib/lsp/hydranium-document-update-handler.js +1 -1
  148. package/lib/lsp/hydranium-document-update-handler.js.map +1 -1
  149. package/lib/lsp/index.d.ts +1 -1
  150. package/lib/lsp/index.d.ts.map +1 -1
  151. package/lib/lsp/index.js +1 -1
  152. package/lib/lsp/index.js.map +1 -1
  153. package/lib/lsp/lsp-latency.d.ts +39 -0
  154. package/lib/lsp/lsp-latency.d.ts.map +1 -0
  155. package/lib/lsp/lsp-latency.js +58 -0
  156. package/lib/lsp/lsp-latency.js.map +1 -0
  157. package/lib/lsp/semantic-token-provider.d.ts +34 -1
  158. package/lib/lsp/semantic-token-provider.d.ts.map +1 -1
  159. package/lib/lsp/semantic-token-provider.js +55 -8
  160. package/lib/lsp/semantic-token-provider.js.map +1 -1
  161. package/lib/messages/carriers.d.ts +54 -0
  162. package/lib/messages/carriers.d.ts.map +1 -0
  163. package/lib/messages/carriers.js +62 -0
  164. package/lib/messages/carriers.js.map +1 -0
  165. package/lib/messages/index.d.ts +25 -0
  166. package/lib/messages/index.d.ts.map +1 -0
  167. package/lib/messages/index.js +25 -0
  168. package/lib/messages/index.js.map +1 -0
  169. package/lib/messages/renderer.d.ts +136 -0
  170. package/lib/messages/renderer.d.ts.map +1 -0
  171. package/lib/messages/renderer.js +159 -0
  172. package/lib/messages/renderer.js.map +1 -0
  173. package/lib/node/heap-ceiling.d.ts +61 -0
  174. package/lib/node/heap-ceiling.d.ts.map +1 -0
  175. package/lib/node/heap-ceiling.js +72 -0
  176. package/lib/node/heap-ceiling.js.map +1 -0
  177. package/lib/node/index.d.ts +1 -0
  178. package/lib/node/index.d.ts.map +1 -1
  179. package/lib/node/index.js +1 -0
  180. package/lib/node/index.js.map +1 -1
  181. package/lib/node/latency-from-env.d.ts +1 -1
  182. package/lib/node/latency-from-env.js +1 -1
  183. package/lib/node/node-file-system-provider.d.ts.map +1 -1
  184. package/lib/node/node-file-system-provider.js +1 -40
  185. package/lib/node/node-file-system-provider.js.map +1 -1
  186. package/lib/node/profiling-run.d.ts +2 -2
  187. package/lib/node/profiling-run.js +1 -1
  188. package/lib/node/profiling-run.js.map +1 -1
  189. package/lib/node/rename-over-open-readers.d.ts +52 -0
  190. package/lib/node/rename-over-open-readers.d.ts.map +1 -0
  191. package/lib/node/rename-over-open-readers.js +66 -0
  192. package/lib/node/rename-over-open-readers.js.map +1 -0
  193. package/lib/testing/fake-document.d.ts +16 -4
  194. package/lib/testing/fake-document.d.ts.map +1 -1
  195. package/lib/testing/fake-document.js +18 -3
  196. package/lib/testing/fake-document.js.map +1 -1
  197. package/lib/testing/make-noop-shared-services.d.ts +14 -0
  198. package/lib/testing/make-noop-shared-services.d.ts.map +1 -1
  199. package/lib/testing/make-noop-shared-services.js +28 -2
  200. package/lib/testing/make-noop-shared-services.js.map +1 -1
  201. package/lib/testing/make-test-services.d.ts +44 -8
  202. package/lib/testing/make-test-services.d.ts.map +1 -1
  203. package/lib/testing/make-test-services.js +19 -3
  204. package/lib/testing/make-test-services.js.map +1 -1
  205. package/lib/testing/node/spawned-server.d.ts +14 -0
  206. package/lib/testing/node/spawned-server.d.ts.map +1 -1
  207. package/lib/testing/node/spawned-server.js +33 -1
  208. package/lib/testing/node/spawned-server.js.map +1 -1
  209. package/lib/testing/playwright/flaky-network-proxy.d.ts +76 -0
  210. package/lib/testing/playwright/flaky-network-proxy.d.ts.map +1 -0
  211. package/lib/testing/playwright/flaky-network-proxy.js +164 -0
  212. package/lib/testing/playwright/flaky-network-proxy.js.map +1 -0
  213. package/lib/testing/playwright/index.d.ts +1 -0
  214. package/lib/testing/playwright/index.d.ts.map +1 -1
  215. package/lib/testing/playwright/index.js +1 -0
  216. package/lib/testing/playwright/index.js.map +1 -1
  217. package/lib/testing/playwright/server-log-capture.d.ts +14 -4
  218. package/lib/testing/playwright/server-log-capture.d.ts.map +1 -1
  219. package/lib/testing/playwright/server-log-capture.js +21 -4
  220. package/lib/testing/playwright/server-log-capture.js.map +1 -1
  221. package/lib/testing/playwright/server-log-rename-reporter.d.ts.map +1 -1
  222. package/lib/testing/playwright/server-log-rename-reporter.js +10 -1
  223. package/lib/testing/playwright/server-log-rename-reporter.js.map +1 -1
  224. package/lib/testing/stub-ast-document-manager.d.ts +5 -5
  225. package/lib/testing/stub-ast-document-manager.d.ts.map +1 -1
  226. package/lib/testing/stub-ast-document-manager.js +4 -6
  227. package/lib/testing/stub-ast-document-manager.js.map +1 -1
  228. package/lib/testing/stub-document-builder.d.ts +8 -0
  229. package/lib/testing/stub-document-builder.d.ts.map +1 -1
  230. package/lib/testing/stub-document-builder.js +22 -3
  231. package/lib/testing/stub-document-builder.js.map +1 -1
  232. package/lib/testing/stub-langium-documents.d.ts +3 -2
  233. package/lib/testing/stub-langium-documents.d.ts.map +1 -1
  234. package/lib/testing/stub-langium-documents.js.map +1 -1
  235. package/lib/testing/stub-model-service.d.ts +5 -4
  236. package/lib/testing/stub-model-service.d.ts.map +1 -1
  237. package/lib/testing/stub-model-service.js +2 -2
  238. package/lib/testing/stub-model-service.js.map +1 -1
  239. package/package.json +17 -8
  240. package/src/documents/ast-document-manager.ts +129 -36
  241. package/src/documents/client-ids.ts +5 -22
  242. package/src/documents/hydranium-text-documents.ts +167 -61
  243. package/src/documents/language-client-text-shadow.ts +59 -11
  244. package/src/documents/self-save-registry.ts +52 -13
  245. package/src/index.ts +5 -0
  246. package/src/langium/ast-extension/ast-node-builder.ts +66 -22
  247. package/src/langium/bootstrap.ts +16 -9
  248. package/src/langium/config/configuration-provider.ts +119 -0
  249. package/src/langium/config/index.ts +1 -0
  250. package/src/langium/diagnostics/lsp-logger.ts +41 -6
  251. package/src/langium/document-builder/build-pipeline-integration.ts +14 -1
  252. package/src/langium/document-builder/build-session.ts +87 -0
  253. package/src/langium/document-builder/document-builder.ts +339 -11
  254. package/src/langium/document-builder/index.ts +1 -0
  255. package/src/langium/integration-services.ts +67 -6
  256. package/src/langium/integrity/integrity-service.ts +35 -1
  257. package/src/langium/keys/containment.ts +87 -0
  258. package/src/langium/keys/index.ts +1 -0
  259. package/src/langium/keys/name-based-key-provider.ts +4 -0
  260. package/src/langium/model-service/model-service.ts +211 -30
  261. package/src/langium/module.ts +106 -21
  262. package/src/langium/naming/name-provider.ts +27 -5
  263. package/src/langium/naming/name-separator-validation.ts +34 -5
  264. package/src/langium/residency/cst-residency-service.ts +36 -12
  265. package/src/langium/scope/hydranium-scope-provider.ts +40 -22
  266. package/src/langium/shared-services.ts +19 -2
  267. package/src/langium/transfer/transfer-encoder.ts +85 -24
  268. package/src/langium/validation/document-validator.ts +537 -11
  269. package/src/langium/workspace/document-uri-policy.ts +3 -4
  270. package/src/langium/workspace/hydranium-langium-document-factory.ts +34 -0
  271. package/src/langium/workspace/hydranium-workspace-manager.ts +30 -1
  272. package/src/langium/workspace/in-memory-file-system-provider.ts +13 -3
  273. package/src/langium/workspace/initialize-workspace.ts +34 -5
  274. package/src/langium/workspace/langium-documents.ts +106 -33
  275. package/src/locale/index.ts +10 -0
  276. package/src/locale/server-locale.ts +86 -0
  277. package/src/lsp/hydranium-document-update-handler.ts +1 -1
  278. package/src/lsp/index.ts +1 -1
  279. package/src/lsp/lsp-latency.ts +62 -0
  280. package/src/lsp/semantic-token-provider.ts +74 -7
  281. package/src/messages/carriers.ts +78 -0
  282. package/src/messages/index.ts +36 -0
  283. package/src/messages/renderer.ts +204 -0
  284. package/src/node/heap-ceiling.ts +108 -0
  285. package/src/node/index.ts +1 -0
  286. package/src/node/latency-from-env.ts +1 -1
  287. package/src/node/node-file-system-provider.ts +1 -41
  288. package/src/node/profiling-run.ts +3 -3
  289. package/src/node/rename-over-open-readers.ts +78 -0
  290. package/src/testing/fake-document.ts +24 -5
  291. package/src/testing/make-noop-shared-services.ts +50 -2
  292. package/src/testing/make-test-services.ts +73 -18
  293. package/src/testing/node/spawned-server.ts +35 -1
  294. package/src/testing/playwright/flaky-network-proxy.ts +240 -0
  295. package/src/testing/playwright/index.ts +1 -0
  296. package/src/testing/playwright/server-log-capture.ts +24 -5
  297. package/src/testing/playwright/server-log-rename-reporter.ts +12 -1
  298. package/src/testing/stub-ast-document-manager.ts +10 -14
  299. package/src/testing/stub-document-builder.ts +32 -3
  300. package/src/testing/stub-langium-documents.ts +3 -2
  301. package/src/testing/stub-model-service.ts +7 -6
  302. package/lib/lsp/instrument-connection.d.ts +0 -36
  303. package/lib/lsp/instrument-connection.d.ts.map +0 -1
  304. package/lib/lsp/instrument-connection.js +0 -62
  305. package/lib/lsp/instrument-connection.js.map +0 -1
  306. package/src/lsp/instrument-connection.ts +0 -66
@@ -14,7 +14,9 @@ import {
14
14
  CstUtils,
15
15
  GrammarAST,
16
16
  interruptAndCheck,
17
+ isLeafCstNode,
17
18
  type LangiumDocument,
19
+ type LeafCstNode,
18
20
  type ReferenceInfo
19
21
  } from '@hydranium/langium';
20
22
  import { AbstractSemanticTokenProvider, type SemanticTokenAcceptor } from '@hydranium/langium/lsp';
@@ -54,6 +56,23 @@ export interface HydraniumSemanticTokenProviderOptions {
54
56
  * render in the editor's default foreground.
55
57
  */
56
58
  readonly highlightKeywords?: boolean;
59
+
60
+ /**
61
+ * Also emit a `comment` token for every comment leaf of the CST.
62
+ *
63
+ * OFF by default for the same reason as {@link highlightKeywords}, and the
64
+ * loss is larger: a TextMate grammar distinguishes `comment.line` from
65
+ * `comment.block` and scopes the delimiters separately, where a semantic
66
+ * token carries one flat `comment` that overrides all of them. It exists
67
+ * for the host that ships no client-side grammar, where a comment otherwise
68
+ * renders in the editor's default foreground.
69
+ *
70
+ * What counts as a comment is every hidden terminal the lexer retains,
71
+ * which is every hidden terminal whose pattern is not whitespace. A grammar
72
+ * whose hidden non-whitespace terminal means something other than a comment
73
+ * is miscoloured, and this option is the place to say no.
74
+ */
75
+ readonly highlightComments?: boolean;
57
76
  }
58
77
 
59
78
  /**
@@ -133,7 +152,9 @@ export abstract class AbstractHydraniumSemanticTokenProvider extends AbstractSem
133
152
  cancelToken: CancellationToken
134
153
  ): Promise<void> {
135
154
  await super.computeHighlighting(document, acceptor, cancelToken);
136
- if (this.options.highlightKeywords !== true) {
155
+ const keywords = this.options.highlightKeywords === true;
156
+ const comments = this.options.highlightComments === true;
157
+ if (!keywords && !comments) {
137
158
  return;
138
159
  }
139
160
  const root = document.parseResult.value.$cstNode;
@@ -142,14 +163,60 @@ export abstract class AbstractHydraniumSemanticTokenProvider extends AbstractSem
142
163
  }
143
164
  for (const cst of CstUtils.streamCst(root)) {
144
165
  await interruptAndCheck(cancelToken);
145
- // The grammar source is the whole filter. A keyword is always a leaf,
146
- // and the hidden leaves a comment or a run of whitespace contributes
147
- // are sourced from a terminal rule rather than a `Keyword` — so
148
- // neither a composite-node check nor a hidden-token check adds
149
- // anything here.
150
- if (GrammarAST.isKeyword(cst.grammarSource)) {
166
+ // A keyword is always a leaf with a `Keyword` grammar source, so that
167
+ // check alone separates it from everything else in the walk.
168
+ if (keywords && GrammarAST.isKeyword(cst.grammarSource)) {
151
169
  acceptor({ cst, type: SemanticTokenTypes.keyword });
152
170
  }
171
+ // A comment leaf cannot be recognised the same way — the CST builder
172
+ // adds hidden nodes from the token alone, so `grammarSource` is
173
+ // undefined, which is also why the keyword filter never matches one.
174
+ //
175
+ // `hidden` alone IS the comment test, and nothing narrower is needed:
176
+ // the token builder groups a hidden terminal as `Lexer.SKIPPED` when
177
+ // its pattern matches whitespace and as `hidden` otherwise, so the
178
+ // lexer discards whitespace before a CST node is ever built and every
179
+ // hidden leaf that survives is a comment. Classifying the terminal
180
+ // again here would be a second guard for the same property, which no
181
+ // test could then distinguish. An adopter whose token builder RETAINS
182
+ // whitespace breaks that equivalence and would colour its gaps.
183
+ if (comments && isLeafCstNode(cst) && cst.hidden) {
184
+ this.acceptComment(cst, acceptor);
185
+ }
186
+ }
187
+ }
188
+
189
+ /**
190
+ * Emit a comment as ONE TOKEN PER LINE, never as one multi-line range.
191
+ *
192
+ * A block comment is the first token this provider emits that can span
193
+ * lines, and the upstream encoder mishandles that for a client which does
194
+ * not advertise `multilineTokenSupport` — the split path computes the first
195
+ * line's length as `nextLineOffset - range.start.character - 1`, subtracting
196
+ * a COLUMN from a document OFFSET, so the length is right only for a token
197
+ * starting on line 0 and overruns its line everywhere else. No client in
198
+ * this repository advertises that capability, so the broken path is the one
199
+ * taken. Splitting here means every range handed over starts and ends on one
200
+ * line and the arithmetic is never reached.
201
+ *
202
+ * Lines come from the leaf's own text rather than from the document, so
203
+ * nothing has to re-derive where the comment ends.
204
+ */
205
+ protected acceptComment(cst: LeafCstNode, acceptor: SemanticTokenAcceptor): void {
206
+ const lines = cst.text.split('\n');
207
+ for (let index = 0; index < lines.length; index++) {
208
+ // A `\r\n` document leaves the carriage return on the line's end;
209
+ // colouring it would extend the token past the visible text.
210
+ const length = lines[index].replace(/\r$/, '').length;
211
+ const character = index === 0 ? cst.range.start.character : 0;
212
+ if (length === 0) {
213
+ continue;
214
+ }
215
+ const line = cst.range.start.line + index;
216
+ acceptor({
217
+ range: { start: { line, character }, end: { line, character: character + length } },
218
+ type: SemanticTokenTypes.comment
219
+ });
153
220
  }
154
221
  }
155
222
 
@@ -0,0 +1,78 @@
1
+ /********************************************************************************
2
+ * Copyright (c) 2026 CrossBreeze, EclipseSource and others.
3
+ *
4
+ * This program and the accompanying materials are made available under the
5
+ * terms of the MIT License which is available in the project root.
6
+ *
7
+ * SPDX-License-Identifier: MIT
8
+ ********************************************************************************/
9
+
10
+ import {
11
+ hasMessageIdentity,
12
+ messageData,
13
+ type HydraniumMessageData,
14
+ type MessageDefinition,
15
+ type ParamsArg,
16
+ type ResolvedMessage
17
+ } from '@hydranium/protocol';
18
+ import type { AstNode, DiagnosticData, DiagnosticInfo, Properties, ValidationAcceptor } from '@hydranium/langium';
19
+ import { Diagnostic } from 'vscode-languageserver-protocol';
20
+
21
+ /**
22
+ * Raise a validation diagnostic from a declaration, so the call site never
23
+ * restates the code or the sentence.
24
+ *
25
+ * `code` is omitted from `info` because this owns it — the framework claims LSP
26
+ * `Diagnostic.code` for framework codes, which collides with no adopter today
27
+ * and is a stated rule rather than an accident. `data` is deliberately NOT
28
+ * omitted: Langium owns `data.code` for code-action dispatch, so a caller has to
29
+ * be able to request a quick fix. The identity is merged OVER whatever they
30
+ * pass, which makes the two conventions co-exist rather than compete.
31
+ *
32
+ * `data` admits adopter-owned keys beside Langium's, which is why the index
33
+ * signature is there rather than a bare `Partial<DiagnosticData>`. Langium's
34
+ * shape is closed, and a diagnostic that carries a COMPANION payload for its own
35
+ * surface to read — the field a form must highlight, say — has nowhere else to
36
+ * put it: an encoder projecting that payload reads `diagnostic.data`, so the
37
+ * narrower type made the identity and the companion mutually exclusive.
38
+ *
39
+ * The identity lands in both `code` and `data.hydranium` on purpose. `code` is
40
+ * what survives to the editor surface; Theia's converter drops `data` before the
41
+ * squiggle, so a parameterised diagnostic falls back to the server's English
42
+ * there while any adopter-owned surface can still render the parameterised form
43
+ * from the marker store.
44
+ *
45
+ * `DiagnosticInfo` must be Langium's own type: a `Parameters<ValidationAcceptor>[2]`
46
+ * shortcut compiles but loses the `property?: Properties<N>` relation. The `data`
47
+ * re-type has to be an intersection rather than an `Omit` alone, because Langium
48
+ * declares `data?: unknown` and an `unknown` cannot be spread.
49
+ */
50
+ export function acceptMessage<S extends string, N extends AstNode, P extends Properties<N> = Properties<N>>(
51
+ accept: ValidationAcceptor,
52
+ severity: 'error' | 'warning' | 'info' | 'hint',
53
+ message: MessageDefinition<S>,
54
+ info: Omit<DiagnosticInfo<N, P>, 'code' | 'data'> & { data?: Partial<DiagnosticData> & Record<string, unknown> },
55
+ ...params: ParamsArg<S>
56
+ ): void {
57
+ const data: HydraniumMessageData & Partial<DiagnosticData> & Record<string, unknown> = {
58
+ ...info.data,
59
+ ...messageData(message, ...params)
60
+ };
61
+ accept(severity, message.format(...params), { ...info, code: message.code, data });
62
+ }
63
+
64
+ /**
65
+ * Recover the identity from a published diagnostic, for a surface that
66
+ * identifies or renders diagnostics itself.
67
+ *
68
+ * `Diagnostic.message` is `string | MarkupContent` in LSP 3.17+, so the text
69
+ * comes from upstream's own `Diagnostic.getMessageString` rather than a
70
+ * hand-rolled narrowing — consuming the library in its style, and one fewer
71
+ * place restating the union.
72
+ */
73
+ export function resolvedFromDiagnostic(diagnostic: Diagnostic): ResolvedMessage | undefined {
74
+ if (!hasMessageIdentity(diagnostic.data)) {
75
+ return undefined;
76
+ }
77
+ return { ...diagnostic.data.hydranium, text: Diagnostic.getMessageString(diagnostic) };
78
+ }
@@ -0,0 +1,36 @@
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
+ * Every user-facing message `@hydranium/core` raises, plus the carrier helpers
12
+ * that attach an identity to one.
13
+ *
14
+ * Declarations stay beside their call sites and are re-exported here, so this is
15
+ * enumeration rather than centralization: a code's package segment has to name
16
+ * the package that raises it. The English is a fallback, not a contract; the
17
+ * code is the contract, and renaming one is a breaking change.
18
+ */
19
+
20
+ export * from './carriers.js';
21
+ export * from './renderer.js';
22
+
23
+ export { MODEL_UPDATE_EDIT } from '../langium/model-service/model-service.js';
24
+ export { SEPARATOR_IN_NAME } from '../langium/naming/name-separator-validation.js';
25
+ export {
26
+ INVALID_DEDENT,
27
+ UNEXPECTED_CHARACTER,
28
+ MISSING_ITERATION,
29
+ NO_VIABLE_ALTERNATIVE,
30
+ TRAILING_INPUT,
31
+ UNEXPECTED_TOKEN,
32
+ UNPOPPABLE_LEXER_MODE,
33
+ UNRESOLVED_REFERENCE
34
+ } from '../langium/validation/document-validator.js';
35
+ export { NO_LOADABLE_CONTENT } from '../langium/workspace/langium-documents.js';
36
+ export { NO_SUCH_FILE, NO_SUCH_PATH } from '../langium/workspace/in-memory-file-system-provider.js';
@@ -0,0 +1,204 @@
1
+ /********************************************************************************
2
+ * Copyright (c) 2026 CrossBreeze, EclipseSource and others.
3
+ *
4
+ * This program and the accompanying materials are made available under the
5
+ * terms of the MIT License which is available in the project root.
6
+ *
7
+ * SPDX-License-Identifier: MIT
8
+ ********************************************************************************/
9
+
10
+ import {
11
+ describeError,
12
+ renderFrameworkMessage,
13
+ resolve,
14
+ resolvedFromResponseError,
15
+ type MessageDefinition,
16
+ type ParamsArg,
17
+ type ResolvedMessage,
18
+ type Tracer
19
+ } from '@hydranium/protocol';
20
+ import { SimpleCache } from '@hydranium/langium';
21
+ import type { ResponseError } from 'vscode-jsonrpc';
22
+ import { Diagnostic } from 'vscode-languageserver-protocol';
23
+ import { type LogNameOptions } from '../langium/diagnostics/logger.js';
24
+ import type { ServerSharedServicesMinimal } from '../langium/shared-services.js';
25
+ import type { ServerLocale } from '../locale/server-locale.js';
26
+ import { resolvedFromDiagnostic } from './carriers.js';
27
+
28
+ /** Construction options for {@link DefaultMessageRenderer}. */
29
+ export type MessageRendererOptions = LogNameOptions;
30
+
31
+ /**
32
+ * The render contract the `MessageRenderer` slot holds, implemented by
33
+ * {@link DefaultMessageRenderer}.
34
+ *
35
+ * An interface rather than the class, so the slot is compared STRUCTURALLY. A
36
+ * class-typed slot carries its `protected` members into every assignability
37
+ * check and TypeScript compares those nominally — which makes the slot
38
+ * unsatisfiable by a subclass declared against a second physical copy of this
39
+ * package, which any duplicated install produces. It also
40
+ * lets an adopter REPLACE this declaration rather than intersect with it, so
41
+ * slot resolution does not depend on the order a services type is written in.
42
+ *
43
+ * Every method carries a no-throw contract; see the implementation.
44
+ */
45
+ export interface MessageRenderer {
46
+ renderDiagnostic(diagnostic: Diagnostic): string;
47
+ renderError(error: ResponseError<unknown>): string;
48
+ renderMessage<S extends string>(message: MessageDefinition<S>, ...params: ParamsArg<S>): string;
49
+ }
50
+
51
+ /**
52
+ * Renders every user-facing message the server sends, in the locale the server
53
+ * was handed at init. The framework ships no catalogue, so its own behaviour is
54
+ * a pass-through.
55
+ *
56
+ * Adopters override {@link translationsFor}: the public render methods carry
57
+ * the no-throw contract, and the catalogue lookup they wrap is what can fail.
58
+ *
59
+ * Two render methods rather than one, because what is useful to an adopter is
60
+ * the carrier's structured fields and the two carriers have different ones. A
61
+ * single `render(text)` would force an adopter to match English prose, which
62
+ * breaks on the first Langium reword.
63
+ */
64
+ export class DefaultMessageRenderer implements MessageRenderer {
65
+ protected readonly tracer: Tracer;
66
+ protected readonly serverLocale: ServerLocale;
67
+ /**
68
+ * {@link translationsFor}'s answer per locale, `undefined` answers included —
69
+ * a `SimpleCache` distinguishes "absent" from "cached as none", which matters
70
+ * because shipping no catalogue is the framework's own hot path.
71
+ *
72
+ * `SimpleCache` rather than Langium's `WorkspaceCache`: the eviction axis
73
+ * there is document change, and a catalogue does not depend on documents, so
74
+ * it would evict on every build AND put a `DocumentBuilder` dependency on a
75
+ * service the shared tier declares free of one. Nothing evicts this: the
76
+ * locale arrives once per process. A subclass whose catalogue can change
77
+ * clears it.
78
+ */
79
+ protected readonly catalogues = new SimpleCache<string | undefined, Record<string, string> | undefined>();
80
+
81
+ constructor(services: ServerSharedServicesMinimal, options: MessageRendererOptions = {}) {
82
+ this.serverLocale = services.ServerLocale;
83
+ this.tracer = services.Tracer.for(options.logName ?? 'MessageRenderer').trace('instantiated');
84
+ }
85
+
86
+ /**
87
+ * The sentence to publish for `diagnostic`, replacing its current `message`.
88
+ * Sees lexer and parser errors too, which Langium pushes onto the document
89
+ * without routing them through `toDiagnostic`.
90
+ *
91
+ * **Must not throw**, which is why the guard is here and not at the call
92
+ * site: this runs inside the `Validated` phase, and Langium's
93
+ * `notifyDocumentPhase` rethrows anything that is not a cancellation — so an
94
+ * escaping error leaves the document AT `Validated` with the phase's
95
+ * listeners never run, and the client receives no diagnostics for that file.
96
+ * A subclass overriding this method takes that contract on itself.
97
+ */
98
+ renderDiagnostic(diagnostic: Diagnostic): string {
99
+ try {
100
+ const resolved = resolvedFromDiagnostic(diagnostic);
101
+ return resolved ? this.render(resolved) : Diagnostic.getMessageString(diagnostic);
102
+ } catch (err: unknown) {
103
+ this.reportFailure(err, 'a diagnostic');
104
+ return Diagnostic.getMessageString(diagnostic);
105
+ }
106
+ }
107
+
108
+ /**
109
+ * The sentence to send for `error`, replacing its current `message`. Same
110
+ * no-throw contract as {@link renderDiagnostic}: an escaping error replaces a
111
+ * typed rejection the caller can handle with one it cannot.
112
+ */
113
+ renderError(error: ResponseError<unknown>): string {
114
+ try {
115
+ const resolved = resolvedFromResponseError(error);
116
+ return resolved ? this.render(resolved) : error.message;
117
+ } catch (err: unknown) {
118
+ this.reportFailure(err, 'an RPC error');
119
+ return error.message;
120
+ }
121
+ }
122
+
123
+ /**
124
+ * The sentence for a declaration the caller holds directly, for a carrier
125
+ * with no slot to put an identity in.
126
+ *
127
+ * GLSP's action protocol is the case: every member of its message, status
128
+ * and reject actions is prose or an enum, so a code cannot travel and the
129
+ * raise site is the last place that still knows which message this is.
130
+ * Prefer {@link renderDiagnostic} / {@link renderError} wherever a carrier
131
+ * does hold the identity — they keep the render off the raise site, so an
132
+ * adopter's own messages ride the same one binding.
133
+ *
134
+ * Same no-throw contract as the carrier methods.
135
+ */
136
+ renderMessage<S extends string>(message: MessageDefinition<S>, ...params: ParamsArg<S>): string {
137
+ // `resolve` is inside the guard with the render, not before it: it calls
138
+ // the declaration's own `format`, which for an adopter declaration is
139
+ // arbitrary code, and a throw there would escape a method whose contract
140
+ // says it cannot.
141
+ let resolved: ResolvedMessage | undefined;
142
+ try {
143
+ resolved = resolve(message, ...params);
144
+ return this.render(resolved);
145
+ } catch (err: unknown) {
146
+ this.reportFailure(err, `the message '${message.code}'`);
147
+ // Unset only when `format` ITSELF threw, which leaves the
148
+ // uninterpolated template as the only text there is. A failed render
149
+ // still has the resolved English.
150
+ return resolved?.text ?? message.text;
151
+ }
152
+ }
153
+
154
+ /**
155
+ * The catalogue for the current locale, or `undefined` for none — the
156
+ * framework's answer, shipping none. Overriding this leaves every identity
157
+ * decision, every pass-through and the no-throw guard in place.
158
+ *
159
+ * **Called once per locale, not once per message**, so an override may load
160
+ * a file or build a map without that cost landing per diagnostic. The
161
+ * corollary is that a catalogue mutated in place afterwards is not seen;
162
+ * clear {@link catalogues} to invalidate.
163
+ *
164
+ * An adopter wanting Langium's own uncoded sentences instead matches
165
+ * `Diagnostic.data.code` from an overridden {@link renderDiagnostic}, never
166
+ * the sentence.
167
+ */
168
+ protected translationsFor(_locale: string | undefined): Record<string, string> | undefined {
169
+ return undefined;
170
+ }
171
+
172
+ /**
173
+ * Resolve one identity against the current locale's catalogue.
174
+ *
175
+ * Reads the locale per call. Copying it into a field at construction pins
176
+ * whatever was there before init ran, which is always `undefined` — services
177
+ * compose first.
178
+ *
179
+ * The catalogue behind it is memoized, because a workspace-wide validation
180
+ * renders once per diagnostic and the naive override — parse a JSON file,
181
+ * build a map — then pays that per diagnostic rather than per locale.
182
+ */
183
+ protected render(message: ResolvedMessage): string {
184
+ const locale = this.serverLocale.value;
185
+ return renderFrameworkMessage(
186
+ message,
187
+ this.catalogues.get(locale, () => this.translationsFor(locale))
188
+ );
189
+ }
190
+
191
+ /**
192
+ * Emit a failed render. Logged rather than swallowed: the fallback output is
193
+ * byte-identical to a correctly-configured default, so a throwing catalogue
194
+ * is otherwise invisible.
195
+ */
196
+ protected reportFailure(err: unknown, carrier: string): void {
197
+ this.tracer.error(this.formatRenderFailure(err, carrier));
198
+ }
199
+
200
+ /** Format the failed-render line. Override to name the adopter's catalogue entry. */
201
+ protected formatRenderFailure(err: unknown, carrier: string): string {
202
+ return `rendering ${carrier} failed; falling back to the server's own text. ${describeError(err)}`;
203
+ }
204
+ }
@@ -0,0 +1,108 @@
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
+ * Choosing `--max-old-space-size` for a child process, which is a decision no
12
+ * caller gets right by picking a number.
13
+ *
14
+ * A fixed ceiling is sized for the machine the author had. Pass 8192 to a
15
+ * process under a 2 GiB cgroup limit and V8 lets old space grow past the limit
16
+ * without ever collecting hard, so the kernel OOM-kills the whole container
17
+ * before V8 has any reason to act — the parent sees a signal, not a heap error,
18
+ * and everything sharing the cgroup dies with it. Pass nothing on a large
19
+ * desktop and V8 sizes from physical RAM, which for a memory-heavy tool is well
20
+ * under what it needs.
21
+ *
22
+ * Both are the same mistake: a ceiling stated without reference to the limit
23
+ * that is actually in force. The rule here is to name the desktop default
24
+ * explicitly and step aside inside a container, where Node derives its own
25
+ * ceiling from the cgroup limit and a runaway heap therefore fails INSIDE the
26
+ * child — attributable, and reported as a heap error against one process rather
27
+ * than as a kill against every process in the cgroup.
28
+ */
29
+
30
+ import * as os from 'node:os';
31
+
32
+ /** Options for {@link heapCeilingArgs}. */
33
+ export interface HeapCeilingOptions {
34
+ /**
35
+ * Ceiling in MiB to pass when no cgroup limit is in force. Name the value a
36
+ * memory-heavy run on a workstation needs; it is ignored inside a container.
37
+ */
38
+ readonly desktopDefaultMb: number;
39
+ /**
40
+ * Caller-supplied override, typically an environment variable, and typically
41
+ * `undefined`. A finite value at or above {@link minMb} wins everywhere,
42
+ * container or not — an operator who states a number has decided. An explicit
43
+ * `0` means "let Node decide" and emits no flag. Anything unparseable is
44
+ * REPORTED through {@link warn} rather than ignored: `8G` is a natural thing
45
+ * to type into a variable measured in MiB, and silently dropping it leaves
46
+ * the operator believing a ceiling is in force.
47
+ */
48
+ readonly envValue?: string;
49
+ /**
50
+ * Smallest override to pass on. Below it, {@link warn} is called and NO flag
51
+ * is emitted: a value that small can only be a misconfiguration — GiB typed
52
+ * where MiB was meant — and V8 fatals at startup once it is small enough.
53
+ * Deliberately not clamped UP: running with a different number than the one
54
+ * configured hides the mistake instead of surfacing it. Omitted means no floor.
55
+ */
56
+ readonly minMb?: number;
57
+ /** Where a rejected override is reported. Defaults to `console.warn`. */
58
+ readonly warn?: (message: string) => void;
59
+ /** Cgroup limit in bytes; defaults to this process's. Injectable for tests. */
60
+ readonly constrained?: number;
61
+ /** Host physical memory in bytes; defaults to `os.totalmem()`. Injectable for tests. */
62
+ readonly total?: number;
63
+ }
64
+
65
+ /**
66
+ * Whether a cgroup memory limit is in force — i.e. whether the OOM killer is
67
+ * watching a ceiling lower than (or equal to) the machine's own.
68
+ *
69
+ * **`constrained > 0` is not the test, and that is the whole reason this is a
70
+ * named function.** With no limit set, cgroup v2 reports 2^64 and v1 reports
71
+ * ~2^63 rather than 0, so the naive test reads every desktop as a container.
72
+ * Neither sentinel can equal `os.totalmem()`, so comparing against the host
73
+ * total costs nothing and rules both out. The comparison is `<=` rather than
74
+ * `<` so a limit set to exactly the host's RAM still counts as a limit.
75
+ */
76
+ export function isMemoryConstrained(constrained = process.constrainedMemory?.() ?? 0, total = os.totalmem()): boolean {
77
+ return constrained > 0 && constrained <= total;
78
+ }
79
+
80
+ /**
81
+ * The `execArgv` entries that set a child's heap ceiling: `[]` to let Node size
82
+ * the heap itself, or a single `--max-old-space-size=<mb>`.
83
+ *
84
+ * Returns an array rather than a string so a caller can spread it
85
+ * unconditionally into an argv it is building.
86
+ */
87
+ export function heapCeilingArgs(options: HeapCeilingOptions): string[] {
88
+ const { desktopDefaultMb, envValue, minMb, warn = (message: string) => console.warn(message) } = options;
89
+ if (envValue !== undefined) {
90
+ const mb = Number(envValue);
91
+ // An explicit 0 is a decision — "let Node decide" — so it passes quietly.
92
+ // Anything else that is not a positive number is a typo, and the operator
93
+ // who typed it is the one person who cannot tell it was dropped.
94
+ if (!Number.isFinite(mb) || mb < 0) {
95
+ warn(`Ignoring the heap ceiling '${envValue}': expected a whole number of MiB. Node will size the heap instead.`);
96
+ return [];
97
+ }
98
+ if (mb === 0) {
99
+ return [];
100
+ }
101
+ if (minMb !== undefined && mb < minMb) {
102
+ warn(`Ignoring a heap ceiling of ${envValue} MiB: below the ${minMb} MiB minimum. Node will size the heap instead.`);
103
+ return [];
104
+ }
105
+ return [`--max-old-space-size=${Math.floor(mb)}`];
106
+ }
107
+ return isMemoryConstrained(options.constrained, options.total) ? [] : [`--max-old-space-size=${desktopDefaultMb}`];
108
+ }
package/src/node/index.ts CHANGED
@@ -35,6 +35,7 @@ export * from './server-diagnostics.js';
35
35
  // entry alongside the default policy.
36
36
  export * from './ast-ground-truth.js';
37
37
  export * from './event-loop-monitor.js';
38
+ export * from './heap-ceiling.js';
38
39
  export * from './latency-from-env.js';
39
40
  export * from './measure-memory.js';
40
41
  export * from './memory-monitor.js';
@@ -29,7 +29,7 @@ export function isLatencyEnabled(): boolean {
29
29
 
30
30
  /**
31
31
  * A {@link LatencyCollector} when {@link DEFAULT_LATENCY_ENV} is set, otherwise
32
- * `undefined`. Heads pass the result straight to `instrumentLspConnection`, the
32
+ * `undefined`. Heads pass the result straight to `lspLatencyOptions`, the
33
33
  * `DataServer` `latency` option and the RPC binder; all three treat `undefined`
34
34
  * as "seam off", so this single factory is the one place a head decides whether
35
35
  * timing runs. `clock` is forwarded to the collector so tests stay deterministic.
@@ -15,6 +15,7 @@ import { realpathSync } from 'node:fs';
15
15
  import * as fsp from 'node:fs/promises';
16
16
  import { type WritableFileSystemProvider } from '../documents/ast-document-manager.js';
17
17
  import { type SelfSaveRegistry } from '../documents/self-save-registry.js';
18
+ import { renameOverOpenReaders } from './rename-over-open-readers.js';
18
19
  import { type LogNameOptions } from '../langium/diagnostics/logger.js';
19
20
  import { serverSharedFactory, type ServerSharedServicesMinimal } from '../langium/shared-services.js';
20
21
  import { serveVirtualDocument } from '../langium/workspace/virtual-document.js';
@@ -195,47 +196,6 @@ async function replacedFile(path: string): Promise<ReplacedFile | undefined> {
195
196
  }
196
197
  }
197
198
 
198
- /**
199
- * Errno values a rename reports on Windows when another handle holds the
200
- * destination open. POSIX renames are unaffected by open handles, so this
201
- * cannot fire there and the retry below costs nothing.
202
- */
203
- const RENAME_CONTENTION_CODES = new Set(['EPERM', 'EACCES', 'EBUSY']);
204
-
205
- /**
206
- * `rename` the staged content over `destination`, retrying while Windows
207
- * reports the destination as held open.
208
- *
209
- * The staging file exists so a reader never sees a half-written file, and on
210
- * Windows the very presence of that reader is what makes the replacing rename
211
- * fail — so the indivisible write breaks under exactly the contention it was
212
- * built for, and it breaks intermittently, which is worse than never working.
213
- * A reader's handle is released in milliseconds, so waiting turns a spurious
214
- * failure into a slightly later success.
215
- *
216
- * BOUNDED, not open-ended: a genuine permission fault raises the same errno and
217
- * is distinguishable from contention only by never clearing, so an unbounded
218
- * wait would convert a hard error into a hang. Exhausting the budget rethrows
219
- * the last failure, leaving the caller's cleanup and error contract unchanged.
220
- */
221
- async function renameOverOpenReaders(staging: string, destination: string): Promise<void> {
222
- const deadline = Date.now() + 2_000;
223
- for (let attempt = 0; ; attempt++) {
224
- try {
225
- await fsp.rename(staging, destination);
226
- return;
227
- } catch (err: unknown) {
228
- const code = err instanceof Error && 'code' in err ? String((err as NodeJS.ErrnoException).code) : undefined;
229
- if (code === undefined || !RENAME_CONTENTION_CODES.has(code) || Date.now() >= deadline) {
230
- throw err;
231
- }
232
- // Backs off to keep a long contention window from spinning, capped so
233
- // a late attempt still lands promptly once the handle is released.
234
- await new Promise(resolve => setTimeout(resolve, Math.min(2 ** attempt, 50)));
235
- }
236
- }
237
- }
238
-
239
199
  /**
240
200
  * Module fragment that binds the writable Node {@link DefaultFileSystemProvider},
241
201
  * spread into the services context on a Node host.
@@ -55,8 +55,8 @@ export interface ProfilingRunOptions {
55
55
  /**
56
56
  * Optional latency collector. When present, {@link ProfilingRun.finish} writes
57
57
  * its report to `server-latency.json` and records a `server-latency` manifest artefact. A
58
- * head feeds it via the RPC binding / `instrumentLspConnection`; a pure
59
- * headless build with no request traffic leaves it empty.
58
+ * head feeds it via the RPC binding / `lspLatencyOptions`; a pure headless
59
+ * build with no request traffic leaves it empty.
60
60
  */
61
61
  latency?: LatencyCollector;
62
62
  }
@@ -97,7 +97,7 @@ export class ProfilingRun {
97
97
  // `HYDRANIUM_LOG_FILE` env, which every `@hydranium/core` copy reads when
98
98
  // its logger is CONSTRUCTED — so `ProfilingRun.start` must run before the
99
99
  // head's services are created (as `measureModelMemory` does). This is the
100
- // only mechanism that crosses a yalc'd adopter's separate core copy; a
100
+ // only mechanism that crosses an adopter's separate core copy; a
101
101
  // process-local `setLogFilePath` would only reach this module's own copy.
102
102
  this.previousLogFileEnv = process.env[DEFAULT_LOG_FILE_ENV];
103
103
  process.env[DEFAULT_LOG_FILE_ENV] = this.serverLogPath;