@hydranium/core 1.0.0-next.7 → 1.0.0-next.71
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 +58 -5
- package/lib/documents/ast-document-manager.d.ts.map +1 -1
- package/lib/documents/ast-document-manager.js +50 -18
- package/lib/documents/ast-document-manager.js.map +1 -1
- package/lib/documents/client-ids.d.ts +5 -19
- package/lib/documents/client-ids.d.ts.map +1 -1
- package/lib/documents/client-ids.js +5 -19
- package/lib/documents/client-ids.js.map +1 -1
- package/lib/documents/hydranium-text-documents.d.ts +51 -17
- package/lib/documents/hydranium-text-documents.d.ts.map +1 -1
- package/lib/documents/hydranium-text-documents.js +136 -40
- package/lib/documents/hydranium-text-documents.js.map +1 -1
- package/lib/documents/language-client-text-shadow.d.ts +41 -9
- package/lib/documents/language-client-text-shadow.d.ts.map +1 -1
- package/lib/documents/language-client-text-shadow.js +56 -11
- 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/config/configuration-provider.d.ts +81 -0
- package/lib/langium/config/configuration-provider.d.ts.map +1 -0
- package/lib/langium/config/configuration-provider.js +112 -0
- package/lib/langium/config/configuration-provider.js.map +1 -0
- package/lib/langium/config/index.d.ts +1 -0
- package/lib/langium/config/index.d.ts.map +1 -1
- package/lib/langium/config/index.js +1 -0
- package/lib/langium/config/index.js.map +1 -1
- package/lib/langium/diagnostics/lsp-logger.d.ts +17 -0
- package/lib/langium/diagnostics/lsp-logger.d.ts.map +1 -1
- package/lib/langium/diagnostics/lsp-logger.js +40 -6
- package/lib/langium/diagnostics/lsp-logger.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 +26 -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/lsp/index.d.ts +1 -1
- package/lib/lsp/index.d.ts.map +1 -1
- package/lib/lsp/index.js +1 -1
- package/lib/lsp/index.js.map +1 -1
- package/lib/lsp/lsp-latency.d.ts +39 -0
- package/lib/lsp/lsp-latency.d.ts.map +1 -0
- package/lib/lsp/lsp-latency.js +58 -0
- package/lib/lsp/lsp-latency.js.map +1 -0
- 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/latency-from-env.d.ts +1 -1
- package/lib/node/latency-from-env.js +1 -1
- 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/profiling-run.d.ts +2 -2
- package/lib/node/profiling-run.js +1 -1
- package/lib/node/profiling-run.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/node/spawned-server.d.ts +14 -0
- package/lib/testing/node/spawned-server.d.ts.map +1 -1
- package/lib/testing/node/spawned-server.js +33 -1
- package/lib/testing/node/spawned-server.js.map +1 -1
- package/lib/testing/playwright/flaky-network-proxy.d.ts +76 -0
- package/lib/testing/playwright/flaky-network-proxy.d.ts.map +1 -0
- package/lib/testing/playwright/flaky-network-proxy.js +164 -0
- package/lib/testing/playwright/flaky-network-proxy.js.map +1 -0
- package/lib/testing/playwright/index.d.ts +1 -0
- package/lib/testing/playwright/index.d.ts.map +1 -1
- package/lib/testing/playwright/index.js +1 -0
- package/lib/testing/playwright/index.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 +99 -23
- package/src/documents/client-ids.ts +5 -22
- package/src/documents/hydranium-text-documents.ts +161 -55
- package/src/documents/language-client-text-shadow.ts +59 -11
- 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/config/configuration-provider.ts +119 -0
- package/src/langium/config/index.ts +1 -0
- package/src/langium/diagnostics/lsp-logger.ts +41 -6
- 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 +104 -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/lsp/index.ts +1 -1
- package/src/lsp/lsp-latency.ts +62 -0
- package/src/messages/carriers.ts +78 -0
- package/src/messages/index.ts +27 -0
- package/src/messages/renderer.ts +204 -0
- package/src/node/latency-from-env.ts +1 -1
- package/src/node/node-file-system-provider.ts +1 -41
- package/src/node/profiling-run.ts +3 -3
- 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/node/spawned-server.ts +35 -1
- package/src/testing/playwright/flaky-network-proxy.ts +240 -0
- package/src/testing/playwright/index.ts +1 -0
- 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
- package/lib/lsp/instrument-connection.d.ts +0 -36
- package/lib/lsp/instrument-connection.d.ts.map +0 -1
- package/lib/lsp/instrument-connection.js +0 -62
- package/lib/lsp/instrument-connection.js.map +0 -1
- package/src/lsp/instrument-connection.ts +0 -66
|
@@ -7,19 +7,74 @@
|
|
|
7
7
|
* SPDX-License-Identifier: MIT
|
|
8
8
|
********************************************************************************/
|
|
9
9
|
import { type LogThreshold, type MaybeObservableValue, ObservableValue, type Tracer } from '@hydranium/protocol';
|
|
10
|
-
import { type AstNode, type AstNodeLocator, DefaultDocumentValidator, type DiagnosticInfo, type LangiumDocument, type LangiumCoreServices, type ValidateSingleNodeOptions, type ValidationOptions, type ValidationSeverity } from '@hydranium/langium';
|
|
10
|
+
import { type AstNode, type AstNodeLocator, type AstReflection, DefaultDocumentValidator, type DiagnosticInfo, type LangiumDocument, type LangiumCoreServices, type ValidateSingleNodeOptions, type ValidationOptions, type ValidationSeverity } from '@hydranium/langium';
|
|
11
11
|
import type { CancellationToken } from 'vscode-languageserver-protocol';
|
|
12
|
-
import
|
|
12
|
+
import { Diagnostic } from 'vscode-languageserver-types';
|
|
13
13
|
import { type LogNameOptions } from '../diagnostics/logger.js';
|
|
14
14
|
/**
|
|
15
|
-
* Diagnostic
|
|
16
|
-
*
|
|
17
|
-
*
|
|
15
|
+
* Diagnostic read off a `LangiumDocument`: an LSP {@link Diagnostic} that MAY
|
|
16
|
+
* carry the protocol-level `element` path and `property` name from
|
|
17
|
+
* {@link TransferDiagnostic}.
|
|
18
|
+
*
|
|
19
|
+
* `element` is optional because a document's diagnostics do not all come from
|
|
20
|
+
* this validator. {@link HydraniumDocumentValidator.toDiagnostic} always sets
|
|
21
|
+
* one, but Langium pushes lexer and parser errors straight onto the document
|
|
22
|
+
* without routing them through it, so a document that fails to parse carries
|
|
23
|
+
* diagnostics with no path at all. Treat it as absent, not empty.
|
|
24
|
+
*
|
|
25
|
+
* Narrowing `LangiumDocument.diagnostics` to this type instead is unavailable:
|
|
26
|
+
* declaration merging may add a member but not retype one, and augmenting the
|
|
27
|
+
* LSP `Diagnostic` reaches only one of the two declaration files its package
|
|
28
|
+
* ships, since the `exports` map splits `import` from `default` with no `types`
|
|
29
|
+
* condition. Consumers therefore cast at the read, and the cast is sound only
|
|
30
|
+
* because this field is optional.
|
|
18
31
|
*/
|
|
19
32
|
export interface TransferLspDiagnostic extends Diagnostic {
|
|
20
|
-
element
|
|
33
|
+
element?: string;
|
|
21
34
|
property?: string;
|
|
22
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* A reference resolved to nothing.
|
|
38
|
+
*
|
|
39
|
+
* **The English is byte-identical to Langium's `DefaultLinker.createLinkingError`
|
|
40
|
+
* sentence, and must stay so.** The identity is attached to a diagnostic Langium
|
|
41
|
+
* already worded, so a divergence here would silently change the text every
|
|
42
|
+
* adopter without a catalogue sees. {@link HydraniumDocumentValidator.processLinkingErrors}
|
|
43
|
+
* attaches it only when the two match exactly, which is also what keeps an
|
|
44
|
+
* adopter's own reworded linking error from being mislabelled as this one.
|
|
45
|
+
*
|
|
46
|
+
* It exists because this is the most-seen validation error in any language built
|
|
47
|
+
* on the framework, and Langium puts its own code in `data.code` rather than on
|
|
48
|
+
* `Diagnostic.code` — so without a framework identity every adopter wanting to
|
|
49
|
+
* render it has to special-case Langium's shape.
|
|
50
|
+
*/
|
|
51
|
+
export declare const UNRESOLVED_REFERENCE: import("@hydranium/protocol").MessageDefinition<"Could not resolve reference to {referenceType} named '{refText}'.">;
|
|
52
|
+
/**
|
|
53
|
+
* A character no token of the grammar can start with.
|
|
54
|
+
*
|
|
55
|
+
* **The English is byte-identical to CHEVROTAIN's
|
|
56
|
+
* `defaultLexerErrorProvider.buildUnexpectedCharactersMessage`, and must stay
|
|
57
|
+
* so** — one layer further out than {@link UNRESOLVED_REFERENCE}, whose sentence
|
|
58
|
+
* is Langium's. Langium words neither: `processLexingErrors` copies
|
|
59
|
+
* `lexerDiagnostic.message` through untouched, so the text an adopter sees today
|
|
60
|
+
* is produced two dependencies down and is the only thing this identity may
|
|
61
|
+
* claim to be. {@link HydraniumDocumentValidator.identifyLexingError} attaches
|
|
62
|
+
* it only when the two match exactly, which is also what keeps a custom lexer's
|
|
63
|
+
* own diagnostics — Langium admits any of them through `lexerReport` — from
|
|
64
|
+
* being mislabelled as this one.
|
|
65
|
+
*
|
|
66
|
+
* It exists because a lexing error is the FIRST message a user of a new language
|
|
67
|
+
* sees and the one an adopter cannot reach: every other diagnostic worth
|
|
68
|
+
* translating either carries an identity already or is raised by adopter code,
|
|
69
|
+
* while this one arrives with a Langium `data.code` naming a KIND and no
|
|
70
|
+
* parameters at all — so a catalogue had nothing to key on and nothing to
|
|
71
|
+
* interpolate.
|
|
72
|
+
*
|
|
73
|
+
* `skipped` rather than `length`, matching what the sentence says the number
|
|
74
|
+
* means: chevrotain reports how many characters the lexer discarded to recover,
|
|
75
|
+
* which for a single stray character is one and for a run of them is the run.
|
|
76
|
+
*/
|
|
77
|
+
export declare const LEXING_ERROR: import("@hydranium/protocol").MessageDefinition<"unexpected character: ->{character}<- at offset: {offset}, skipped {skipped} characters.">;
|
|
23
78
|
export interface DocumentValidatorOptions extends LogNameOptions {
|
|
24
79
|
/**
|
|
25
80
|
* Level at which the `validateDocument` timing line is emitted, or `'off'`
|
|
@@ -65,6 +120,7 @@ export interface DocumentValidatorOptions extends LogNameOptions {
|
|
|
65
120
|
export declare class HydraniumDocumentValidator extends DefaultDocumentValidator {
|
|
66
121
|
protected readonly tracer: Tracer;
|
|
67
122
|
protected readonly astNodeLocator: AstNodeLocator;
|
|
123
|
+
protected readonly reflection: AstReflection;
|
|
68
124
|
protected readonly logLevel: ObservableValue<LogThreshold>;
|
|
69
125
|
protected readonly logAfterMs: ObservableValue<number>;
|
|
70
126
|
protected readonly validateVirtualDocuments: ObservableValue<boolean>;
|
|
@@ -75,6 +131,41 @@ export declare class HydraniumDocumentValidator extends DefaultDocumentValidator
|
|
|
75
131
|
};
|
|
76
132
|
}, options?: DocumentValidatorOptions);
|
|
77
133
|
validateDocument(document: LangiumDocument, options?: ValidationOptions, cancelToken?: CancellationToken): Promise<Diagnostic[]>;
|
|
134
|
+
/**
|
|
135
|
+
* Langium's validation pass, plus the framework identity on the lexing
|
|
136
|
+
* diagnostics it produced.
|
|
137
|
+
*
|
|
138
|
+
* **Here rather than in an override of `processLexingErrors`, and the reason
|
|
139
|
+
* is that the seam cannot see what the identity needs.** Langium hands that
|
|
140
|
+
* method a `ParseResult`, which carries the AST and the error lists but not
|
|
141
|
+
* the source text — and the offending CHARACTER is the parameter a
|
|
142
|
+
* translation exists to interpolate. The document does carry it, and this is
|
|
143
|
+
* the innermost point that still holds one. Reconstructing the character by
|
|
144
|
+
* matching it out of the finished sentence was the alternative, and it
|
|
145
|
+
* inverts the direction the rest of this file works in: every other identity
|
|
146
|
+
* here is derived from structured fields and CHECKED against the prose.
|
|
147
|
+
*
|
|
148
|
+
* Inside the timing span rather than around it, so the line accounts for the
|
|
149
|
+
* whole pass.
|
|
150
|
+
*/
|
|
151
|
+
protected validateAndIdentify(document: LangiumDocument, options?: ValidationOptions, cancelToken?: CancellationToken): Promise<Diagnostic[]>;
|
|
152
|
+
/**
|
|
153
|
+
* Add the {@link LEXING_ERROR} identity to one diagnostic, or return it
|
|
154
|
+
* untouched when it is not the sentence that identity renders.
|
|
155
|
+
*
|
|
156
|
+
* The parameters come from the diagnostic's own RANGE, not from
|
|
157
|
+
* `parseResult.lexerErrors`. Both hold the same numbers, and the range is the
|
|
158
|
+
* one that needs no assumption about upstream: correlating the two lists
|
|
159
|
+
* would depend on Langium appending one diagnostic per lexer error in order,
|
|
160
|
+
* which is true today and is an internal of the method being wrapped.
|
|
161
|
+
*
|
|
162
|
+
* **The format-and-compare is the whole discriminator, and it validates the
|
|
163
|
+
* reconstruction as well as the identity.** A range that did not round-trip
|
|
164
|
+
* to the offset chevrotain reported would produce a different sentence and be
|
|
165
|
+
* declined, so a wrong parameter set can never be attached to a right-looking
|
|
166
|
+
* message.
|
|
167
|
+
*/
|
|
168
|
+
protected identifyLexingError(document: LangiumDocument, diagnostic: Diagnostic): Diagnostic;
|
|
78
169
|
/**
|
|
79
170
|
* Skip validation for a node **and its children** when
|
|
80
171
|
* {@link shouldSkipValidation} returns true.
|
|
@@ -89,6 +180,54 @@ export declare class HydraniumDocumentValidator extends DefaultDocumentValidator
|
|
|
89
180
|
* `super.shouldSkipValidation(node) || ...`.
|
|
90
181
|
*/
|
|
91
182
|
protected shouldSkipValidation(node: AstNode): boolean;
|
|
183
|
+
/**
|
|
184
|
+
* Langium's linking-error pass, plus the framework identity on each
|
|
185
|
+
* diagnostic it produced.
|
|
186
|
+
*
|
|
187
|
+
* Langium puts its own `linking-error` marker in `data.code` and leaves
|
|
188
|
+
* `Diagnostic.code` unset, so nothing identifies the message on a surface
|
|
189
|
+
* that drops `data` — which is every editor surface. This adds the framework
|
|
190
|
+
* identity to both `code` and `data.hydranium` while LEAVING `data.code` in
|
|
191
|
+
* place: `stopAfterLinkingErrors` and Langium's code-action dispatch both
|
|
192
|
+
* read it.
|
|
193
|
+
*
|
|
194
|
+
* **The identity is attached only when the message is the one
|
|
195
|
+
* {@link UNRESOLVED_REFERENCE} renders.** Two other sentences reach this
|
|
196
|
+
* list: the linker's exception form, raised when resolution itself throws,
|
|
197
|
+
* and whatever an adopter overriding `createLinkingError` chose. Labelling
|
|
198
|
+
* either would make a catalogue render the wrong sentence — and for the
|
|
199
|
+
* exception form it would discard the underlying cause. Comparing against
|
|
200
|
+
* the locally rendered English is what discriminates; there is no structural
|
|
201
|
+
* field that does.
|
|
202
|
+
*/
|
|
203
|
+
protected processLinkingErrors(document: LangiumDocument, diagnostics: Diagnostic[], options: ValidationOptions): void;
|
|
204
|
+
/**
|
|
205
|
+
* Add the {@link UNRESOLVED_REFERENCE} identity to one linking diagnostic,
|
|
206
|
+
* or return it untouched when its message is not the sentence that identity
|
|
207
|
+
* renders.
|
|
208
|
+
*
|
|
209
|
+
* `refText` comes from the `data` Langium populated; `referenceType` is not
|
|
210
|
+
* in it, so it is recovered the same way `createLinkingError` produced it —
|
|
211
|
+
* through the reflection, from the container type and property.
|
|
212
|
+
*/
|
|
213
|
+
protected identifyLinkingError(diagnostic: Diagnostic): Diagnostic;
|
|
214
|
+
/**
|
|
215
|
+
* The declared target type of the reference this diagnostic came from, or
|
|
216
|
+
* `undefined` when the reflection cannot name one.
|
|
217
|
+
*
|
|
218
|
+
* **The lookup can throw, and that is the reason this is a method rather
|
|
219
|
+
* than an inline call.** `AbstractAstReflection.getReferenceType` raises on
|
|
220
|
+
* an unknown container `$type` and on a property that is not a reference —
|
|
221
|
+
* and the linking error whose type it cannot name is the one most likely to
|
|
222
|
+
* reach here, because `DefaultLinker` catches its OWN failed lookup and
|
|
223
|
+
* turns it into the exception-form message. Rethrowing would take
|
|
224
|
+
* `validateDocument` with it, since Langium wraps `processLinkingErrors` in
|
|
225
|
+
* no try: a diagnostic Langium degraded gracefully would become a failed
|
|
226
|
+
* build. Declining is also the right answer on the merits — a reference
|
|
227
|
+
* whose type cannot be named is not the message
|
|
228
|
+
* {@link UNRESOLVED_REFERENCE} claims.
|
|
229
|
+
*/
|
|
230
|
+
protected referenceTypeOf(containerType: string, property: string, refText: string): string | undefined;
|
|
92
231
|
protected toDiagnostic<N extends AstNode>(severity: ValidationSeverity, message: string, info: DiagnosticInfo<N, string>): TransferLspDiagnostic;
|
|
93
232
|
/**
|
|
94
233
|
* Construct the `element` path for a diagnostic. Falls back through:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document-validator.d.ts","sourceRoot":"","sources":["../../../src/langium/validation/document-validator.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,
|
|
1
|
+
{"version":3,"file":"document-validator.d.ts","sourceRoot":"","sources":["../../../src/langium/validation/document-validator.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAIJ,KAAK,YAAY,EACjB,KAAK,oBAAoB,EACzB,eAAe,EACf,KAAK,MAAM,EAEb,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACJ,KAAK,OAAO,EACZ,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,wBAAwB,EACxB,KAAK,cAAc,EAEnB,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,yBAAyB,EAC9B,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACzB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAIxE,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAI/D;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,WAAW,qBAAsB,SAAQ,UAAU;IACtD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,oBAAoB,sHAGhC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,YAAY,6IAGxB,CAAC;AAiBF,MAAM,WAAW,wBAAyB,SAAQ,cAAc;IAC7D;;;;;OAKG;IACH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AiB,EAC3B,WAAW,CAAC,EAAE,iBAAiB,GAC/B,OAAO,CAAC,UAAU,EAAE,CAAC;IAWxB;;;;;;;;;;;;;;;OAeG;IACH,SAAS,CAAC,mBAAmB,CAAC,QAAQ,EAAE,eAAe,EAAE,UAAU,EAAE,UAAU,GAAG,UAAU;IAqB5F;;;OAGG;cACgB,yBAAyB,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,iBAAiB,GAAG,yBAAyB;IAOlH;;;;;;;OAOG;IACH,SAAS,CAAC,oBAAoB,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO;IAItD;;;;;;;;;;;;;;;;;;;OAmBG;cACgB,oBAAoB,CAAC,QAAQ,EAAE,eAAe,EAAE,WAAW,EAAE,UAAU,EAAE,EAAE,OAAO,EAAE,iBAAiB,GAAG,IAAI;IAQ/H;;;;;;;;OAQG;IACH,SAAS,CAAC,oBAAoB,CAAC,UAAU,EAAE,UAAU,GAAG,UAAU;IAkBlE;;;;;;;;;;;;;;;OAeG;IACH,SAAS,CAAC,eAAe,CAAC,aAAa,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;cAapF,YAAY,CAAC,CAAC,SAAS,OAAO,EAC9C,QAAQ,EAAE,kBAAkB,EAC5B,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,cAAc,CAAC,CAAC,EAAE,MAAM,CAAC,GAC/B,qBAAqB;IAWxB;;;;;;;;;;OAUG;IACH,SAAS,CAAC,gBAAgB,CAAC,CAAC,SAAS,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC,EAAE,MAAM,CAAC,GAAG,MAAM;CAejG"}
|
|
@@ -6,10 +6,70 @@
|
|
|
6
6
|
*
|
|
7
7
|
* SPDX-License-Identifier: MIT
|
|
8
8
|
********************************************************************************/
|
|
9
|
-
import { ObservableValue, TransferDiagnostic } from '@hydranium/protocol';
|
|
10
|
-
import { DefaultDocumentValidator } from '@hydranium/langium';
|
|
9
|
+
import { defineMessage, describeError, messageData, ObservableValue, TransferDiagnostic } from '@hydranium/protocol';
|
|
10
|
+
import { DefaultDocumentValidator, DocumentValidator } from '@hydranium/langium';
|
|
11
|
+
// A VALUE import, for `Diagnostic.getMessageString`: `message` is
|
|
12
|
+
// `string | MarkupContent` in LSP 3.17+, so upstream's own reader is what
|
|
13
|
+
// narrows it rather than a hand-rolled union check here.
|
|
14
|
+
import { Diagnostic } from 'vscode-languageserver-types';
|
|
11
15
|
import { isSyntheticNode } from '../workspace/synthetic.js';
|
|
12
16
|
import { isVirtualUri } from '../workspace/virtual-document.js';
|
|
17
|
+
/**
|
|
18
|
+
* A reference resolved to nothing.
|
|
19
|
+
*
|
|
20
|
+
* **The English is byte-identical to Langium's `DefaultLinker.createLinkingError`
|
|
21
|
+
* sentence, and must stay so.** The identity is attached to a diagnostic Langium
|
|
22
|
+
* already worded, so a divergence here would silently change the text every
|
|
23
|
+
* adopter without a catalogue sees. {@link HydraniumDocumentValidator.processLinkingErrors}
|
|
24
|
+
* attaches it only when the two match exactly, which is also what keeps an
|
|
25
|
+
* adopter's own reworded linking error from being mislabelled as this one.
|
|
26
|
+
*
|
|
27
|
+
* It exists because this is the most-seen validation error in any language built
|
|
28
|
+
* on the framework, and Langium puts its own code in `data.code` rather than on
|
|
29
|
+
* `Diagnostic.code` — so without a framework identity every adopter wanting to
|
|
30
|
+
* render it has to special-case Langium's shape.
|
|
31
|
+
*/
|
|
32
|
+
export const UNRESOLVED_REFERENCE = defineMessage('hydranium/core/unresolved-reference', "Could not resolve reference to {referenceType} named '{refText}'.");
|
|
33
|
+
/**
|
|
34
|
+
* A character no token of the grammar can start with.
|
|
35
|
+
*
|
|
36
|
+
* **The English is byte-identical to CHEVROTAIN's
|
|
37
|
+
* `defaultLexerErrorProvider.buildUnexpectedCharactersMessage`, and must stay
|
|
38
|
+
* so** — one layer further out than {@link UNRESOLVED_REFERENCE}, whose sentence
|
|
39
|
+
* is Langium's. Langium words neither: `processLexingErrors` copies
|
|
40
|
+
* `lexerDiagnostic.message` through untouched, so the text an adopter sees today
|
|
41
|
+
* is produced two dependencies down and is the only thing this identity may
|
|
42
|
+
* claim to be. {@link HydraniumDocumentValidator.identifyLexingError} attaches
|
|
43
|
+
* it only when the two match exactly, which is also what keeps a custom lexer's
|
|
44
|
+
* own diagnostics — Langium admits any of them through `lexerReport` — from
|
|
45
|
+
* being mislabelled as this one.
|
|
46
|
+
*
|
|
47
|
+
* It exists because a lexing error is the FIRST message a user of a new language
|
|
48
|
+
* sees and the one an adopter cannot reach: every other diagnostic worth
|
|
49
|
+
* translating either carries an identity already or is raised by adopter code,
|
|
50
|
+
* while this one arrives with a Langium `data.code` naming a KIND and no
|
|
51
|
+
* parameters at all — so a catalogue had nothing to key on and nothing to
|
|
52
|
+
* interpolate.
|
|
53
|
+
*
|
|
54
|
+
* `skipped` rather than `length`, matching what the sentence says the number
|
|
55
|
+
* means: chevrotain reports how many characters the lexer discarded to recover,
|
|
56
|
+
* which for a single stray character is one and for a run of them is the run.
|
|
57
|
+
*/
|
|
58
|
+
export const LEXING_ERROR = defineMessage('hydranium/core/lexing-error', 'unexpected character: ->{character}<- at offset: {offset}, skipped {skipped} characters.');
|
|
59
|
+
/**
|
|
60
|
+
* Langium's own `data.code` values for a diagnostic that came out of the lexer.
|
|
61
|
+
*
|
|
62
|
+
* All four severities, not just the error one: `lexerReport` admits warnings and
|
|
63
|
+
* below, and a token builder that downgrades a stray character still produces
|
|
64
|
+
* the same sentence. Gating on the error code alone would leave the identity off
|
|
65
|
+
* a message that is word-for-word the one it names.
|
|
66
|
+
*/
|
|
67
|
+
const LEXING_CODES = new Set([
|
|
68
|
+
DocumentValidator.LexingError,
|
|
69
|
+
DocumentValidator.LexingWarning,
|
|
70
|
+
DocumentValidator.LexingInfo,
|
|
71
|
+
DocumentValidator.LexingHint
|
|
72
|
+
]);
|
|
13
73
|
/**
|
|
14
74
|
* Default validator behaviour for `@hydranium/core` consumers:
|
|
15
75
|
*
|
|
@@ -24,6 +84,7 @@ import { isVirtualUri } from '../workspace/virtual-document.js';
|
|
|
24
84
|
export class HydraniumDocumentValidator extends DefaultDocumentValidator {
|
|
25
85
|
tracer;
|
|
26
86
|
astNodeLocator;
|
|
87
|
+
reflection;
|
|
27
88
|
logLevel;
|
|
28
89
|
logAfterMs;
|
|
29
90
|
validateVirtualDocuments;
|
|
@@ -32,6 +93,7 @@ export class HydraniumDocumentValidator extends DefaultDocumentValidator {
|
|
|
32
93
|
super(services);
|
|
33
94
|
this.tracer = services.shared.Tracer.for(options.logName ?? 'DocumentValidator').trace('instantiated');
|
|
34
95
|
this.astNodeLocator = services.workspace.AstNodeLocator;
|
|
96
|
+
this.reflection = services.shared.AstReflection;
|
|
35
97
|
this.logLevel = ObservableValue.from(options.logLevel ?? 'debug');
|
|
36
98
|
this.logAfterMs = ObservableValue.from(options.logAfterMs ?? 20);
|
|
37
99
|
this.validateVirtualDocuments = ObservableValue.from(options.validateVirtualDocuments ?? false);
|
|
@@ -48,15 +110,78 @@ export class HydraniumDocumentValidator extends DefaultDocumentValidator {
|
|
|
48
110
|
}
|
|
49
111
|
const level = this.logLevel.value;
|
|
50
112
|
if (level === 'off') {
|
|
51
|
-
return
|
|
113
|
+
return this.validateAndIdentify(document, options, cancelToken);
|
|
52
114
|
}
|
|
53
115
|
// `level` is narrowed to `LogLevel` past the early-return.
|
|
54
116
|
return this.tracer
|
|
55
117
|
.withUri(document.uri.toString())
|
|
56
|
-
.time('validateDocument', () =>
|
|
118
|
+
.time('validateDocument', () => this.validateAndIdentify(document, options, cancelToken), level, {
|
|
57
119
|
logAfterMs: this.logAfterMs.value
|
|
58
120
|
});
|
|
59
121
|
}
|
|
122
|
+
/**
|
|
123
|
+
* Langium's validation pass, plus the framework identity on the lexing
|
|
124
|
+
* diagnostics it produced.
|
|
125
|
+
*
|
|
126
|
+
* **Here rather than in an override of `processLexingErrors`, and the reason
|
|
127
|
+
* is that the seam cannot see what the identity needs.** Langium hands that
|
|
128
|
+
* method a `ParseResult`, which carries the AST and the error lists but not
|
|
129
|
+
* the source text — and the offending CHARACTER is the parameter a
|
|
130
|
+
* translation exists to interpolate. The document does carry it, and this is
|
|
131
|
+
* the innermost point that still holds one. Reconstructing the character by
|
|
132
|
+
* matching it out of the finished sentence was the alternative, and it
|
|
133
|
+
* inverts the direction the rest of this file works in: every other identity
|
|
134
|
+
* here is derived from structured fields and CHECKED against the prose.
|
|
135
|
+
*
|
|
136
|
+
* Inside the timing span rather than around it, so the line accounts for the
|
|
137
|
+
* whole pass.
|
|
138
|
+
*/
|
|
139
|
+
async validateAndIdentify(document, options, cancelToken) {
|
|
140
|
+
const diagnostics = await super.validateDocument(document, options, cancelToken);
|
|
141
|
+
// Mapped in place over the array Langium built, rather than filtered and
|
|
142
|
+
// re-concatenated: the publish order is the diagnostic order and a
|
|
143
|
+
// reordering would move a squiggle's entry in the problems list.
|
|
144
|
+
for (let index = 0; index < diagnostics.length; index++) {
|
|
145
|
+
diagnostics[index] = this.identifyLexingError(document, diagnostics[index]);
|
|
146
|
+
}
|
|
147
|
+
return diagnostics;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Add the {@link LEXING_ERROR} identity to one diagnostic, or return it
|
|
151
|
+
* untouched when it is not the sentence that identity renders.
|
|
152
|
+
*
|
|
153
|
+
* The parameters come from the diagnostic's own RANGE, not from
|
|
154
|
+
* `parseResult.lexerErrors`. Both hold the same numbers, and the range is the
|
|
155
|
+
* one that needs no assumption about upstream: correlating the two lists
|
|
156
|
+
* would depend on Langium appending one diagnostic per lexer error in order,
|
|
157
|
+
* which is true today and is an internal of the method being wrapped.
|
|
158
|
+
*
|
|
159
|
+
* **The format-and-compare is the whole discriminator, and it validates the
|
|
160
|
+
* reconstruction as well as the identity.** A range that did not round-trip
|
|
161
|
+
* to the offset chevrotain reported would produce a different sentence and be
|
|
162
|
+
* declined, so a wrong parameter set can never be attached to a right-looking
|
|
163
|
+
* message.
|
|
164
|
+
*/
|
|
165
|
+
identifyLexingError(document, diagnostic) {
|
|
166
|
+
const data = diagnostic.data;
|
|
167
|
+
if (!LEXING_CODES.has(data?.code)) {
|
|
168
|
+
return diagnostic;
|
|
169
|
+
}
|
|
170
|
+
const text = document.textDocument;
|
|
171
|
+
const offset = text.offsetAt(diagnostic.range.start);
|
|
172
|
+
const params = {
|
|
173
|
+
character: text.getText().charAt(offset),
|
|
174
|
+
offset,
|
|
175
|
+
skipped: text.offsetAt(diagnostic.range.end) - offset
|
|
176
|
+
};
|
|
177
|
+
if (Diagnostic.getMessageString(diagnostic) !== LEXING_ERROR.format(params)) {
|
|
178
|
+
return diagnostic;
|
|
179
|
+
}
|
|
180
|
+
// Merged OVER Langium's data, so `data.code` survives for the readers that
|
|
181
|
+
// switch on it — `stopAfterLexingErrors` is one, and the GLSP head's
|
|
182
|
+
// read-only decision is another.
|
|
183
|
+
return { ...diagnostic, code: LEXING_ERROR.code, data: { ...data, ...messageData(LEXING_ERROR, params) } };
|
|
184
|
+
}
|
|
60
185
|
/**
|
|
61
186
|
* Skip validation for a node **and its children** when
|
|
62
187
|
* {@link shouldSkipValidation} returns true.
|
|
@@ -78,6 +203,88 @@ export class HydraniumDocumentValidator extends DefaultDocumentValidator {
|
|
|
78
203
|
shouldSkipValidation(node) {
|
|
79
204
|
return !this.validateSyntheticNodes.value && isSyntheticNode(node);
|
|
80
205
|
}
|
|
206
|
+
/**
|
|
207
|
+
* Langium's linking-error pass, plus the framework identity on each
|
|
208
|
+
* diagnostic it produced.
|
|
209
|
+
*
|
|
210
|
+
* Langium puts its own `linking-error` marker in `data.code` and leaves
|
|
211
|
+
* `Diagnostic.code` unset, so nothing identifies the message on a surface
|
|
212
|
+
* that drops `data` — which is every editor surface. This adds the framework
|
|
213
|
+
* identity to both `code` and `data.hydranium` while LEAVING `data.code` in
|
|
214
|
+
* place: `stopAfterLinkingErrors` and Langium's code-action dispatch both
|
|
215
|
+
* read it.
|
|
216
|
+
*
|
|
217
|
+
* **The identity is attached only when the message is the one
|
|
218
|
+
* {@link UNRESOLVED_REFERENCE} renders.** Two other sentences reach this
|
|
219
|
+
* list: the linker's exception form, raised when resolution itself throws,
|
|
220
|
+
* and whatever an adopter overriding `createLinkingError` chose. Labelling
|
|
221
|
+
* either would make a catalogue render the wrong sentence — and for the
|
|
222
|
+
* exception form it would discard the underlying cause. Comparing against
|
|
223
|
+
* the locally rendered English is what discriminates; there is no structural
|
|
224
|
+
* field that does.
|
|
225
|
+
*/
|
|
226
|
+
processLinkingErrors(document, diagnostics, options) {
|
|
227
|
+
const from = diagnostics.length;
|
|
228
|
+
super.processLinkingErrors(document, diagnostics, options);
|
|
229
|
+
for (let index = from; index < diagnostics.length; index++) {
|
|
230
|
+
diagnostics[index] = this.identifyLinkingError(diagnostics[index]);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Add the {@link UNRESOLVED_REFERENCE} identity to one linking diagnostic,
|
|
235
|
+
* or return it untouched when its message is not the sentence that identity
|
|
236
|
+
* renders.
|
|
237
|
+
*
|
|
238
|
+
* `refText` comes from the `data` Langium populated; `referenceType` is not
|
|
239
|
+
* in it, so it is recovered the same way `createLinkingError` produced it —
|
|
240
|
+
* through the reflection, from the container type and property.
|
|
241
|
+
*/
|
|
242
|
+
identifyLinkingError(diagnostic) {
|
|
243
|
+
const data = diagnostic.data;
|
|
244
|
+
if (typeof data?.refText !== 'string' || typeof data.containerType !== 'string' || typeof data.property !== 'string') {
|
|
245
|
+
return diagnostic;
|
|
246
|
+
}
|
|
247
|
+
const referenceType = this.referenceTypeOf(data.containerType, data.property, data.refText);
|
|
248
|
+
if (referenceType === undefined) {
|
|
249
|
+
return diagnostic;
|
|
250
|
+
}
|
|
251
|
+
const params = { referenceType, refText: data.refText };
|
|
252
|
+
if (diagnostic.message !== UNRESOLVED_REFERENCE.format(params)) {
|
|
253
|
+
return diagnostic;
|
|
254
|
+
}
|
|
255
|
+
// Merged OVER Langium's data rather than replacing it, so `data.code`
|
|
256
|
+
// survives for the readers that switch on it.
|
|
257
|
+
return { ...diagnostic, code: UNRESOLVED_REFERENCE.code, data: { ...data, ...messageData(UNRESOLVED_REFERENCE, params) } };
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* The declared target type of the reference this diagnostic came from, or
|
|
261
|
+
* `undefined` when the reflection cannot name one.
|
|
262
|
+
*
|
|
263
|
+
* **The lookup can throw, and that is the reason this is a method rather
|
|
264
|
+
* than an inline call.** `AbstractAstReflection.getReferenceType` raises on
|
|
265
|
+
* an unknown container `$type` and on a property that is not a reference —
|
|
266
|
+
* and the linking error whose type it cannot name is the one most likely to
|
|
267
|
+
* reach here, because `DefaultLinker` catches its OWN failed lookup and
|
|
268
|
+
* turns it into the exception-form message. Rethrowing would take
|
|
269
|
+
* `validateDocument` with it, since Langium wraps `processLinkingErrors` in
|
|
270
|
+
* no try: a diagnostic Langium degraded gracefully would become a failed
|
|
271
|
+
* build. Declining is also the right answer on the merits — a reference
|
|
272
|
+
* whose type cannot be named is not the message
|
|
273
|
+
* {@link UNRESOLVED_REFERENCE} claims.
|
|
274
|
+
*/
|
|
275
|
+
referenceTypeOf(containerType, property, refText) {
|
|
276
|
+
try {
|
|
277
|
+
return this.reflection.getReferenceType({
|
|
278
|
+
container: { $type: containerType },
|
|
279
|
+
property,
|
|
280
|
+
reference: { $refText: refText }
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
catch (err) {
|
|
284
|
+
this.tracer.debug(`cannot name the reference type for ${containerType}.${property}: ${describeError(err)}`);
|
|
285
|
+
return undefined;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
81
288
|
toDiagnostic(severity, message, info) {
|
|
82
289
|
const base = super.toDiagnostic(severity, message, info);
|
|
83
290
|
const node = info.node;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document-validator.js","sourceRoot":"","sources":["../../../src/langium/validation/document-validator.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,
|
|
1
|
+
{"version":3,"file":"document-validator.js","sourceRoot":"","sources":["../../../src/langium/validation/document-validator.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EACJ,aAAa,EACb,aAAa,EACb,WAAW,EAGX,eAAe,EAEf,kBAAkB,EACpB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAIJ,wBAAwB,EAExB,iBAAiB,EAMnB,MAAM,oBAAoB,CAAC;AAE5B,kEAAkE;AAClE,0EAA0E;AAC1E,yDAAyD;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAEzD,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAyBhE;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,aAAa,CAC9C,qCAAqC,EACrC,mEAAmE,CACrE,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,aAAa,CACtC,6BAA6B,EAC7B,0FAA0F,CAC5F,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,YAAY,GAAyB,IAAI,GAAG,CAAC;IAChD,iBAAiB,CAAC,WAAW;IAC7B,iBAAiB,CAAC,aAAa;IAC/B,iBAAiB,CAAC,UAAU;IAC5B,iBAAiB,CAAC,UAAU;CAC9B,CAAC,CAAC;AAkCH;;;;;;;;;;GAUG;AACH,MAAM,OAAO,0BAA2B,SAAQ,wBAAwB;IAClD,MAAM,CAAS;IACf,cAAc,CAAiB;IAC/B,UAAU,CAAgB;IAC1B,QAAQ,CAAgC;IACxC,UAAU,CAA0B;IACpC,wBAAwB,CAA2B;IACnD,sBAAsB,CAA2B;IAEpE,YAAY,QAA8D,EAAE,UAAoC,EAAE;QAC/G,KAAK,CAAC,QAAQ,CAAC,CAAC;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,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,IAAI,CAAC,UAAU,IAAK,EAAE,KAAK,EAAE,OAAO,EAAc,CAAC,CAAC;QACtI,MAAM,QAAQ,GAAG,UAAU,IAAI,aAAa,CAAC;QAC7C,IAAI,CAAC,QAAQ,EAAE,CAAC;YACb,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,2EAA2E,CAAC,CAAC;YAC9F,OAAO,EAAE,CAAC;QACb,CAAC;QACD,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS,IAAI,QAAQ,CAAC,QAAQ,CAAC,GAAG,kBAAkB,CAAC,uBAAuB,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC;YAC/G,OAAO,QAAQ,CAAC;QACnB,CAAC;QACD,OAAO,IAAI,CAAC,QAAQ;YACjB,CAAC,CAAC,GAAG,QAAQ,GAAG,kBAAkB,CAAC,yBAAyB,GAAG,IAAI,CAAC,QAAQ,GAAG,kBAAkB,CAAC,uBAAuB,GAAG,IAAI,CAAC,KAAK,EAAE;YACxI,CAAC,CAAC,GAAG,QAAQ,GAAG,kBAAkB,CAAC,uBAAuB,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC;IAChF,CAAC;CACH"}
|
|
@@ -91,10 +91,9 @@ export declare class DefaultDocumentUriPolicy implements DocumentUriPolicy {
|
|
|
91
91
|
/**
|
|
92
92
|
* No filesystem access, so existence cannot be checked — every URI is
|
|
93
93
|
* treated as loadable and returned unchanged. A later load that misses
|
|
94
|
-
* therefore reaches the filesystem and throws, which
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
* is what makes a missing file a placeholder rather than an error.
|
|
94
|
+
* therefore reaches the filesystem and throws, which reports the miss with
|
|
95
|
+
* the reason the read failed. Under a policy that CAN check, the miss is
|
|
96
|
+
* caught earlier and reported without one.
|
|
98
97
|
*/
|
|
99
98
|
loadUri(uri: URI | string): URI | undefined;
|
|
100
99
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document-uri-policy.d.ts","sourceRoot":"","sources":["../../../src/langium/workspace/document-uri-policy.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,KAAK,YAAY,EAAkB,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,KAAK,GAAG,EAAY,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,KAAK,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AAEzE;;;;;;;GAOG;AACH,MAAM,WAAW,yBAAyB;IACvC,QAAQ,CAAC,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,GAAG,SAAS,CAAC;CACvC;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,EAAE,EAAE,EAAE,yBAAyB,GAAG,GAAG,GAAG,SAAS,CAIxG;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,MAAM,WAAW,iBAAiB;IAC/B,YAAY,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,GAAG,YAAY,CAAC;IAC9C;;;;OAIG;IACH,OAAO,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,GAAG,GAAG,GAAG,SAAS,CAAC;CAC9C;AAED;;;;;GAKG;AACH,qBAAa,wBAAyB,YAAW,iBAAiB;IAC/D,YAAY,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,GAAG,YAAY;IAM7C
|
|
1
|
+
{"version":3,"file":"document-uri-policy.d.ts","sourceRoot":"","sources":["../../../src/langium/workspace/document-uri-policy.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,KAAK,YAAY,EAAkB,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,KAAK,GAAG,EAAY,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,KAAK,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AAEzE;;;;;;;GAOG;AACH,MAAM,WAAW,yBAAyB;IACvC,QAAQ,CAAC,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,GAAG,SAAS,CAAC;CACvC;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,EAAE,EAAE,EAAE,yBAAyB,GAAG,GAAG,GAAG,SAAS,CAIxG;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,MAAM,WAAW,iBAAiB;IAC/B,YAAY,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,GAAG,YAAY,CAAC;IAC9C;;;;OAIG;IACH,OAAO,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,GAAG,GAAG,GAAG,SAAS,CAAC;CAC9C;AAED;;;;;GAKG;AACH,qBAAa,wBAAyB,YAAW,iBAAiB;IAC/D,YAAY,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,GAAG,YAAY;IAM7C;;;;;;OAMG;IACH,OAAO,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,GAAG,GAAG,GAAG,SAAS;CAG7C;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,qBAAa,yBAA0B,SAAQ,wBAAwB;IACpE,SAAS,CAAC,QAAQ,CAAC,EAAE,EAAE,yBAAyB,CAAC;gBAErC,QAAQ,EAAE,2BAA2B;IAKxC,YAAY,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,GAAG,YAAY;IAQ7C,OAAO,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,GAAG,GAAG,GAAG,SAAS;CAStD"}
|
|
@@ -42,10 +42,9 @@ export class DefaultDocumentUriPolicy {
|
|
|
42
42
|
/**
|
|
43
43
|
* No filesystem access, so existence cannot be checked — every URI is
|
|
44
44
|
* treated as loadable and returned unchanged. A later load that misses
|
|
45
|
-
* therefore reaches the filesystem and throws, which
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
* is what makes a missing file a placeholder rather than an error.
|
|
45
|
+
* therefore reaches the filesystem and throws, which reports the miss with
|
|
46
|
+
* the reason the read failed. Under a policy that CAN check, the miss is
|
|
47
|
+
* caught earlier and reported without one.
|
|
49
48
|
*/
|
|
50
49
|
loadUri(uri) {
|
|
51
50
|
return UriUtils.toUri(uri);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document-uri-policy.js","sourceRoot":"","sources":["../../../src/langium/workspace/document-uri-policy.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAqB,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAY,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAexD;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,sBAAsB,CAAC,GAAiB,EAAE,EAA6B;IACpF,MAAM,MAAM,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACnC,MAAM,IAAI,GAAG,MAAM,IAAI,EAAE,CAAC,QAAQ,EAAE,CAAC,MAAM,CAAC,CAAC;IAC7C,OAAO,IAAI,IAAI,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,QAAQ,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;AAC1F,CAAC;AAgDD;;;;;GAKG;AACH,MAAM,OAAO,wBAAwB;IAClC,YAAY,CAAC,GAAiB;QAC3B,yEAAyE;QACzE,6EAA6E;QAC7E,OAAO,cAAc,CAAC,QAAQ,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;IAClD,CAAC;IAED
|
|
1
|
+
{"version":3,"file":"document-uri-policy.js","sourceRoot":"","sources":["../../../src/langium/workspace/document-uri-policy.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAqB,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAA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,CAAC,CAAC,CAAC,cAAc,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;IACpF,CAAC;IAEQ,OAAO,CAAC,GAAiB;QAC/B,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC;YACrB,OAAO,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAC7B,CAAC;QACD,MAAM,MAAM,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACnC,kEAAkE;QAClE,yEAAyE;QACzE,OAAO,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;IACrD,CAAC;CACH"}
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* SPDX-License-Identifier: MIT
|
|
8
8
|
********************************************************************************/
|
|
9
9
|
import { type AstNode, DefaultLangiumDocumentFactory, type LangiumDocument, type URI } from '@hydranium/langium';
|
|
10
|
+
import { type ExtendedServiceRegistry } from '../service-registry.js';
|
|
10
11
|
/**
|
|
11
12
|
* Framework `LangiumDocumentFactory` that fills in the one thing Langium
|
|
12
13
|
* leaves empty for a code-built document: its text.
|
|
@@ -34,6 +35,30 @@ import { type AstNode, DefaultLangiumDocumentFactory, type LangiumDocument, type
|
|
|
34
35
|
* node identity is preserved.
|
|
35
36
|
*/
|
|
36
37
|
export declare class HydraniumLangiumDocumentFactory extends DefaultLangiumDocumentFactory {
|
|
38
|
+
/**
|
|
39
|
+
* Narrows the inherited Langium `ServiceRegistry` field to the framework's
|
|
40
|
+
* {@link ExtendedServiceRegistry}, so the by-id lookup below needs no
|
|
41
|
+
* per-callsite cast. The framework's shared module binds that class.
|
|
42
|
+
*/
|
|
43
|
+
protected readonly serviceRegistry: ExtendedServiceRegistry;
|
|
44
|
+
/**
|
|
45
|
+
* Parse `text` for `uri` under the grammar `languageId` names, instead of
|
|
46
|
+
* the one `uri` routes to.
|
|
47
|
+
*
|
|
48
|
+
* For a URI that routes to no grammar at all: a directory, or any other URI
|
|
49
|
+
* that names no file and so carries no extension. Langium's ladder ends at
|
|
50
|
+
* the extension, so it reports `no services for the extension ''` from
|
|
51
|
+
* inside the parse — naming neither the URI nor the caller that could have
|
|
52
|
+
* said which grammar it meant.
|
|
53
|
+
*
|
|
54
|
+
* The caller supplies the language because nothing else can. A URI with no
|
|
55
|
+
* extension carries no routing signal, and choosing on its behalf would be a
|
|
56
|
+
* guess the moment a second grammar is registered — which is why this takes
|
|
57
|
+
* the id rather than falling back to a sole registered language.
|
|
58
|
+
*
|
|
59
|
+
* @throws when `languageId` names no registered grammar.
|
|
60
|
+
*/
|
|
61
|
+
fromStringInLanguage<T extends AstNode = AstNode>(text: string, uri: URI, languageId: string): LangiumDocument<T>;
|
|
37
62
|
fromModel<T extends AstNode = AstNode>(model: T, uri: URI): LangiumDocument<T>;
|
|
38
63
|
/**
|
|
39
64
|
* Serialize `model` via the per-language serializer, or `undefined` if none
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hydranium-langium-document-factory.d.ts","sourceRoot":"","sources":["../../../src/langium/workspace/hydranium-langium-document-factory.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EACJ,KAAK,OAAO,EAEZ,6BAA6B,EAC7B,KAAK,eAAe,EAEpB,KAAK,GAAG,EACV,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"hydranium-langium-document-factory.d.ts","sourceRoot":"","sources":["../../../src/langium/workspace/hydranium-langium-document-factory.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EACJ,KAAK,OAAO,EAEZ,6BAA6B,EAC7B,KAAK,eAAe,EAEpB,KAAK,GAAG,EACV,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,KAAK,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAQtE;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,qBAAa,+BAAgC,SAAQ,6BAA6B;IAC/E;;;;OAIG;IACH,mBAA2B,eAAe,EAAE,uBAAuB,CAAC;IAEpE;;;;;;;;;;;;;;;;OAgBG;IACH,oBAAoB,CAAC,CAAC,SAAS,OAAO,GAAG,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,GAAG,eAAe,CAAC,CAAC,CAAC;IASxG,SAAS,CAAC,CAAC,SAAS,OAAO,GAAG,OAAO,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,GAAG,GAAG,eAAe,CAAC,CAAC,CAAC;IAYvF;;;;OAIG;IACH,SAAS,CAAC,cAAc,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,GAAG,MAAM,GAAG,SAAS;CASxE"}
|
|
@@ -34,6 +34,31 @@ import { AstUtils, DefaultLangiumDocumentFactory } from '@hydranium/langium';
|
|
|
34
34
|
* node identity is preserved.
|
|
35
35
|
*/
|
|
36
36
|
export class HydraniumLangiumDocumentFactory extends DefaultLangiumDocumentFactory {
|
|
37
|
+
/**
|
|
38
|
+
* Parse `text` for `uri` under the grammar `languageId` names, instead of
|
|
39
|
+
* the one `uri` routes to.
|
|
40
|
+
*
|
|
41
|
+
* For a URI that routes to no grammar at all: a directory, or any other URI
|
|
42
|
+
* that names no file and so carries no extension. Langium's ladder ends at
|
|
43
|
+
* the extension, so it reports `no services for the extension ''` from
|
|
44
|
+
* inside the parse — naming neither the URI nor the caller that could have
|
|
45
|
+
* said which grammar it meant.
|
|
46
|
+
*
|
|
47
|
+
* The caller supplies the language because nothing else can. A URI with no
|
|
48
|
+
* extension carries no routing signal, and choosing on its behalf would be a
|
|
49
|
+
* guess the moment a second grammar is registered — which is why this takes
|
|
50
|
+
* the id rather than falling back to a sole registered language.
|
|
51
|
+
*
|
|
52
|
+
* @throws when `languageId` names no registered grammar.
|
|
53
|
+
*/
|
|
54
|
+
fromStringInLanguage(text, uri, languageId) {
|
|
55
|
+
const services = this.serviceRegistry.getServicesById(languageId);
|
|
56
|
+
if (!services) {
|
|
57
|
+
throw new Error(`No grammar is registered for the language id '${languageId}' (parsing ${uri.toString()}).`);
|
|
58
|
+
}
|
|
59
|
+
const parseResult = services.parser.LangiumParser.parse(text);
|
|
60
|
+
return this.createLangiumDocument(parseResult, uri, undefined, text);
|
|
61
|
+
}
|
|
37
62
|
fromModel(model, uri) {
|
|
38
63
|
// Make the code-built AST as structurally complete as a parsed one — the
|
|
39
64
|
// parser links containers, `fromModel` does not. In place (identity kept).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hydranium-langium-document-factory.js","sourceRoot":"","sources":["../../../src/langium/workspace/hydranium-langium-document-factory.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAEJ,QAAQ,EACR,6BAA6B,EAI/B,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"hydranium-langium-document-factory.js","sourceRoot":"","sources":["../../../src/langium/workspace/hydranium-langium-document-factory.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAEJ,QAAQ,EACR,6BAA6B,EAI/B,MAAM,oBAAoB,CAAC;AAS5B;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,OAAO,+BAAgC,SAAQ,6BAA6B;IAQ/E;;;;;;;;;;;;;;;;OAgBG;IACH,oBAAoB,CAA8B,IAAY,EAAE,GAAQ,EAAE,UAAkB;QACzF,MAAM,QAAQ,GAAG,IAAI,CAAC,eAAe,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC;QAClE,IAAI,CAAC,QAAQ,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,iDAAiD,UAAU,cAAc,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QAChH,CAAC;QACD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