@hydranium/core 1.0.0-next.7 → 1.0.0-next.70

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 (286) hide show
  1. package/lib/documents/ast-document-manager.d.ts +58 -5
  2. package/lib/documents/ast-document-manager.d.ts.map +1 -1
  3. package/lib/documents/ast-document-manager.js +50 -18
  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 +51 -17
  10. package/lib/documents/hydranium-text-documents.d.ts.map +1 -1
  11. package/lib/documents/hydranium-text-documents.js +136 -40
  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 +103 -7
  81. package/lib/langium/model-service/model-service.d.ts.map +1 -1
  82. package/lib/langium/model-service/model-service.js +70 -89
  83. package/lib/langium/model-service/model-service.js.map +1 -1
  84. package/lib/langium/module.d.ts +82 -13
  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 +10 -0
  89. package/lib/langium/naming/name-provider.d.ts.map +1 -1
  90. package/lib/langium/naming/name-provider.js.map +1 -1
  91. package/lib/langium/naming/name-separator-validation.d.ts +23 -0
  92. package/lib/langium/naming/name-separator-validation.d.ts.map +1 -1
  93. package/lib/langium/naming/name-separator-validation.js +30 -1
  94. package/lib/langium/naming/name-separator-validation.js.map +1 -1
  95. package/lib/langium/residency/cst-residency-service.d.ts +31 -9
  96. package/lib/langium/residency/cst-residency-service.d.ts.map +1 -1
  97. package/lib/langium/residency/cst-residency-service.js +13 -56
  98. package/lib/langium/residency/cst-residency-service.js.map +1 -1
  99. package/lib/langium/scope/hydranium-scope-provider.d.ts +32 -13
  100. package/lib/langium/scope/hydranium-scope-provider.d.ts.map +1 -1
  101. package/lib/langium/scope/hydranium-scope-provider.js +37 -20
  102. package/lib/langium/scope/hydranium-scope-provider.js.map +1 -1
  103. package/lib/langium/shared-services.d.ts +15 -2
  104. package/lib/langium/shared-services.d.ts.map +1 -1
  105. package/lib/langium/shared-services.js.map +1 -1
  106. package/lib/langium/transfer/transfer-encoder.d.ts +33 -2
  107. package/lib/langium/transfer/transfer-encoder.d.ts.map +1 -1
  108. package/lib/langium/transfer/transfer-encoder.js +14 -3
  109. package/lib/langium/transfer/transfer-encoder.js.map +1 -1
  110. package/lib/langium/validation/document-validator.d.ts +145 -6
  111. package/lib/langium/validation/document-validator.d.ts.map +1 -1
  112. package/lib/langium/validation/document-validator.js +211 -4
  113. package/lib/langium/validation/document-validator.js.map +1 -1
  114. package/lib/langium/workspace/document-uri-policy.d.ts +3 -4
  115. package/lib/langium/workspace/document-uri-policy.d.ts.map +1 -1
  116. package/lib/langium/workspace/document-uri-policy.js +3 -4
  117. package/lib/langium/workspace/document-uri-policy.js.map +1 -1
  118. package/lib/langium/workspace/hydranium-langium-document-factory.d.ts +25 -0
  119. package/lib/langium/workspace/hydranium-langium-document-factory.d.ts.map +1 -1
  120. package/lib/langium/workspace/hydranium-langium-document-factory.js +25 -0
  121. package/lib/langium/workspace/hydranium-langium-document-factory.js.map +1 -1
  122. package/lib/langium/workspace/hydranium-workspace-manager.d.ts +21 -1
  123. package/lib/langium/workspace/hydranium-workspace-manager.d.ts.map +1 -1
  124. package/lib/langium/workspace/hydranium-workspace-manager.js +28 -0
  125. package/lib/langium/workspace/hydranium-workspace-manager.js.map +1 -1
  126. package/lib/langium/workspace/in-memory-file-system-provider.d.ts +8 -0
  127. package/lib/langium/workspace/in-memory-file-system-provider.d.ts.map +1 -1
  128. package/lib/langium/workspace/in-memory-file-system-provider.js +11 -2
  129. package/lib/langium/workspace/in-memory-file-system-provider.js.map +1 -1
  130. package/lib/langium/workspace/initialize-workspace.d.ts +22 -2
  131. package/lib/langium/workspace/initialize-workspace.d.ts.map +1 -1
  132. package/lib/langium/workspace/initialize-workspace.js +13 -5
  133. package/lib/langium/workspace/initialize-workspace.js.map +1 -1
  134. package/lib/langium/workspace/langium-documents.d.ts +79 -17
  135. package/lib/langium/workspace/langium-documents.d.ts.map +1 -1
  136. package/lib/langium/workspace/langium-documents.js +83 -28
  137. package/lib/langium/workspace/langium-documents.js.map +1 -1
  138. package/lib/locale/index.d.ts +10 -0
  139. package/lib/locale/index.d.ts.map +1 -0
  140. package/lib/locale/index.js +10 -0
  141. package/lib/locale/index.js.map +1 -0
  142. package/lib/locale/server-locale.d.ts +73 -0
  143. package/lib/locale/server-locale.d.ts.map +1 -0
  144. package/lib/locale/server-locale.js +61 -0
  145. package/lib/locale/server-locale.js.map +1 -0
  146. package/lib/lsp/hydranium-document-update-handler.js +1 -1
  147. package/lib/lsp/hydranium-document-update-handler.js.map +1 -1
  148. package/lib/lsp/index.d.ts +1 -1
  149. package/lib/lsp/index.d.ts.map +1 -1
  150. package/lib/lsp/index.js +1 -1
  151. package/lib/lsp/index.js.map +1 -1
  152. package/lib/lsp/lsp-latency.d.ts +39 -0
  153. package/lib/lsp/lsp-latency.d.ts.map +1 -0
  154. package/lib/lsp/lsp-latency.js +58 -0
  155. package/lib/lsp/lsp-latency.js.map +1 -0
  156. package/lib/messages/carriers.d.ts +54 -0
  157. package/lib/messages/carriers.d.ts.map +1 -0
  158. package/lib/messages/carriers.js +62 -0
  159. package/lib/messages/carriers.js.map +1 -0
  160. package/lib/messages/index.d.ts +25 -0
  161. package/lib/messages/index.d.ts.map +1 -0
  162. package/lib/messages/index.js +25 -0
  163. package/lib/messages/index.js.map +1 -0
  164. package/lib/messages/renderer.d.ts +136 -0
  165. package/lib/messages/renderer.d.ts.map +1 -0
  166. package/lib/messages/renderer.js +159 -0
  167. package/lib/messages/renderer.js.map +1 -0
  168. package/lib/node/latency-from-env.d.ts +1 -1
  169. package/lib/node/latency-from-env.js +1 -1
  170. package/lib/node/node-file-system-provider.d.ts.map +1 -1
  171. package/lib/node/node-file-system-provider.js +1 -40
  172. package/lib/node/node-file-system-provider.js.map +1 -1
  173. package/lib/node/profiling-run.d.ts +2 -2
  174. package/lib/node/profiling-run.js +1 -1
  175. package/lib/node/profiling-run.js.map +1 -1
  176. package/lib/node/rename-over-open-readers.d.ts +52 -0
  177. package/lib/node/rename-over-open-readers.d.ts.map +1 -0
  178. package/lib/node/rename-over-open-readers.js +66 -0
  179. package/lib/node/rename-over-open-readers.js.map +1 -0
  180. package/lib/testing/fake-document.d.ts +14 -3
  181. package/lib/testing/fake-document.d.ts.map +1 -1
  182. package/lib/testing/fake-document.js +18 -3
  183. package/lib/testing/fake-document.js.map +1 -1
  184. package/lib/testing/make-noop-shared-services.d.ts +14 -0
  185. package/lib/testing/make-noop-shared-services.d.ts.map +1 -1
  186. package/lib/testing/make-noop-shared-services.js +28 -2
  187. package/lib/testing/make-noop-shared-services.js.map +1 -1
  188. package/lib/testing/make-test-services.d.ts +31 -4
  189. package/lib/testing/make-test-services.d.ts.map +1 -1
  190. package/lib/testing/make-test-services.js +19 -3
  191. package/lib/testing/make-test-services.js.map +1 -1
  192. package/lib/testing/node/spawned-server.d.ts +14 -0
  193. package/lib/testing/node/spawned-server.d.ts.map +1 -1
  194. package/lib/testing/node/spawned-server.js +33 -1
  195. package/lib/testing/node/spawned-server.js.map +1 -1
  196. package/lib/testing/playwright/flaky-network-proxy.d.ts +76 -0
  197. package/lib/testing/playwright/flaky-network-proxy.d.ts.map +1 -0
  198. package/lib/testing/playwright/flaky-network-proxy.js +164 -0
  199. package/lib/testing/playwright/flaky-network-proxy.js.map +1 -0
  200. package/lib/testing/playwright/index.d.ts +1 -0
  201. package/lib/testing/playwright/index.d.ts.map +1 -1
  202. package/lib/testing/playwright/index.js +1 -0
  203. package/lib/testing/playwright/index.js.map +1 -1
  204. package/lib/testing/playwright/server-log-capture.d.ts +14 -4
  205. package/lib/testing/playwright/server-log-capture.d.ts.map +1 -1
  206. package/lib/testing/playwright/server-log-capture.js +21 -4
  207. package/lib/testing/playwright/server-log-capture.js.map +1 -1
  208. package/lib/testing/playwright/server-log-rename-reporter.d.ts.map +1 -1
  209. package/lib/testing/playwright/server-log-rename-reporter.js +10 -1
  210. package/lib/testing/playwright/server-log-rename-reporter.js.map +1 -1
  211. package/lib/testing/stub-ast-document-manager.d.ts +3 -4
  212. package/lib/testing/stub-ast-document-manager.d.ts.map +1 -1
  213. package/lib/testing/stub-ast-document-manager.js +2 -5
  214. package/lib/testing/stub-ast-document-manager.js.map +1 -1
  215. package/lib/testing/stub-document-builder.d.ts +8 -0
  216. package/lib/testing/stub-document-builder.d.ts.map +1 -1
  217. package/lib/testing/stub-document-builder.js +22 -3
  218. package/lib/testing/stub-document-builder.js.map +1 -1
  219. package/lib/testing/stub-model-service.d.ts +1 -1
  220. package/lib/testing/stub-model-service.d.ts.map +1 -1
  221. package/lib/testing/stub-model-service.js +2 -2
  222. package/lib/testing/stub-model-service.js.map +1 -1
  223. package/package.json +17 -8
  224. package/src/documents/ast-document-manager.ts +99 -23
  225. package/src/documents/client-ids.ts +5 -22
  226. package/src/documents/hydranium-text-documents.ts +161 -55
  227. package/src/documents/language-client-text-shadow.ts +59 -11
  228. package/src/documents/self-save-registry.ts +52 -13
  229. package/src/index.ts +5 -0
  230. package/src/langium/ast-extension/ast-node-builder.ts +66 -22
  231. package/src/langium/bootstrap.ts +16 -9
  232. package/src/langium/config/configuration-provider.ts +119 -0
  233. package/src/langium/config/index.ts +1 -0
  234. package/src/langium/diagnostics/lsp-logger.ts +41 -6
  235. package/src/langium/document-builder/build-pipeline-integration.ts +14 -1
  236. package/src/langium/document-builder/build-session.ts +87 -0
  237. package/src/langium/document-builder/document-builder.ts +339 -11
  238. package/src/langium/document-builder/index.ts +1 -0
  239. package/src/langium/integration-services.ts +67 -6
  240. package/src/langium/integrity/integrity-service.ts +35 -1
  241. package/src/langium/keys/containment.ts +87 -0
  242. package/src/langium/keys/index.ts +1 -0
  243. package/src/langium/keys/name-based-key-provider.ts +4 -0
  244. package/src/langium/model-service/model-service.ts +145 -22
  245. package/src/langium/module.ts +104 -19
  246. package/src/langium/naming/name-provider.ts +10 -0
  247. package/src/langium/naming/name-separator-validation.ts +34 -5
  248. package/src/langium/residency/cst-residency-service.ts +36 -12
  249. package/src/langium/scope/hydranium-scope-provider.ts +40 -22
  250. package/src/langium/shared-services.ts +19 -2
  251. package/src/langium/transfer/transfer-encoder.ts +45 -3
  252. package/src/langium/validation/document-validator.ts +255 -8
  253. package/src/langium/workspace/document-uri-policy.ts +3 -4
  254. package/src/langium/workspace/hydranium-langium-document-factory.ts +34 -0
  255. package/src/langium/workspace/hydranium-workspace-manager.ts +30 -1
  256. package/src/langium/workspace/in-memory-file-system-provider.ts +13 -3
  257. package/src/langium/workspace/initialize-workspace.ts +34 -5
  258. package/src/langium/workspace/langium-documents.ts +106 -33
  259. package/src/locale/index.ts +10 -0
  260. package/src/locale/server-locale.ts +86 -0
  261. package/src/lsp/hydranium-document-update-handler.ts +1 -1
  262. package/src/lsp/index.ts +1 -1
  263. package/src/lsp/lsp-latency.ts +62 -0
  264. package/src/messages/carriers.ts +78 -0
  265. package/src/messages/index.ts +27 -0
  266. package/src/messages/renderer.ts +204 -0
  267. package/src/node/latency-from-env.ts +1 -1
  268. package/src/node/node-file-system-provider.ts +1 -41
  269. package/src/node/profiling-run.ts +3 -3
  270. package/src/node/rename-over-open-readers.ts +78 -0
  271. package/src/testing/fake-document.ts +22 -4
  272. package/src/testing/make-noop-shared-services.ts +50 -2
  273. package/src/testing/make-test-services.ts +49 -7
  274. package/src/testing/node/spawned-server.ts +35 -1
  275. package/src/testing/playwright/flaky-network-proxy.ts +240 -0
  276. package/src/testing/playwright/index.ts +1 -0
  277. package/src/testing/playwright/server-log-capture.ts +24 -5
  278. package/src/testing/playwright/server-log-rename-reporter.ts +12 -1
  279. package/src/testing/stub-ast-document-manager.ts +5 -10
  280. package/src/testing/stub-document-builder.ts +32 -3
  281. package/src/testing/stub-model-service.ts +2 -2
  282. package/lib/lsp/instrument-connection.d.ts +0 -36
  283. package/lib/lsp/instrument-connection.d.ts.map +0 -1
  284. package/lib/lsp/instrument-connection.js +0 -62
  285. package/lib/lsp/instrument-connection.js.map +0 -1
  286. package/src/lsp/instrument-connection.ts +0 -66
