@hydranium/core 1.0.0-next.30 → 1.0.0-next.32
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/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 +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/model-service/model-service.d.ts +26 -0
- package/lib/langium/model-service/model-service.d.ts.map +1 -1
- package/lib/langium/model-service/model-service.js +31 -3
- 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/scope/hydranium-scope-provider.d.ts +10 -6
- package/lib/langium/scope/hydranium-scope-provider.d.ts.map +1 -1
- package/lib/langium/scope/hydranium-scope-provider.js +15 -11
- package/lib/langium/scope/hydranium-scope-provider.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 +66 -1
- package/lib/langium/validation/document-validator.d.ts.map +1 -1
- package/lib/langium/validation/document-validator.js +101 -1
- package/lib/langium/validation/document-validator.js.map +1 -1
- package/lib/langium/workspace/hydranium-workspace-manager.d.ts +11 -1
- package/lib/langium/workspace/hydranium-workspace-manager.d.ts.map +1 -1
- package/lib/langium/workspace/hydranium-workspace-manager.js +15 -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 +49 -0
- package/lib/locale/server-locale.d.ts.map +1 -0
- package/lib/locale/server-locale.js +51 -0
- package/lib/locale/server-locale.js.map +1 -0
- package/lib/messages/carriers.d.ts +7 -6
- package/lib/messages/carriers.d.ts.map +1 -1
- package/lib/messages/carriers.js +8 -7
- 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/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 +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/ast-extension/ast-node-builder.ts +66 -22
- package/src/langium/bootstrap.ts +8 -1
- package/src/langium/document-builder/document-builder.ts +70 -2
- package/src/langium/model-service/model-service.ts +33 -2
- 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/scope/hydranium-scope-provider.ts +15 -11
- package/src/langium/shared-services.ts +13 -2
- package/src/langium/validation/document-validator.ts +117 -1
- package/src/langium/workspace/hydranium-workspace-manager.ts +18 -1
- package/src/langium/workspace/initialize-workspace.ts +34 -5
- package/src/locale/index.ts +10 -0
- package/src/locale/server-locale.ts +61 -0
- package/src/messages/carriers.ts +8 -8
- package/src/messages/index.ts +3 -0
- package/src/messages/renderer.ts +184 -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 +43 -1
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2026 CrossBreeze, EclipseSource and others.
|
|
3
|
+
*
|
|
4
|
+
* This program and the accompanying materials are made available under the
|
|
5
|
+
* terms of the MIT License which is available in the project root.
|
|
6
|
+
*
|
|
7
|
+
* SPDX-License-Identifier: MIT
|
|
8
|
+
********************************************************************************/
|
|
9
|
+
import { describeError, renderFrameworkMessage, resolve, resolvedFromResponseError } from '@hydranium/protocol';
|
|
10
|
+
import { SimpleCache } from '@hydranium/langium';
|
|
11
|
+
import { Diagnostic } from 'vscode-languageserver-protocol';
|
|
12
|
+
import { resolvedFromDiagnostic } from './carriers.js';
|
|
13
|
+
/**
|
|
14
|
+
* Renders every user-facing message the server sends, in the locale the server
|
|
15
|
+
* was handed at init. The framework ships no catalogue, so its own behaviour is
|
|
16
|
+
* a pass-through.
|
|
17
|
+
*
|
|
18
|
+
* Adopters override {@link translationsFor}: the public render methods carry
|
|
19
|
+
* the no-throw contract, and the catalogue lookup they wrap is what can fail.
|
|
20
|
+
*
|
|
21
|
+
* Two render methods rather than one, because what is useful to an adopter is
|
|
22
|
+
* the carrier's structured fields and the two carriers have different ones. A
|
|
23
|
+
* single `render(text)` would force an adopter to match English prose, which
|
|
24
|
+
* breaks on the first Langium reword.
|
|
25
|
+
*/
|
|
26
|
+
export class ServerMessageRenderer {
|
|
27
|
+
tracer;
|
|
28
|
+
serverLocale;
|
|
29
|
+
/**
|
|
30
|
+
* {@link translationsFor}'s answer per locale, `undefined` answers included —
|
|
31
|
+
* a `SimpleCache` distinguishes "absent" from "cached as none", which matters
|
|
32
|
+
* because shipping no catalogue is the framework's own hot path.
|
|
33
|
+
*
|
|
34
|
+
* `SimpleCache` rather than Langium's `WorkspaceCache`: the eviction axis
|
|
35
|
+
* there is document change, and a catalogue does not depend on documents, so
|
|
36
|
+
* it would evict on every build AND put a `DocumentBuilder` dependency on a
|
|
37
|
+
* service the shared tier declares free of one. Nothing evicts this: the
|
|
38
|
+
* locale arrives once per process. A subclass whose catalogue can change
|
|
39
|
+
* clears it.
|
|
40
|
+
*/
|
|
41
|
+
catalogues = new SimpleCache();
|
|
42
|
+
constructor(services, options = {}) {
|
|
43
|
+
this.serverLocale = services.ServerLocale;
|
|
44
|
+
this.tracer = services.Tracer.for(options.logName ?? 'MessageRenderer').trace('instantiated');
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* The sentence to publish for `diagnostic`, replacing its current `message`.
|
|
48
|
+
* Sees lexer and parser errors too, which Langium pushes onto the document
|
|
49
|
+
* without routing them through `toDiagnostic`.
|
|
50
|
+
*
|
|
51
|
+
* **Must not throw**, which is why the guard is here and not at the call
|
|
52
|
+
* site: this runs inside the `Validated` phase, and Langium's
|
|
53
|
+
* `notifyDocumentPhase` rethrows anything that is not a cancellation — so an
|
|
54
|
+
* escaping error leaves the document AT `Validated` with the phase's
|
|
55
|
+
* listeners never run, and the client receives no diagnostics for that file.
|
|
56
|
+
* A subclass overriding this method takes that contract on itself.
|
|
57
|
+
*/
|
|
58
|
+
renderDiagnostic(diagnostic) {
|
|
59
|
+
try {
|
|
60
|
+
const resolved = resolvedFromDiagnostic(diagnostic);
|
|
61
|
+
return resolved ? this.render(resolved) : Diagnostic.getMessageString(diagnostic);
|
|
62
|
+
}
|
|
63
|
+
catch (err) {
|
|
64
|
+
this.reportFailure(err, 'a diagnostic');
|
|
65
|
+
return Diagnostic.getMessageString(diagnostic);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* The sentence to send for `error`, replacing its current `message`. Same
|
|
70
|
+
* no-throw contract as {@link renderDiagnostic}: an escaping error replaces a
|
|
71
|
+
* typed rejection the caller can handle with one it cannot.
|
|
72
|
+
*/
|
|
73
|
+
renderError(error) {
|
|
74
|
+
try {
|
|
75
|
+
const resolved = resolvedFromResponseError(error);
|
|
76
|
+
return resolved ? this.render(resolved) : error.message;
|
|
77
|
+
}
|
|
78
|
+
catch (err) {
|
|
79
|
+
this.reportFailure(err, 'an RPC error');
|
|
80
|
+
return error.message;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* The sentence for a declaration the caller holds directly, for a carrier
|
|
85
|
+
* with no slot to put an identity in.
|
|
86
|
+
*
|
|
87
|
+
* GLSP's action protocol is the case: every member of its message, status
|
|
88
|
+
* and reject actions is prose or an enum, so a code cannot travel and the
|
|
89
|
+
* raise site is the last place that still knows which message this is.
|
|
90
|
+
* Prefer {@link renderDiagnostic} / {@link renderError} wherever a carrier
|
|
91
|
+
* does hold the identity — they keep the render off the raise site, so an
|
|
92
|
+
* adopter's own messages ride the same one binding.
|
|
93
|
+
*
|
|
94
|
+
* Same no-throw contract as the carrier methods.
|
|
95
|
+
*/
|
|
96
|
+
renderMessage(message, ...params) {
|
|
97
|
+
// `resolve` is inside the guard with the render, not before it: it calls
|
|
98
|
+
// the declaration's own `format`, which for an adopter declaration is
|
|
99
|
+
// arbitrary code, and a throw there would escape a method whose contract
|
|
100
|
+
// says it cannot.
|
|
101
|
+
let resolved;
|
|
102
|
+
try {
|
|
103
|
+
resolved = resolve(message, ...params);
|
|
104
|
+
return this.render(resolved);
|
|
105
|
+
}
|
|
106
|
+
catch (err) {
|
|
107
|
+
this.reportFailure(err, `the message '${message.code}'`);
|
|
108
|
+
// Unset only when `format` ITSELF threw, which leaves the
|
|
109
|
+
// uninterpolated template as the only text there is. A failed render
|
|
110
|
+
// still has the resolved English.
|
|
111
|
+
return resolved?.text ?? message.text;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* The catalogue for the current locale, or `undefined` for none — the
|
|
116
|
+
* framework's answer, shipping none. Overriding this leaves every identity
|
|
117
|
+
* decision, every pass-through and the no-throw guard in place.
|
|
118
|
+
*
|
|
119
|
+
* **Called once per locale, not once per message**, so an override may load
|
|
120
|
+
* a file or build a map without that cost landing per diagnostic. The
|
|
121
|
+
* corollary is that a catalogue mutated in place afterwards is not seen;
|
|
122
|
+
* clear {@link catalogues} to invalidate.
|
|
123
|
+
*
|
|
124
|
+
* An adopter wanting Langium's own uncoded sentences instead matches
|
|
125
|
+
* `Diagnostic.data.code` from an overridden {@link renderDiagnostic}, never
|
|
126
|
+
* the sentence.
|
|
127
|
+
*/
|
|
128
|
+
translationsFor(_locale) {
|
|
129
|
+
return undefined;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Resolve one identity against the current locale's catalogue.
|
|
133
|
+
*
|
|
134
|
+
* Reads the locale per call. Copying it into a field at construction pins
|
|
135
|
+
* whatever was there before init ran, which is always `undefined` — services
|
|
136
|
+
* compose first.
|
|
137
|
+
*
|
|
138
|
+
* The catalogue behind it is memoized, because a workspace-wide validation
|
|
139
|
+
* renders once per diagnostic and the naive override — parse a JSON file,
|
|
140
|
+
* build a map — then pays that per diagnostic rather than per locale.
|
|
141
|
+
*/
|
|
142
|
+
render(message) {
|
|
143
|
+
const locale = this.serverLocale.value;
|
|
144
|
+
return renderFrameworkMessage(message, this.catalogues.get(locale, () => this.translationsFor(locale)));
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Emit a failed render. Logged rather than swallowed: the fallback output is
|
|
148
|
+
* byte-identical to a correctly-configured default, so a throwing catalogue
|
|
149
|
+
* is otherwise invisible.
|
|
150
|
+
*/
|
|
151
|
+
reportFailure(err, carrier) {
|
|
152
|
+
this.tracer.error(this.formatRenderFailure(err, carrier));
|
|
153
|
+
}
|
|
154
|
+
/** Format the failed-render line. Override to name the adopter's catalogue entry. */
|
|
155
|
+
formatRenderFailure(err, carrier) {
|
|
156
|
+
return `rendering ${carrier} failed; falling back to the server's own text. ${describeError(err)}`;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
//# sourceMappingURL=renderer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderer.js","sourceRoot":"","sources":["../../src/messages/renderer.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EACJ,aAAa,EACb,sBAAsB,EACtB,OAAO,EACP,yBAAyB,EAK3B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAI5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAKvD;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,qBAAqB;IACZ,MAAM,C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ifier: MIT
|
|
8
8
|
********************************************************************************/
|
|
9
|
-
import { DocumentState, type AstNode, type LangiumDocument, type URI } from '@hydranium/langium';
|
|
9
|
+
import { DocumentState, type AstNode, type AstReflection, type LangiumDocument, type URI } from '@hydranium/langium';
|
|
10
10
|
/**
|
|
11
11
|
* Build a typed AST-node fixture for unit tests.
|
|
12
12
|
*
|
|
@@ -21,13 +21,24 @@ import { DocumentState, type AstNode, type LangiumDocument, type URI } from '@hy
|
|
|
21
21
|
* framework synthetic node, and marking it would change scope/index behaviour.
|
|
22
22
|
* A test that wants a genuine synthetic node calls `markSynthetic` explicitly.
|
|
23
23
|
*
|
|
24
|
+
* **Without a `reflection`, the fixture carries only what the test spells out**,
|
|
25
|
+
* which is a shape production never produces: a parsed or built node always has
|
|
26
|
+
* its grammar-declared containment arrays, so a fixture that omits one lets a
|
|
27
|
+
* test pass against an impossible node, and lets code that walks a list crash
|
|
28
|
+
* only under test. Pass the grammar's reflection whenever the type is a real
|
|
29
|
+
* one and the code under test reads a collection off it. Fixtures typed against
|
|
30
|
+
* ad-hoc names have no reflection to pass and keep the plain form.
|
|
31
|
+
*
|
|
24
32
|
* @param node the node shape — `$type` is required; every other property is a
|
|
25
33
|
* value the test cares about (`$container`, cross-reference values, internal
|
|
26
|
-
* `_id` fields, …).
|
|
34
|
+
* `_id` fields, …).
|
|
35
|
+
* @param reflection when given, pre-fills the grammar's declared defaults the
|
|
36
|
+
* same way {@link buildAstNode} does, and the result is a fresh object rather
|
|
37
|
+
* than `node` itself. Omitted, `node` is returned by reference.
|
|
27
38
|
*/
|
|
28
39
|
export declare function makeFakeAstNode<TAst extends AstNode = AstNode>(node: {
|
|
29
40
|
$type: string;
|
|
30
|
-
} & Record<string, unknown
|
|
41
|
+
} & Record<string, unknown>, reflection?: AstReflection): TAst;
|
|
31
42
|
/**
|
|
32
43
|
* Options for {@link makeFakeDocument}.
|
|
33
44
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fake-document.d.ts","sourceRoot":"","sources":["../../src/testing/fake-document.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,aAAa,EAAE,KAAK,OAAO,EAAE,KAAK,eAAe,EAAY,KAAK,GAAG,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"fake-document.d.ts","sourceRoot":"","sources":["../../src/testing/fake-document.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,aAAa,EAAE,KAAK,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,eAAe,EAAY,KAAK,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAG/H;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,eAAe,CAAC,IAAI,SAAS,OAAO,GAAG,OAAO,EAC3D,IAAI,EAAE;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACjD,UAAU,CAAC,EAAE,aAAa,GAC1B,IAAI,CAKN;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,mBAAmB,CAAC,IAAI,SAAS,OAAO,EAAE,WAAW;IACnE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,WAAW,CAAC,EAAE,WAAW,EAAE,CAAC;IAC5B,kFAAkF;IAClF,WAAW,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC;IAC5D;;;;OAIG;IACH,UAAU,CAAC,EAAE,SAAS,OAAO,EAAE,CAAC;IAChC;;;;OAIG;IACH,YAAY,CAAC,EAAE,eAAe,CAAC,IAAI,CAAC,CAAC,cAAc,CAAC,CAAC;CACvD;AAiBD;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,SAAS,OAAO,GAAG,OAAO,EAAE,WAAW,GAAG,OAAO,EACnF,GAAG,EAAE,MAAM,GAAG,GAAG,EACjB,IAAI,EAAE,IAAI,EACV,OAAO,GAAE,mBAAmB,CAAC,IAAI,EAAE,WAAW,CAAM,GACpD,eAAe,CAAC,IAAI,CAAC,CA2BvB"}
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* SPDX-License-Identifier: MIT
|
|
8
8
|
********************************************************************************/
|
|
9
9
|
import { DocumentState, UriUtils } from '@hydranium/langium';
|
|
10
|
+
import { buildAstNode } from '../langium/ast-extension/ast-node-builder.js';
|
|
10
11
|
/**
|
|
11
12
|
* Build a typed AST-node fixture for unit tests.
|
|
12
13
|
*
|
|
@@ -21,12 +22,26 @@ import { DocumentState, UriUtils } from '@hydranium/langium';
|
|
|
21
22
|
* framework synthetic node, and marking it would change scope/index behaviour.
|
|
22
23
|
* A test that wants a genuine synthetic node calls `markSynthetic` explicitly.
|
|
23
24
|
*
|
|
25
|
+
* **Without a `reflection`, the fixture carries only what the test spells out**,
|
|
26
|
+
* which is a shape production never produces: a parsed or built node always has
|
|
27
|
+
* its grammar-declared containment arrays, so a fixture that omits one lets a
|
|
28
|
+
* test pass against an impossible node, and lets code that walks a list crash
|
|
29
|
+
* only under test. Pass the grammar's reflection whenever the type is a real
|
|
30
|
+
* one and the code under test reads a collection off it. Fixtures typed against
|
|
31
|
+
* ad-hoc names have no reflection to pass and keep the plain form.
|
|
32
|
+
*
|
|
24
33
|
* @param node the node shape — `$type` is required; every other property is a
|
|
25
34
|
* value the test cares about (`$container`, cross-reference values, internal
|
|
26
|
-
* `_id` fields, …).
|
|
35
|
+
* `_id` fields, …).
|
|
36
|
+
* @param reflection when given, pre-fills the grammar's declared defaults the
|
|
37
|
+
* same way {@link buildAstNode} does, and the result is a fresh object rather
|
|
38
|
+
* than `node` itself. Omitted, `node` is returned by reference.
|
|
27
39
|
*/
|
|
28
|
-
export function makeFakeAstNode(node) {
|
|
29
|
-
|
|
40
|
+
export function makeFakeAstNode(node, reflection) {
|
|
41
|
+
if (!reflection) {
|
|
42
|
+
return node;
|
|
43
|
+
}
|
|
44
|
+
return buildAstNode(reflection, node.$type, node);
|
|
30
45
|
}
|
|
31
46
|
/**
|
|
32
47
|
* Serialise `root` for the fake document's default text. AST fixtures routinely
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fake-document.js","sourceRoot":"","sources":["../../src/testing/fake-document.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"fake-document.js","sourceRoot":"","sources":["../../src/testing/fake-document.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,aAAa,EAA0D,QAAQ,EAAY,MAAM,oBAAoB,CAAC;AAC/H,OAAO,EAAE,YAAY,EAAE,MAAM,8CAA8C,CAAC;AAE5E;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,UAAU,eAAe,CAC5B,IAAiD,EACjD,UAA0B;IAE1B,IAAI,CAAC,UAAU,EAAE,CAAC;QACf,OAAO,IAAuB,CAAC;IAClC,CAAC;IACD,OAAO,YAAY,CAAO,UAAU,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AAC3D,CAAC;AA+BD;;;;;;GAMG;AACH,SAAS,iBAAiB,CAAC,IAAa;IACrC,IAAI,CAAC;QACF,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;IAAC,MAAM,CAAC;QACN,OAAO,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAG,IAAwC,EAAE,KAAK,EAAE,CAAC,CAAC;IACtF,CAAC;AACJ,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,gBAAgB,CAC7B,GAAiB,EACjB,IAAU,EACV,UAAkD,EAAE;IAEpD,MAAM,MAAM,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACnC,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,iBAAiB,CAAC,IAAI,CAAC,CAAC;IACrD,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,CAAC,CAAC;IACrC,MAAM,QAAQ,GAAG;QACd,GAAG,EAAE,MAAM;QACX,WAAW,EAAE;YACV,KAAK,EAAE,IAAI;YACX,YAAY,EAAE,EAAE;YAChB,WAAW,EAAE,EAAE;YACf,GAAG,OAAO,CAAC,WAAW;SACxB;QACD,YAAY,EAAE,OAAO,CAAC,YAAY,IAAI;YACnC,GAAG,EAAE,MAAM,CAAC,QAAQ,EAAE;YACtB,OAAO;YACP,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI;SACrB;QACD,WAAW,EAAE,CAAC,OAAO,CAAC,WAAW,IAAI,EAAE,CAAU;QACjD,UAAU,EAAE,OAAO,CAAC,UAAU,IAAI,EAAE;QACpC,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,aAAa,CAAC,SAAS;KACb,CAAC;IACtC,0EAA0E;IAC1E,qEAAqE;IACrE,sEAAsE;IACtE,iCAAiC;IAChC,IAA8C,CAAC,SAAS,GAAG,QAAQ,CAAC;IACrE,OAAO,QAAQ,CAAC;AACnB,CAAC"}
|
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
********************************************************************************/
|
|
9
9
|
import { type Clock, type Logger, type Tracer } from '@hydranium/protocol';
|
|
10
10
|
import type { ServerSharedServicesMinimal } from '../langium/shared-services.js';
|
|
11
|
+
import { ServerLocale } from '../locale/server-locale.js';
|
|
12
|
+
import { ServerMessageRenderer } from '../messages/renderer.js';
|
|
11
13
|
/**
|
|
12
14
|
* Overrides for {@link makeNoopSharedServices}. The three observability slots
|
|
13
15
|
* are typed (they are the boilerplate this helper exists to default);
|
|
@@ -27,6 +29,18 @@ export interface NoopSharedServicesOverrides {
|
|
|
27
29
|
Logger?: Logger;
|
|
28
30
|
/** Bound on the top-level `Tracer` slot. Default: a `DefaultTracer` over `Logger` + `Clock`. */
|
|
29
31
|
Tracer?: Tracer;
|
|
32
|
+
/** Factory for the `ServerLocale` slot. Default: a real one, reporting no locale. */
|
|
33
|
+
ServerLocale?: (services: ServerSharedServicesMinimal) => ServerLocale;
|
|
34
|
+
/**
|
|
35
|
+
* Factory for the `MessageRenderer` slot. Default: the real
|
|
36
|
+
* {@link ServerMessageRenderer}, whose no-catalogue behaviour is a
|
|
37
|
+
* pass-through — so the default is the framework's own behaviour, not a stub.
|
|
38
|
+
*
|
|
39
|
+
* A factory rather than an instance, because a renderer reads the tree it is
|
|
40
|
+
* bound into. Both slots are resolved lazily, so an override is honoured
|
|
41
|
+
* however late the caller reads them.
|
|
42
|
+
*/
|
|
43
|
+
MessageRenderer?: (services: ServerSharedServicesMinimal) => ServerMessageRenderer;
|
|
30
44
|
/** Per-slot `workspace` overrides. Slots left out resolve to `undefined`. */
|
|
31
45
|
workspace?: Record<string, unknown>;
|
|
32
46
|
/** Any other minimal slot (`ServiceRegistry`, `AstReflection`, `additionalDocuments`, …). */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"make-noop-shared-services.d.ts","sourceRoot":"","sources":["../../src/testing/make-noop-shared-services.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,KAAK,KAAK,EAAiB,KAAK,MAAM,EAA2B,KAAK,MAAM,EAAE,MAAM,qBAAqB,CAAC;AACnH,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"make-noop-shared-services.d.ts","sourceRoot":"","sources":["../../src/testing/make-noop-shared-services.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,KAAK,KAAK,EAAiB,KAAK,MAAM,EAA2B,KAAK,MAAM,EAAE,MAAM,qBAAqB,CAAC;AACnH,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AACjF,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEhE;;;;;;;GAOG;AACH,MAAM,WAAW,2BAA2B;IACzC,yEAAyE;IACzE,KAAK,CAAC,EAAE,KAAK,CAAC;IACd;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gGAAgG;IAChG,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,qFAAqF;IACrF,YAAY,CAAC,EAAE,CAAC,QAAQ,EAAE,2BAA2B,KAAK,YAAY,CAAC;IACvE;;;;;;;;OAQG;IACH,eAAe,CAAC,EAAE,CAAC,QAAQ,EAAE,2BAA2B,KAAK,qBAAqB,CAAC;IACnF,6EAA6E;IAC7E,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACpC,6FAA6F;IAC7F,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;CAC1B;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,SAAS,2BAA2B,GAAG,2BAA2B,EACvG,SAAS,GAAE,2BAAgC,GAC3C,CAAC,CA8BH"}
|
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
* SPDX-License-Identifier: MIT
|
|
8
8
|
********************************************************************************/
|
|
9
9
|
import { DefaultTracer, NoopLogger, SystemClock } from '@hydranium/protocol';
|
|
10
|
+
import { ServerLocale } from '../locale/server-locale.js';
|
|
11
|
+
import { ServerMessageRenderer } from '../messages/renderer.js';
|
|
10
12
|
/**
|
|
11
13
|
* Build a {@link ServerSharedServicesMinimal} tree backed by no-op defaults for
|
|
12
14
|
* the observability slots every framework component reads (`Clock` / `Logger` /
|
|
@@ -33,11 +35,12 @@ import { DefaultTracer, NoopLogger, SystemClock } from '@hydranium/protocol';
|
|
|
33
35
|
* are still undefined and should be overridden if the code under test reads them.
|
|
34
36
|
*/
|
|
35
37
|
export function makeNoopSharedServices(overrides = {}) {
|
|
36
|
-
const { Clock: clock, Logger: logger, Tracer: tracer, workspace, additionalDocuments, ...restTop } = overrides;
|
|
38
|
+
const { Clock: clock, Logger: logger, Tracer: tracer, ServerLocale: serverLocale, MessageRenderer: messageRenderer, workspace, additionalDocuments, ...restTop } = overrides;
|
|
37
39
|
const resolvedClock = clock ?? new SystemClock();
|
|
38
40
|
const resolvedLogger = logger ?? new NoopLogger();
|
|
39
41
|
const resolvedTracer = tracer ?? new DefaultTracer(resolvedLogger, resolvedClock);
|
|
40
|
-
|
|
42
|
+
// Assembled in two steps, because both defaults read the tree they belong to.
|
|
43
|
+
const services = {
|
|
41
44
|
Clock: resolvedClock,
|
|
42
45
|
Logger: resolvedLogger,
|
|
43
46
|
Tracer: resolvedTracer,
|
|
@@ -45,5 +48,28 @@ export function makeNoopSharedServices(overrides = {}) {
|
|
|
45
48
|
...restTop,
|
|
46
49
|
workspace: { ...(workspace ?? {}) }
|
|
47
50
|
};
|
|
51
|
+
// Lazy, like Langium's own per-slot construction — and load-bearing here:
|
|
52
|
+
// both services emit an `instantiated` trace, so building them eagerly puts
|
|
53
|
+
// two lines into the capture of every test that passes a capturing logger
|
|
54
|
+
// and asserts on emptiness.
|
|
55
|
+
defineLazySlot(services, 'ServerLocale', () => serverLocale?.(services) ?? new ServerLocale(services));
|
|
56
|
+
defineLazySlot(services, 'MessageRenderer', () => messageRenderer?.(services) ?? new ServerMessageRenderer(services));
|
|
57
|
+
return services;
|
|
58
|
+
}
|
|
59
|
+
/** Install `name` as a memoized getter, so nothing is constructed until it is read. */
|
|
60
|
+
function defineLazySlot(target, name, create) {
|
|
61
|
+
let resolved;
|
|
62
|
+
let built = false;
|
|
63
|
+
Object.defineProperty(target, name, {
|
|
64
|
+
configurable: true,
|
|
65
|
+
enumerable: true,
|
|
66
|
+
get: () => {
|
|
67
|
+
if (!built) {
|
|
68
|
+
resolved = create();
|
|
69
|
+
built = true;
|
|
70
|
+
}
|
|
71
|
+
return resolved;
|
|
72
|
+
}
|
|
73
|
+
});
|
|
48
74
|
}
|
|
49
75
|
//# sourceMappingURL=make-noop-shared-services.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"make-noop-shared-services.js","sourceRoot":"","sources":["../../src/testing/make-noop-shared-services.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAc,aAAa,EAAe,UAAU,EAAE,WAAW,EAAe,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"make-noop-shared-services.js","sourceRoot":"","sources":["../../src/testing/make-noop-shared-services.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAc,aAAa,EAAe,UAAU,EAAE,WAAW,EAAe,MAAM,qBAAqB,CAAC;AAEnH,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAuChE;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,UAAU,sBAAsB,CACnC,YAAyC,EAAE;IAE3C,MAAM,EACH,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,YAAY,EAC1B,eAAe,EAAE,eAAe,EAChC,SAAS,EACT,mBAAmB,EACnB,GAAG,OAAO,EACZ,GAAG,SAAS,CAAC;IACd,MAAM,aAAa,GAAG,KAAK,IAAI,IAAI,WAAW,EAAE,CAAC;IACjD,MAAM,cAAc,GAAG,MAAM,IAAI,IAAI,UAAU,EAAE,CAAC;IAClD,MAAM,cAAc,GAAG,MAAM,IAAI,IAAI,aAAa,CAAC,cAAc,EAAE,aAAa,CAAC,CAAC;IAClF,8EAA8E;IAC9E,MAAM,QAAQ,GAAG;QACd,KAAK,EAAE,aAAa;QACpB,MAAM,EAAE,cAAc;QACtB,MAAM,EAAE,cAAc;QACtB,mBAAmB,EAAE,mBAAmB,IAAI,EAAE;QAC9C,GAAG,OAAO;QACV,SAAS,EAAE,EAAE,GAAG,CAAC,SAAS,IAAI,EAAE,CAAC,EAAE;KACrB,CAAC;IAClB,0EAA0E;IAC1E,4EAA4E;IAC5E,0EAA0E;IAC1E,4BAA4B;IAC5B,cAAc,CAAC,QAAQ,EAAE,cAAc,EAAE,GAAG,EAAE,CAAC,YAAY,EAAE,CAAC,QAAQ,CAAC,IAAI,IAAI,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC;IACvG,cAAc,CAAC,QAAQ,EAAE,iBAAiB,EAAE,GAAG,EAAE,CAAC,eAAe,EAAE,CAAC,QAAQ,CAAC,IAAI,IAAI,qBAAqB,CAAC,QAAQ,CAAC,CAAC,CAAC;IACtH,OAAO,QAAQ,CAAC;AACnB,CAAC;AAED,uFAAuF;AACvF,SAAS,cAAc,CAAC,MAAc,EAAE,IAAY,EAAE,MAAqB;IACxE,IAAI,QAAiB,CAAC;IACtB,IAAI,KAAK,GAAG,KAAK,CAAC;IAClB,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,IAAI,EAAE;QACjC,YAAY,EAAE,IAAI;QAClB,UAAU,EAAE,IAAI;QAChB,GAAG,EAAE,GAAG,EAAE;YACP,IAAI,CAAC,KAAK,EAAE,CAAC;gBACV,QAAQ,GAAG,MAAM,EAAE,CAAC;gBACpB,KAAK,GAAG,IAAI,CAAC;YAChB,CAAC;YACD,OAAO,QAAQ,CAAC;QACnB,CAAC;KACH,CAAC,CAAC;AACN,CAAC"}
|
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
* SPDX-License-Identifier: MIT
|
|
8
8
|
********************************************************************************/
|
|
9
9
|
import { type Clock, type Logger, type Project, type Tracer, type TransferDiagnostic, type TransferElement } from '@hydranium/protocol';
|
|
10
|
+
import { ServerLocale } from '../locale/server-locale.js';
|
|
11
|
+
import { ServerMessageRenderer } from '../messages/renderer.js';
|
|
10
12
|
import type { Harness } from '@hydranium/protocol/testing';
|
|
11
13
|
import { type AstNode, type AstNodeDescription, type WorkspaceLock } from '@hydranium/langium';
|
|
12
14
|
import type { ModelService, ModelServiceOptions } from '../langium/model-service/model-service.js';
|
|
@@ -74,6 +76,15 @@ export interface TestSharedServices<TAst extends AstNode = AstNode, TDiagnostic
|
|
|
74
76
|
TransferEncoder: TransferEncoder<unknown, TDiagnostic>;
|
|
75
77
|
ModelService: ModelService<TAst, TDiagnostic, TTransfer>;
|
|
76
78
|
};
|
|
79
|
+
/**
|
|
80
|
+
* The REAL services, not stubs — the framework renderer's no-catalogue
|
|
81
|
+
* behaviour is a pass-through, so the stub tree agrees with a production one
|
|
82
|
+
* unless a test installs a catalogue. Bound rather than omitted because
|
|
83
|
+
* `HydraniumDocumentBuilder` renders through the renderer on every
|
|
84
|
+
* `Validated` phase, where an omitted slot is a `TypeError`.
|
|
85
|
+
*/
|
|
86
|
+
readonly ServerLocale: ServerLocale;
|
|
87
|
+
readonly MessageRenderer: ServerMessageRenderer;
|
|
77
88
|
}
|
|
78
89
|
/** Optional configuration for {@link makeTestServices}. */
|
|
79
90
|
export interface MakeTestServicesOptions<TAst extends AstNode = AstNode, TDiagnostic extends TransferDiagnostic = TransferDiagnostic, TTransfer extends TransferElement = TransferElement, TProject extends Project = Project> {
|
|
@@ -87,6 +98,14 @@ export interface MakeTestServicesOptions<TAst extends AstNode = AstNode, TDiagno
|
|
|
87
98
|
* for tests that don't assert on the produced text.
|
|
88
99
|
*/
|
|
89
100
|
serialize?: (uri: string, root: TTransfer) => string;
|
|
101
|
+
/**
|
|
102
|
+
* Renderer bound on `MessageRenderer`. Default: the framework's own, which
|
|
103
|
+
* passes every sentence through unchanged. Supply one to install a catalogue
|
|
104
|
+
* or to drive the throwing path.
|
|
105
|
+
*/
|
|
106
|
+
messageRenderer?: (services: ServerSharedServices<TProject>) => ServerMessageRenderer;
|
|
107
|
+
/** Locale handed to the bundle's {@link ServerLocale}. Default: none, i.e. the framework's English. */
|
|
108
|
+
locale?: string;
|
|
90
109
|
/**
|
|
91
110
|
* Languages to register on a {@link StubServiceRegistry} bound on the
|
|
92
111
|
* `ServiceRegistry` slot. This is how a test gets multi-language routing:
|
|
@@ -202,6 +221,14 @@ export interface TestServicesBundle<TAst extends AstNode = AstNode, TDiagnostic
|
|
|
202
221
|
readonly logger: Logger;
|
|
203
222
|
/** The clock bound on the `Clock` slot — a `makeFakeClock()` if one was passed. */
|
|
204
223
|
readonly clock: Clock;
|
|
224
|
+
/**
|
|
225
|
+
* The service bound on `ServerLocale`, so a test can hand over a locale
|
|
226
|
+
* mid-run — which is also how it verifies the renderer reads the locale per
|
|
227
|
+
* render rather than caching it at construction.
|
|
228
|
+
*/
|
|
229
|
+
readonly serverLocale: ServerLocale;
|
|
230
|
+
/** The renderer bound on `MessageRenderer` — the framework's own unless one was supplied. */
|
|
231
|
+
readonly messageRenderer: ServerMessageRenderer;
|
|
205
232
|
}
|
|
206
233
|
/**
|
|
207
234
|
* Build a {@link ServerSharedServices} tree backed by the framework's
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"make-test-services.d.ts","sourceRoot":"","sources":["../../src/testing/make-test-services.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EACJ,KAAK,KAAK,EAEV,KAAK,MAAM,EAEX,KAAK,OAAO,EAEZ,KAAK,MAAM,EACX,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,kBAAkB,EAAE,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAC/F,OAAO,KAAK,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AACnG,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,yCAAyC,CAAC;AAC1E,OAAO,EA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AE,QAAQ,CAAC,CAoH5D"}
|
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
* SPDX-License-Identifier: MIT
|
|
8
8
|
********************************************************************************/
|
|
9
9
|
import { DefaultTracer, NoopLogger, SystemClock } from '@hydranium/protocol';
|
|
10
|
+
import { ServerLocale } from '../locale/server-locale.js';
|
|
11
|
+
import { ServerMessageRenderer } from '../messages/renderer.js';
|
|
10
12
|
import { TransferEncoder } from '../langium/transfer/transfer-encoder.js';
|
|
11
13
|
import { DefaultDocumentUriPolicy } from '../langium/workspace/document-uri-policy.js';
|
|
12
14
|
import { HydraniumWorkspaceLock } from '../langium/workspace/hydranium-workspace-lock.js';
|
|
@@ -88,9 +90,21 @@ export function makeTestServices(options = {}) {
|
|
|
88
90
|
...(indexManager ? { IndexManager: indexManager } : {}),
|
|
89
91
|
WorkspaceLock: new HydraniumWorkspaceLock()
|
|
90
92
|
},
|
|
91
|
-
model: {}
|
|
93
|
+
model: {},
|
|
94
|
+
ServerLocale: {},
|
|
95
|
+
MessageRenderer: {}
|
|
92
96
|
};
|
|
93
97
|
const sharedServices = services;
|
|
98
|
+
// Patched in after the literal, like `model` below: both read the tree they
|
|
99
|
+
// belong to, and the renderer reads the locale service.
|
|
100
|
+
const mutableMessages = services;
|
|
101
|
+
const serverLocale = new ServerLocale(sharedServices);
|
|
102
|
+
if (options.locale) {
|
|
103
|
+
serverLocale.accept(options.locale);
|
|
104
|
+
}
|
|
105
|
+
mutableMessages.ServerLocale = serverLocale;
|
|
106
|
+
const messageRenderer = options.messageRenderer?.(sharedServices) ?? new ServerMessageRenderer(sharedServices);
|
|
107
|
+
mutableMessages.MessageRenderer = messageRenderer;
|
|
94
108
|
const serialize = options.serialize ?? ((_uri, root) => JSON.stringify(root));
|
|
95
109
|
const transferEncoder = options.transferEncoder
|
|
96
110
|
? options.transferEncoder(sharedServices)
|
|
@@ -117,6 +131,8 @@ export function makeTestServices(options = {}) {
|
|
|
117
131
|
transferEncoder,
|
|
118
132
|
logger,
|
|
119
133
|
clock,
|
|
134
|
+
serverLocale,
|
|
135
|
+
messageRenderer,
|
|
120
136
|
dispose: () => {
|
|
121
137
|
// No-op: the bundled stubs hold only in-memory state (maps, arrays),
|
|
122
138
|
// released with the bundle when it goes out of scope. The hook exists
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"make-test-services.js","sourceRoot":"","sources":["../../src/testing/make-test-services.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAEJ,aAAa,EAEb,UAAU,EAEV,WAAW,EAIb,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"make-test-services.js","sourceRoot":"","sources":["../../src/testing/make-test-services.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAEJ,aAAa,EAEb,UAAU,EAEV,WAAW,EAIb,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAKhE,OAAO,EAAE,eAAe,EAAE,MAAM,yCAAyC,CAAC;AAC1E,OAAO,EAAE,wBAAwB,EAA0B,MAAM,6CAA6C,CAAC;AAC/G,OAAO,EAAE,sBAAsB,EAAE,MAAM,kDAAkD,CAAC;AAE1F,OAAO,EAAE,uBAAuB,EAA4B,MAAM,4BAA4B,CAAC;AAC/F,OAAO,EAAE,oBAAoB,EAAyB,MAAM,yBAAyB,CAAC;AACtF,OAAO,EAAE,wBAAwB,EAA6B,MAAM,6BAA6B,CAAC;AAClG,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,0BAA0B,EAA+B,MAAM,gCAAgC,CAAC;AACzG,OAAO,EAAE,sBAAsB,EAA2B,MAAM,2BAA2B,CAAC;AAC5F,OAAO,EAAE,wBAAwB,EAA6B,MAAM,8BAA8B,CAAC;AACnG,OAAO,EAAE,8BAA8B,EA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C;AACL,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hydranium/core",
|
|
3
|
-
"version": "1.0.0-next.
|
|
3
|
+
"version": "1.0.0-next.32",
|
|
4
4
|
"description": "Foundational runtime of the hydranium framework: AST coordination layer (services, integrity, AST extension, serialization, multi-client documents) plus the LSP textual head at the /lsp subpath. Consumed by protocol-head packages (@hydranium/data-server, @hydranium/glsp-server).",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"hydranium",
|
|
@@ -104,8 +104,8 @@
|
|
|
104
104
|
"diff": "^5.2.0"
|
|
105
105
|
},
|
|
106
106
|
"devDependencies": {
|
|
107
|
-
"@hydranium/langium": "1.0.0-next.
|
|
108
|
-
"@hydranium/protocol": "1.0.0-next.
|
|
107
|
+
"@hydranium/langium": "1.0.0-next.32",
|
|
108
|
+
"@hydranium/protocol": "1.0.0-next.32",
|
|
109
109
|
"@playwright/test": "^1.40.0",
|
|
110
110
|
"@types/diff": "^5.2.0",
|
|
111
111
|
"rimraf": "^5.0.0",
|
|
@@ -117,8 +117,8 @@
|
|
|
117
117
|
"vscode-languageserver-types": "^3.17.5"
|
|
118
118
|
},
|
|
119
119
|
"peerDependencies": {
|
|
120
|
-
"@hydranium/langium": "1.0.0-next.
|
|
121
|
-
"@hydranium/protocol": "1.0.0-next.
|
|
120
|
+
"@hydranium/langium": "1.0.0-next.32",
|
|
121
|
+
"@hydranium/protocol": "1.0.0-next.32",
|
|
122
122
|
"@playwright/test": "^1.40.0",
|
|
123
123
|
"vscode-jsonrpc": "9.0.1",
|
|
124
124
|
"vscode-languageserver": "~10.0.1",
|
|
@@ -985,9 +985,20 @@ export class HydraniumTextDocuments<T extends TextDocument = TextDocument> exten
|
|
|
985
985
|
// it is exactly what the caller retries with after a rejection, so
|
|
986
986
|
// gating it there would refuse the recovery too.
|
|
987
987
|
const version = isFullReplace(edits) ? UNKNOWN_CLIENT_VERSION : this.languageClientVersion(uri);
|
|
988
|
+
// A full `ApplyWorkspaceEditParams`, `edit` and all — NOT a bare
|
|
989
|
+
// `WorkspaceEdit` with a `label` beside it. `applyEdit` takes
|
|
990
|
+
// `ApplyWorkspaceEditParams | WorkspaceEdit` and discriminates on
|
|
991
|
+
// `!!value.edit`, so `{ label, documentChanges }` is wrapped as
|
|
992
|
+
// `{ edit: { label, documentChanges } }` — putting the label inside
|
|
993
|
+
// the edit, where LSP defines no such field and no client reads it.
|
|
994
|
+
// The union is also what hides it at compile time: excess-property
|
|
995
|
+
// checking admits a property present in EITHER member, so an object
|
|
996
|
+
// matching neither type-checks against the union.
|
|
988
997
|
const result = await connection.workspace.applyEdit({
|
|
989
998
|
label: options?.label,
|
|
990
|
-
|
|
999
|
+
edit: {
|
|
1000
|
+
documentChanges: [TextDocumentEdit.create(OptionalVersionedTextDocumentIdentifier.create(targetUri, version), edits)]
|
|
1001
|
+
}
|
|
991
1002
|
});
|
|
992
1003
|
if (result && result.applied === false) {
|
|
993
1004
|
this.__shadow.invalidate(targetUri);
|
package/src/index.ts
CHANGED
|
@@ -35,5 +35,6 @@ export * from './langium/workspace/index.js';
|
|
|
35
35
|
export * from './langium/service-registry.js';
|
|
36
36
|
export * from './langium/language-types.js';
|
|
37
37
|
export * from './launcher/index.js';
|
|
38
|
+
export * from './locale/index.js';
|
|
38
39
|
export * from './documents/index.js';
|
|
39
40
|
export * from './util/index.js';
|