@hydranium/glsp-server 1.0.0-next.12 → 1.0.0-next.123
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/README.md +13 -2
- package/lib/command/hydranium-glsp-recording-command.d.ts +22 -22
- package/lib/command/hydranium-glsp-recording-command.d.ts.map +1 -1
- package/lib/command/hydranium-glsp-recording-command.js +25 -26
- package/lib/command/hydranium-glsp-recording-command.js.map +1 -1
- package/lib/launcher/hydranium-glsp-server.d.ts +4 -3
- package/lib/launcher/hydranium-glsp-server.d.ts.map +1 -1
- package/lib/launcher/hydranium-glsp-server.js +4 -3
- package/lib/launcher/hydranium-glsp-server.js.map +1 -1
- package/lib/messages/index.d.ts +24 -0
- package/lib/messages/index.d.ts.map +1 -0
- package/lib/messages/index.js +24 -0
- package/lib/messages/index.js.map +1 -0
- package/lib/node/start-glsp-server.js +1 -1
- package/lib/node/start-glsp-server.js.map +1 -1
- package/lib/state/abstract-hydranium-glsp-state.d.ts +110 -43
- package/lib/state/abstract-hydranium-glsp-state.d.ts.map +1 -1
- package/lib/state/abstract-hydranium-glsp-state.js +130 -41
- package/lib/state/abstract-hydranium-glsp-state.js.map +1 -1
- package/lib/state/full-text-hydranium-glsp-state.d.ts +6 -6
- package/lib/state/full-text-hydranium-glsp-state.d.ts.map +1 -1
- package/lib/state/full-text-hydranium-glsp-state.js +6 -10
- package/lib/state/full-text-hydranium-glsp-state.js.map +1 -1
- package/lib/state/reconcile-source-model-write.d.ts +9 -8
- package/lib/state/reconcile-source-model-write.d.ts.map +1 -1
- package/lib/state/reconcile-source-model-write.js +8 -8
- package/lib/state/reconcile-source-model-write.js.map +1 -1
- package/lib/state/reconciling-multi-document-glsp-state.d.ts +59 -59
- package/lib/state/reconciling-multi-document-glsp-state.d.ts.map +1 -1
- package/lib/state/reconciling-multi-document-glsp-state.js +84 -82
- package/lib/state/reconciling-multi-document-glsp-state.js.map +1 -1
- package/lib/state/reconciling-transfer-hydranium-glsp-state.d.ts +19 -18
- package/lib/state/reconciling-transfer-hydranium-glsp-state.d.ts.map +1 -1
- package/lib/state/reconciling-transfer-hydranium-glsp-state.js +26 -30
- package/lib/state/reconciling-transfer-hydranium-glsp-state.js.map +1 -1
- package/lib/storage/hydranium-glsp-storage.d.ts +271 -76
- package/lib/storage/hydranium-glsp-storage.d.ts.map +1 -1
- package/lib/storage/hydranium-glsp-storage.js +383 -87
- package/lib/storage/hydranium-glsp-storage.js.map +1 -1
- package/lib/storage/index.d.ts +1 -1
- package/lib/storage/index.js +1 -1
- package/lib/storage/save-delivery-policy.d.ts +46 -0
- package/lib/storage/save-delivery-policy.d.ts.map +1 -0
- package/lib/storage/{save-conflict-policy.js → save-delivery-policy.js} +7 -8
- package/lib/storage/save-delivery-policy.js.map +1 -0
- package/lib/validation/diagnostic-markers.d.ts +2 -2
- package/lib/validation/diagnostic-markers.d.ts.map +1 -1
- package/lib/validation/diagnostic-markers.js +7 -0
- package/lib/validation/diagnostic-markers.js.map +1 -1
- package/lib/validation/hydranium-glsp-model-validator.d.ts.map +1 -1
- package/lib/validation/hydranium-glsp-model-validator.js +1 -1
- package/lib/validation/hydranium-glsp-model-validator.js.map +1 -1
- package/package.json +17 -8
- package/src/command/hydranium-glsp-recording-command.ts +26 -26
- package/src/launcher/hydranium-glsp-server.ts +4 -3
- package/src/messages/index.ts +30 -0
- package/src/node/start-glsp-server.ts +1 -1
- package/src/state/abstract-hydranium-glsp-state.ts +162 -51
- package/src/state/full-text-hydranium-glsp-state.ts +7 -11
- package/src/state/reconcile-source-model-write.ts +18 -15
- package/src/state/reconciling-multi-document-glsp-state.ts +86 -83
- package/src/state/reconciling-transfer-hydranium-glsp-state.ts +27 -31
- package/src/storage/hydranium-glsp-storage.ts +445 -97
- package/src/storage/index.ts +1 -1
- package/src/storage/save-delivery-policy.ts +44 -0
- package/src/validation/diagnostic-markers.ts +10 -3
- package/src/validation/hydranium-glsp-model-validator.ts +3 -3
- package/lib/storage/save-conflict-policy.d.ts +0 -56
- package/lib/storage/save-conflict-policy.d.ts.map +0 -1
- package/lib/storage/save-conflict-policy.js.map +0 -1
- package/src/storage/save-conflict-policy.ts +0 -52
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"abstract-hydranium-glsp-state.d.ts","sourceRoot":"","sources":["../../src/state/abstract-hydranium-glsp-state.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,iBAAiB,EAAE,KAAK,YAAY,EAAkB,MAAM,sBAAsB,CAAC;AAC5F,OAAO,EAAE,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAErD,OAAO,EAAE,KAAK,OAAO,EAAE,aAAa,EAAO,MAAM,oBAAoB,CAAC;AACtE,OAAO,EACJ,KAAK,sBAAsB,EAC3B,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,0BAA0B,EAC/B,KAAK,sBAAsB,EAC3B,KAAK,oBAAoB,EAC3B,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"abstract-hydranium-glsp-state.d.ts","sourceRoot":"","sources":["../../src/state/abstract-hydranium-glsp-state.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,iBAAiB,EAAE,KAAK,YAAY,EAAkB,MAAM,sBAAsB,CAAC;AAC5F,OAAO,EAAE,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAErD,OAAO,EAAE,KAAK,OAAO,EAAE,aAAa,EAAO,MAAM,oBAAoB,CAAC;AACtE,OAAO,EACJ,KAAK,aAAa,EAClB,KAAK,sBAAsB,EAC3B,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,0BAA0B,EAC/B,KAAK,sBAAsB,EAC3B,KAAK,oBAAoB,EAC3B,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACJ,KAAK,OAAO,EACZ,KAAK,eAAe,EACpB,KAAK,gBA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,eAAe,GAAG,SAAS;IAO3D;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,SAAS,CAAC,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,eAAe;IAkB3D,qFAAqF;IACrF,SAAS,CAAC,wBAAwB,IAAI,IAAI;IAM1C;;;;;;OAMG;IACH,SAAS,CAAC,iBAAiB,IAAI,IAAI;IAenC;;;;;;;;;;OAUG;cACa,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC;IAW1E;;;;OAIG;IACG,KAAK,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAKhD;;;;;;OAMG;cACa,gBAAgB,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IA8BrE;;;;;;OAMG;cACa,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC;IAIjD;;;;;;;OAOG;IACH,SAAS,CAAC,sBAAsB,CAAC,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,GAAG,sBAAsB;IAO/F;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA0CG;IACH,QAAQ,CAAC,iBAAiB,CAAC,KAAK,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,YAAY,CAAC,IAAI,CAAC;CACxF"}
|
|
@@ -20,6 +20,7 @@ import { DefaultModelState, SOURCE_URI_ARG } from '@eclipse-glsp/server';
|
|
|
20
20
|
import { Emitter } from 'vscode-jsonrpc';
|
|
21
21
|
import { inject, injectable, optional } from 'inversify';
|
|
22
22
|
import { DocumentState, URI } from '@hydranium/langium';
|
|
23
|
+
import { asSnapshotVersion, NO_MATCHING_VERSION } from '@hydranium/protocol';
|
|
23
24
|
import { HydraniumTypes } from './hydranium-shared-core-services.js';
|
|
24
25
|
import { ModelReadyTimeoutError } from './model-ready-timeout-error.js';
|
|
25
26
|
/**
|
|
@@ -79,11 +80,35 @@ let AbstractHydraniumGlspState = class AbstractHydraniumGlspState extends Defaul
|
|
|
79
80
|
* getters fall back to it before then, so logging is never `undefined`.
|
|
80
81
|
*/
|
|
81
82
|
baseTracer;
|
|
83
|
+
/**
|
|
84
|
+
* The client session this diagram works as, registered under `clientId` by
|
|
85
|
+
* the source-model storage and ended with the GLSP client session.
|
|
86
|
+
* `undefined` for GLSP's placeholder client, and when the id was held by
|
|
87
|
+
* another participant, in which case the diagram does not load.
|
|
88
|
+
*
|
|
89
|
+
* Every write of the diagram goes through this session, which writes only a
|
|
90
|
+
* document it has open and opens nothing. A one-shot write to a document
|
|
91
|
+
* outside the write set goes through
|
|
92
|
+
* {@link ClientSession.withOpen}, and a document the diagram brings into
|
|
93
|
+
* existence through {@link ClientSession.create}.
|
|
94
|
+
*/
|
|
95
|
+
modelSession;
|
|
96
|
+
/**
|
|
97
|
+
* {@link modelSession}, or a throw without one: the diagram never loaded or
|
|
98
|
+
* has ended. Looking `clientId` up through `ModelService.getSession` instead
|
|
99
|
+
* would write as whichever participant holds that id.
|
|
100
|
+
*/
|
|
101
|
+
requireModelSession() {
|
|
102
|
+
if (!this.modelSession) {
|
|
103
|
+
throw new Error(`No client session is registered for ${this.clientId}; the diagram cannot write`);
|
|
104
|
+
}
|
|
105
|
+
return this.modelSession;
|
|
106
|
+
}
|
|
82
107
|
_sourceUri;
|
|
83
108
|
_sourceRoot;
|
|
84
109
|
_tracer;
|
|
85
|
-
|
|
86
|
-
/**
|
|
110
|
+
_basedOn = asSnapshotVersion(0);
|
|
111
|
+
/** Snapshot versions of the secondary write set, keyed by URI. See {@link trackSecondaryDocument}. */
|
|
87
112
|
_secondaryVersions = new Map();
|
|
88
113
|
/** Backing emitter for {@link onSecondaryUrisChanged}; fired only on a membership change. */
|
|
89
114
|
secondaryUrisChangedEmitter = new Emitter();
|
|
@@ -103,7 +128,7 @@ let AbstractHydraniumGlspState = class AbstractHydraniumGlspState extends Defaul
|
|
|
103
128
|
setSourceRoot(uri, root) {
|
|
104
129
|
this._sourceUri = uri;
|
|
105
130
|
this._sourceRoot = root;
|
|
106
|
-
this.
|
|
131
|
+
this._basedOn = this.readSnapshotVersion(uri);
|
|
107
132
|
// Re-read the secondary write set for the same reason the primary is
|
|
108
133
|
// re-read: the write that brought us here advanced their versions too, and
|
|
109
134
|
// a stale based-on version would gate the NEXT command against a
|
|
@@ -112,7 +137,7 @@ let AbstractHydraniumGlspState = class AbstractHydraniumGlspState extends Defaul
|
|
|
112
137
|
this.refreshSecondaryVersions();
|
|
113
138
|
this.set(SOURCE_URI_ARG, uri);
|
|
114
139
|
this._tracer = this.baseTracer.withUri(uri);
|
|
115
|
-
this.tracer.debug(`Captured source root at doc.version=v${this.
|
|
140
|
+
this.tracer.debug(`Captured source root at doc.version=v${this._basedOn}`);
|
|
116
141
|
this.checkDeclaredLanguage(uri);
|
|
117
142
|
this.index.indexSourceRoot(root, uri);
|
|
118
143
|
}
|
|
@@ -218,32 +243,42 @@ let AbstractHydraniumGlspState = class AbstractHydraniumGlspState extends Defaul
|
|
|
218
243
|
return this._tracer ?? this.baseTracer;
|
|
219
244
|
}
|
|
220
245
|
/**
|
|
221
|
-
*
|
|
222
|
-
*
|
|
223
|
-
* at that point in time — frozen until the next `setSourceRoot`, then
|
|
224
|
-
* re-read from `LangiumDocuments`.
|
|
246
|
+
* Snapshot version taken at the last {@link setSourceRoot} call — frozen
|
|
247
|
+
* until the next one, then re-read from the document store.
|
|
225
248
|
*
|
|
226
249
|
* Threaded by `HydraniumGlspRecordingCommand` into
|
|
227
|
-
* {@link updateSourceModel}
|
|
228
|
-
*
|
|
229
|
-
* conflict gate against the captured based-on version. See
|
|
250
|
+
* {@link updateSourceModel} so the downstream session `update` / `save`
|
|
251
|
+
* gates against what the command was authored on. See
|
|
230
252
|
* `@hydranium/protocol#ConflictError` for the detection contract.
|
|
231
253
|
*
|
|
254
|
+
* **This, not a number read at write time, is what a write must be gated
|
|
255
|
+
* on.** A version read when the write is issued is the store's current one,
|
|
256
|
+
* so it matches by construction and the gate can never fire.
|
|
257
|
+
*/
|
|
258
|
+
get basedOn() {
|
|
259
|
+
return this._basedOn;
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Text-document version of {@link basedOn}. Mirrors the server-side
|
|
263
|
+
* `TextDocuments.version(uri)` counter as of the snapshot, or is
|
|
264
|
+
* `NO_MATCHING_VERSION` when the store's text could not be tied to the
|
|
265
|
+
* root (see {@link readSnapshotVersion}).
|
|
266
|
+
*
|
|
232
267
|
* Falls back to `0` when the document is absent from `LangiumDocuments`
|
|
233
|
-
*
|
|
234
|
-
* that was never opened. Callers that need to distinguish
|
|
268
|
+
* when the snapshot is taken — the same observable state callers see for a
|
|
269
|
+
* doc that was never opened. Callers that need to distinguish
|
|
235
270
|
* "never-versioned" from "v0" must consult the document registry
|
|
236
271
|
* directly.
|
|
237
272
|
*/
|
|
238
273
|
get version() {
|
|
239
|
-
return this.
|
|
274
|
+
return this._basedOn;
|
|
240
275
|
}
|
|
241
276
|
// ============================================================
|
|
242
277
|
// Secondary documents — the write set beyond the primary
|
|
243
278
|
// ============================================================
|
|
244
279
|
/**
|
|
245
|
-
* Register `uri` as a document this state also writes,
|
|
246
|
-
* text-document version.
|
|
280
|
+
* Register `uri` as a document this state also writes, snapshotting its
|
|
281
|
+
* current text-document version.
|
|
247
282
|
*
|
|
248
283
|
* A diagram whose layout lives in its own file, or whose canvas creates
|
|
249
284
|
* elements in a referenced semantic document, writes more than the document
|
|
@@ -256,7 +291,7 @@ let AbstractHydraniumGlspState = class AbstractHydraniumGlspState extends Defaul
|
|
|
256
291
|
* identified once the operation names the node. What the framework supplies
|
|
257
292
|
* is the part an adopter cannot reconstruct after the fact — the version each
|
|
258
293
|
* document was at BEFORE the command mutated anything (see
|
|
259
|
-
* {@link
|
|
294
|
+
* {@link snapshotVersionOf}). Idempotent; registering the primary is ignored,
|
|
260
295
|
* since {@link version} already tracks it. Registering a URI not already in
|
|
261
296
|
* the set fires {@link onSecondaryUrisChanged}.
|
|
262
297
|
*/
|
|
@@ -265,7 +300,7 @@ let AbstractHydraniumGlspState = class AbstractHydraniumGlspState extends Defaul
|
|
|
265
300
|
return;
|
|
266
301
|
}
|
|
267
302
|
const added = !this._secondaryVersions.has(uri);
|
|
268
|
-
this._secondaryVersions.set(uri, this.
|
|
303
|
+
this._secondaryVersions.set(uri, this.readSnapshotVersion(uri));
|
|
269
304
|
if (added) {
|
|
270
305
|
this.secondaryUrisChangedEmitter.fire();
|
|
271
306
|
}
|
|
@@ -283,14 +318,15 @@ let AbstractHydraniumGlspState = class AbstractHydraniumGlspState extends Defaul
|
|
|
283
318
|
}
|
|
284
319
|
/**
|
|
285
320
|
* Fires whenever the secondary write set gains or loses a URI — never when a
|
|
286
|
-
* tracked document's
|
|
321
|
+
* tracked document's snapshot version is merely refreshed, which happens on
|
|
287
322
|
* every {@link setSourceRoot} and changes nothing a subscriber cares about.
|
|
288
323
|
*
|
|
289
324
|
* **This exists so no caller has to know when the set can change.** The set is
|
|
290
325
|
* usually discovered rather than known, and the discovery point is an
|
|
291
|
-
* operation handler naming a node — not a
|
|
292
|
-
* re-derived the set after each
|
|
293
|
-
* it silently: the document would simply never be
|
|
326
|
+
* operation handler naming a node — not a read of the source root. A
|
|
327
|
+
* subscriber that instead re-derived the set after each such read would miss
|
|
328
|
+
* exactly that case, and miss it silently: the document would simply never be
|
|
329
|
+
* watched, with nothing logged.
|
|
294
330
|
* Announcing the change here moves the obligation to the one place that can
|
|
295
331
|
* always discharge it.
|
|
296
332
|
*
|
|
@@ -307,35 +343,67 @@ let AbstractHydraniumGlspState = class AbstractHydraniumGlspState extends Defaul
|
|
|
307
343
|
return [...this._secondaryVersions.keys()];
|
|
308
344
|
}
|
|
309
345
|
/**
|
|
310
|
-
*
|
|
311
|
-
*
|
|
312
|
-
*
|
|
346
|
+
* Snapshot version for `uri` — {@link basedOn} for the primary, the version
|
|
347
|
+
* taken at {@link trackSecondaryDocument} (refreshed by {@link setSourceRoot})
|
|
348
|
+
* for a secondary, `undefined` for anything untracked.
|
|
313
349
|
*
|
|
314
|
-
* `undefined` rather than
|
|
350
|
+
* `undefined` rather than v0 for an untracked URI deliberately: `0` is a real
|
|
315
351
|
* version meaning "present but never edited", so collapsing the two would let
|
|
316
|
-
* a caller gate a write against a document
|
|
352
|
+
* a caller gate a write against a document this state never read.
|
|
317
353
|
*/
|
|
318
|
-
|
|
354
|
+
snapshotVersionOf(uri) {
|
|
319
355
|
if (uri === this._sourceUri) {
|
|
320
|
-
return this.
|
|
356
|
+
return this._basedOn;
|
|
321
357
|
}
|
|
322
358
|
return this._secondaryVersions.get(uri);
|
|
323
359
|
}
|
|
324
360
|
/**
|
|
325
|
-
* Read a document's
|
|
326
|
-
* canonicalizing gateway
|
|
327
|
-
* the document keyed by its real path rather than
|
|
328
|
-
* would silently weaken the conflict gate).
|
|
329
|
-
*
|
|
330
|
-
*
|
|
361
|
+
* Read a document's version out of the live store and mark it as a snapshot,
|
|
362
|
+
* through the model service's canonicalizing gateway so a URI spelled through
|
|
363
|
+
* a symlink still resolves to the document keyed by its real path rather than
|
|
364
|
+
* stranding at `0` (which would silently weaken the conflict gate).
|
|
365
|
+
*
|
|
366
|
+
* **Call this only at the point the source root is read.** It is the one
|
|
367
|
+
* place the framework turns a live version into a snapshot one, and the value
|
|
368
|
+
* is true only because that is where it is called. Called at write time it
|
|
369
|
+
* answers with the version the write is about to be compared against, so the
|
|
370
|
+
* gate passes unconditionally.
|
|
371
|
+
*
|
|
372
|
+
* Falls back to v0 for a URI neither store knows, matching what
|
|
373
|
+
* {@link version} reports for a document that was never opened.
|
|
374
|
+
*
|
|
375
|
+
* **The version of the text store, which the gate compares against.**
|
|
376
|
+
* When the store holds the text the root was parsed from, that is its
|
|
377
|
+
* version, even while the built document still carries an older number.
|
|
378
|
+
* When the store holds other text, `NO_MATCHING_VERSION`, so the write
|
|
379
|
+
* conflicts instead of overwriting text the root never saw: the
|
|
380
|
+
* reconciling states reconcile it, `FullTextHydraniumGlspState` throws the
|
|
381
|
+
* `ConflictError`. When the root keeps no syntax tree to read its text
|
|
382
|
+
* from, the built document's text stands in for it, unless the built
|
|
383
|
+
* document IS the store's, whose text says nothing about what was parsed;
|
|
384
|
+
* that also gets `NO_MATCHING_VERSION`.
|
|
331
385
|
*/
|
|
332
|
-
|
|
333
|
-
|
|
386
|
+
readSnapshotVersion(uri) {
|
|
387
|
+
const document = this.sharedServices.model.ModelService.getDocument(uri);
|
|
388
|
+
const stored = document && this.sharedServices.workspace.TextDocuments.get(uri);
|
|
389
|
+
if (stored) {
|
|
390
|
+
const parsed = document.parseResult.value.$cstNode?.root.fullText;
|
|
391
|
+
if (parsed !== undefined) {
|
|
392
|
+
return parsed === stored.getText() ? asSnapshotVersion(stored.version) : NO_MATCHING_VERSION;
|
|
393
|
+
}
|
|
394
|
+
if (document.textDocument === stored) {
|
|
395
|
+
return NO_MATCHING_VERSION;
|
|
396
|
+
}
|
|
397
|
+
if (stored.version !== document.textDocument.version && stored.getText() === document.textDocument.getText()) {
|
|
398
|
+
return asSnapshotVersion(stored.version);
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
return this.sharedServices.model.ModelService.snapshot(uri)?.version ?? asSnapshotVersion(0);
|
|
334
402
|
}
|
|
335
|
-
/** Re-
|
|
403
|
+
/** Re-take every registered secondary's snapshot version from the document store. */
|
|
336
404
|
refreshSecondaryVersions() {
|
|
337
405
|
for (const uri of [...this._secondaryVersions.keys()]) {
|
|
338
|
-
this._secondaryVersions.set(uri, this.
|
|
406
|
+
this._secondaryVersions.set(uri, this.readSnapshotVersion(uri));
|
|
339
407
|
}
|
|
340
408
|
}
|
|
341
409
|
/**
|
|
@@ -359,6 +427,27 @@ let AbstractHydraniumGlspState = class AbstractHydraniumGlspState extends Defaul
|
|
|
359
427
|
this.setSourceRoot(this._sourceUri, root);
|
|
360
428
|
}
|
|
361
429
|
}
|
|
430
|
+
/**
|
|
431
|
+
* The root that `uri`'s text parses to (the text store's, or the built
|
|
432
|
+
* document's when the store holds none), read once the document has
|
|
433
|
+
* validated; `undefined` when it cannot be read.
|
|
434
|
+
*
|
|
435
|
+
* **Parsed afresh, never the built root.** Operation handlers edit the
|
|
436
|
+
* built root in place, so until a rebuild replaces it, it already holds
|
|
437
|
+
* the edit being reconciled, and replaying the edit onto it applies it
|
|
438
|
+
* twice. The root is parsed, not linked: an encoder hook reading a
|
|
439
|
+
* reference's `ref` sees `undefined` on it.
|
|
440
|
+
*/
|
|
441
|
+
async readCurrentRoot(uri) {
|
|
442
|
+
const modelService = this.sharedServices.model.ModelService;
|
|
443
|
+
if (!(await modelService.validated(uri).catch(() => undefined))) {
|
|
444
|
+
return undefined;
|
|
445
|
+
}
|
|
446
|
+
const text = this.sharedServices.workspace.TextDocuments.get(uri)?.getText() ?? modelService.getDocument(uri)?.textDocument.getText();
|
|
447
|
+
return text === undefined
|
|
448
|
+
? undefined
|
|
449
|
+
: this.sharedServices.workspace.LangiumDocumentFactory.fromString(text, URI.parse(uri)).parseResult.value;
|
|
450
|
+
}
|
|
362
451
|
/**
|
|
363
452
|
* Wait until the captured document reaches `state`, then run
|
|
364
453
|
* {@link onReadyRefreshed} so consumers see a fresh AST. Wraps the
|
|
@@ -382,8 +471,8 @@ let AbstractHydraniumGlspState = class AbstractHydraniumGlspState extends Defaul
|
|
|
382
471
|
const timeout = new Promise((resolve, reject) => {
|
|
383
472
|
timer = this.sharedServices.Clock.setTimer(() => {
|
|
384
473
|
const elapsed = Math.round(stopwatch.elapsedMs);
|
|
385
|
-
//
|
|
386
|
-
//
|
|
474
|
+
// Through the model service's canonicalizing gateway, so a symlinked
|
|
475
|
+
// `_sourceUri` is not reported as a hard timeout.
|
|
387
476
|
const doc = this.sharedServices.model.ModelService.getDocument(uri);
|
|
388
477
|
if (doc && doc.state >= state) {
|
|
389
478
|
this.logger.warn(`Missed '${DocumentState[state]}' notification after ${elapsed}ms; document is already at state ` +
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"abstract-hydranium-glsp-state.js","sourceRoot":"","sources":["../../src/state/abstract-hydranium-glsp-state.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;;;;;;;;;;;AAElF,OAAO,EAAE,iBAAiB,EAAqB,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC5F,OAAO,EAAE,OAAO,EAAc,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,EAAgB,aAAa,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"abstract-hydranium-glsp-state.js","sourceRoot":"","sources":["../../src/state/abstract-hydranium-glsp-state.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;;;;;;;;;;;AAElF,OAAO,EAAE,iBAAiB,EAAqB,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC5F,OAAO,EAAE,OAAO,EAAc,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,EAAgB,aAAa,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAUtE,OAAO,EAOJ,iBAAiB,EACjB,mBAAmB,EACrB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AACrE,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAExE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEI,IAAe,0BAA0B,GAAzC,MAAe,0BAAyE,SAAQ,iBAAiB;;IACvD,cAAc,CAAwB;IAEpG;;;;;;;;OAQG;IAC+C,gBAAgB,CAAoB;IAEtF;;;;;OAKG;IAC+C,UAAU,CAAU;IAKtE;;;;;;;;;;;OAWG;IACH,YAAY,CAA0B;IAEtC;;;;OAIG;IACO,mBAAmB;QAC1B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AAO,IAAI,sBAAsB,CAAC,SAAS,EAAE,aAAa,CAAC,KAAK,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;IACvF,CAAC;;AA5e6D;IAA7D,MAAM,CAAC,cAAc,CAAC,kBAAkB,CAAC;;kEAA0D;AAWlD;IAAjD,MAAM,CAAC,cAAc,CAAC,gBAAgB,CAAC;;oEAA8C;AAQpC;IAAjD,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC;;8DAAwC;AAwGT;IAA5D,MAAM,CAAC,cAAc,CAAC,eAAe,CAAC;IAAE,QAAQ,EAAE;;mEAAmD;AA5HnF,0BAA0B;IAD/C,UAAU,EAAE;GACS,0BAA0B,CA2hB/C"}
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
********************************************************************************/
|
|
9
9
|
import { type JsonModelState } from '@eclipse-glsp/server';
|
|
10
10
|
import { type AstNode } from '@hydranium/langium';
|
|
11
|
-
import { type MaybePromise } from '@hydranium/protocol';
|
|
11
|
+
import { type BasedOn, type MaybePromise } from '@hydranium/protocol';
|
|
12
12
|
import { AbstractHydraniumGlspState } from './abstract-hydranium-glsp-state.js';
|
|
13
13
|
/** Whole-document-text source model: the serialised text of the source root. */
|
|
14
14
|
export interface FullTextSourceModel {
|
|
@@ -27,17 +27,17 @@ export interface FullTextSourceModel {
|
|
|
27
27
|
* `serializer.Serializer` reached via `sharedServices.ServiceRegistry`
|
|
28
28
|
* (so multi-grammar workspaces route to the right serializer). `MaybePromise`
|
|
29
29
|
* because serialization may be async; the sync fast path is preserved.
|
|
30
|
-
* - {@link updateSourceModel} pushes the text back through
|
|
31
|
-
* `
|
|
32
|
-
*
|
|
30
|
+
* - {@link updateSourceModel} pushes the text back through the diagram's
|
|
31
|
+
* session (`update` accepts a raw text payload) and captures the re-parsed
|
|
32
|
+
* root, gated on the caller's `basedOn`; it throws without a session.
|
|
33
33
|
*
|
|
34
|
-
* No `
|
|
34
|
+
* No `base` / conflict reconcile: a whole-document model has exactly one
|
|
35
35
|
* field, so every concurrent edit is a same-field collision and undo / redo
|
|
36
36
|
* degrade to drop-on-divergence. Adopters that need field-level undo use
|
|
37
37
|
* `ReconcilingTransferHydraniumGlspState` instead.
|
|
38
38
|
*/
|
|
39
39
|
export declare class FullTextHydraniumGlspState<TRoot extends AstNode> extends AbstractHydraniumGlspState<TRoot, FullTextSourceModel> implements JsonModelState<FullTextSourceModel> {
|
|
40
40
|
get sourceModel(): MaybePromise<FullTextSourceModel>;
|
|
41
|
-
updateSourceModel(model: FullTextSourceModel): Promise<void>;
|
|
41
|
+
updateSourceModel(model: FullTextSourceModel, basedOn?: BasedOn): Promise<void>;
|
|
42
42
|
}
|
|
43
43
|
//# sourceMappingURL=full-text-hydranium-glsp-state.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"full-text-hydranium-glsp-state.d.ts","sourceRoot":"","sources":["../../src/state/full-text-hydranium-glsp-state.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE3D,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,EAAiB,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"full-text-hydranium-glsp-state.d.ts","sourceRoot":"","sources":["../../src/state/full-text-hydranium-glsp-state.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE3D,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,EAAE,KAAK,OAAO,EAAiB,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACrF,OAAO,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AAEhF,gFAAgF;AAChF,MAAM,WAAW,mBAAmB;IACjC,IAAI,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBACa,0BAA0B,CAAC,KAAK,SAAS,OAAO,CAC1D,SAAQ,0BAA0B,CAAC,KAAK,EAAE,mBAAmB,CAC7D,YAAW,cAAc,CAAC,mBAAmB,CAAC;IAE9C,IAAI,WAAW,IAAI,YAAY,CAAC,mBAAmB,CAAC,CAInD;IAEK,iBAAiB,CAAC,KAAK,EAAE,mBAAmB,EAAE,OAAO,GAAE,OAAsB,GAAG,OAAO,CAAC,IAAI,CAAC;CAIrG"}
|
|
@@ -29,11 +29,11 @@ import { AbstractHydraniumGlspState } from './abstract-hydranium-glsp-state.js';
|
|
|
29
29
|
* `serializer.Serializer` reached via `sharedServices.ServiceRegistry`
|
|
30
30
|
* (so multi-grammar workspaces route to the right serializer). `MaybePromise`
|
|
31
31
|
* because serialization may be async; the sync fast path is preserved.
|
|
32
|
-
* - {@link updateSourceModel} pushes the text back through
|
|
33
|
-
* `
|
|
34
|
-
*
|
|
32
|
+
* - {@link updateSourceModel} pushes the text back through the diagram's
|
|
33
|
+
* session (`update` accepts a raw text payload) and captures the re-parsed
|
|
34
|
+
* root, gated on the caller's `basedOn`; it throws without a session.
|
|
35
35
|
*
|
|
36
|
-
* No `
|
|
36
|
+
* No `base` / conflict reconcile: a whole-document model has exactly one
|
|
37
37
|
* field, so every concurrent edit is a same-field collision and undo / redo
|
|
38
38
|
* degrade to drop-on-divergence. Adopters that need field-level undo use
|
|
39
39
|
* `ReconcilingTransferHydraniumGlspState` instead.
|
|
@@ -44,12 +44,8 @@ let FullTextHydraniumGlspState = class FullTextHydraniumGlspState extends Abstra
|
|
|
44
44
|
const text = serializer.serializeAst(this._sourceRoot);
|
|
45
45
|
return isPromiseLike(text) ? text.then(value => ({ text: value })) : { text };
|
|
46
46
|
}
|
|
47
|
-
async updateSourceModel(model) {
|
|
48
|
-
const document = await this.
|
|
49
|
-
uri: this._sourceUri,
|
|
50
|
-
model: model.text,
|
|
51
|
-
clientId: this.clientId
|
|
52
|
-
});
|
|
47
|
+
async updateSourceModel(model, basedOn = this.basedOn) {
|
|
48
|
+
const document = await this.requireModelSession().update({ uri: this._sourceUri, model: model.text, basedOn });
|
|
53
49
|
this.setSourceRoot(this._sourceUri, document.root);
|
|
54
50
|
}
|
|
55
51
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"full-text-hydranium-glsp-state.js","sourceRoot":"","sources":["../../src/state/full-text-hydranium-glsp-state.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;;;;;;;AAGlF,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC,OAAO,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AACzC,OAAO,
|
|
1
|
+
{"version":3,"file":"full-text-hydranium-glsp-state.js","sourceRoot":"","sources":["../../src/state/full-text-hydranium-glsp-state.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;;;;;;;AAGlF,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC,OAAO,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AACzC,OAAO,EAAgB,aAAa,EAAqB,MAAM,qBAAqB,CAAC;AACrF,OAAO,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AAOhF;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEI,IAAM,0BAA0B,GAAhC,MAAM,0BACV,SAAQ,0BAAsD;IAG9D,IAAI,WAAW;QACZ,MAAM,UAAU,GAAG,IAAI,CAAC,cAAc,CAAC,eAAe,CAAC,WAAW,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,UAAU,CAAC;QACrH,MAAM,IAAI,GAAG,UAAU,CAAC,YAAY,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACvD,OAAO,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC;IACjF,CAAC;IAED,KAAK,CAAC,iBAAiB,CAAC,KAA0B,EAAE,UAAmB,IAAI,CAAC,OAAO;QAChF,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,mBAAmB,EAAE,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;QAC/G,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,IAAa,CAAC,CAAC;IAC/D,CAAC;CACH,CAAA;AAdY,0BAA0B;IADtC,UAAU,EAAE;GACA,0BAA0B,CActC"}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* SPDX-License-Identifier: MIT
|
|
8
8
|
********************************************************************************/
|
|
9
|
-
import { type ConflictResolver, type Logger } from '@hydranium/protocol';
|
|
9
|
+
import { type BasedOn, type ConflictResolver, type Logger } from '@hydranium/protocol';
|
|
10
10
|
/**
|
|
11
11
|
* The I/O and policy a {@link reconcileSourceModelWrite} call needs. Deliberately
|
|
12
12
|
* a plain record rather than a base class: the states that use it differ in what
|
|
@@ -16,15 +16,16 @@ import { type ConflictResolver, type Logger } from '@hydranium/protocol';
|
|
|
16
16
|
*/
|
|
17
17
|
export interface SourceModelWriteHooks<TModel> {
|
|
18
18
|
/**
|
|
19
|
-
* Write `model` and
|
|
20
|
-
* on the first attempt (opting into the `ConflictError` gate) and
|
|
21
|
-
* on the merged / forced retries, where the
|
|
19
|
+
* Write `model` and record the resulting state. Called with the caller's own
|
|
20
|
+
* `basedOn` on the first attempt (opting into the `ConflictError` gate) and
|
|
21
|
+
* with `'anything'` on the merged / forced retries, where the reconcile has
|
|
22
|
+
* already decided to win and the point is to land the write.
|
|
22
23
|
*/
|
|
23
|
-
persist(model: TModel,
|
|
24
|
+
persist(model: TModel, basedOn: BasedOn): Promise<void>;
|
|
24
25
|
/** Current server-side projection, or `undefined` when unavailable. */
|
|
25
26
|
refetch(): Promise<TModel | undefined>;
|
|
26
|
-
/**
|
|
27
|
-
readonly
|
|
27
|
+
/** The last in-sync projection the user's intent is measured against. */
|
|
28
|
+
readonly base: TModel | undefined;
|
|
28
29
|
readonly conflictResolver: ConflictResolver;
|
|
29
30
|
readonly logger: Logger;
|
|
30
31
|
/** Invoked when the edit is dropped, so the caller can resync its own state. */
|
|
@@ -39,5 +40,5 @@ export interface SourceModelWriteHooks<TModel> {
|
|
|
39
40
|
* re-thrown untouched — this function only knows how to handle the specific
|
|
40
41
|
* failure of "the based-on version was superseded".
|
|
41
42
|
*/
|
|
42
|
-
export declare function reconcileSourceModelWrite<TModel extends object>(model: TModel,
|
|
43
|
+
export declare function reconcileSourceModelWrite<TModel extends object>(model: TModel, basedOn: BasedOn, hooks: SourceModelWriteHooks<TModel>): Promise<void>;
|
|
43
44
|
//# sourceMappingURL=reconcile-source-model-write.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reconcile-source-model-write.d.ts","sourceRoot":"","sources":["../../src/state/reconcile-source-model-write.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,KAAK,gBAAgB,EAAE,KAAK,MAAM,EAAmB,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"reconcile-source-model-write.d.ts","sourceRoot":"","sources":["../../src/state/reconcile-source-model-write.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,gBAAgB,EAAE,KAAK,MAAM,EAAmB,MAAM,qBAAqB,CAAC;AAExG;;;;;;GAMG;AACH,MAAM,WAAW,qBAAqB,CAAC,MAAM;IAC1C;;;;;OAKG;IACH,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxD,uEAAuE;IACvE,OAAO,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IACvC,yEAAyE;IACzE,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,QAAQ,CAAC,gBAAgB,EAAE,gBAAgB,CAAC;IAC5C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,gFAAgF;IAChF,iBAAiB,IAAI,IAAI,CAAC;CAC5B;AAED;;;;;;;;GAQG;AACH,wBAAsB,yBAAyB,CAAC,MAAM,SAAS,MAAM,EAClE,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,qBAAqB,CAAC,MAAM,CAAC,GACpC,OAAO,CAAC,IAAI,CAAC,CA8Bf"}
|
|
@@ -16,30 +16,30 @@ import { isConflictError } from '@hydranium/protocol';
|
|
|
16
16
|
* re-thrown untouched — this function only knows how to handle the specific
|
|
17
17
|
* failure of "the based-on version was superseded".
|
|
18
18
|
*/
|
|
19
|
-
export async function reconcileSourceModelWrite(model,
|
|
19
|
+
export async function reconcileSourceModelWrite(model, basedOn, hooks) {
|
|
20
20
|
try {
|
|
21
|
-
await hooks.persist(model,
|
|
21
|
+
await hooks.persist(model, basedOn);
|
|
22
22
|
}
|
|
23
23
|
catch (err) {
|
|
24
24
|
if (!isConflictError(err)) {
|
|
25
25
|
throw err;
|
|
26
26
|
}
|
|
27
|
-
const outcome = await hooks.conflictResolver.resolve(hooks.
|
|
27
|
+
const outcome = await hooks.conflictResolver.resolve(hooks.base ?? model, model, () => hooks.refetch());
|
|
28
28
|
switch (outcome.status) {
|
|
29
29
|
case 'merged':
|
|
30
|
-
await hooks.persist(outcome.merged);
|
|
30
|
+
await hooks.persist(outcome.merged, 'anything');
|
|
31
31
|
return;
|
|
32
32
|
case 'no-op':
|
|
33
|
-
hooks.logger.debug(`updateSourceModel no-op (v${err.
|
|
33
|
+
hooks.logger.debug(`updateSourceModel no-op (v${err.expectedVersion} → v${err.actualVersion}); already in sync`);
|
|
34
34
|
return;
|
|
35
35
|
case 'conflict':
|
|
36
|
-
hooks.logger.warn(`updateSourceModel conflict (v${err.
|
|
36
|
+
hooks.logger.warn(`updateSourceModel conflict (v${err.expectedVersion} → v${err.actualVersion}); dropping the diagram edit — ` +
|
|
37
37
|
'a foreign writer changed the same field');
|
|
38
38
|
hooks.onConflictDropped();
|
|
39
39
|
return;
|
|
40
40
|
case 'unavailable':
|
|
41
|
-
hooks.logger.warn(`updateSourceModel refetch unavailable (v${err.
|
|
42
|
-
await hooks.persist(model);
|
|
41
|
+
hooks.logger.warn(`updateSourceModel refetch unavailable (v${err.expectedVersion} → v${err.actualVersion}); forcing without version`);
|
|
42
|
+
await hooks.persist(model, 'anything');
|
|
43
43
|
return;
|
|
44
44
|
}
|
|
45
45
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reconcile-source-model-write.js","sourceRoot":"","sources":["../../src/state/reconcile-source-model-write.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,
|
|
1
|
+
{"version":3,"file":"reconcile-source-model-write.js","sourceRoot":"","sources":["../../src/state/reconcile-source-model-write.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAoD,eAAe,EAAE,MAAM,qBAAqB,CAAC;AA2BxG;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAC5C,KAAa,EACb,OAAgB,EAChB,KAAoC;IAEpC,IAAI,CAAC;QACF,MAAM,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IACvC,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACZ,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,EAAE,CAAC;YACzB,MAAM,GAAG,CAAC;QACb,CAAC;QACD,MAAM,OAAO,GAAG,MAAM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