@hydranium/glsp-server 1.0.0-next.117 → 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/lib/command/hydranium-glsp-recording-command.d.ts +1 -1
- package/lib/command/hydranium-glsp-recording-command.js +1 -1
- package/lib/messages/index.d.ts +1 -1
- package/lib/messages/index.d.ts.map +1 -1
- package/lib/messages/index.js +1 -1
- package/lib/messages/index.js.map +1 -1
- package/lib/state/abstract-hydranium-glsp-state.d.ts +52 -8
- package/lib/state/abstract-hydranium-glsp-state.d.ts.map +1 -1
- package/lib/state/abstract-hydranium-glsp-state.js +77 -5
- package/lib/state/abstract-hydranium-glsp-state.js.map +1 -1
- package/lib/state/full-text-hydranium-glsp-state.d.ts +4 -4
- package/lib/state/full-text-hydranium-glsp-state.d.ts.map +1 -1
- package/lib/state/full-text-hydranium-glsp-state.js +5 -10
- package/lib/state/full-text-hydranium-glsp-state.js.map +1 -1
- package/lib/state/reconcile-source-model-write.d.ts +2 -2
- package/lib/state/reconcile-source-model-write.d.ts.map +1 -1
- package/lib/state/reconcile-source-model-write.js +1 -1
- package/lib/state/reconcile-source-model-write.js.map +1 -1
- package/lib/state/reconciling-multi-document-glsp-state.d.ts +54 -74
- package/lib/state/reconciling-multi-document-glsp-state.d.ts.map +1 -1
- package/lib/state/reconciling-multi-document-glsp-state.js +77 -102
- package/lib/state/reconciling-multi-document-glsp-state.js.map +1 -1
- package/lib/state/reconciling-transfer-hydranium-glsp-state.d.ts +16 -15
- package/lib/state/reconciling-transfer-hydranium-glsp-state.d.ts.map +1 -1
- package/lib/state/reconciling-transfer-hydranium-glsp-state.js +21 -25
- package/lib/state/reconciling-transfer-hydranium-glsp-state.js.map +1 -1
- package/lib/storage/hydranium-glsp-storage.d.ts +103 -26
- package/lib/storage/hydranium-glsp-storage.d.ts.map +1 -1
- package/lib/storage/hydranium-glsp-storage.js +199 -32
- package/lib/storage/hydranium-glsp-storage.js.map +1 -1
- package/package.json +7 -7
- package/src/command/hydranium-glsp-recording-command.ts +1 -1
- package/src/messages/index.ts +6 -1
- package/src/state/abstract-hydranium-glsp-state.ts +85 -8
- package/src/state/full-text-hydranium-glsp-state.ts +5 -10
- package/src/state/reconcile-source-model-write.ts +3 -3
- package/src/state/reconciling-multi-document-glsp-state.ts +78 -103
- package/src/state/reconciling-transfer-hydranium-glsp-state.ts +21 -25
- package/src/storage/hydranium-glsp-storage.ts +236 -33
|
@@ -45,7 +45,7 @@ export type HydraniumGlspRecordingState<TSourceModel extends AnyObject> = Abstra
|
|
|
45
45
|
* `modelState.updateSourceModel(newModel)` with the model only. The
|
|
46
46
|
* framework lift overrides `postChange` so it also threads the snapshot
|
|
47
47
|
* version taken at command start — letting the downstream
|
|
48
|
-
* `
|
|
48
|
+
* session `update` opt into the `ConflictError` gate. Undo / redo
|
|
49
49
|
* postChange calls pass `'anything'`: the user authored against the recorded
|
|
50
50
|
* patch, not against a specific server version, so re-applying it should
|
|
51
51
|
* succeed regardless of intervening edits. The recorded patch itself encodes
|
|
@@ -31,7 +31,7 @@ import { JsonRecordingCommand } from '@eclipse-glsp/server';
|
|
|
31
31
|
* `modelState.updateSourceModel(newModel)` with the model only. The
|
|
32
32
|
* framework lift overrides `postChange` so it also threads the snapshot
|
|
33
33
|
* version taken at command start — letting the downstream
|
|
34
|
-
* `
|
|
34
|
+
* session `update` opt into the `ConflictError` gate. Undo / redo
|
|
35
35
|
* postChange calls pass `'anything'`: the user authored against the recorded
|
|
36
36
|
* patch, not against a specific server version, so re-applying it should
|
|
37
37
|
* succeed regardless of intervening edits. The recorded patch itself encodes
|
package/lib/messages/index.d.ts
CHANGED
|
@@ -20,5 +20,5 @@
|
|
|
20
20
|
* The barrel is also how an adopter rendering their own diagram chrome
|
|
21
21
|
* discovers the codes exist.
|
|
22
22
|
*/
|
|
23
|
-
export { DIAGRAM_READONLY_PARSE_ERROR, SAVE_TARGET_UNKNOWN, SOURCE_URI_MISSING } from '../storage/hydranium-glsp-storage.js';
|
|
23
|
+
export { DIAGRAM_READONLY_PARSE_ERROR, DIAGRAM_SESSION_REFUSED, SAVE_TARGET_UNKNOWN, SOURCE_URI_MISSING } from '../storage/hydranium-glsp-storage.js';
|
|
24
24
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/messages/index.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF;;;;;;;;;;;;;GAaG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/messages/index.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF;;;;;;;;;;;;;GAaG;AAEH,OAAO,EACJ,4BAA4B,EAC5B,uBAAuB,EACvB,mBAAmB,EACnB,kBAAkB,EACpB,MAAM,sCAAsC,CAAC"}
|
package/lib/messages/index.js
CHANGED
|
@@ -20,5 +20,5 @@
|
|
|
20
20
|
* The barrel is also how an adopter rendering their own diagram chrome
|
|
21
21
|
* discovers the codes exist.
|
|
22
22
|
*/
|
|
23
|
-
export { DIAGRAM_READONLY_PARSE_ERROR, SAVE_TARGET_UNKNOWN, SOURCE_URI_MISSING } from '../storage/hydranium-glsp-storage.js';
|
|
23
|
+
export { DIAGRAM_READONLY_PARSE_ERROR, DIAGRAM_SESSION_REFUSED, SAVE_TARGET_UNKNOWN, SOURCE_URI_MISSING } from '../storage/hydranium-glsp-storage.js';
|
|
24
24
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/messages/index.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF;;;;;;;;;;;;;GAaG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/messages/index.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF;;;;;;;;;;;;;GAaG;AAEH,OAAO,EACJ,4BAA4B,EAC5B,uBAAuB,EACvB,mBAAmB,EACnB,kBAAkB,EACpB,MAAM,sCAAsC,CAAC"}
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
import { DefaultModelState, type MaybePromise } from '@eclipse-glsp/server';
|
|
10
10
|
import { Emitter, type Event } from 'vscode-jsonrpc';
|
|
11
11
|
import { type AstNode, DocumentState } from '@hydranium/langium';
|
|
12
|
-
import { type HydraniumScopeProvider, type LanguageTarget, type NameProvider, type ReferenceCandidateProvider, type ServerLanguageServices, type ServerSharedServices } from '@hydranium/core';
|
|
12
|
+
import { type ClientSession, type HydraniumScopeProvider, type LanguageTarget, type NameProvider, type ReferenceCandidateProvider, type ServerLanguageServices, type ServerSharedServices } from '@hydranium/core';
|
|
13
13
|
import { type BasedOn, type SnapshotVersion, type ConflictResolver, type Logger, type Tracer } from '@hydranium/protocol';
|
|
14
14
|
import { type HydraniumGlspIndex } from './hydranium-glsp-index.js';
|
|
15
15
|
import { ModelReadyTimeoutError } from './model-ready-timeout-error.js';
|
|
@@ -71,6 +71,25 @@ export declare abstract class AbstractHydraniumGlspState<TRoot extends AstNode,
|
|
|
71
71
|
protected readonly baseTracer: Tracer;
|
|
72
72
|
/** Narrows {@link DefaultModelState.index} to the framework-extended index type. */
|
|
73
73
|
readonly index: HydraniumGlspIndex;
|
|
74
|
+
/**
|
|
75
|
+
* The client session this diagram works as, registered under `clientId` by
|
|
76
|
+
* the source-model storage and ended with the GLSP client session.
|
|
77
|
+
* `undefined` for GLSP's placeholder client, and when the id was held by
|
|
78
|
+
* another participant, in which case the diagram does not load.
|
|
79
|
+
*
|
|
80
|
+
* Every write of the diagram goes through this session, which writes only a
|
|
81
|
+
* document it has open and opens nothing. A one-shot write to a document
|
|
82
|
+
* outside the write set goes through
|
|
83
|
+
* {@link ClientSession.withOpen}, and a document the diagram brings into
|
|
84
|
+
* existence through {@link ClientSession.create}.
|
|
85
|
+
*/
|
|
86
|
+
modelSession?: ClientSession<AstNode>;
|
|
87
|
+
/**
|
|
88
|
+
* {@link modelSession}, or a throw without one: the diagram never loaded or
|
|
89
|
+
* has ended. Looking `clientId` up through `ModelService.getSession` instead
|
|
90
|
+
* would write as whichever participant holds that id.
|
|
91
|
+
*/
|
|
92
|
+
protected requireModelSession(): ClientSession<AstNode>;
|
|
74
93
|
protected _sourceUri: string;
|
|
75
94
|
protected _sourceRoot: TRoot;
|
|
76
95
|
protected _tracer?: Tracer;
|
|
@@ -174,8 +193,8 @@ export declare abstract class AbstractHydraniumGlspState<TRoot extends AstNode,
|
|
|
174
193
|
* until the next one, then re-read from the document store.
|
|
175
194
|
*
|
|
176
195
|
* Threaded by `HydraniumGlspRecordingCommand` into
|
|
177
|
-
* {@link updateSourceModel} so the downstream `
|
|
178
|
-
*
|
|
196
|
+
* {@link updateSourceModel} so the downstream session `update` / `save`
|
|
197
|
+
* gates against what the command was authored on. See
|
|
179
198
|
* `@hydranium/protocol#ConflictError` for the detection contract.
|
|
180
199
|
*
|
|
181
200
|
* **This, not a number read at write time, is what a write must be gated
|
|
@@ -185,7 +204,9 @@ export declare abstract class AbstractHydraniumGlspState<TRoot extends AstNode,
|
|
|
185
204
|
get basedOn(): SnapshotVersion;
|
|
186
205
|
/**
|
|
187
206
|
* Text-document version of {@link basedOn}. Mirrors the server-side
|
|
188
|
-
* `TextDocuments.version(uri)` counter as of the snapshot
|
|
207
|
+
* `TextDocuments.version(uri)` counter as of the snapshot, or is
|
|
208
|
+
* `NO_MATCHING_VERSION` when the store's text could not be tied to the
|
|
209
|
+
* root (see {@link readSnapshotVersion}).
|
|
189
210
|
*
|
|
190
211
|
* Falls back to `0` when the document is absent from `LangiumDocuments`
|
|
191
212
|
* when the snapshot is taken — the same observable state callers see for a
|
|
@@ -263,8 +284,19 @@ export declare abstract class AbstractHydraniumGlspState<TRoot extends AstNode,
|
|
|
263
284
|
* answers with the version the write is about to be compared against, so the
|
|
264
285
|
* gate passes unconditionally.
|
|
265
286
|
*
|
|
266
|
-
* Falls back to v0 for a URI
|
|
287
|
+
* Falls back to v0 for a URI neither store knows, matching what
|
|
267
288
|
* {@link version} reports for a document that was never opened.
|
|
289
|
+
*
|
|
290
|
+
* **The version of the text store, which the gate compares against.**
|
|
291
|
+
* When the store holds the text the root was parsed from, that is its
|
|
292
|
+
* version, even while the built document still carries an older number.
|
|
293
|
+
* When the store holds other text, `NO_MATCHING_VERSION`, so the write
|
|
294
|
+
* conflicts instead of overwriting text the root never saw: the
|
|
295
|
+
* reconciling states reconcile it, `FullTextHydraniumGlspState` throws the
|
|
296
|
+
* `ConflictError`. When the root keeps no syntax tree to read its text
|
|
297
|
+
* from, the built document's text stands in for it, unless the built
|
|
298
|
+
* document IS the store's, whose text says nothing about what was parsed;
|
|
299
|
+
* that also gets `NO_MATCHING_VERSION`.
|
|
268
300
|
*/
|
|
269
301
|
protected readSnapshotVersion(uri: string): SnapshotVersion;
|
|
270
302
|
/** Re-take every registered secondary's snapshot version from the document store. */
|
|
@@ -277,6 +309,18 @@ export declare abstract class AbstractHydraniumGlspState<TRoot extends AstNode,
|
|
|
277
309
|
* handlers) must see the root the freshly built document carries.
|
|
278
310
|
*/
|
|
279
311
|
protected refreshSourceRoot(): void;
|
|
312
|
+
/**
|
|
313
|
+
* The root that `uri`'s text parses to (the text store's, or the built
|
|
314
|
+
* document's when the store holds none), read once the document has
|
|
315
|
+
* validated; `undefined` when it cannot be read.
|
|
316
|
+
*
|
|
317
|
+
* **Parsed afresh, never the built root.** Operation handlers edit the
|
|
318
|
+
* built root in place, so until a rebuild replaces it, it already holds
|
|
319
|
+
* the edit being reconciled, and replaying the edit onto it applies it
|
|
320
|
+
* twice. The root is parsed, not linked: an encoder hook reading a
|
|
321
|
+
* reference's `ref` sees `undefined` on it.
|
|
322
|
+
*/
|
|
323
|
+
protected readCurrentRoot(uri: string): Promise<AstNode | undefined>;
|
|
280
324
|
/**
|
|
281
325
|
* Wait until the captured document reaches `state`, then run
|
|
282
326
|
* {@link onReadyRefreshed} so consumers see a fresh AST. Wraps the
|
|
@@ -335,9 +379,9 @@ export declare abstract class AbstractHydraniumGlspState<TRoot extends AstNode,
|
|
|
335
379
|
* intersection at the recording-command call site.
|
|
336
380
|
*
|
|
337
381
|
* `basedOn` is the snapshot version taken at command start by
|
|
338
|
-
* `HydraniumGlspRecordingCommand.execute`. Adopters that
|
|
339
|
-
*
|
|
340
|
-
*
|
|
382
|
+
* `HydraniumGlspRecordingCommand.execute`. Adopters that write through the
|
|
383
|
+
* diagram's session forward it as the args' `basedOn` field; adopters whose
|
|
384
|
+
* write path doesn't go through the session ignore it.
|
|
341
385
|
* `'anything'` when the writer is not the recording command (an external
|
|
342
386
|
* storage refresh, an undo replaying a recorded patch), which is a write
|
|
343
387
|
* authored against no particular server version.
|
|
@@ -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,EACJ,KAAK,OAAO,EACZ,KAAK,eAAe,EACpB,KAAK,gBAAgB,EAErB,KAAK,MAAM,EACX,KAAK,MAAM,
|
|
1
|
+
{"version":3,"file":"abstract-hydranium-glsp-state.d.ts","sourceRoot":"","sources":["../../src/state/abstract-hydranium-glsp-state.ts"],"names":[],"mappings":"AAAA;;;;;;;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C,KAAK,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,YAAY,CAAC,IAAI,CAAC;CACxF"}
|
|
@@ -20,7 +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 } from '@hydranium/protocol';
|
|
23
|
+
import { asSnapshotVersion, NO_MATCHING_VERSION } from '@hydranium/protocol';
|
|
24
24
|
import { HydraniumTypes } from './hydranium-shared-core-services.js';
|
|
25
25
|
import { ModelReadyTimeoutError } from './model-ready-timeout-error.js';
|
|
26
26
|
/**
|
|
@@ -80,6 +80,30 @@ let AbstractHydraniumGlspState = class AbstractHydraniumGlspState extends Defaul
|
|
|
80
80
|
* getters fall back to it before then, so logging is never `undefined`.
|
|
81
81
|
*/
|
|
82
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
|
+
}
|
|
83
107
|
_sourceUri;
|
|
84
108
|
_sourceRoot;
|
|
85
109
|
_tracer;
|
|
@@ -223,8 +247,8 @@ let AbstractHydraniumGlspState = class AbstractHydraniumGlspState extends Defaul
|
|
|
223
247
|
* until the next one, then re-read from the document store.
|
|
224
248
|
*
|
|
225
249
|
* Threaded by `HydraniumGlspRecordingCommand` into
|
|
226
|
-
* {@link updateSourceModel} so the downstream `
|
|
227
|
-
*
|
|
250
|
+
* {@link updateSourceModel} so the downstream session `update` / `save`
|
|
251
|
+
* gates against what the command was authored on. See
|
|
228
252
|
* `@hydranium/protocol#ConflictError` for the detection contract.
|
|
229
253
|
*
|
|
230
254
|
* **This, not a number read at write time, is what a write must be gated
|
|
@@ -236,7 +260,9 @@ let AbstractHydraniumGlspState = class AbstractHydraniumGlspState extends Defaul
|
|
|
236
260
|
}
|
|
237
261
|
/**
|
|
238
262
|
* Text-document version of {@link basedOn}. Mirrors the server-side
|
|
239
|
-
* `TextDocuments.version(uri)` counter as of the snapshot
|
|
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}).
|
|
240
266
|
*
|
|
241
267
|
* Falls back to `0` when the document is absent from `LangiumDocuments`
|
|
242
268
|
* when the snapshot is taken — the same observable state callers see for a
|
|
@@ -343,10 +369,35 @@ let AbstractHydraniumGlspState = class AbstractHydraniumGlspState extends Defaul
|
|
|
343
369
|
* answers with the version the write is about to be compared against, so the
|
|
344
370
|
* gate passes unconditionally.
|
|
345
371
|
*
|
|
346
|
-
* Falls back to v0 for a URI
|
|
372
|
+
* Falls back to v0 for a URI neither store knows, matching what
|
|
347
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`.
|
|
348
385
|
*/
|
|
349
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
|
+
}
|
|
350
401
|
return this.sharedServices.model.ModelService.snapshot(uri)?.version ?? asSnapshotVersion(0);
|
|
351
402
|
}
|
|
352
403
|
/** Re-take every registered secondary's snapshot version from the document store. */
|
|
@@ -376,6 +427,27 @@ let AbstractHydraniumGlspState = class AbstractHydraniumGlspState extends Defaul
|
|
|
376
427
|
this.setSourceRoot(this._sourceUri, root);
|
|
377
428
|
}
|
|
378
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
|
+
}
|
|
379
451
|
/**
|
|
380
452
|
* Wait until the captured document reaches `state`, then run
|
|
381
453
|
* {@link onReadyRefreshed} so consumers see a fresh AST. Wraps the
|
|
@@ -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;;;;;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
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.
|
|
@@ -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,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;
|
|
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.
|
|
@@ -45,12 +45,7 @@ let FullTextHydraniumGlspState = class FullTextHydraniumGlspState extends Abstra
|
|
|
45
45
|
return isPromiseLike(text) ? text.then(value => ({ text: value })) : { text };
|
|
46
46
|
}
|
|
47
47
|
async updateSourceModel(model, basedOn = this.basedOn) {
|
|
48
|
-
const document = await this.
|
|
49
|
-
uri: this._sourceUri,
|
|
50
|
-
model: model.text,
|
|
51
|
-
clientId: this.clientId,
|
|
52
|
-
basedOn
|
|
53
|
-
});
|
|
48
|
+
const document = await this.requireModelSession().update({ uri: this._sourceUri, model: model.text, basedOn });
|
|
54
49
|
this.setSourceRoot(this._sourceUri, document.root);
|
|
55
50
|
}
|
|
56
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,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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AC,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"}
|
|
@@ -24,8 +24,8 @@ export interface SourceModelWriteHooks<TModel> {
|
|
|
24
24
|
persist(model: TModel, basedOn: BasedOn): Promise<void>;
|
|
25
25
|
/** Current server-side projection, or `undefined` when unavailable. */
|
|
26
26
|
refetch(): Promise<TModel | undefined>;
|
|
27
|
-
/**
|
|
28
|
-
readonly
|
|
27
|
+
/** The last in-sync projection the user's intent is measured against. */
|
|
28
|
+
readonly base: TModel | undefined;
|
|
29
29
|
readonly conflictResolver: ConflictResolver;
|
|
30
30
|
readonly logger: Logger;
|
|
31
31
|
/** Invoked when the edit is dropped, so the caller can resync its own state. */
|
|
@@ -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,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,
|
|
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"}
|
|
@@ -24,7 +24,7 @@ export async function reconcileSourceModelWrite(model, basedOn, hooks) {
|
|
|
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
30
|
await hooks.persist(outcome.merged, 'anything');
|
|
@@ -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,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,KAAK,CAAC,gBAAgB,CAAC,OAAO,CAAC,KAAK,CAAC,
|
|
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,KAAK,CA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