@hydranium/core 1.0.0-next.31 → 1.0.0-next.33
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/hydranium-text-documents.d.ts.map +1 -1
- package/lib/documents/hydranium-text-documents.js +12 -1
- package/lib/documents/hydranium-text-documents.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/langium/bootstrap.d.ts.map +1 -1
- package/lib/langium/bootstrap.js +8 -1
- package/lib/langium/bootstrap.js.map +1 -1
- package/lib/langium/document-builder/document-builder.d.ts +33 -1
- package/lib/langium/document-builder/document-builder.d.ts.map +1 -1
- package/lib/langium/document-builder/document-builder.js +68 -2
- package/lib/langium/document-builder/document-builder.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 +39 -2
- package/lib/langium/model-service/model-service.d.ts.map +1 -1
- package/lib/langium/model-service/model-service.js +44 -5
- package/lib/langium/model-service/model-service.js.map +1 -1
- package/lib/langium/module.d.ts +20 -0
- package/lib/langium/module.d.ts.map +1 -1
- package/lib/langium/module.js +4 -0
- 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 -1
- package/lib/langium/naming/name-separator-validation.d.ts.map +1 -1
- package/lib/langium/naming/name-separator-validation.js +22 -0
- package/lib/langium/naming/name-separator-validation.js.map +1 -1
- package/lib/langium/shared-services.d.ts +13 -2
- package/lib/langium/shared-services.d.ts.map +1 -1
- package/lib/langium/shared-services.js.map +1 -1
- package/lib/langium/validation/document-validator.d.ts +128 -2
- 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/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/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/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 +59 -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/messages/carriers.d.ts +15 -7
- package/lib/messages/carriers.d.ts.map +1 -1
- package/lib/messages/carriers.js +19 -8
- package/lib/messages/carriers.js.map +1 -1
- package/lib/messages/index.d.ts +3 -0
- package/lib/messages/index.d.ts.map +1 -1
- package/lib/messages/index.js +3 -0
- package/lib/messages/index.js.map +1 -1
- package/lib/messages/renderer.d.ts +117 -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/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 +27 -0
- package/lib/testing/make-test-services.d.ts.map +1 -1
- package/lib/testing/make-test-services.js +17 -1
- package/lib/testing/make-test-services.js.map +1 -1
- package/package.json +5 -5
- package/src/documents/hydranium-text-documents.ts +12 -1
- package/src/index.ts +1 -0
- package/src/langium/bootstrap.ts +8 -1
- package/src/langium/document-builder/document-builder.ts +70 -2
- 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 +46 -4
- package/src/langium/module.ts +22 -0
- package/src/langium/naming/name-provider.ts +10 -0
- package/src/langium/naming/name-separator-validation.ts +25 -3
- package/src/langium/shared-services.ts +13 -2
- package/src/langium/validation/document-validator.ts +238 -4
- package/src/langium/workspace/hydranium-workspace-manager.ts +30 -1
- package/src/langium/workspace/initialize-workspace.ts +34 -5
- package/src/locale/index.ts +10 -0
- package/src/locale/server-locale.ts +71 -0
- package/src/messages/carriers.ts +20 -10
- package/src/messages/index.ts +3 -0
- package/src/messages/renderer.ts +184 -0
- package/src/testing/make-noop-shared-services.ts +50 -2
- package/src/testing/make-test-services.ts +43 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"name-provider.js","sourceRoot":"","sources":["../../../src/langium/naming/name-provider.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,6BAA6B,EAAE,MAAM,qBAAqB,CAAC;AAC9F,OAAO,EAEJ,QAAQ,EAER,aAAa,EACb,YAAY,EAGd,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"name-provider.js","sourceRoot":"","sources":["../../../src/langium/naming/name-provider.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AA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AAC,OAAO,CAAC,CAAC;QAChD,MAAM,UAAU,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,YAAY,CAAC,WAAW,CAAC,IAAI,CAAC;aAC5E,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;aACvD,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC;aACpC,OAAO,EAAE,CAAC;QACd,OAAO,cAAc,CAAC,QAAQ,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;IACzD,CAAC;IAED;;;;;OAKG;IACO,kBAAkB,CAAC,OAAyB;QACnD,MAAM,QAAQ,GAAG,OAAO,EAAE,kBAAkB,CAAC;QAC7C,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;YAC1B,OAAO,GAAG,EAAE,CAAC,KAAK,CAAC;QACtB,CAAC;QACD,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,iBAAiB,CAAC,YAAY,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAC;QAClG,OAAO,WAAW,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,iBAAiB,CAAC,YAAY,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC,KAAK,MAAM,CAAC;IAC1H,CAAC;CACH"}
|
|
@@ -7,10 +7,32 @@
|
|
|
7
7
|
* SPDX-License-Identifier: MIT
|
|
8
8
|
********************************************************************************/
|
|
9
9
|
import { type AstNode, type ValidationAcceptor } from '@hydranium/langium';
|
|
10
|
-
export declare const SEPARATOR_IN_NAME: import("@hydranium/protocol").MessageDefinition<"Name '{name}' contains the configured name separator '{separator}', which is reserved for qualified-name composition — use a different character.">;
|
|
11
10
|
import { type ServerLanguageServices } from '../language-module.js';
|
|
12
11
|
import { type ValidationCheckContribution, type ValidationCheckRegistry } from '../validation/validation-contribution.js';
|
|
13
12
|
import type { NameProvider } from './name-provider.js';
|
|
13
|
+
/**
|
|
14
|
+
* A name value that collides with the qualified-name separator.
|
|
15
|
+
*
|
|
16
|
+
* **The sentence addresses a MODELLER, and the remedy it names is theirs**:
|
|
17
|
+
* where `name` really is the identifier, a different character is the fix and
|
|
18
|
+
* the only one available to whoever is typing.
|
|
19
|
+
*
|
|
20
|
+
* **The adopter-facing failure is a different one, and this message cannot
|
|
21
|
+
* carry it.** With `nameProperties` left at its default `['name']` over a
|
|
22
|
+
* grammar where `name` is a display LABEL — a `STRING` legitimately holding
|
|
23
|
+
* `"Order.Line"` — this fires on every dotted label at once, and "use a
|
|
24
|
+
* different character" is then advice nobody can act on: the content is
|
|
25
|
+
* correct and the configuration is not. A burst of this diagnostic across
|
|
26
|
+
* unrelated nodes is that misconfiguration, not a naming problem, and the fix
|
|
27
|
+
* is `nameProperties`. Widening the sentence to say both was rejected: a
|
|
28
|
+
* modeller cannot act on a DI option, and naming one in an editor squiggle
|
|
29
|
+
* teaches the wrong audience.
|
|
30
|
+
*
|
|
31
|
+
* Unreachable from a grammar whose identifier charset excludes the separator,
|
|
32
|
+
* which is every example here and the reference adopter — so it reads as dead
|
|
33
|
+
* and is not: it guards the configuration, not the content.
|
|
34
|
+
*/
|
|
35
|
+
export declare const SEPARATOR_IN_NAME: import("@hydranium/protocol").MessageDefinition<"Name '{name}' contains the configured name separator '{separator}', which is reserved for qualified-name composition — use a different character.">;
|
|
14
36
|
/**
|
|
15
37
|
* Per-node validation check: flag name-bearing AST nodes whose name
|
|
16
38
|
* value contains the configured name separator. Such values produce
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"name-separator-validation.d.ts","sourceRoot":"","sources":["../../../src/langium/naming/name-separator-validation.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,kBAAkB,EAAyB,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"name-separator-validation.d.ts","sourceRoot":"","sources":["../../../src/langium/naming/name-separator-validation.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,kBAAkB,EAAyB,MAAM,oBAAoB,CAAC;AAGlG,OAAO,EAAE,KAAK,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,EAAE,KAAK,2BAA2B,EAAE,KAAK,uBAAuB,EAAE,MAAM,0CAA0C,CAAC;AAC1H,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,iBAAiB,sMAG7B,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,kBAAkB,CAAC,YAAY,EAAE,YAAY,GAAG,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,kBAAkB,KAAK,IAAI,CAelH;AAED;;;;;;;;;GASG;AACH,qBAAa,8BAA+B,YAAW,2BAA2B;IAC/E,SAAS,CAAC,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;gBAElC,QAAQ,EAAE,sBAAsB;IAI5C,wBAAwB,CAAC,QAAQ,EAAE,uBAAuB,GAAG,IAAI;CAMnE"}
|
|
@@ -8,6 +8,28 @@
|
|
|
8
8
|
********************************************************************************/
|
|
9
9
|
import { defineMessage } from '@hydranium/protocol';
|
|
10
10
|
import { acceptMessage } from '../../messages/carriers.js';
|
|
11
|
+
/**
|
|
12
|
+
* A name value that collides with the qualified-name separator.
|
|
13
|
+
*
|
|
14
|
+
* **The sentence addresses a MODELLER, and the remedy it names is theirs**:
|
|
15
|
+
* where `name` really is the identifier, a different character is the fix and
|
|
16
|
+
* the only one available to whoever is typing.
|
|
17
|
+
*
|
|
18
|
+
* **The adopter-facing failure is a different one, and this message cannot
|
|
19
|
+
* carry it.** With `nameProperties` left at its default `['name']` over a
|
|
20
|
+
* grammar where `name` is a display LABEL — a `STRING` legitimately holding
|
|
21
|
+
* `"Order.Line"` — this fires on every dotted label at once, and "use a
|
|
22
|
+
* different character" is then advice nobody can act on: the content is
|
|
23
|
+
* correct and the configuration is not. A burst of this diagnostic across
|
|
24
|
+
* unrelated nodes is that misconfiguration, not a naming problem, and the fix
|
|
25
|
+
* is `nameProperties`. Widening the sentence to say both was rejected: a
|
|
26
|
+
* modeller cannot act on a DI option, and naming one in an editor squiggle
|
|
27
|
+
* teaches the wrong audience.
|
|
28
|
+
*
|
|
29
|
+
* Unreachable from a grammar whose identifier charset excludes the separator,
|
|
30
|
+
* which is every example here and the reference adopter — so it reads as dead
|
|
31
|
+
* and is not: it guards the configuration, not the content.
|
|
32
|
+
*/
|
|
11
33
|
export const SEPARATOR_IN_NAME = defineMessage('hydranium/core/separator-in-name', "Name '{name}' contains the configured name separator '{separator}', which is reserved for qualified-name composition — use a different character.");
|
|
12
34
|
/**
|
|
13
35
|
* Per-node validation check: flag name-bearing AST nodes whose name
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"name-separator-validation.js","sourceRoot":"","sources":["../../../src/langium/naming/name-separator-validation.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAGlF,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"name-separator-validation.js","sourceRoot":"","sources":["../../../src/langium/naming/name-separator-validation.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAGlF,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAK3D;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,aAAa,CAC3C,kCAAkC,EAClC,mJAAmJ,CACrJ,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,kBAAkB,CAAC,YAA0B;IAC1D,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE;QACrB,MAAM,OAAO,GAAG,YAAY,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QAC9C,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACvD,OAAO;QACV,CAAC;QACD,MAAM,SAAS,GAAG,YAAY,CAAC,aAAa,CAAC;QAC7C,IAAI,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;YAC/B,kEAAkE;YAClE,mEAAmE;YACnE,wEAAwE;YACxE,+DAA+D;YAC/D,aAAa,CAAC,MAAM,EAAE,OAAO,EAAE,iBAAiB,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC,CAAC;QAC7F,CAAC;IACJ,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,OAAO,8BAA8B;IACrB,YAAY,CAAe;IAE9C,YAAY,QAAgC;QACzC,IAAI,CAAC,YAAY,GAAG,QAAQ,CAAC,UAAU,CAAC,YAAY,CAAC;IACxD,CAAC;IAED,wBAAwB,CAAC,QAAiC;QACvD,MAAM,MAAM,GAA2C;YACpD,OAAO,EAAE,kBAAkB,CAAC,IAAI,CAAC,YAAY,CAAC;SAChD,CAAC;QACF,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC7B,CAAC;CACH"}
|
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
********************************************************************************/
|
|
9
9
|
import type { Clock, Logger, Project, Tracer } from '@hydranium/protocol';
|
|
10
10
|
import type { LangiumSharedCoreServices } from '@hydranium/langium';
|
|
11
|
+
import type { ServerLocale } from '../locale/server-locale.js';
|
|
12
|
+
import type { ServerMessageRenderer } from '../messages/renderer.js';
|
|
11
13
|
import type { SelfSaveRegistry } from '../documents/self-save-registry.js';
|
|
12
14
|
import type { WritableFileSystemProvider } from '../documents/ast-document-manager.js';
|
|
13
15
|
import type { HydraniumDocumentRegistry } from './workspace/langium-documents.js';
|
|
@@ -26,8 +28,9 @@ import type { AdditionalDocumentContribution } from './workspace/additional-docu
|
|
|
26
28
|
* framework additions that other framework services consume: the dedicated
|
|
27
29
|
* {@link Clock}, {@link Logger} and {@link Tracer} top-level slots (injectable
|
|
28
30
|
* time source, emission-only logger, and the measure-and-emit tracer composed
|
|
29
|
-
* from the other two), the {@link AdditionalDocumentContribution} group,
|
|
30
|
-
* {@link
|
|
31
|
+
* from the other two), the {@link AdditionalDocumentContribution} group, the
|
|
32
|
+
* {@link ServerMessageRenderer} and the {@link ServerLocale} it renders in,
|
|
33
|
+
* an {@link ExtendedServiceRegistry}, and on `workspace` a writable file-system
|
|
31
34
|
* provider plus {@link HydraniumWorkspaceManager}, {@link ProjectManager},
|
|
32
35
|
* {@link SelfSaveRegistry}, {@link BuildPipelineIntegration},
|
|
33
36
|
* {@link BuildPhasePassService}, {@link CstResidencyService} and
|
|
@@ -56,6 +59,14 @@ export interface ServerSharedServicesMinimal<TProject extends Project = Project>
|
|
|
56
59
|
* adopters deep-merge contributions that seed built-in / stdlib documents.
|
|
57
60
|
*/
|
|
58
61
|
additionalDocuments: Record<string, AdditionalDocumentContribution>;
|
|
62
|
+
/**
|
|
63
|
+
* Renders each user-facing message once, before the server sends it. On the
|
|
64
|
+
* shared tier with no workspace dependency, because all three heads'
|
|
65
|
+
* messages pass through it.
|
|
66
|
+
*/
|
|
67
|
+
MessageRenderer: ServerMessageRenderer;
|
|
68
|
+
/** The locale an init handed the server, for whoever renders in it. */
|
|
69
|
+
ServerLocale: ServerLocale;
|
|
59
70
|
/**
|
|
60
71
|
* Narrows Langium's base `ServiceRegistry` slot to the framework impl the
|
|
61
72
|
* framework always binds, so the abstaining lookups — `getServicesFor`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared-services.d.ts","sourceRoot":"","sources":["../../src/langium/shared-services.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC1E,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AACvF,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;AAClF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gDAAgD,CAAC;AAC5F,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAChF,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,kDAAkD,CAAC;AACjG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AAC5E,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,4CAA4C,CAAC;AAC5F,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,iDAAiD,CAAC;AAEtG
|
|
1
|
+
{"version":3,"file":"shared-services.d.ts","sourceRoot":"","sources":["../../src/langium/shared-services.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC1E,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,KAAK,E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B,EAAE,yBAAyB,CAAC;QAK7B,gBAAgB,EAAE,yBAAyB,CAAC;QAC3D,cAAc,EAAE,cAAc,CAAC,QAAQ,CAAC,CAAC;QACzC,gBAAgB,EAAE,gBAAgB,CAAC;QACnC,wBAAwB,EAAE,wBAAwB,CAAC;QACnD,qBAAqB,EAAE,qBAAqB,CAAC;QAC7C,mBAAmB,EAAE,mBAAmB,CAAC;QACzC,iBAAiB,EAAE,iBAAiB,CAAC;KACvC,CAAC;CACJ;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC,QAAQ,EAAE,2BAA2B,KAAK,OAAO,GAAG,CAAC,QAAQ,EAAE,OAAO,KAAK,OAAO,CAEvI"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared-services.js","sourceRoot":"","sources":["../../src/langium/shared-services.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;
|
|
1
|
+
{"version":3,"file":"shared-services.js","sourceRoot":"","sources":["../../src/langium/shared-services.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAgGlF;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,mBAAmB,CAAU,MAA0D;IACpG,OAAO,QAAQ,CAAC,EAAE,CAAC,MAAM,CAAC,QAAuC,CAAC,CAAC;AACtE,CAAC"}
|
|
@@ -7,9 +7,9 @@
|
|
|
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
15
|
* Diagnostic read off a `LangiumDocument`: an LSP {@link Diagnostic} that MAY
|
|
@@ -33,6 +33,48 @@ export interface TransferLspDiagnostic extends Diagnostic {
|
|
|
33
33
|
element?: string;
|
|
34
34
|
property?: string;
|
|
35
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.">;
|
|
36
78
|
export interface DocumentValidatorOptions extends LogNameOptions {
|
|
37
79
|
/**
|
|
38
80
|
* Level at which the `validateDocument` timing line is emitted, or `'off'`
|
|
@@ -78,6 +120,7 @@ export interface DocumentValidatorOptions extends LogNameOptions {
|
|
|
78
120
|
export declare class HydraniumDocumentValidator extends DefaultDocumentValidator {
|
|
79
121
|
protected readonly tracer: Tracer;
|
|
80
122
|
protected readonly astNodeLocator: AstNodeLocator;
|
|
123
|
+
protected readonly reflection: AstReflection;
|
|
81
124
|
protected readonly logLevel: ObservableValue<LogThreshold>;
|
|
82
125
|
protected readonly logAfterMs: ObservableValue<number>;
|
|
83
126
|
protected readonly validateVirtualDocuments: ObservableValue<boolean>;
|
|
@@ -88,6 +131,41 @@ export declare class HydraniumDocumentValidator extends DefaultDocumentValidator
|
|
|
88
131
|
};
|
|
89
132
|
}, options?: DocumentValidatorOptions);
|
|
90
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;
|
|
91
169
|
/**
|
|
92
170
|
* Skip validation for a node **and its children** when
|
|
93
171
|
* {@link shouldSkipValidation} returns true.
|
|
@@ -102,6 +180,54 @@ export declare class HydraniumDocumentValidator extends DefaultDocumentValidator
|
|
|
102
180
|
* `super.shouldSkipValidation(node) || ...`.
|
|
103
181
|
*/
|
|
104
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;
|
|
105
231
|
protected toDiagnostic<N extends AstNode>(severity: ValidationSeverity, message: string, info: DiagnosticInfo<N, string>): TransferLspDiagnostic;
|
|
106
232
|
/**
|
|
107
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;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AAO,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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