@@ -7,12 +7,23 @@
7
7
  * SPDX-License-Identifier: MIT
8
8
  ********************************************************************************/
9
9
 
10
- import { type LogThreshold, type MaybeObservableValue, ObservableValue, type Tracer, TransferDiagnostic } from '@hydranium/protocol';
10
+ import {
11
+ defineMessage,
12
+ describeError,
13
+ messageData,
14
+ type LogThreshold,
15
+ type MaybeObservableValue,
16
+ ObservableValue,
17
+ type Tracer,
18
+ TransferDiagnostic
19
+ } from '@hydranium/protocol';
11
20
  import {
12
21
  type AstNode,
13
22
  type AstNodeLocator,
23
+ type AstReflection,
14
24
  DefaultDocumentValidator,
15
25
  type DiagnosticInfo,
26
+ DocumentValidator,
16
27
  type LangiumDocument,
17
28
  type LangiumCoreServices,
18
29
  type ValidateSingleNodeOptions,
@@ -20,21 +31,102 @@ import {
20
31
  type ValidationSeverity
21
32
  } from '@hydranium/langium';
22
33
  import type { CancellationToken } from 'vscode-languageserver-protocol';
23
- import type { Diagnostic } from 'vscode-languageserver-types';
34
+ // A VALUE import, for `Diagnostic.getMessageString`: `message` is
35
+ // `string | MarkupContent` in LSP 3.17+, so upstream's own reader is what
36
+ // narrows it rather than a hand-rolled union check here.
37
+ import { Diagnostic } from 'vscode-languageserver-types';
24
38
  import { type LogNameOptions } from '../diagnostics/logger.js';
25
39
  import { isSyntheticNode } from '../workspace/synthetic.js';
26
40
  import { isVirtualUri } from '../workspace/virtual-document.js';
27
41
 
28
42
  /**
29
- * Diagnostic shape produced by {@link HydraniumDocumentValidator}: an LSP
30
- * {@link Diagnostic} extended with the protocol-level `element` path and
31
- * optional `property` name from {@link TransferDiagnostic}.
43
+ * Diagnostic read off a `LangiumDocument`: an LSP {@link Diagnostic} that MAY
44
+ * carry the protocol-level `element` path and `property` name from
45
+ * {@link TransferDiagnostic}.
46
+ *
47
+ * `element` is optional because a document's diagnostics do not all come from
48
+ * this validator. {@link HydraniumDocumentValidator.toDiagnostic} always sets
49
+ * one, but Langium pushes lexer and parser errors straight onto the document
50
+ * without routing them through it, so a document that fails to parse carries
51
+ * diagnostics with no path at all. Treat it as absent, not empty.
52
+ *
53
+ * Narrowing `LangiumDocument.diagnostics` to this type instead is unavailable:
54
+ * declaration merging may add a member but not retype one, and augmenting the
55
+ * LSP `Diagnostic` reaches only one of the two declaration files its package
56
+ * ships, since the `exports` map splits `import` from `default` with no `types`
57
+ * condition. Consumers therefore cast at the read, and the cast is sound only
58
+ * because this field is optional.
32
59
  */
33
60
  export interface TransferLspDiagnostic extends Diagnostic {
34
- element: string;
61
+ element?: string;
35
62
  property?: string;
36
63
  }
37
64
 
65
+ /**
66
+ * A reference resolved to nothing.
67
+ *
68
+ * **The English is byte-identical to Langium's `DefaultLinker.createLinkingError`
69
+ * sentence, and must stay so.** The identity is attached to a diagnostic Langium
70
+ * already worded, so a divergence here would silently change the text every
71
+ * adopter without a catalogue sees. {@link HydraniumDocumentValidator.processLinkingErrors}
72
+ * attaches it only when the two match exactly, which is also what keeps an
73
+ * adopter's own reworded linking error from being mislabelled as this one.
74
+ *
75
+ * It exists because this is the most-seen validation error in any language built
76
+ * on the framework, and Langium puts its own code in `data.code` rather than on
77
+ * `Diagnostic.code` — so without a framework identity every adopter wanting to
78
+ * render it has to special-case Langium's shape.
79
+ */
80
+ export const UNRESOLVED_REFERENCE = defineMessage(
81
+ 'hydranium/core/unresolved-reference',
82
+ "Could not resolve reference to {referenceType} named '{refText}'."
83
+ );
84
+
85
+ /**
86
+ * A character no token of the grammar can start with.
87
+ *
88
+ * **The English is byte-identical to CHEVROTAIN's
89
+ * `defaultLexerErrorProvider.buildUnexpectedCharactersMessage`, and must stay
90
+ * so** — one layer further out than {@link UNRESOLVED_REFERENCE}, whose sentence
91
+ * is Langium's. Langium words neither: `processLexingErrors` copies
92
+ * `lexerDiagnostic.message` through untouched, so the text an adopter sees today
93
+ * is produced two dependencies down and is the only thing this identity may
94
+ * claim to be. {@link HydraniumDocumentValidator.identifyLexingError} attaches
95
+ * it only when the two match exactly, which is also what keeps a custom lexer's
96
+ * own diagnostics — Langium admits any of them through `lexerReport` — from
97
+ * being mislabelled as this one.
98
+ *
99
+ * It exists because a lexing error is the FIRST message a user of a new language
100
+ * sees and the one an adopter cannot reach: every other diagnostic worth
101
+ * translating either carries an identity already or is raised by adopter code,
102
+ * while this one arrives with a Langium `data.code` naming a KIND and no
103
+ * parameters at all — so a catalogue had nothing to key on and nothing to
104
+ * interpolate.
105
+ *
106
+ * `skipped` rather than `length`, matching what the sentence says the number
107
+ * means: chevrotain reports how many characters the lexer discarded to recover,
108
+ * which for a single stray character is one and for a run of them is the run.
109
+ */
110
+ export const LEXING_ERROR = defineMessage(
111
+ 'hydranium/core/lexing-error',
112
+ 'unexpected character: ->{character}<- at offset: {offset}, skipped {skipped} characters.'
113
+ );
114
+
115
+ /**
116
+ * Langium's own `data.code` values for a diagnostic that came out of the lexer.
117
+ *
118
+ * All four severities, not just the error one: `lexerReport` admits warnings and
119
+ * below, and a token builder that downgrades a stray character still produces
120
+ * the same sentence. Gating on the error code alone would leave the identity off
121
+ * a message that is word-for-word the one it names.
122
+ */
123
+ const LEXING_CODES: ReadonlySet<unknown> = new Set([
124
+ DocumentValidator.LexingError,
125
+ DocumentValidator.LexingWarning,
126
+ DocumentValidator.LexingInfo,
127
+ DocumentValidator.LexingHint
128
+ ]);
129
+
38
130
  export interface DocumentValidatorOptions extends LogNameOptions {
39
131
  /**
40
132
  * Level at which the `validateDocument` timing line is emitted, or `'off'`
@@ -81,6 +173,7 @@ export interface DocumentValidatorOptions extends LogNameOptions {
81
173
  export class HydraniumDocumentValidator extends DefaultDocumentValidator {
82
174
  protected readonly tracer: Tracer;
83
175
  protected readonly astNodeLocator: AstNodeLocator;
176
+ protected readonly reflection: AstReflection;
84
177
  protected readonly logLevel: ObservableValue<LogThreshold>;
85
178
  protected readonly logAfterMs: ObservableValue<number>;
86
179
  protected readonly validateVirtualDocuments: ObservableValue<boolean>;
@@ -90,6 +183,7 @@ export class HydraniumDocumentValidator extends DefaultDocumentValidator {
90
183
  super(services);
91
184
  this.tracer = services.shared.Tracer.for(options.logName ?? 'DocumentValidator').trace('instantiated');
92
185
  this.astNodeLocator = services.workspace.AstNodeLocator;
186
+ this.reflection = services.shared.AstReflection;
93
187
  this.logLevel = ObservableValue.from(options.logLevel ?? 'debug');
94
188
  this.logAfterMs = ObservableValue.from(options.logAfterMs ?? 20);
95
189
  this.validateVirtualDocuments = ObservableValue.from(options.validateVirtualDocuments ?? false);
@@ -111,16 +205,85 @@ export class HydraniumDocumentValidator extends DefaultDocumentValidator {
111
205
  }
112
206
  const level = this.logLevel.value;
113
207
  if (level === 'off') {
114
- return super.validateDocument(document, options, cancelToken);
208
+ return this.validateAndIdentify(document, options, cancelToken);
115
209
  }
116
210
  // `level` is narrowed to `LogLevel` past the early-return.
117
211
  return this.tracer
118
212
  .withUri(document.uri.toString())
119
- .time('validateDocument', () => super.validateDocument(document, options, cancelToken), level, {
213
+ .time('validateDocument', () => this.validateAndIdentify(document, options, cancelToken), level, {
120
214
  logAfterMs: this.logAfterMs.value
121
215
  });
122
216
  }
123
217
 
218
+ /**
219
+ * Langium's validation pass, plus the framework identity on the lexing
220
+ * diagnostics it produced.
221
+ *
222
+ * **Here rather than in an override of `processLexingErrors`, and the reason
223
+ * is that the seam cannot see what the identity needs.** Langium hands that
224
+ * method a `ParseResult`, which carries the AST and the error lists but not
225
+ * the source text — and the offending CHARACTER is the parameter a
226
+ * translation exists to interpolate. The document does carry it, and this is
227
+ * the innermost point that still holds one. Reconstructing the character by
228
+ * matching it out of the finished sentence was the alternative, and it
229
+ * inverts the direction the rest of this file works in: every other identity
230
+ * here is derived from structured fields and CHECKED against the prose.
231
+ *
232
+ * Inside the timing span rather than around it, so the line accounts for the
233
+ * whole pass.
234
+ */
235
+ protected async validateAndIdentify(
236
+ document: LangiumDocument,
237
+ options?: ValidationOptions,
238
+ cancelToken?: CancellationToken
239
+ ): Promise<Diagnostic[]> {
240
+ const diagnostics = await super.validateDocument(document, options, cancelToken);
241
+ // Mapped in place over the array Langium built, rather than filtered and
242
+ // re-concatenated: the publish order is the diagnostic order and a
243
+ // reordering would move a squiggle's entry in the problems list.
244
+ for (let index = 0; index < diagnostics.length; index++) {
245
+ diagnostics[index] = this.identifyLexingError(document, diagnostics[index]);
246
+ }
247
+ return diagnostics;
248
+ }
249
+
250
+ /**
251
+ * Add the {@link LEXING_ERROR} identity to one diagnostic, or return it
252
+ * untouched when it is not the sentence that identity renders.
253
+ *
254
+ * The parameters come from the diagnostic's own RANGE, not from
255
+ * `parseResult.lexerErrors`. Both hold the same numbers, and the range is the
256
+ * one that needs no assumption about upstream: correlating the two lists
257
+ * would depend on Langium appending one diagnostic per lexer error in order,
258
+ * which is true today and is an internal of the method being wrapped.
259
+ *
260
+ * **The format-and-compare is the whole discriminator, and it validates the
261
+ * reconstruction as well as the identity.** A range that did not round-trip
262
+ * to the offset chevrotain reported would produce a different sentence and be
263
+ * declined, so a wrong parameter set can never be attached to a right-looking
264
+ * message.
265
+ */
266
+ protected identifyLexingError(document: LangiumDocument, diagnostic: Diagnostic): Diagnostic {
267
+ const data = diagnostic.data as { code?: unknown } | undefined;
268
+ if (!LEXING_CODES.has(data?.code)) {
269
+ return diagnostic;
270
+ }
271
+ const text = document.textDocument;
272
+ const offset = text.offsetAt(diagnostic.range.start);
273
+ const params = {
274
+ character: text.getText().charAt(offset),
275
+ offset,
276
+ skipped: text.offsetAt(diagnostic.range.end) - offset
277
+ };
278
+ if (Diagnostic.getMessageString(diagnostic) !== LEXING_ERROR.format(params)) {
279
+ return diagnostic;
280
+ }
281
+ // Merged OVER Langium's data, so `data.code` survives for the readers that
282
+ // switch on it — `stopAfterLexingErrors` is one, and the GLSP head's
283
+ // read-only decision is another.
284
+ return { ...diagnostic, code: LEXING_ERROR.code, data: { ...data, ...messageData(LEXING_ERROR, params) } };
285
+ }
286
+
124
287
  /**
125
288
  * Skip validation for a node **and its children** when
126
289
  * {@link shouldSkipValidation} returns true.
@@ -144,6 +307,90 @@ export class HydraniumDocumentValidator extends DefaultDocumentValidator {
144
307
  return !this.validateSyntheticNodes.value && isSyntheticNode(node);
145
308
  }
146
309
 
310
+ /**
311
+ * Langium's linking-error pass, plus the framework identity on each
312
+ * diagnostic it produced.
313
+ *
314
+ * Langium puts its own `linking-error` marker in `data.code` and leaves
315
+ * `Diagnostic.code` unset, so nothing identifies the message on a surface
316
+ * that drops `data` — which is every editor surface. This adds the framework
317
+ * identity to both `code` and `data.hydranium` while LEAVING `data.code` in
318
+ * place: `stopAfterLinkingErrors` and Langium's code-action dispatch both
319
+ * read it.
320
+ *
321
+ * **The identity is attached only when the message is the one
322
+ * {@link UNRESOLVED_REFERENCE} renders.** Two other sentences reach this
323
+ * list: the linker's exception form, raised when resolution itself throws,
324
+ * and whatever an adopter overriding `createLinkingError` chose. Labelling
325
+ * either would make a catalogue render the wrong sentence — and for the
326
+ * exception form it would discard the underlying cause. Comparing against
327
+ * the locally rendered English is what discriminates; there is no structural
328
+ * field that does.
329
+ */
330
+ protected override processLinkingErrors(document: LangiumDocument, diagnostics: Diagnostic[], options: ValidationOptions): void {
331
+ const from = diagnostics.length;
332
+ super.processLinkingErrors(document, diagnostics, options);
333
+ for (let index = from; index < diagnostics.length; index++) {
334
+ diagnostics[index] = this.identifyLinkingError(diagnostics[index]);
335
+ }
336
+ }
337
+
338
+ /**
339
+ * Add the {@link UNRESOLVED_REFERENCE} identity to one linking diagnostic,
340
+ * or return it untouched when its message is not the sentence that identity
341
+ * renders.
342
+ *
343
+ * `refText` comes from the `data` Langium populated; `referenceType` is not
344
+ * in it, so it is recovered the same way `createLinkingError` produced it —
345
+ * through the reflection, from the container type and property.
346
+ */
347
+ protected identifyLinkingError(diagnostic: Diagnostic): Diagnostic {
348
+ const data = diagnostic.data as { code?: unknown; refText?: unknown; containerType?: unknown; property?: unknown } | undefined;
349
+ if (typeof data?.refText !== 'string' || typeof data.containerType !== 'string' || typeof data.property !== 'string') {
350
+ return diagnostic;
351
+ }
352
+ const referenceType = this.referenceTypeOf(data.containerType, data.property, data.refText);
353
+ if (referenceType === undefined) {
354
+ return diagnostic;
355
+ }
356
+ const params = { referenceType, refText: data.refText };
357
+ if (diagnostic.message !== UNRESOLVED_REFERENCE.format(params)) {
358
+ return diagnostic;
359
+ }
360
+ // Merged OVER Langium's data rather than replacing it, so `data.code`
361
+ // survives for the readers that switch on it.
362
+ return { ...diagnostic, code: UNRESOLVED_REFERENCE.code, data: { ...data, ...messageData(UNRESOLVED_REFERENCE, params) } };
363
+ }
364
+
365
+ /**
366
+ * The declared target type of the reference this diagnostic came from, or
367
+ * `undefined` when the reflection cannot name one.
368
+ *
369
+ * **The lookup can throw, and that is the reason this is a method rather
370
+ * than an inline call.** `AbstractAstReflection.getReferenceType` raises on
371
+ * an unknown container `$type` and on a property that is not a reference —
372
+ * and the linking error whose type it cannot name is the one most likely to
373
+ * reach here, because `DefaultLinker` catches its OWN failed lookup and
374
+ * turns it into the exception-form message. Rethrowing would take
375
+ * `validateDocument` with it, since Langium wraps `processLinkingErrors` in
376
+ * no try: a diagnostic Langium degraded gracefully would become a failed
377
+ * build. Declining is also the right answer on the merits — a reference
378
+ * whose type cannot be named is not the message
379
+ * {@link UNRESOLVED_REFERENCE} claims.
380
+ */
381
+ protected referenceTypeOf(containerType: string, property: string, refText: string): string | undefined {
382
+ try {
383
+ return this.reflection.getReferenceType({
384
+ container: { $type: containerType } as AstNode,
385
+ property,
386
+ reference: { $refText: refText }
387
+ } as Parameters<AstReflection['getReferenceType']>[0]);
388
+ } catch (err: unknown) {
389
+ this.tracer.debug(`cannot name the reference type for ${containerType}.${property}: ${describeError(err)}`);
390
+ return undefined;
391
+ }
392
+ }
393
+
147
394
  protected override toDiagnostic<N extends AstNode>(
148
395
  severity: ValidationSeverity,
149
396
  message: string,
@@ -105,10 +105,9 @@ export class DefaultDocumentUriPolicy implements DocumentUriPolicy {
105
105
  /**
106
106
  * No filesystem access, so existence cannot be checked — every URI is
107
107
  * treated as loadable and returned unchanged. A later load that misses
108
- * therefore reaches the filesystem and throws, which
109
- * `AbstractHydraniumLangiumDocuments.getOrCreateDocument` absorbs into its
110
- * empty-document fallback: under this policy that fallback, not this method,
111
- * is what makes a missing file a placeholder rather than an error.
108
+ * therefore reaches the filesystem and throws, which reports the miss with
109
+ * the reason the read failed. Under a policy that CAN check, the miss is
110
+ * caught earlier and reported without one.
112
111
  */
113
112
  loadUri(uri: URI | string): URI | undefined {
114
113
  return UriUtils.toUri(uri);
@@ -15,6 +15,7 @@ import {
15
15
  type ParseResult,
16
16
  type URI
17
17
  } from '@hydranium/langium';
18
+ import { type ExtendedServiceRegistry } from '../service-registry.js';
18
19
  import { type Serializer } from '../serialization/serializer.js';
19
20
 
20
21
  /** Structural view of the per-language serializer slot on the resolved services. */
@@ -49,6 +50,39 @@ interface WithSerializer {
49
50
  * node identity is preserved.
50
51
  */
51
52
  export class HydraniumLangiumDocumentFactory extends DefaultLangiumDocumentFactory {
53
+ /**
54
+ * Narrows the inherited Langium `ServiceRegistry` field to the framework's
55
+ * {@link ExtendedServiceRegistry}, so the by-id lookup below needs no
56
+ * per-callsite cast. The framework's shared module binds that class.
57
+ */
58
+ declare protected readonly serviceRegistry: ExtendedServiceRegistry;
59
+
60
+ /**
61
+ * Parse `text` for `uri` under the grammar `languageId` names, instead of
62
+ * the one `uri` routes to.
63
+ *
64
+ * For a URI that routes to no grammar at all: a directory, or any other URI
65
+ * that names no file and so carries no extension. Langium's ladder ends at
66
+ * the extension, so it reports `no services for the extension ''` from
67
+ * inside the parse — naming neither the URI nor the caller that could have
68
+ * said which grammar it meant.
69
+ *
70
+ * The caller supplies the language because nothing else can. A URI with no
71
+ * extension carries no routing signal, and choosing on its behalf would be a
72
+ * guess the moment a second grammar is registered — which is why this takes
73
+ * the id rather than falling back to a sole registered language.
74
+ *
75
+ * @throws when `languageId` names no registered grammar.
76
+ */
77
+ fromStringInLanguage<T extends AstNode = AstNode>(text: string, uri: URI, languageId: string): LangiumDocument<T> {
78
+ const services = this.serviceRegistry.getServicesById(languageId);
79
+ if (!services) {
80
+ throw new Error(`No grammar is registered for the language id '${languageId}' (parsing ${uri.toString()}).`);
81
+ }
82
+ const parseResult: ParseResult<T> = services.parser.LangiumParser.parse<T>(text);
83
+ return this.createLangiumDocument<T>(parseResult, uri, undefined, text);
84
+ }
85
+
52
86
  override fromModel<T extends AstNode = AstNode>(model: T, uri: URI): LangiumDocument<T> {
53
87
  // Make the code-built AST as structurally complete as a parsed one — the
54
88
  // parser links containers, `fromModel` does not. In place (identity kept).
@@ -9,9 +9,10 @@
9
9
 
10
10
  import { Deferred, type Logger, type Tracer } from '@hydranium/protocol';
11
11
  import { DefaultWorkspaceManager, DocumentState, type LangiumDocument, UriUtils, type URI } from '@hydranium/langium';
12
- import { type CancellationToken } from 'vscode-languageserver';
12
+ import { type CancellationToken, type InitializeParams } from 'vscode-languageserver';
13
13
  import type { WorkspaceFolder } from 'vscode-languageserver-types';
14
14
  import { type LogNameOptions, resolveLogFilePlaceholder, toLogFileWorkspaceToken } from '../diagnostics/logger.js';
15
+ import type { ServerLocale } from '../../locale/server-locale.js';
15
16
  import type { ProjectChangeEvent } from '../project/project-change-event.js';
16
17
  import type { ProjectManager } from '../project/project-manager.js';
17
18
  import type { ServerSharedServicesMinimal } from '../shared-services.js';
@@ -156,6 +157,8 @@ export class HydraniumWorkspaceManager extends DefaultWorkspaceManager {
156
157
  readonly workspaceInitialized: Promise<unknown> = this.workspaceInitializedDeferred.promise;
157
158
 
158
159
  protected readonly uriPolicy: DocumentUriPolicy;
160
+ /** Handed the client's locale at init; read by whoever renders in it. */
161
+ protected readonly serverLocale: ServerLocale;
159
162
  protected readonly writableFileSystemProvider: WritableFileSystemProvider;
160
163
  protected readonly additionalDocuments: Record<string, AdditionalDocumentContribution>;
161
164
  /** Registry consulted by {@link warnIfUnroutable} to check a seeded document routes. */
@@ -166,6 +169,7 @@ export class HydraniumWorkspaceManager extends DefaultWorkspaceManager {
166
169
  this.projectManager = services.workspace.ProjectManager;
167
170
  this.projectManager.onProjectsChanged(event => this.onProjectsChanged(event));
168
171
  this.uriPolicy = services.workspace.DocumentUriPolicy;
172
+ this.serverLocale = services.ServerLocale;
169
173
  this.writableFileSystemProvider = services.workspace.FileSystemProvider;
170
174
  this.additionalDocuments = services.additionalDocuments;
171
175
  this.languageRegistry = services.ServiceRegistry;
@@ -360,6 +364,31 @@ export class HydraniumWorkspaceManager extends DefaultWorkspaceManager {
360
364
  }
361
365
  }
362
366
 
367
+ /**
368
+ * Forward the locale the client declared, then Langium's own read of the
369
+ * params. `DefaultWorkspaceManager.initialize` reads `workspaceFolders`
370
+ * alone, so `params.locale` would otherwise be discarded — and this is the
371
+ * only place it arrives, which the headless init seams route through too.
372
+ *
373
+ * **The ABSENT case is reported from here rather than from `ServerLocale`,
374
+ * because this is the only end that can see it.** `accept` is not called
375
+ * when no locale was declared — nor should it be, since `''` is a claim
376
+ * about a language rather than the absence of one — so a log written there
377
+ * covers one of the two outcomes and leaves the other looking like a server
378
+ * that never reached init. Both lines are at `info` for the reason `accept`
379
+ * gives: the framework ships no catalogue, so an undeclared locale and an
380
+ * untranslated code produce the same English and the log is what separates
381
+ * them.
382
+ */
383
+ override initialize(params: InitializeParams): void {
384
+ if (params.locale) {
385
+ this.serverLocale.accept(params.locale);
386
+ } else {
387
+ this.tracer.info("no locale declared at init — rendering messages in the framework's English");
388
+ }
389
+ super.initialize(params);
390
+ }
391
+
363
392
  /**
364
393
  * Override of Langium's workspace setup to resolve / reject
365
394
  * {@link workspaceInitializedDeferred} once setup completes. Adopters with
@@ -8,12 +8,22 @@
8
8
  ********************************************************************************/
9
9
 
10
10
  import { type FileSystemNode, URI } from '@hydranium/langium';
11
- import { type Tracer } from '@hydranium/protocol';
11
+ import { defineMessage, type Tracer } from '@hydranium/protocol';
12
12
  import { type WritableFileSystemProvider } from '../../documents/ast-document-manager.js';
13
13
  import { type LogNameOptions } from '../diagnostics/logger.js';
14
14
  import { serverSharedFactory, type ServerSharedServicesMinimal } from '../shared-services.js';
15
15
  import { serveVirtualDocument } from './virtual-document.js';
16
16
 
17
+ /**
18
+ * The browser host's spelling of "the document is not there". Its Node
19
+ * counterpart is `NO_LOADABLE_CONTENT`: this provider has no `realpath`, so the
20
+ * URI policy cannot answer the existence question ahead of the read and the miss
21
+ * surfaces here instead.
22
+ */
23
+ export const NO_SUCH_FILE = defineMessage('hydranium/core/no-such-file', 'No such file: {uri}');
24
+
25
+ export const NO_SUCH_PATH = defineMessage('hydranium/core/no-such-path', 'No such file or directory: {uri}');
26
+
17
27
  /**
18
28
  * File content keyed by path, for seeding an {@link InMemoryFileSystemProvider}.
19
29
  *
@@ -127,7 +137,7 @@ export class InMemoryFileSystemProvider implements WritableFileSystemProvider {
127
137
  }
128
138
  const content = this.files.get(normalize(uri));
129
139
  if (content === undefined) {
130
- throw new Error(`No such file: ${uri.toString()}`);
140
+ throw new Error(NO_SUCH_FILE.format({ uri: uri.toString() }));
131
141
  }
132
142
  return content;
133
143
  }
@@ -152,7 +162,7 @@ export class InMemoryFileSystemProvider implements WritableFileSystemProvider {
152
162
  if (this.hasChildren(path)) {
153
163
  return { isFile: false, isDirectory: true, uri };
154
164
  }
155
- throw new Error(`No such file or directory: ${uri.toString()}`);
165
+ throw new Error(NO_SUCH_PATH.format({ uri: uri.toString() }));
156
166
  }
157
167
 
158
168
  exists(uri: URI): Promise<boolean> {
@@ -18,6 +18,25 @@ import type { ServerSharedServicesMinimal } from '../shared-services.js';
18
18
  /** A workspace folder root accepted by the headless init seams: a filesystem path or a {@link URI}. */
19
19
  export type WorkspaceFolderInput = string | URI;
20
20
 
21
+ /**
22
+ * Options for the headless init seams.
23
+ *
24
+ * **Optional, and the parameter is optional too**, so that no existing caller
25
+ * has to change to gain a field it does not set.
26
+ */
27
+ export interface ProgrammaticInitOptions {
28
+ /**
29
+ * The locale to render user-facing server messages in — the headless
30
+ * equivalent of LSP `initialize`'s `locale`, for a head with no LSP
31
+ * connection (`startStdioServer`, the CLI subcommands, a test harness).
32
+ *
33
+ * Omitted means no locale, which the default renderer resolves as the
34
+ * framework's English. That is the correct answer for a headless tool: it
35
+ * has no reading user to have a language.
36
+ */
37
+ readonly locale?: string;
38
+ }
39
+
21
40
  /**
22
41
  * Normalize the seam's flexible folder argument to LSP {@link WorkspaceFolder}s.
23
42
  * A `string` is resolved to an absolute filesystem path and wrapped as a
@@ -58,17 +77,25 @@ function toWorkspaceFolders(folders: WorkspaceFolderInput | ReadonlyArray<Worksp
58
77
  *
59
78
  * @param services the shared services tree the workspace manager lives on
60
79
  * @param folders one or more workspace roots (filesystem paths or URIs)
80
+ * @param options the message locale, when the caller has one
61
81
  */
62
82
  export async function initializeWorkspaceProgrammatically(
63
83
  services: ServerSharedServicesMinimal,
64
- folders: WorkspaceFolderInput | ReadonlyArray<WorkspaceFolderInput>
84
+ folders: WorkspaceFolderInput | ReadonlyArray<WorkspaceFolderInput>,
85
+ options: ProgrammaticInitOptions = {}
65
86
  ): Promise<void> {
66
87
  const workspaceFolders = toWorkspaceFolders(folders);
67
88
  const manager = services.workspace.WorkspaceManager;
68
- // `initialize` records the folders (DefaultWorkspaceManager reads only this
89
+ // `locale` goes through the synthesized params rather than a direct
90
+ // `acceptLocale` call, so this seam and a real LSP `initialize` reach the
91
+ // slot by the SAME path — an adopter overriding the capture in
92
+ // `HydraniumWorkspaceManager.initialize` is honoured headlessly too, which a
93
+ // second write site here would silently bypass.
94
+ //
95
+ // `initialize` records the folders (DefaultWorkspaceManager reads only that
69
96
  // field); `initialized` runs `mutex.write(initializeWorkspace)` and resolves
70
97
  // once discovery + the init build settle, so awaiting it is the ready gate.
71
- manager.initialize({ workspaceFolders } as InitializeParams);
98
+ manager.initialize({ workspaceFolders, locale: options.locale } as InitializeParams);
72
99
  await manager.initialized({} as InitializedParams);
73
100
  }
74
101
 
@@ -91,12 +118,14 @@ export async function initializeWorkspaceProgrammatically(
91
118
  *
92
119
  * @param services the shared services tree the workspace manager lives on
93
120
  * @param folders one or more workspace roots (filesystem paths or URIs)
121
+ * @param options the message locale, when the caller has one
94
122
  */
95
123
  export async function buildWorkspaceProgrammatically(
96
124
  services: ServerSharedServicesMinimal,
97
- folders: WorkspaceFolderInput | ReadonlyArray<WorkspaceFolderInput>
125
+ folders: WorkspaceFolderInput | ReadonlyArray<WorkspaceFolderInput>,
126
+ options: ProgrammaticInitOptions = {}
98
127
  ): Promise<void> {
99
- await initializeWorkspaceProgrammatically(services, folders);
128
+ await initializeWorkspaceProgrammatically(services, folders, options);
100
129
  const documents = services.workspace.LangiumDocuments.all.toArray();
101
130
  await services.workspace.DocumentBuilder.build(documents, { validation: true });
102
131
  }