@hydranium/core 1.0.0-next.4 → 1.0.0-next.42
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.
- package/lib/documents/ast-document-manager.d.ts +42 -5
- package/lib/documents/ast-document-manager.d.ts.map +1 -1
- package/lib/documents/ast-document-manager.js +9 -12
- package/lib/documents/ast-document-manager.js.map +1 -1
- package/lib/documents/hydranium-text-documents.d.ts.map +1 -1
- package/lib/documents/hydranium-text-documents.js +41 -9
- package/lib/documents/hydranium-text-documents.js.map +1 -1
- package/lib/documents/language-client-text-shadow.d.ts +24 -1
- package/lib/documents/language-client-text-shadow.d.ts.map +1 -1
- package/lib/documents/language-client-text-shadow.js +36 -2
- package/lib/documents/language-client-text-shadow.js.map +1 -1
- package/lib/documents/self-save-registry.d.ts +37 -6
- package/lib/documents/self-save-registry.d.ts.map +1 -1
- package/lib/documents/self-save-registry.js +28 -15
- package/lib/documents/self-save-registry.js.map +1 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +5 -0
- package/lib/index.js.map +1 -1
- package/lib/langium/ast-extension/ast-node-builder.d.ts +32 -9
- package/lib/langium/ast-extension/ast-node-builder.d.ts.map +1 -1
- package/lib/langium/ast-extension/ast-node-builder.js +60 -22
- package/lib/langium/ast-extension/ast-node-builder.js.map +1 -1
- package/lib/langium/bootstrap.d.ts.map +1 -1
- package/lib/langium/bootstrap.js +16 -9
- package/lib/langium/bootstrap.js.map +1 -1
- package/lib/langium/document-builder/build-pipeline-integration.d.ts +13 -1
- package/lib/langium/document-builder/build-pipeline-integration.d.ts.map +1 -1
- package/lib/langium/document-builder/build-pipeline-integration.js +1 -1
- package/lib/langium/document-builder/build-pipeline-integration.js.map +1 -1
- package/lib/langium/document-builder/build-session.d.ts +93 -0
- package/lib/langium/document-builder/build-session.d.ts.map +1 -0
- package/lib/langium/document-builder/build-session.js +72 -0
- package/lib/langium/document-builder/build-session.js.map +1 -0
- package/lib/langium/document-builder/document-builder.d.ts +150 -7
- package/lib/langium/document-builder/document-builder.d.ts.map +1 -1
- package/lib/langium/document-builder/document-builder.js +298 -11
- package/lib/langium/document-builder/document-builder.js.map +1 -1
- package/lib/langium/document-builder/index.d.ts +1 -0
- package/lib/langium/document-builder/index.d.ts.map +1 -1
- package/lib/langium/document-builder/index.js +1 -0
- package/lib/langium/document-builder/index.js.map +1 -1
- package/lib/langium/integration-services.d.ts +45 -1
- package/lib/langium/integration-services.d.ts.map +1 -1
- package/lib/langium/integration-services.js +10 -5
- package/lib/langium/integration-services.js.map +1 -1
- package/lib/langium/integrity/integrity-service.d.ts +5 -0
- package/lib/langium/integrity/integrity-service.d.ts.map +1 -1
- package/lib/langium/integrity/integrity-service.js +34 -1
- package/lib/langium/integrity/integrity-service.js.map +1 -1
- package/lib/langium/keys/containment.d.ts +64 -0
- package/lib/langium/keys/containment.d.ts.map +1 -0
- package/lib/langium/keys/containment.js +53 -0
- package/lib/langium/keys/containment.js.map +1 -0
- package/lib/langium/keys/index.d.ts +1 -0
- package/lib/langium/keys/index.d.ts.map +1 -1
- package/lib/langium/keys/index.js +1 -0
- package/lib/langium/keys/index.js.map +1 -1
- package/lib/langium/keys/name-based-key-provider.d.ts +4 -0
- package/lib/langium/keys/name-based-key-provider.d.ts.map +1 -1
- package/lib/langium/keys/name-based-key-provider.js +4 -0
- package/lib/langium/keys/name-based-key-provider.js.map +1 -1
- package/lib/langium/model-service/model-service.d.ts +103 -7
- package/lib/langium/model-service/model-service.d.ts.map +1 -1
- package/lib/langium/model-service/model-service.js +70 -89
- package/lib/langium/model-service/model-service.js.map +1 -1
- package/lib/langium/module.d.ts +82 -13
- package/lib/langium/module.d.ts.map +1 -1
- package/lib/langium/module.js +21 -12
- package/lib/langium/module.js.map +1 -1
- package/lib/langium/naming/name-provider.d.ts +10 -0
- package/lib/langium/naming/name-provider.d.ts.map +1 -1
- package/lib/langium/naming/name-provider.js.map +1 -1
- package/lib/langium/naming/name-separator-validation.d.ts +23 -0
- package/lib/langium/naming/name-separator-validation.d.ts.map +1 -1
- package/lib/langium/naming/name-separator-validation.js +30 -1
- package/lib/langium/naming/name-separator-validation.js.map +1 -1
- package/lib/langium/residency/cst-residency-service.d.ts +31 -9
- package/lib/langium/residency/cst-residency-service.d.ts.map +1 -1
- package/lib/langium/residency/cst-residency-service.js +13 -56
- package/lib/langium/residency/cst-residency-service.js.map +1 -1
- package/lib/langium/scope/hydranium-scope-provider.d.ts +32 -13
- package/lib/langium/scope/hydranium-scope-provider.d.ts.map +1 -1
- package/lib/langium/scope/hydranium-scope-provider.js +37 -20
- package/lib/langium/scope/hydranium-scope-provider.js.map +1 -1
- package/lib/langium/shared-services.d.ts +15 -2
- package/lib/langium/shared-services.d.ts.map +1 -1
- package/lib/langium/shared-services.js.map +1 -1
- package/lib/langium/transfer/transfer-encoder.d.ts +33 -2
- package/lib/langium/transfer/transfer-encoder.d.ts.map +1 -1
- package/lib/langium/transfer/transfer-encoder.js +14 -3
- package/lib/langium/transfer/transfer-encoder.js.map +1 -1
- package/lib/langium/validation/document-validator.d.ts +145 -6
- package/lib/langium/validation/document-validator.d.ts.map +1 -1
- package/lib/langium/validation/document-validator.js +211 -4
- package/lib/langium/validation/document-validator.js.map +1 -1
- package/lib/langium/workspace/document-uri-policy.d.ts +3 -4
- package/lib/langium/workspace/document-uri-policy.d.ts.map +1 -1
- package/lib/langium/workspace/document-uri-policy.js +3 -4
- package/lib/langium/workspace/document-uri-policy.js.map +1 -1
- package/lib/langium/workspace/hydranium-langium-document-factory.d.ts +25 -0
- package/lib/langium/workspace/hydranium-langium-document-factory.d.ts.map +1 -1
- package/lib/langium/workspace/hydranium-langium-document-factory.js +25 -0
- package/lib/langium/workspace/hydranium-langium-document-factory.js.map +1 -1
- package/lib/langium/workspace/hydranium-workspace-manager.d.ts +21 -1
- package/lib/langium/workspace/hydranium-workspace-manager.d.ts.map +1 -1
- package/lib/langium/workspace/hydranium-workspace-manager.js +28 -0
- package/lib/langium/workspace/hydranium-workspace-manager.js.map +1 -1
- package/lib/langium/workspace/in-memory-file-system-provider.d.ts +8 -0
- package/lib/langium/workspace/in-memory-file-system-provider.d.ts.map +1 -1
- package/lib/langium/workspace/in-memory-file-system-provider.js +11 -2
- package/lib/langium/workspace/in-memory-file-system-provider.js.map +1 -1
- package/lib/langium/workspace/initialize-workspace.d.ts +22 -2
- package/lib/langium/workspace/initialize-workspace.d.ts.map +1 -1
- package/lib/langium/workspace/initialize-workspace.js +13 -5
- package/lib/langium/workspace/initialize-workspace.js.map +1 -1
- package/lib/langium/workspace/langium-documents.d.ts +79 -17
- package/lib/langium/workspace/langium-documents.d.ts.map +1 -1
- package/lib/langium/workspace/langium-documents.js +83 -28
- package/lib/langium/workspace/langium-documents.js.map +1 -1
- package/lib/locale/index.d.ts +10 -0
- package/lib/locale/index.d.ts.map +1 -0
- package/lib/locale/index.js +10 -0
- package/lib/locale/index.js.map +1 -0
- package/lib/locale/server-locale.d.ts +73 -0
- package/lib/locale/server-locale.d.ts.map +1 -0
- package/lib/locale/server-locale.js +61 -0
- package/lib/locale/server-locale.js.map +1 -0
- package/lib/lsp/hydranium-document-update-handler.js +1 -1
- package/lib/lsp/hydranium-document-update-handler.js.map +1 -1
- package/lib/messages/carriers.d.ts +54 -0
- package/lib/messages/carriers.d.ts.map +1 -0
- package/lib/messages/carriers.js +62 -0
- package/lib/messages/carriers.js.map +1 -0
- package/lib/messages/index.d.ts +25 -0
- package/lib/messages/index.d.ts.map +1 -0
- package/lib/messages/index.js +25 -0
- package/lib/messages/index.js.map +1 -0
- package/lib/messages/renderer.d.ts +136 -0
- package/lib/messages/renderer.d.ts.map +1 -0
- package/lib/messages/renderer.js +159 -0
- package/lib/messages/renderer.js.map +1 -0
- package/lib/node/node-file-system-provider.d.ts.map +1 -1
- package/lib/node/node-file-system-provider.js +1 -40
- package/lib/node/node-file-system-provider.js.map +1 -1
- package/lib/node/rename-over-open-readers.d.ts +52 -0
- package/lib/node/rename-over-open-readers.d.ts.map +1 -0
- package/lib/node/rename-over-open-readers.js +66 -0
- package/lib/node/rename-over-open-readers.js.map +1 -0
- package/lib/testing/fake-document.d.ts +14 -3
- package/lib/testing/fake-document.d.ts.map +1 -1
- package/lib/testing/fake-document.js +18 -3
- package/lib/testing/fake-document.js.map +1 -1
- package/lib/testing/make-noop-shared-services.d.ts +14 -0
- package/lib/testing/make-noop-shared-services.d.ts.map +1 -1
- package/lib/testing/make-noop-shared-services.js +28 -2
- package/lib/testing/make-noop-shared-services.js.map +1 -1
- package/lib/testing/make-test-services.d.ts +31 -4
- package/lib/testing/make-test-services.d.ts.map +1 -1
- package/lib/testing/make-test-services.js +19 -3
- package/lib/testing/make-test-services.js.map +1 -1
- package/lib/testing/playwright/server-log-capture.d.ts +14 -4
- package/lib/testing/playwright/server-log-capture.d.ts.map +1 -1
- package/lib/testing/playwright/server-log-capture.js +21 -4
- package/lib/testing/playwright/server-log-capture.js.map +1 -1
- package/lib/testing/playwright/server-log-rename-reporter.d.ts.map +1 -1
- package/lib/testing/playwright/server-log-rename-reporter.js +10 -1
- package/lib/testing/playwright/server-log-rename-reporter.js.map +1 -1
- package/lib/testing/stub-ast-document-manager.d.ts +3 -4
- package/lib/testing/stub-ast-document-manager.d.ts.map +1 -1
- package/lib/testing/stub-ast-document-manager.js +2 -5
- package/lib/testing/stub-ast-document-manager.js.map +1 -1
- package/lib/testing/stub-document-builder.d.ts +8 -0
- package/lib/testing/stub-document-builder.d.ts.map +1 -1
- package/lib/testing/stub-document-builder.js +22 -3
- package/lib/testing/stub-document-builder.js.map +1 -1
- package/lib/testing/stub-model-service.d.ts +1 -1
- package/lib/testing/stub-model-service.d.ts.map +1 -1
- package/lib/testing/stub-model-service.js +2 -2
- package/lib/testing/stub-model-service.js.map +1 -1
- package/package.json +17 -8
- package/src/documents/ast-document-manager.ts +55 -14
- package/src/documents/hydranium-text-documents.ts +41 -9
- package/src/documents/language-client-text-shadow.ts +38 -2
- package/src/documents/self-save-registry.ts +52 -13
- package/src/index.ts +5 -0
- package/src/langium/ast-extension/ast-node-builder.ts +66 -22
- package/src/langium/bootstrap.ts +16 -9
- package/src/langium/document-builder/build-pipeline-integration.ts +14 -1
- package/src/langium/document-builder/build-session.ts +87 -0
- package/src/langium/document-builder/document-builder.ts +339 -11
- package/src/langium/document-builder/index.ts +1 -0
- package/src/langium/integration-services.ts +67 -6
- package/src/langium/integrity/integrity-service.ts +35 -1
- package/src/langium/keys/containment.ts +87 -0
- package/src/langium/keys/index.ts +1 -0
- package/src/langium/keys/name-based-key-provider.ts +4 -0
- package/src/langium/model-service/model-service.ts +145 -22
- package/src/langium/module.ts +99 -19
- package/src/langium/naming/name-provider.ts +10 -0
- package/src/langium/naming/name-separator-validation.ts +34 -5
- package/src/langium/residency/cst-residency-service.ts +36 -12
- package/src/langium/scope/hydranium-scope-provider.ts +40 -22
- package/src/langium/shared-services.ts +19 -2
- package/src/langium/transfer/transfer-encoder.ts +45 -3
- package/src/langium/validation/document-validator.ts +255 -8
- package/src/langium/workspace/document-uri-policy.ts +3 -4
- package/src/langium/workspace/hydranium-langium-document-factory.ts +34 -0
- package/src/langium/workspace/hydranium-workspace-manager.ts +30 -1
- package/src/langium/workspace/in-memory-file-system-provider.ts +13 -3
- package/src/langium/workspace/initialize-workspace.ts +34 -5
- package/src/langium/workspace/langium-documents.ts +106 -33
- package/src/locale/index.ts +10 -0
- package/src/locale/server-locale.ts +86 -0
- package/src/lsp/hydranium-document-update-handler.ts +1 -1
- package/src/messages/carriers.ts +78 -0
- package/src/messages/index.ts +27 -0
- package/src/messages/renderer.ts +204 -0
- package/src/node/node-file-system-provider.ts +1 -41
- package/src/node/rename-over-open-readers.ts +78 -0
- package/src/testing/fake-document.ts +22 -4
- package/src/testing/make-noop-shared-services.ts +50 -2
- package/src/testing/make-test-services.ts +49 -7
- package/src/testing/playwright/server-log-capture.ts +24 -5
- package/src/testing/playwright/server-log-rename-reporter.ts +12 -1
- package/src/testing/stub-ast-document-manager.ts +5 -10
- package/src/testing/stub-document-builder.ts +32 -3
- package/src/testing/stub-model-service.ts +2 -2
|
@@ -7,8 +7,17 @@
|
|
|
7
7
|
* SPDX-License-Identifier: MIT
|
|
8
8
|
********************************************************************************/
|
|
9
9
|
import { URI } from '@hydranium/langium';
|
|
10
|
+
import { defineMessage } from '@hydranium/protocol';
|
|
10
11
|
import { serverSharedFactory } from '../shared-services.js';
|
|
11
12
|
import { serveVirtualDocument } from './virtual-document.js';
|
|
13
|
+
/**
|
|
14
|
+
* The browser host's spelling of "the document is not there". Its Node
|
|
15
|
+
* counterpart is `NO_LOADABLE_CONTENT`: this provider has no `realpath`, so the
|
|
16
|
+
* URI policy cannot answer the existence question ahead of the read and the miss
|
|
17
|
+
* surfaces here instead.
|
|
18
|
+
*/
|
|
19
|
+
export const NO_SUCH_FILE = defineMessage('hydranium/core/no-such-file', 'No such file: {uri}');
|
|
20
|
+
export const NO_SUCH_PATH = defineMessage('hydranium/core/no-such-path', 'No such file or directory: {uri}');
|
|
12
21
|
/**
|
|
13
22
|
* A writable filesystem held in a `Map`, for a host with no disk — a browser
|
|
14
23
|
* worker, or a test that needs the workspace walk to find real content.
|
|
@@ -94,7 +103,7 @@ export class InMemoryFileSystemProvider {
|
|
|
94
103
|
}
|
|
95
104
|
const content = this.files.get(normalize(uri));
|
|
96
105
|
if (content === undefined) {
|
|
97
|
-
throw new Error(
|
|
106
|
+
throw new Error(NO_SUCH_FILE.format({ uri: uri.toString() }));
|
|
98
107
|
}
|
|
99
108
|
return content;
|
|
100
109
|
}
|
|
@@ -115,7 +124,7 @@ export class InMemoryFileSystemProvider {
|
|
|
115
124
|
if (this.hasChildren(path)) {
|
|
116
125
|
return { isFile: false, isDirectory: true, uri };
|
|
117
126
|
}
|
|
118
|
-
throw new Error(
|
|
127
|
+
throw new Error(NO_SUCH_PATH.format({ uri: uri.toString() }));
|
|
119
128
|
}
|
|
120
129
|
exists(uri) {
|
|
121
130
|
return Promise.resolve(this.existsSync(uri));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"in-memory-file-system-provider.js","sourceRoot":"","sources":["../../../src/langium/workspace/in-memory-file-system-provider.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAuB,GAAG,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"in-memory-file-system-provider.js","sourceRoot":"","sources":["../../../src/langium/workspace/in-memory-file-system-provider.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAuB,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAe,MAAM,qBAAqB,CAAC;AAGjE,OAAO,EAAE,mBAAmB,EAAoC,MAAM,uBAAuB,CAAC;AAC9F,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAE7D;;;;;GAKG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,aAAa,CAAC,6BAA6B,EAAE,qBAAqB,CAAC,CAAC;AAEhG,MAAM,CAAC,MAAM,YAAY,GAAG,aAAa,CAAC,6BAA6B,EAAE,kCAAkC,CAAC,CAAC;AAuB7G;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,MAAM,OAAO,0BAA0B;IAKd;IAJH,KAAK,GAAG,IAAI,GAAG,EAAkB,CAAC;IAClC,MAAM,CAAS;IAElC,YACsB,QAAqC,EACxD,UAAqC,EAAE;QADpB,aAAQ,GAAR,QAAQ,CAA6B;QAGxD,MAAM,EAAE,IAAI,GAAG,EAAE,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;QACvC,KAAK,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;YAClD,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC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C,CAAC;IACP,CAAC;IAED;;;;;;;;;OASG;IACO,OAAO,CAAC,GAAiB;QAChC,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC;IACzB,CAAC;IAES,WAAW,CAAC,IAAY;QAC/B,MAAM,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC;QAC1B,KAAK,MAAM,SAAS,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC;YACzC,IAAI,SAAS,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;gBAChC,OAAO,IAAI,CAAC;YACf,CAAC;QACJ,CAAC;QACD,OAAO,KAAK,CAAC;IAChB,CAAC;CACH;AAED;;;;GAIG;AACH,SAAS,SAAS,CAAC,GAAiB;IACjC,MAAM,IAAI,GAAG,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;IAClF,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AACxD,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,kBAAkB,CAAC,UAAqC,EAAE;IAGvE,OAAO;QACJ,kBAAkB,EAAE,mBAAmB,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,0BAA0B,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;KACxG,CAAC;AACL,CAAC"}
|
|
@@ -10,6 +10,24 @@ import { URI } from '@hydranium/langium';
|
|
|
10
10
|
import type { ServerSharedServicesMinimal } from '../shared-services.js';
|
|
11
11
|
/** A workspace folder root accepted by the headless init seams: a filesystem path or a {@link URI}. */
|
|
12
12
|
export type WorkspaceFolderInput = string | URI;
|
|
13
|
+
/**
|
|
14
|
+
* Options for the headless init seams.
|
|
15
|
+
*
|
|
16
|
+
* **Optional, and the parameter is optional too**, so that no existing caller
|
|
17
|
+
* has to change to gain a field it does not set.
|
|
18
|
+
*/
|
|
19
|
+
export interface ProgrammaticInitOptions {
|
|
20
|
+
/**
|
|
21
|
+
* The locale to render user-facing server messages in — the headless
|
|
22
|
+
* equivalent of LSP `initialize`'s `locale`, for a head with no LSP
|
|
23
|
+
* connection (`startStdioServer`, the CLI subcommands, a test harness).
|
|
24
|
+
*
|
|
25
|
+
* Omitted means no locale, which the default renderer resolves as the
|
|
26
|
+
* framework's English. That is the correct answer for a headless tool: it
|
|
27
|
+
* has no reading user to have a language.
|
|
28
|
+
*/
|
|
29
|
+
readonly locale?: string;
|
|
30
|
+
}
|
|
13
31
|
/**
|
|
14
32
|
* Initialize a hydranium workspace **without an LSP `initialize` request** —
|
|
15
33
|
* the headless counterpart to the editor entry. Drives the workspace manager's
|
|
@@ -37,8 +55,9 @@ export type WorkspaceFolderInput = string | URI;
|
|
|
37
55
|
*
|
|
38
56
|
* @param services the shared services tree the workspace manager lives on
|
|
39
57
|
* @param folders one or more workspace roots (filesystem paths or URIs)
|
|
58
|
+
* @param options the message locale, when the caller has one
|
|
40
59
|
*/
|
|
41
|
-
export declare function initializeWorkspaceProgrammatically(services: ServerSharedServicesMinimal, folders: WorkspaceFolderInput | ReadonlyArray<WorkspaceFolderInput
|
|
60
|
+
export declare function initializeWorkspaceProgrammatically(services: ServerSharedServicesMinimal, folders: WorkspaceFolderInput | ReadonlyArray<WorkspaceFolderInput>, options?: ProgrammaticInitOptions): Promise<void>;
|
|
42
61
|
/**
|
|
43
62
|
* {@link initializeWorkspaceProgrammatically} **and then build every registered
|
|
44
63
|
* document to `Validated`** — the "fully-built workspace" convenience for
|
|
@@ -58,6 +77,7 @@ export declare function initializeWorkspaceProgrammatically(services: ServerShar
|
|
|
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
|
-
export declare function buildWorkspaceProgrammatically(services: ServerSharedServicesMinimal, folders: WorkspaceFolderInput | ReadonlyArray<WorkspaceFolderInput
|
|
82
|
+
export declare function buildWorkspaceProgrammatically(services: ServerSharedServicesMinimal, folders: WorkspaceFolderInput | ReadonlyArray<WorkspaceFolderInput>, options?: ProgrammaticInitOptions): Promise<void>;
|
|
63
83
|
//# sourceMappingURL=initialize-workspace.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initialize-workspace.d.ts","sourceRoot":"","sources":["../../../src/langium/workspace/initialize-workspace.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAY,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAMnD,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AAEzE,uGAAuG;AACvG,MAAM,MAAM,oBAAoB,GAAG,MAAM,GAAG,GAAG,CAAC;
|
|
1
|
+
{"version":3,"file":"initialize-workspace.d.ts","sourceRoot":"","sources":["../../../src/langium/workspace/initialize-workspace.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAY,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAMnD,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AAEzE,uGAAuG;AACvG,MAAM,MAAM,oBAAoB,GAAG,MAAM,GAAG,GAAG,CAAC;AAEhD;;;;;GAKG;AACH,MAAM,WAAW,uBAAuB;IACrC;;;;;;;;OAQG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC3B;AAeD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAsB,mCAAmC,CACtD,QAAQ,EAAE,2BAA2B,EACrC,OAAO,EAAE,oBAAoB,GAAG,aAAa,CAAC,oBAAoB,CAAC,EACnE,OAAO,GAAE,uBAA4B,GACrC,OAAO,CAAC,IAAI,CAAC,CAcf;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,8BAA8B,CACjD,QAAQ,EAAE,2BAA2B,EACrC,OAAO,EAAE,oBAAoB,GAAG,aAAa,CAAC,oBAAoB,CAAC,EACnE,OAAO,GAAE,uBAA4B,GACrC,OAAO,CAAC,IAAI,CAAC,CAIf"}
|
|
@@ -50,14 +50,21 @@ function toWorkspaceFolders(folders) {
|
|
|
50
50
|
*
|
|
51
51
|
* @param services the shared services tree the workspace manager lives on
|
|
52
52
|
* @param folders one or more workspace roots (filesystem paths or URIs)
|
|
53
|
+
* @param options the message locale, when the caller has one
|
|
53
54
|
*/
|
|
54
|
-
export async function initializeWorkspaceProgrammatically(services, folders) {
|
|
55
|
+
export async function initializeWorkspaceProgrammatically(services, folders, options = {}) {
|
|
55
56
|
const workspaceFolders = toWorkspaceFolders(folders);
|
|
56
57
|
const manager = services.workspace.WorkspaceManager;
|
|
57
|
-
// `
|
|
58
|
+
// `locale` goes through the synthesized params rather than a direct
|
|
59
|
+
// `acceptLocale` call, so this seam and a real LSP `initialize` reach the
|
|
60
|
+
// slot by the SAME path — an adopter overriding the capture in
|
|
61
|
+
// `HydraniumWorkspaceManager.initialize` is honoured headlessly too, which a
|
|
62
|
+
// second write site here would silently bypass.
|
|
63
|
+
//
|
|
64
|
+
// `initialize` records the folders (DefaultWorkspaceManager reads only that
|
|
58
65
|
// field); `initialized` runs `mutex.write(initializeWorkspace)` and resolves
|
|
59
66
|
// once discovery + the init build settle, so awaiting it is the ready gate.
|
|
60
|
-
manager.initialize({ workspaceFolders });
|
|
67
|
+
manager.initialize({ workspaceFolders, locale: options.locale });
|
|
61
68
|
await manager.initialized({});
|
|
62
69
|
}
|
|
63
70
|
/**
|
|
@@ -79,9 +86,10 @@ export async function initializeWorkspaceProgrammatically(services, folders) {
|
|
|
79
86
|
*
|
|
80
87
|
* @param services the shared services tree the workspace manager lives on
|
|
81
88
|
* @param folders one or more workspace roots (filesystem paths or URIs)
|
|
89
|
+
* @param options the message locale, when the caller has one
|
|
82
90
|
*/
|
|
83
|
-
export async function buildWorkspaceProgrammatically(services, folders) {
|
|
84
|
-
await initializeWorkspaceProgrammatically(services, folders);
|
|
91
|
+
export async function buildWorkspaceProgrammatically(services, folders, options = {}) {
|
|
92
|
+
await initializeWorkspaceProgrammatically(services, folders, options);
|
|
85
93
|
const documents = services.workspace.LangiumDocuments.all.toArray();
|
|
86
94
|
await services.workspace.DocumentBuilder.build(documents, { validation: true });
|
|
87
95
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initialize-workspace.js","sourceRoot":"","sources":["../../../src/langium/workspace/initialize-workspace.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AACnD,8EAA8E;AAC9E,8EAA8E;AAC9E,8EAA8E;AAC9E,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"initialize-workspace.js","sourceRoot":"","sources":["../../../src/langium/workspace/initialize-workspace.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AACnD,8EAA8E;AAC9E,8EAA8E;AAC9E,8EAA8E;AAC9E,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AA0B7B;;;;GAIG;AACH,SAAS,kBAAkB,CAAC,OAAmE;IAC5F,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAA+B,CAAC,CAAC;IAClF,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;QACrB,MAAM,GAAG,GAAG,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,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
|
|
6
6
|
*
|
|
7
7
|
* SPDX-License-Identifier: MIT
|
|
8
8
|
********************************************************************************/
|
|
9
|
-
import { type
|
|
10
|
-
import { type AstNode, DefaultLangiumDocuments, type LangiumDocument, type URI } from '@hydranium/langium';
|
|
9
|
+
import { type AstNode, DefaultLangiumDocuments, type LangiumDocument, type LangiumDocuments, type URI } from '@hydranium/langium';
|
|
11
10
|
import { type ServerSharedServicesMinimal } from '../shared-services.js';
|
|
12
11
|
import { type DocumentUriPolicy } from './document-uri-policy.js';
|
|
12
|
+
import { type HydraniumLangiumDocumentFactory } from './hydranium-langium-document-factory.js';
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
15
|
-
*
|
|
14
|
+
* The document a caller asked to load is not there.
|
|
15
|
+
*
|
|
16
|
+
* User-facing, and the Node host's spelling of it: `loadUri` returns `undefined`
|
|
17
|
+
* exactly when the URI policy's `realpath` reports the path absent. A host whose
|
|
18
|
+
* provider has no `realpath` never reaches this — the miss surfaces from the
|
|
19
|
+
* provider instead, so the same condition has one declaration per host.
|
|
20
|
+
*/
|
|
21
|
+
export declare const NO_LOADABLE_CONTENT: import("@hydranium/protocol").MessageDefinition<"No loadable content for {uri}">;
|
|
22
|
+
/**
|
|
23
|
+
* A stand-in was asked for at a URI that routes to no grammar, and no language
|
|
24
|
+
* id was given to route it instead.
|
|
25
|
+
*
|
|
26
|
+
* User-facing, and raised BEFORE the parse: left to Langium's ladder the same
|
|
27
|
+
* condition surfaces as `no services for the extension ''`, which names neither
|
|
28
|
+
* the URI nor the argument that would have answered.
|
|
29
|
+
*/
|
|
30
|
+
export declare const NO_LANGUAGE_FOR_STAND_IN: import("@hydranium/protocol").MessageDefinition<"No grammar routes {uri}; pass a languageId to say which one the stand-in should parse with">;
|
|
31
|
+
/**
|
|
32
|
+
* The registry surface the framework adds on top of Langium's
|
|
33
|
+
* {@link LangiumDocuments}. Declared separately from the implementing class so
|
|
34
|
+
* the shared-services slot can narrow to it: the class takes the services tree
|
|
35
|
+
* as its constructor parameter, so naming the CLASS there would make that type
|
|
36
|
+
* depend on itself.
|
|
37
|
+
*/
|
|
38
|
+
export interface HydraniumDocumentRegistry extends LangiumDocuments {
|
|
39
|
+
createEmptyDocument(uri: URI, languageId?: string): LangiumDocument<AstNode>;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Default `LangiumDocuments` for `@hydranium/core` consumers, extending
|
|
43
|
+
* Langium's {@link DefaultLangiumDocuments} with:
|
|
16
44
|
*
|
|
17
45
|
* 1. **Identity via the {@link DocumentUriPolicy} seam.**
|
|
18
46
|
* `getOrCreateDocument` resolves the requested URI through the seam — the
|
|
@@ -22,26 +50,60 @@ import { type DocumentUriPolicy } from './document-uri-policy.js';
|
|
|
22
50
|
* `LangiumDocuments` override. The default resolves to the URI unchanged
|
|
23
51
|
* (`DefaultDocumentUriPolicy`), matching Langium's own keying.
|
|
24
52
|
*
|
|
25
|
-
* 2.
|
|
26
|
-
* document
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
53
|
+
* 2. **A load that finds nothing rejects**, rather than answering with a
|
|
54
|
+
* transient empty document. An empty AST validates clean, so a placeholder
|
|
55
|
+
* hands the caller something that silently is not the file, and a caller
|
|
56
|
+
* that wants a document for a URI with no content on disk cannot use one
|
|
57
|
+
* anyway: it is unregistered, so no build, index or save can see it, and
|
|
58
|
+
* `LangiumDocumentFactory.update` reads from disk. Content that legitimately
|
|
59
|
+
* lives outside the filesystem belongs in a virtual document, which carries
|
|
60
|
+
* real source text.
|
|
33
61
|
*/
|
|
34
|
-
export declare
|
|
62
|
+
export declare class HydraniumLangiumDocuments extends DefaultLangiumDocuments implements HydraniumDocumentRegistry {
|
|
35
63
|
protected readonly services: ServerSharedServicesMinimal;
|
|
36
64
|
/** Document-identity seam, shared with the text store, event filters, and builder. */
|
|
37
65
|
protected readonly uriPolicy: DocumentUriPolicy;
|
|
38
|
-
|
|
66
|
+
/**
|
|
67
|
+
* Narrows the inherited Langium factory field to the framework's, so the
|
|
68
|
+
* language-explicit `fromStringInLanguage` below needs no cast. The
|
|
69
|
+
* framework's shared module binds that class.
|
|
70
|
+
*/
|
|
71
|
+
protected readonly langiumDocumentFactory: HydraniumLangiumDocumentFactory;
|
|
39
72
|
constructor(services: ServerSharedServicesMinimal);
|
|
40
73
|
/**
|
|
41
|
-
* Build a transient
|
|
42
|
-
*
|
|
74
|
+
* Build a transient document for `uri` by parsing empty text with the
|
|
75
|
+
* grammar `languageId` names, or the one `uri` routes to when it is
|
|
76
|
+
* omitted, so the root is that language's entry type with every containment
|
|
77
|
+
* list initialised.
|
|
78
|
+
*
|
|
79
|
+
* For callers that need a document at a URI with no content on disk — the
|
|
80
|
+
* scope provider querying before a file exists is the case it was added for.
|
|
81
|
+
* `getOrCreateDocument` deliberately does NOT fall back to this: fabricating
|
|
82
|
+
* a document behind a caller that asked to LOAD one hands back something
|
|
83
|
+
* that silently is not the file, whereas calling this is a caller saying it
|
|
84
|
+
* wants a stand-in.
|
|
85
|
+
*
|
|
86
|
+
* **Pass `languageId` whenever the URI names no file.** The create-element
|
|
87
|
+
* flow this exists for asks at the DIRECTORY a file is about to be written
|
|
88
|
+
* into, and a directory URI has no extension for the routing ladder to end
|
|
89
|
+
* on — so omitting the id there fails inside the parse, on an empty
|
|
90
|
+
* extension rather than on the URI. A caller in that position always knows
|
|
91
|
+
* its language: {@link HydraniumScopeProvider} is bound per grammar, and a
|
|
92
|
+
* request that names no document at all still carries the AST type
|
|
93
|
+
* `ExtendedServiceRegistry.soleServicesByType` routes on.
|
|
94
|
+
*
|
|
95
|
+
* The result is not registered, so nothing downstream can see it, and
|
|
96
|
+
* `LangiumDocumentFactory.update` would read from disk. It is a probe, not a
|
|
97
|
+
* document under construction; content that must survive belongs in a
|
|
98
|
+
* virtual document, which carries real source text.
|
|
99
|
+
*
|
|
100
|
+
* Building the root by hand instead needs the entry type name and a cast
|
|
101
|
+
* past the generated types, and leaves those lists `undefined`. A grammar
|
|
102
|
+
* whose entry rule opens with mandatory syntax yields a parse error here,
|
|
103
|
+
* and it is kept: `AstReflection.isComplete` is `false` for such a root
|
|
104
|
+
* however it is built, so the error states the same thing.
|
|
43
105
|
*/
|
|
44
|
-
|
|
106
|
+
createEmptyDocument(uri: URI, languageId?: string): LangiumDocument<AstNode>;
|
|
45
107
|
getOrCreateDocument(uri: URI): Promise<LangiumDocument<AstNode>>;
|
|
46
108
|
}
|
|
47
109
|
//# sourceMappingURL=langium-documents.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"langium-documents.d.ts","sourceRoot":"","sources":["../../../src/langium/workspace/langium-documents.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"langium-documents.d.ts","sourceRoot":"","sources":["../../../src/langium/workspace/langium-documents.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,KAAK,OAAO,EAAE,uBAAuB,EAAE,KAAK,eAAe,EAAE,KAAK,gBAAgB,EAAE,KAAK,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAElI,OAAO,EAAE,KAAK,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AACzE,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,KAAK,+BAA+B,EAAE,MAAM,yCAAyC,CAAC;AAE/F;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,kFAAuF,CAAC;AAExH;;;;;;;GAOG;AACH,eAAO,MAAM,wBAAwB,+IAGpC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,WAAW,yBAA0B,SAAQ,gBAAgB;IAChE,mBAAmB,CAAC,GAAG,EAAE,GAAG,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,eAAe,CAAC,OAAO,CAAC,CAAC;CAC/E;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAAa,yBAA0B,SAAQ,uBAAwB,YAAW,yBAAyB;uBAWhE,QAAQ,EAAE,2BAA2B;IAV7E,sFAAsF;IACtF,SAAS,CAAC,QAAQ,CAAC,SAAS,EAAE,iBAAiB,CAAC;IAEhD;;;;OAIG;IACH,mBAA2B,sBAAsB,EAAE,+BAA+B,CAAC;gBAE3C,QAAQ,EAAE,2BAA2B;IAK7E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgCG;IACH,mBAAmB,CAAC,GAAG,EAAE,GAAG,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,eAAe,CAAC,OAAO,CAAC;IAe7D,mBAAmB,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;CAgCjF"}
|
|
@@ -7,9 +7,28 @@
|
|
|
7
7
|
* SPDX-License-Identifier: MIT
|
|
8
8
|
********************************************************************************/
|
|
9
9
|
import { DefaultLangiumDocuments } from '@hydranium/langium';
|
|
10
|
+
import { defineMessage } from '@hydranium/protocol';
|
|
10
11
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
12
|
+
* The document a caller asked to load is not there.
|
|
13
|
+
*
|
|
14
|
+
* User-facing, and the Node host's spelling of it: `loadUri` returns `undefined`
|
|
15
|
+
* exactly when the URI policy's `realpath` reports the path absent. A host whose
|
|
16
|
+
* provider has no `realpath` never reaches this — the miss surfaces from the
|
|
17
|
+
* provider instead, so the same condition has one declaration per host.
|
|
18
|
+
*/
|
|
19
|
+
export const NO_LOADABLE_CONTENT = defineMessage('hydranium/core/no-loadable-content', 'No loadable content for {uri}');
|
|
20
|
+
/**
|
|
21
|
+
* A stand-in was asked for at a URI that routes to no grammar, and no language
|
|
22
|
+
* id was given to route it instead.
|
|
23
|
+
*
|
|
24
|
+
* User-facing, and raised BEFORE the parse: left to Langium's ladder the same
|
|
25
|
+
* condition surfaces as `no services for the extension ''`, which names neither
|
|
26
|
+
* the URI nor the argument that would have answered.
|
|
27
|
+
*/
|
|
28
|
+
export const NO_LANGUAGE_FOR_STAND_IN = defineMessage('hydranium/core/no-language-for-stand-in', 'No grammar routes {uri}; pass a languageId to say which one the stand-in should parse with');
|
|
29
|
+
/**
|
|
30
|
+
* Default `LangiumDocuments` for `@hydranium/core` consumers, extending
|
|
31
|
+
* Langium's {@link DefaultLangiumDocuments} with:
|
|
13
32
|
*
|
|
14
33
|
* 1. **Identity via the {@link DocumentUriPolicy} seam.**
|
|
15
34
|
* `getOrCreateDocument` resolves the requested URI through the seam — the
|
|
@@ -19,25 +38,70 @@ import { DefaultLangiumDocuments } from '@hydranium/langium';
|
|
|
19
38
|
* `LangiumDocuments` override. The default resolves to the URI unchanged
|
|
20
39
|
* (`DefaultDocumentUriPolicy`), matching Langium's own keying.
|
|
21
40
|
*
|
|
22
|
-
* 2.
|
|
23
|
-
* document
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
41
|
+
* 2. **A load that finds nothing rejects**, rather than answering with a
|
|
42
|
+
* transient empty document. An empty AST validates clean, so a placeholder
|
|
43
|
+
* hands the caller something that silently is not the file, and a caller
|
|
44
|
+
* that wants a document for a URI with no content on disk cannot use one
|
|
45
|
+
* anyway: it is unregistered, so no build, index or save can see it, and
|
|
46
|
+
* `LangiumDocumentFactory.update` reads from disk. Content that legitimately
|
|
47
|
+
* lives outside the filesystem belongs in a virtual document, which carries
|
|
48
|
+
* real source text.
|
|
30
49
|
*/
|
|
31
|
-
export class
|
|
50
|
+
export class HydraniumLangiumDocuments extends DefaultLangiumDocuments {
|
|
32
51
|
services;
|
|
33
52
|
/** Document-identity seam, shared with the text store, event filters, and builder. */
|
|
34
53
|
uriPolicy;
|
|
35
|
-
tracer;
|
|
36
54
|
constructor(services) {
|
|
37
55
|
super(services);
|
|
38
56
|
this.services = services;
|
|
39
57
|
this.uriPolicy = services.workspace.DocumentUriPolicy;
|
|
40
|
-
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Build a transient document for `uri` by parsing empty text with the
|
|
61
|
+
* grammar `languageId` names, or the one `uri` routes to when it is
|
|
62
|
+
* omitted, so the root is that language's entry type with every containment
|
|
63
|
+
* list initialised.
|
|
64
|
+
*
|
|
65
|
+
* For callers that need a document at a URI with no content on disk — the
|
|
66
|
+
* scope provider querying before a file exists is the case it was added for.
|
|
67
|
+
* `getOrCreateDocument` deliberately does NOT fall back to this: fabricating
|
|
68
|
+
* a document behind a caller that asked to LOAD one hands back something
|
|
69
|
+
* that silently is not the file, whereas calling this is a caller saying it
|
|
70
|
+
* wants a stand-in.
|
|
71
|
+
*
|
|
72
|
+
* **Pass `languageId` whenever the URI names no file.** The create-element
|
|
73
|
+
* flow this exists for asks at the DIRECTORY a file is about to be written
|
|
74
|
+
* into, and a directory URI has no extension for the routing ladder to end
|
|
75
|
+
* on — so omitting the id there fails inside the parse, on an empty
|
|
76
|
+
* extension rather than on the URI. A caller in that position always knows
|
|
77
|
+
* its language: {@link HydraniumScopeProvider} is bound per grammar, and a
|
|
78
|
+
* request that names no document at all still carries the AST type
|
|
79
|
+
* `ExtendedServiceRegistry.soleServicesByType` routes on.
|
|
80
|
+
*
|
|
81
|
+
* The result is not registered, so nothing downstream can see it, and
|
|
82
|
+
* `LangiumDocumentFactory.update` would read from disk. It is a probe, not a
|
|
83
|
+
* document under construction; content that must survive belongs in a
|
|
84
|
+
* virtual document, which carries real source text.
|
|
85
|
+
*
|
|
86
|
+
* Building the root by hand instead needs the entry type name and a cast
|
|
87
|
+
* past the generated types, and leaves those lists `undefined`. A grammar
|
|
88
|
+
* whose entry rule opens with mandatory syntax yields a parse error here,
|
|
89
|
+
* and it is kept: `AstReflection.isComplete` is `false` for such a root
|
|
90
|
+
* however it is built, so the error states the same thing.
|
|
91
|
+
*/
|
|
92
|
+
createEmptyDocument(uri, languageId) {
|
|
93
|
+
if (languageId !== undefined) {
|
|
94
|
+
return this.langiumDocumentFactory.fromStringInLanguage('', uri, languageId);
|
|
95
|
+
}
|
|
96
|
+
if (!this.services.ServiceRegistry.getServicesFor(uri)) {
|
|
97
|
+
// Reported here rather than left to the parse, which ends on the empty
|
|
98
|
+
// extension and so names neither the URI nor the id that would have
|
|
99
|
+
// answered.
|
|
100
|
+
throw new Error(NO_LANGUAGE_FOR_STAND_IN.format({ uri: uri.toString() }));
|
|
101
|
+
}
|
|
102
|
+
// The two-argument overload is synchronous; passing a cancellation token
|
|
103
|
+
// selects the promise-returning one, which this contract cannot await.
|
|
104
|
+
return this.langiumDocumentFactory.fromString('', uri);
|
|
41
105
|
}
|
|
42
106
|
async getOrCreateDocument(uri) {
|
|
43
107
|
const resolved = this.uriPolicy.loadUri(uri);
|
|
@@ -58,28 +122,19 @@ export class AbstractHydraniumLangiumDocuments extends DefaultLangiumDocuments {
|
|
|
58
122
|
}
|
|
59
123
|
catch (error) {
|
|
60
124
|
// Load lost a race with a concurrent create — return that document.
|
|
125
|
+
// Checked before propagating, so a race is not reported as a
|
|
126
|
+
// missing file; cancellation carries no document and falls through.
|
|
61
127
|
const reentrant = this.getDocument(resolved);
|
|
62
128
|
if (reentrant) {
|
|
63
129
|
this.services.workspace.CstResidencyService.rehydrate(reentrant);
|
|
64
130
|
return reentrant;
|
|
65
131
|
}
|
|
66
|
-
|
|
67
|
-
// below still runs, because the file-not-found case is the ordinary
|
|
68
|
-
// one here and no provider-independent way to recognise it exists:
|
|
69
|
-
// Node's provider throws `ENOENT`, the in-memory one a bare `Error`,
|
|
70
|
-
// and the provider is a seam an adopter rebinds. Discriminating on
|
|
71
|
-
// message text across that seam would be a worse defect than the
|
|
72
|
-
// one it fixes. So the failure is TRACED rather than propagated —
|
|
73
|
-
// an unreadable-but-present file still degrades to an empty
|
|
74
|
-
// document, but it stops doing so silently.
|
|
75
|
-
this.tracer
|
|
76
|
-
.with(resolved.toString())
|
|
77
|
-
.debug(`Load failed, falling back to an empty document: ${error instanceof Error ? error.message : String(error)}`);
|
|
132
|
+
throw error;
|
|
78
133
|
}
|
|
79
134
|
}
|
|
80
|
-
//
|
|
81
|
-
//
|
|
82
|
-
|
|
135
|
+
// The seam reports no loadable content, so there is nothing to read and
|
|
136
|
+
// no error from a read to carry.
|
|
137
|
+
throw new Error(NO_LOADABLE_CONTENT.format({ uri: uri.toString() }));
|
|
83
138
|
}
|
|
84
139
|
}
|
|
85
140
|
//# sourceMappingURL=langium-documents.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"langium-documents.js","sourceRoot":"","sources":["../../../src/langium/workspace/langium-documents.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;
|
|
1
|
+
{"version":3,"file":"langium-documents.js","sourceRoot":"","sources":["../../../src/langium/workspace/langium-documents.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAgB,uBAAuB,EAAyD,MAAM,oBAAoB,CAAC;AAClI,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAKpD;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,aAAa,CAAC,oCAAoC,EAAE,+BAA+B,CAAC,CAAC;AAExH;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,aAAa,CAClD,yCAAyC,EACzC,4FAA4F,CAC9F,CAAC;AAaF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,OAAO,yBAA0B,SAAQ,uBAAuB;IAW3B;IAVxC,sFAAsF;IACnE,SAAS,CAAoB;IAShD,YAAwC,QAAqC;QAC1E,KAAK,CAAC,QAAQ,CAAC,CAAC;QADqB,aAAQ,GAAR,QAAQ,CAA6B;QAE1E,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC,SAAS,CAAC,iBAAiB,CAAC;IACzD,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgCG;IACH,mBAAmB,CAAC,GAAQ,EAAE,UAAmB;QAC9C,IA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AQ,CAAC,CAAC;gBAC7C,IAAI,SAAS,EAAE,CAAC;oBACb,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,mBAAmB,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;oBACjE,OAAO,SAAS,CAAC;gBACpB,CAAC;gBACD,MAAM,KAAK,CAAC;YACf,CAAC;QACJ,CAAC;QACD,wEAAwE;QACxE,iCAAiC;QACjC,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC;IACxE,CAAC;CACH"}
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
export * from './server-locale.js';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/locale/index.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
export * from './server-locale.js';
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/locale/index.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2026 CrossBreeze, EclipseSource and others.
|
|
3
|
+
*
|
|
4
|
+
* This program and the accompanying materials are made available under the
|
|
5
|
+
* terms of the MIT License which is available in the project root.
|
|
6
|
+
*
|
|
7
|
+
* SPDX-License-Identifier: MIT
|
|
8
|
+
********************************************************************************/
|
|
9
|
+
import type { Tracer } from '@hydranium/protocol';
|
|
10
|
+
import { type LogNameOptions } from '../langium/diagnostics/logger.js';
|
|
11
|
+
import type { ServerSharedServicesMinimal } from '../langium/shared-services.js';
|
|
12
|
+
/** Construction options for {@link ServerLocale}. */
|
|
13
|
+
export type ServerLocaleOptions = LogNameOptions;
|
|
14
|
+
/**
|
|
15
|
+
* The locale contract the `ServerLocale` slot holds, implemented by
|
|
16
|
+
* {@link DefaultServerLocale}.
|
|
17
|
+
*
|
|
18
|
+
* An interface rather than the class, so the slot is compared STRUCTURALLY —
|
|
19
|
+
* a class-typed slot carries its `protected` members into every assignability
|
|
20
|
+
* check, compared nominally, which makes it unsatisfiable across two physical
|
|
21
|
+
* copies of this package and unreplaceable by an adopter's own declaration.
|
|
22
|
+
*/
|
|
23
|
+
export interface ServerLocale {
|
|
24
|
+
/** The locale, or `undefined` when no init supplied one — the framework's English. */
|
|
25
|
+
readonly value: string | undefined;
|
|
26
|
+
accept(locale: string): void;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The locale the server was handed at init, for whoever needs to render in the
|
|
30
|
+
* reading user's language. Held apart from the message renderer that reads it,
|
|
31
|
+
* so replacing the renderer cannot drop locale handling.
|
|
32
|
+
*
|
|
33
|
+
* A plain string in and out. A consumer that must react to a change rather than
|
|
34
|
+
* read the current value wraps this itself — nothing does today, and both real
|
|
35
|
+
* hosts respawn the server on a display-language switch.
|
|
36
|
+
*/
|
|
37
|
+
export declare class DefaultServerLocale implements ServerLocale {
|
|
38
|
+
protected readonly tracer: Tracer;
|
|
39
|
+
protected current: string | undefined;
|
|
40
|
+
constructor(services: ServerSharedServicesMinimal, options?: ServerLocaleOptions);
|
|
41
|
+
/** The locale, or `undefined` when no init supplied one — which means the framework's English. */
|
|
42
|
+
get value(): string | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* Take the locale an init declared.
|
|
45
|
+
*
|
|
46
|
+
* **One locale per process, and the reason the OTHER heads need none of
|
|
47
|
+
* their own.** The data and GLSP heads publish a port over the LSP
|
|
48
|
+
* connection and are reached by forwarding a socket to it, so they are the
|
|
49
|
+
* same process as the LSP head that was handed this locale — there is no
|
|
50
|
+
* topology in which one of them serves a second frontend. The Theia backend
|
|
51
|
+
* is the case that would break it, and it holds no locale precisely because
|
|
52
|
+
* it serves every frontend at once; nothing there writes here.
|
|
53
|
+
*
|
|
54
|
+
* The framework accepts a locale and never sources one, and neither
|
|
55
|
+
* validates nor normalises the tag: rejecting an unfamiliar one would be
|
|
56
|
+
* selecting a locale.
|
|
57
|
+
*
|
|
58
|
+
* Override to ignore the argument, which is how a host pins a locale it
|
|
59
|
+
* already knows but has no LSP client to declare.
|
|
60
|
+
*
|
|
61
|
+
* **The line is at `info`, which is a deliberate exception to the
|
|
62
|
+
* per-service default.** A locale is written once per process and it is the
|
|
63
|
+
* one setting that silently changes every user-facing sentence the server
|
|
64
|
+
* produces, so a reader trying to explain an unexpected language has nothing
|
|
65
|
+
* else to look at: the framework ships no catalogue, so "no entry for this
|
|
66
|
+
* code" and "no locale declared" both render the English and are
|
|
67
|
+
* indistinguishable in the output. At `debug` the line is below the default
|
|
68
|
+
* threshold and therefore absent from exactly the log someone would be
|
|
69
|
+
* reading.
|
|
70
|
+
*/
|
|
71
|
+
accept(locale: string): void;
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=server-locale.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-locale.d.ts","sourceRoot":"","sources":["../../src/locale/server-locale.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAEjF,qDAAqD;AACrD,MAAM,MAAM,mBAAmB,GAAG,cAAc,CAAC;AAEjD;;;;;;;;GAQG;AACH,MAAM,WAAW,YAAY;IAC1B,sFAAsF;IACtF,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B;AAED;;;;;;;;GAQG;AACH,qBAAa,mBAAoB,YAAW,YAAY;IACrD,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAClC,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;gBAE1B,QAAQ,EAAE,2BAA2B,EAAE,OAAO,GAAE,mBAAwB;IAIpF,kGAAkG;IAClG,IAAI,KAAK,IAAI,MAAM,GAAG,SAAS,CAE9B;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACH,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;CAI9B"}
|
|
@@ -0,0 +1,61 @@
|
|
|
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
|
+
* The locale the server was handed at init, for whoever needs to render in the
|
|
11
|
+
* reading user's language. Held apart from the message renderer that reads it,
|
|
12
|
+
* so replacing the renderer cannot drop locale handling.
|
|
13
|
+
*
|
|
14
|
+
* A plain string in and out. A consumer that must react to a change rather than
|
|
15
|
+
* read the current value wraps this itself — nothing does today, and both real
|
|
16
|
+
* hosts respawn the server on a display-language switch.
|
|
17
|
+
*/
|
|
18
|
+
export class DefaultServerLocale {
|
|
19
|
+
tracer;
|
|
20
|
+
current;
|
|
21
|
+
constructor(services, options = {}) {
|
|
22
|
+
this.tracer = services.Tracer.for(options.logName ?? 'ServerLocale').trace('instantiated');
|
|
23
|
+
}
|
|
24
|
+
/** The locale, or `undefined` when no init supplied one — which means the framework's English. */
|
|
25
|
+
get value() {
|
|
26
|
+
return this.current;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Take the locale an init declared.
|
|
30
|
+
*
|
|
31
|
+
* **One locale per process, and the reason the OTHER heads need none of
|
|
32
|
+
* their own.** The data and GLSP heads publish a port over the LSP
|
|
33
|
+
* connection and are reached by forwarding a socket to it, so they are the
|
|
34
|
+
* same process as the LSP head that was handed this locale — there is no
|
|
35
|
+
* topology in which one of them serves a second frontend. The Theia backend
|
|
36
|
+
* is the case that would break it, and it holds no locale precisely because
|
|
37
|
+
* it serves every frontend at once; nothing there writes here.
|
|
38
|
+
*
|
|
39
|
+
* The framework accepts a locale and never sources one, and neither
|
|
40
|
+
* validates nor normalises the tag: rejecting an unfamiliar one would be
|
|
41
|
+
* selecting a locale.
|
|
42
|
+
*
|
|
43
|
+
* Override to ignore the argument, which is how a host pins a locale it
|
|
44
|
+
* already knows but has no LSP client to declare.
|
|
45
|
+
*
|
|
46
|
+
* **The line is at `info`, which is a deliberate exception to the
|
|
47
|
+
* per-service default.** A locale is written once per process and it is the
|
|
48
|
+
* one setting that silently changes every user-facing sentence the server
|
|
49
|
+
* produces, so a reader trying to explain an unexpected language has nothing
|
|
50
|
+
* else to look at: the framework ships no catalogue, so "no entry for this
|
|
51
|
+
* code" and "no locale declared" both render the English and are
|
|
52
|
+
* indistinguishable in the output. At `debug` the line is below the default
|
|
53
|
+
* threshold and therefore absent from exactly the log someone would be
|
|
54
|
+
* reading.
|
|
55
|
+
*/
|
|
56
|
+
accept(locale) {
|
|
57
|
+
this.current = locale;
|
|
58
|
+
this.tracer.info(`rendering messages in locale '${locale}'`);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=server-locale.js.map
|