@hydranium/glsp-server 1.0.0-next.10
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/LICENSE +21 -0
- package/README.md +97 -0
- package/lib/browser/index.d.ts +10 -0
- package/lib/browser/index.d.ts.map +1 -0
- package/lib/browser/index.js +15 -0
- package/lib/browser/index.js.map +1 -0
- package/lib/browser/start-glsp-server-in-worker.d.ts +121 -0
- package/lib/browser/start-glsp-server-in-worker.d.ts.map +1 -0
- package/lib/browser/start-glsp-server-in-worker.js +102 -0
- package/lib/browser/start-glsp-server-in-worker.js.map +1 -0
- package/lib/command/hydranium-glsp-recording-command.d.ts +132 -0
- package/lib/command/hydranium-glsp-recording-command.d.ts.map +1 -0
- package/lib/command/hydranium-glsp-recording-command.js +159 -0
- package/lib/command/hydranium-glsp-recording-command.js.map +1 -0
- package/lib/command/index.d.ts +10 -0
- package/lib/command/index.d.ts.map +1 -0
- package/lib/command/index.js +10 -0
- package/lib/command/index.js.map +1 -0
- package/lib/computed-bounds/hydranium-glsp-computed-bounds-action-handler.d.ts +61 -0
- package/lib/computed-bounds/hydranium-glsp-computed-bounds-action-handler.d.ts.map +1 -0
- package/lib/computed-bounds/hydranium-glsp-computed-bounds-action-handler.js +93 -0
- package/lib/computed-bounds/hydranium-glsp-computed-bounds-action-handler.js.map +1 -0
- package/lib/computed-bounds/index.d.ts +10 -0
- package/lib/computed-bounds/index.d.ts.map +1 -0
- package/lib/computed-bounds/index.js +10 -0
- package/lib/computed-bounds/index.js.map +1 -0
- package/lib/dispatcher/index.d.ts +10 -0
- package/lib/dispatcher/index.d.ts.map +1 -0
- package/lib/dispatcher/index.js +10 -0
- package/lib/dispatcher/index.js.map +1 -0
- package/lib/dispatcher/server-action-dispatcher.d.ts +52 -0
- package/lib/dispatcher/server-action-dispatcher.d.ts.map +1 -0
- package/lib/dispatcher/server-action-dispatcher.js +79 -0
- package/lib/dispatcher/server-action-dispatcher.js.map +1 -0
- package/lib/index.d.ts +19 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +20 -0
- package/lib/index.js.map +1 -0
- package/lib/launcher/abstract-hydranium-glsp-diagram-module.d.ts +75 -0
- package/lib/launcher/abstract-hydranium-glsp-diagram-module.d.ts.map +1 -0
- package/lib/launcher/abstract-hydranium-glsp-diagram-module.js +100 -0
- package/lib/launcher/abstract-hydranium-glsp-diagram-module.js.map +1 -0
- package/lib/launcher/glsp-app-module.d.ts +87 -0
- package/lib/launcher/glsp-app-module.d.ts.map +1 -0
- package/lib/launcher/glsp-app-module.js +71 -0
- package/lib/launcher/glsp-app-module.js.map +1 -0
- package/lib/launcher/glsp-framework-overrides.d.ts +32 -0
- package/lib/launcher/glsp-framework-overrides.d.ts.map +1 -0
- package/lib/launcher/glsp-framework-overrides.js +49 -0
- package/lib/launcher/glsp-framework-overrides.js.map +1 -0
- package/lib/launcher/glsp-server-overrides.d.ts +39 -0
- package/lib/launcher/glsp-server-overrides.d.ts.map +1 -0
- package/lib/launcher/glsp-server-overrides.js +45 -0
- package/lib/launcher/glsp-server-overrides.js.map +1 -0
- package/lib/launcher/hydranium-glsp-server.d.ts +62 -0
- package/lib/launcher/hydranium-glsp-server.d.ts.map +1 -0
- package/lib/launcher/hydranium-glsp-server.js +101 -0
- package/lib/launcher/hydranium-glsp-server.js.map +1 -0
- package/lib/launcher/index.d.ts +12 -0
- package/lib/launcher/index.d.ts.map +1 -0
- package/lib/launcher/index.js +22 -0
- package/lib/launcher/index.js.map +1 -0
- package/lib/logging/glsp-client-logger.d.ts +110 -0
- package/lib/logging/glsp-client-logger.d.ts.map +1 -0
- package/lib/logging/glsp-client-logger.js +151 -0
- package/lib/logging/glsp-client-logger.js.map +1 -0
- package/lib/logging/index.d.ts +10 -0
- package/lib/logging/index.d.ts.map +1 -0
- package/lib/logging/index.js +10 -0
- package/lib/logging/index.js.map +1 -0
- package/lib/node/index.d.ts +10 -0
- package/lib/node/index.d.ts.map +1 -0
- package/lib/node/index.js +13 -0
- package/lib/node/index.js.map +1 -0
- package/lib/node/start-glsp-server.d.ts +122 -0
- package/lib/node/start-glsp-server.d.ts.map +1 -0
- package/lib/node/start-glsp-server.js +103 -0
- package/lib/node/start-glsp-server.js.map +1 -0
- package/lib/state/abstract-hydranium-glsp-state.d.ts +333 -0
- package/lib/state/abstract-hydranium-glsp-state.d.ts.map +1 -0
- package/lib/state/abstract-hydranium-glsp-state.js +451 -0
- package/lib/state/abstract-hydranium-glsp-state.js.map +1 -0
- package/lib/state/full-text-hydranium-glsp-state.d.ts +43 -0
- package/lib/state/full-text-hydranium-glsp-state.d.ts.map +1 -0
- package/lib/state/full-text-hydranium-glsp-state.js +60 -0
- package/lib/state/full-text-hydranium-glsp-state.js.map +1 -0
- package/lib/state/hydranium-glsp-index.d.ts +220 -0
- package/lib/state/hydranium-glsp-index.d.ts.map +1 -0
- package/lib/state/hydranium-glsp-index.js +320 -0
- package/lib/state/hydranium-glsp-index.js.map +1 -0
- package/lib/state/hydranium-shared-core-services.d.ts +90 -0
- package/lib/state/hydranium-shared-core-services.d.ts.map +1 -0
- package/lib/state/hydranium-shared-core-services.js +89 -0
- package/lib/state/hydranium-shared-core-services.js.map +1 -0
- package/lib/state/index.d.ts +17 -0
- package/lib/state/index.d.ts.map +1 -0
- package/lib/state/index.js +17 -0
- package/lib/state/index.js.map +1 -0
- package/lib/state/model-ready-timeout-error.d.ts +28 -0
- package/lib/state/model-ready-timeout-error.d.ts.map +1 -0
- package/lib/state/model-ready-timeout-error.js +36 -0
- package/lib/state/model-ready-timeout-error.js.map +1 -0
- package/lib/state/reconcile-source-model-write.d.ts +43 -0
- package/lib/state/reconcile-source-model-write.d.ts.map +1 -0
- package/lib/state/reconcile-source-model-write.js +47 -0
- package/lib/state/reconcile-source-model-write.js.map +1 -0
- package/lib/state/reconciling-multi-document-glsp-state.d.ts +164 -0
- package/lib/state/reconciling-multi-document-glsp-state.d.ts.map +1 -0
- package/lib/state/reconciling-multi-document-glsp-state.js +222 -0
- package/lib/state/reconciling-multi-document-glsp-state.js.map +1 -0
- package/lib/state/reconciling-transfer-hydranium-glsp-state.d.ts +91 -0
- package/lib/state/reconciling-transfer-hydranium-glsp-state.d.ts.map +1 -0
- package/lib/state/reconciling-transfer-hydranium-glsp-state.js +129 -0
- package/lib/state/reconciling-transfer-hydranium-glsp-state.js.map +1 -0
- package/lib/storage/hydranium-glsp-storage.d.ts +348 -0
- package/lib/storage/hydranium-glsp-storage.d.ts.map +1 -0
- package/lib/storage/hydranium-glsp-storage.js +634 -0
- package/lib/storage/hydranium-glsp-storage.js.map +1 -0
- package/lib/storage/index.d.ts +11 -0
- package/lib/storage/index.d.ts.map +1 -0
- package/lib/storage/index.js +11 -0
- package/lib/storage/index.js.map +1 -0
- package/lib/storage/save-conflict-policy.d.ts +56 -0
- package/lib/storage/save-conflict-policy.d.ts.map +1 -0
- package/lib/storage/save-conflict-policy.js +19 -0
- package/lib/storage/save-conflict-policy.js.map +1 -0
- package/lib/submission/hydranium-glsp-submission-handler.d.ts +109 -0
- package/lib/submission/hydranium-glsp-submission-handler.d.ts.map +1 -0
- package/lib/submission/hydranium-glsp-submission-handler.js +157 -0
- package/lib/submission/hydranium-glsp-submission-handler.js.map +1 -0
- package/lib/submission/index.d.ts +10 -0
- package/lib/submission/index.d.ts.map +1 -0
- package/lib/submission/index.js +10 -0
- package/lib/submission/index.js.map +1 -0
- package/lib/testing/glsp-harness.d.ts +170 -0
- package/lib/testing/glsp-harness.d.ts.map +1 -0
- package/lib/testing/glsp-harness.js +231 -0
- package/lib/testing/glsp-harness.js.map +1 -0
- package/lib/testing/index.d.ts +11 -0
- package/lib/testing/index.d.ts.map +1 -0
- package/lib/testing/index.js +13 -0
- package/lib/testing/index.js.map +1 -0
- package/lib/testing/make-noop-glsp-logger.d.ts +42 -0
- package/lib/testing/make-noop-glsp-logger.d.ts.map +1 -0
- package/lib/testing/make-noop-glsp-logger.js +47 -0
- package/lib/testing/make-noop-glsp-logger.js.map +1 -0
- package/lib/util/index.d.ts +10 -0
- package/lib/util/index.d.ts.map +1 -0
- package/lib/util/index.js +10 -0
- package/lib/util/index.js.map +1 -0
- package/lib/util/service-identifier.d.ts +46 -0
- package/lib/util/service-identifier.d.ts.map +1 -0
- package/lib/util/service-identifier.js +47 -0
- package/lib/util/service-identifier.js.map +1 -0
- package/lib/validation/diagnostic-markers.d.ts +48 -0
- package/lib/validation/diagnostic-markers.d.ts.map +1 -0
- package/lib/validation/diagnostic-markers.js +68 -0
- package/lib/validation/diagnostic-markers.js.map +1 -0
- package/lib/validation/hydranium-glsp-model-validator.d.ts +51 -0
- package/lib/validation/hydranium-glsp-model-validator.d.ts.map +1 -0
- package/lib/validation/hydranium-glsp-model-validator.js +118 -0
- package/lib/validation/hydranium-glsp-model-validator.js.map +1 -0
- package/lib/validation/index.d.ts +11 -0
- package/lib/validation/index.d.ts.map +1 -0
- package/lib/validation/index.js +11 -0
- package/lib/validation/index.js.map +1 -0
- package/package.json +111 -0
- package/src/browser/index.ts +15 -0
- package/src/browser/start-glsp-server-in-worker.ts +202 -0
- package/src/command/hydranium-glsp-recording-command.ts +183 -0
- package/src/command/index.ts +10 -0
- package/src/computed-bounds/hydranium-glsp-computed-bounds-action-handler.ts +103 -0
- package/src/computed-bounds/index.ts +10 -0
- package/src/dispatcher/index.ts +10 -0
- package/src/dispatcher/server-action-dispatcher.ts +72 -0
- package/src/index.ts +20 -0
- package/src/launcher/abstract-hydranium-glsp-diagram-module.ts +117 -0
- package/src/launcher/glsp-app-module.ts +106 -0
- package/src/launcher/glsp-framework-overrides.ts +51 -0
- package/src/launcher/glsp-server-overrides.ts +46 -0
- package/src/launcher/hydranium-glsp-server.ts +104 -0
- package/src/launcher/index.ts +22 -0
- package/src/logging/glsp-client-logger.ts +184 -0
- package/src/logging/index.ts +10 -0
- package/src/node/index.ts +13 -0
- package/src/node/start-glsp-server.ts +214 -0
- package/src/state/abstract-hydranium-glsp-state.ts +503 -0
- package/src/state/full-text-hydranium-glsp-state.ts +63 -0
- package/src/state/hydranium-glsp-index.ts +337 -0
- package/src/state/hydranium-shared-core-services.ts +92 -0
- package/src/state/index.ts +17 -0
- package/src/state/model-ready-timeout-error.ts +33 -0
- package/src/state/reconcile-source-model-write.ts +77 -0
- package/src/state/reconciling-multi-document-glsp-state.ts +248 -0
- package/src/state/reconciling-transfer-hydranium-glsp-state.ts +132 -0
- package/src/storage/hydranium-glsp-storage.ts +660 -0
- package/src/storage/index.ts +11 -0
- package/src/storage/save-conflict-policy.ts +52 -0
- package/src/submission/hydranium-glsp-submission-handler.ts +170 -0
- package/src/submission/index.ts +10 -0
- package/src/testing/glsp-harness.ts +422 -0
- package/src/testing/index.ts +14 -0
- package/src/testing/make-noop-glsp-logger.ts +66 -0
- package/src/util/index.ts +10 -0
- package/src/util/service-identifier.ts +49 -0
- package/src/validation/diagnostic-markers.ts +93 -0
- package/src/validation/hydranium-glsp-model-validator.ts +105 -0
- package/src/validation/index.ts +11 -0
|
@@ -0,0 +1,451 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2023-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
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
10
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
11
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
12
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
13
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
14
|
+
};
|
|
15
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
16
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
17
|
+
};
|
|
18
|
+
var AbstractHydraniumGlspState_1;
|
|
19
|
+
import { DefaultModelState, SOURCE_URI_ARG } from '@eclipse-glsp/server';
|
|
20
|
+
import { Emitter } from 'vscode-jsonrpc';
|
|
21
|
+
import { inject, injectable, optional } from 'inversify';
|
|
22
|
+
import { DocumentState, URI } from '@hydranium/langium';
|
|
23
|
+
import { HydraniumTypes } from './hydranium-shared-core-services.js';
|
|
24
|
+
import { ModelReadyTimeoutError } from './model-ready-timeout-error.js';
|
|
25
|
+
/**
|
|
26
|
+
* GLSP model state base shared by all hydranium adopters. Tracks the source
|
|
27
|
+
* AST root + URI alongside GLSP's GModel, exposes a build-state wait with
|
|
28
|
+
* timeout-and-race semantics, and wires a logger labelled with the adopter's
|
|
29
|
+
* component name + current document URI.
|
|
30
|
+
*
|
|
31
|
+
* **Source-root vs GLSP's `sourceUri`.** GLSP's {@link DefaultModelState}
|
|
32
|
+
* stores `sourceUri` via the loosely-typed properties map
|
|
33
|
+
* (`state.set(SOURCE_URI_ARG, uri)`). This base class makes the URI a
|
|
34
|
+
* first-class typed field set through {@link setSourceRoot}, then mirrors
|
|
35
|
+
* the value into the inherited properties map so legacy code paths that
|
|
36
|
+
* still call `state.get(SOURCE_URI_ARG)` continue to work. The inherited
|
|
37
|
+
* `sourceUri` getter is overridden to a narrowed `string` return (no
|
|
38
|
+
* `undefined` once {@link setSourceRoot} has run).
|
|
39
|
+
*
|
|
40
|
+
* **Hooks.**
|
|
41
|
+
* - {@link onReadyRefreshed} — runs after {@link ready} returns. Default
|
|
42
|
+
* calls {@link refreshSourceRoot} so callers see a fresh AST after a
|
|
43
|
+
* wait that may have rebuilt the document. Adopters whose AST is
|
|
44
|
+
* immutable between build phases can override to a no-op.
|
|
45
|
+
* - {@link buildReadyTimeoutError} — constructs the timeout error with the
|
|
46
|
+
* workspace-relative path + the document builder's build-status snapshot;
|
|
47
|
+
* override only to change the error shape (richer per-adopter output comes
|
|
48
|
+
* from overriding `wsRelativePath` / `formatBuildStatus`).
|
|
49
|
+
* - logging — see {@link baseTracer}. Adopters wanting a different label
|
|
50
|
+
* override `setSourceRoot` and derive via
|
|
51
|
+
* `this.baseTracer.for('Name').withUri(uri)`.
|
|
52
|
+
*
|
|
53
|
+
* **Lifecycle ordering.** Reading {@link sourceUri} or {@link sourceRoot}
|
|
54
|
+
* before the first {@link setSourceRoot} call throws via the
|
|
55
|
+
* definite-assignment assertions — callers must invoke `setSourceRoot`
|
|
56
|
+
* (typically from the storage `loadSourceModel` flow) before reading them.
|
|
57
|
+
* The {@link logger}/{@link tracer} are the exception: the injected
|
|
58
|
+
* {@link baseTracer} is always available, so the getters fall back to it
|
|
59
|
+
* before {@link setSourceRoot} derives the URI-tagged {@link _tracer} —
|
|
60
|
+
* logging is never `undefined`.
|
|
61
|
+
*/
|
|
62
|
+
let AbstractHydraniumGlspState = class AbstractHydraniumGlspState extends DefaultModelState {
|
|
63
|
+
static { AbstractHydraniumGlspState_1 = this; }
|
|
64
|
+
sharedServices;
|
|
65
|
+
/**
|
|
66
|
+
* Conflict-resolution policy consulted when a write races a foreign edit
|
|
67
|
+
* (forward-write, undo, redo, save). Bound by
|
|
68
|
+
* `HydraniumGlspAppModule` to the adopter's choice — default
|
|
69
|
+
* `ReconcilingConflictResolver` (field-level merge) unless the adopter
|
|
70
|
+
* passes a `ForceConflictResolver` (last-writer-wins). Read by
|
|
71
|
+
* `HydraniumGlspRecordingCommand`'s undo / redo and by adopter
|
|
72
|
+
* `updateSourceModel` implementations.
|
|
73
|
+
*/
|
|
74
|
+
conflictResolver;
|
|
75
|
+
/**
|
|
76
|
+
* Per-class tracer, caller-tagged with this state's runtime subclass name by
|
|
77
|
+
* the `HydraniumTypes.Tracer` binding. {@link setSourceRoot} derives the
|
|
78
|
+
* URI-tagged {@link _tracer} from it; the {@link tracer}/{@link logger}
|
|
79
|
+
* getters fall back to it before then, so logging is never `undefined`.
|
|
80
|
+
*/
|
|
81
|
+
baseTracer;
|
|
82
|
+
_sourceUri;
|
|
83
|
+
_sourceRoot;
|
|
84
|
+
_tracer;
|
|
85
|
+
_version = 0;
|
|
86
|
+
/** Based-on versions of the secondary write set, keyed by URI. See {@link trackSecondaryDocument}. */
|
|
87
|
+
_secondaryVersions = new Map();
|
|
88
|
+
/** Backing emitter for {@link onSecondaryUrisChanged}; fired only on a membership change. */
|
|
89
|
+
secondaryUrisChangedEmitter = new Emitter();
|
|
90
|
+
/** Default of one minute. */
|
|
91
|
+
static DEFAULT_READY_TIMEOUT_MS = 60_000;
|
|
92
|
+
/** Maximum wait inside {@link readyWithTimeout} before raising {@link ModelReadyTimeoutError}. */
|
|
93
|
+
readyTimeoutMs = AbstractHydraniumGlspState_1.DEFAULT_READY_TIMEOUT_MS;
|
|
94
|
+
/**
|
|
95
|
+
* Capture a freshly built source root alongside its URI, refresh the
|
|
96
|
+
* logger to label log lines with the URI, and re-index the AST so
|
|
97
|
+
* downstream GModel projection can resolve elements back to nodes.
|
|
98
|
+
*
|
|
99
|
+
* Also mirrors `uri` into the inherited properties map under
|
|
100
|
+
* {@link SOURCE_URI_ARG} so legacy GLSP code paths (`state.get(...)`)
|
|
101
|
+
* stay consistent with the typed field.
|
|
102
|
+
*/
|
|
103
|
+
setSourceRoot(uri, root) {
|
|
104
|
+
this._sourceUri = uri;
|
|
105
|
+
this._sourceRoot = root;
|
|
106
|
+
this._version = this.readDocumentVersion(uri);
|
|
107
|
+
// Re-read the secondary write set for the same reason the primary is
|
|
108
|
+
// re-read: the write that brought us here advanced their versions too, and
|
|
109
|
+
// a stale based-on version would gate the NEXT command against a
|
|
110
|
+
// superseded number — reporting a conflict that is really this state's own
|
|
111
|
+
// last write.
|
|
112
|
+
this.refreshSecondaryVersions();
|
|
113
|
+
this.set(SOURCE_URI_ARG, uri);
|
|
114
|
+
this._tracer = this.baseTracer.withUri(uri);
|
|
115
|
+
this.tracer.debug(`Captured source root at doc.version=v${this._version}`);
|
|
116
|
+
this.checkDeclaredLanguage(uri);
|
|
117
|
+
this.index.indexSourceRoot(root, uri);
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Typed override of {@link DefaultModelState.sourceUri}. Narrows the
|
|
121
|
+
* inherited `string | undefined` to `string` (defined after
|
|
122
|
+
* {@link setSourceRoot}; throws on definite-assignment otherwise).
|
|
123
|
+
*/
|
|
124
|
+
get sourceUri() {
|
|
125
|
+
return this._sourceUri;
|
|
126
|
+
}
|
|
127
|
+
get sourceRoot() {
|
|
128
|
+
return this._sourceRoot;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* The language services of the grammar this DIAGRAM TYPE edits, as declared
|
|
132
|
+
* by `AbstractHydraniumGlspDiagramModule.declareLanguage`.
|
|
133
|
+
*
|
|
134
|
+
* **Named for what it is, not for "the language".** Reach for it only when
|
|
135
|
+
* the thing you are asking about lives in the diagram document itself.
|
|
136
|
+
* Anything reached *through* a reference is decided by its own document: use
|
|
137
|
+
* {@link languageServicesFor}. Making that choice explicit at the call site
|
|
138
|
+
* is the point; a neutral-looking `languageServices` invites the diagram's
|
|
139
|
+
* grammar to be applied to a foreign node, which is the defect this whole
|
|
140
|
+
* seam exists to prevent.
|
|
141
|
+
*
|
|
142
|
+
* Injected rather than derived from {@link sourceUri} so it is available
|
|
143
|
+
* before the first {@link setSourceRoot} — GLSP constructs operation
|
|
144
|
+
* handlers at `InitializeClientSession`, well before `RequestModelAction`.
|
|
145
|
+
* `@optional()` so a harness that binds no diagram module still resolves;
|
|
146
|
+
* `undefined` then means no diagram module declared a grammar.
|
|
147
|
+
*/
|
|
148
|
+
diagramLanguage;
|
|
149
|
+
/**
|
|
150
|
+
* The language services owning `target` — an AST node (routed by its
|
|
151
|
+
* document), a URI, or a URI string — falling back to
|
|
152
|
+
* {@link diagramLanguage} when `target` routes nowhere.
|
|
153
|
+
*
|
|
154
|
+
* Use this wherever the thing being named, keyed or completed may live in
|
|
155
|
+
* another document than the diagram. Two registered languages are free to
|
|
156
|
+
* differ in `nameProperties` / `nameSeparator` and in their element-key
|
|
157
|
+
* strategy, so applying the diagram's provider to a foreign node yields a
|
|
158
|
+
* plausible-looking string that matches nothing — silently, with no
|
|
159
|
+
* diagnostic. The fallback covers the genuinely unroutable case, a synthetic
|
|
160
|
+
* node not yet attached to a document, where the diagram's own language is
|
|
161
|
+
* the only defensible answer.
|
|
162
|
+
*/
|
|
163
|
+
languageServicesFor(target) {
|
|
164
|
+
return this.sharedServices.ServiceRegistry.getServicesFor(target) ?? this.diagramLanguage;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* The `NameProvider` of the language owning `target` — the shorthand for
|
|
168
|
+
* `languageServicesFor(target)?.references.NameProvider`.
|
|
169
|
+
*
|
|
170
|
+
* The shorthands exist because the long form names `target` twice and
|
|
171
|
+
* threads an optional through a four-link chain, which is enough friction
|
|
172
|
+
* that the tempting alternative is a captured provider — the defect this
|
|
173
|
+
* seam exists to prevent. Keeping the correct call the SHORT one is the
|
|
174
|
+
* point. They stay provider-level rather than operation-level so they
|
|
175
|
+
* compose with every provider method and the state does not grow a naming
|
|
176
|
+
* API of its own.
|
|
177
|
+
*/
|
|
178
|
+
nameProviderFor(target) {
|
|
179
|
+
return this.languageServicesFor(target)?.references.NameProvider;
|
|
180
|
+
}
|
|
181
|
+
/** The `ScopeProvider` of the language owning `target`. See {@link nameProviderFor}. */
|
|
182
|
+
scopeProviderFor(target) {
|
|
183
|
+
return this.languageServicesFor(target)?.references.ScopeProvider;
|
|
184
|
+
}
|
|
185
|
+
/** The `ReferenceCandidateProvider` of the language owning `target`. See {@link nameProviderFor}. */
|
|
186
|
+
candidateProviderFor(target) {
|
|
187
|
+
return this.languageServicesFor(target)?.references.CandidateProvider;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Warn when the loaded document does not route to the grammar this diagram
|
|
191
|
+
* module declared.
|
|
192
|
+
*
|
|
193
|
+
* The declared language is the one fact the module states that the grammar
|
|
194
|
+
* itself does not, so it is the one that can drift — a diagram type pointed
|
|
195
|
+
* at the wrong `LanguageMetaData`, or a file extension reassigned. Both
|
|
196
|
+
* would otherwise surface much later as references resolving against the
|
|
197
|
+
* wrong scope. Only a warning, not a throw: the document is loaded and
|
|
198
|
+
* usable either way, and a hard failure here would take out a diagram over
|
|
199
|
+
* a mismatch that may be intentional in an adopter serving one diagram type
|
|
200
|
+
* over several grammars.
|
|
201
|
+
*/
|
|
202
|
+
checkDeclaredLanguage(uri) {
|
|
203
|
+
const declared = this.diagramLanguage?.LanguageMetaData.languageId;
|
|
204
|
+
if (declared === undefined) {
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
const actual = this.sharedServices.ServiceRegistry.getServicesFor(uri)?.LanguageMetaData.languageId;
|
|
208
|
+
if (actual !== undefined && actual !== declared) {
|
|
209
|
+
this.tracer.warn(`Diagram module declares language '${declared}' but this document routes to '${actual}'`);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
/** The observability handle as a plain {@link Logger} (a {@link Tracer} is-a Logger). */
|
|
213
|
+
get logger() {
|
|
214
|
+
return this.tracer;
|
|
215
|
+
}
|
|
216
|
+
/** URI-tagged once {@link setSourceRoot} has run; the class-tagged injected {@link baseTracer} before that. */
|
|
217
|
+
get tracer() {
|
|
218
|
+
return this._tracer ?? this.baseTracer;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Text-document version captured at the last {@link setSourceRoot}
|
|
222
|
+
* call. Mirrors the server-side `TextDocuments.version(uri)` counter
|
|
223
|
+
* at that point in time — frozen until the next `setSourceRoot`, then
|
|
224
|
+
* re-read from `LangiumDocuments`.
|
|
225
|
+
*
|
|
226
|
+
* Threaded by `HydraniumGlspRecordingCommand` into
|
|
227
|
+
* {@link updateSourceModel}'s optional `version` parameter so the
|
|
228
|
+
* downstream `ModelService.update` / `.save` call can opt into the
|
|
229
|
+
* conflict gate against the captured based-on version. See
|
|
230
|
+
* `@hydranium/protocol#ConflictError` for the detection contract.
|
|
231
|
+
*
|
|
232
|
+
* Falls back to `0` when the document is absent from `LangiumDocuments`
|
|
233
|
+
* at capture time — the same observable state callers see for a doc
|
|
234
|
+
* that was never opened. Callers that need to distinguish
|
|
235
|
+
* "never-versioned" from "v0" must consult the document registry
|
|
236
|
+
* directly.
|
|
237
|
+
*/
|
|
238
|
+
get version() {
|
|
239
|
+
return this._version;
|
|
240
|
+
}
|
|
241
|
+
// ============================================================
|
|
242
|
+
// Secondary documents — the write set beyond the primary
|
|
243
|
+
// ============================================================
|
|
244
|
+
/**
|
|
245
|
+
* Register `uri` as a document this state also writes, capturing its current
|
|
246
|
+
* text-document version.
|
|
247
|
+
*
|
|
248
|
+
* A diagram whose layout lives in its own file, or whose canvas creates
|
|
249
|
+
* elements in a referenced semantic document, writes more than the document
|
|
250
|
+
* it was opened on. The primary (`sourceUri`) stays the one that drives
|
|
251
|
+
* GModel projection and the conflict gate; secondaries are the rest of the
|
|
252
|
+
* write set.
|
|
253
|
+
*
|
|
254
|
+
* Registering is the adopter's call because the set is usually discovered
|
|
255
|
+
* rather than known: the semantic document a node belongs to is only
|
|
256
|
+
* identified once the operation names the node. What the framework supplies
|
|
257
|
+
* is the part an adopter cannot reconstruct after the fact — the version each
|
|
258
|
+
* document was at BEFORE the command mutated anything (see
|
|
259
|
+
* {@link capturedVersionOf}). Idempotent; registering the primary is ignored,
|
|
260
|
+
* since {@link version} already tracks it. Registering a URI not already in
|
|
261
|
+
* the set fires {@link onSecondaryUrisChanged}.
|
|
262
|
+
*/
|
|
263
|
+
trackSecondaryDocument(uri) {
|
|
264
|
+
if (uri === this._sourceUri) {
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
const added = !this._secondaryVersions.has(uri);
|
|
268
|
+
this._secondaryVersions.set(uri, this.readDocumentVersion(uri));
|
|
269
|
+
if (added) {
|
|
270
|
+
this.secondaryUrisChangedEmitter.fire();
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Drop every registered secondary. Call when the write set is rebuilt from
|
|
275
|
+
* scratch. Fires {@link onSecondaryUrisChanged} when the set was non-empty.
|
|
276
|
+
*/
|
|
277
|
+
untrackSecondaryDocuments() {
|
|
278
|
+
if (this._secondaryVersions.size === 0) {
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
this._secondaryVersions.clear();
|
|
282
|
+
this.secondaryUrisChangedEmitter.fire();
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Fires whenever the secondary write set gains or loses a URI — never when a
|
|
286
|
+
* tracked document's captured version is merely refreshed, which happens on
|
|
287
|
+
* every {@link setSourceRoot} and changes nothing a subscriber cares about.
|
|
288
|
+
*
|
|
289
|
+
* **This exists so no caller has to know when the set can change.** The set is
|
|
290
|
+
* usually discovered rather than known, and the discovery point is an
|
|
291
|
+
* operation handler naming a node — not a capture. A subscriber that instead
|
|
292
|
+
* re-derived the set after each capture would miss exactly that case, and miss
|
|
293
|
+
* it silently: the document would simply never be watched, with nothing logged.
|
|
294
|
+
* Announcing the change here moves the obligation to the one place that can
|
|
295
|
+
* always discharge it.
|
|
296
|
+
*
|
|
297
|
+
* The set is the one {@link trackSecondaryDocument} /
|
|
298
|
+
* {@link untrackSecondaryDocuments} maintain. A subclass that writes
|
|
299
|
+
* {@link _secondaryVersions} directly bypasses the notification and owns the
|
|
300
|
+
* consequences.
|
|
301
|
+
*/
|
|
302
|
+
get onSecondaryUrisChanged() {
|
|
303
|
+
return this.secondaryUrisChangedEmitter.event;
|
|
304
|
+
}
|
|
305
|
+
/** Registered secondary document URIs, in registration order. */
|
|
306
|
+
get secondaryUris() {
|
|
307
|
+
return [...this._secondaryVersions.keys()];
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Based-on version captured for `uri` — {@link version} for the primary, the
|
|
311
|
+
* value captured at {@link trackSecondaryDocument} (refreshed by
|
|
312
|
+
* {@link setSourceRoot}) for a secondary, `undefined` for anything untracked.
|
|
313
|
+
*
|
|
314
|
+
* `undefined` rather than `0` for an untracked URI deliberately: `0` is a real
|
|
315
|
+
* version meaning "present but never edited", so collapsing the two would let
|
|
316
|
+
* a caller gate a write against a document it never captured.
|
|
317
|
+
*/
|
|
318
|
+
capturedVersionOf(uri) {
|
|
319
|
+
if (uri === this._sourceUri) {
|
|
320
|
+
return this._version;
|
|
321
|
+
}
|
|
322
|
+
return this._secondaryVersions.get(uri);
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* Read a document's current text-document version through the model service's
|
|
326
|
+
* canonicalizing gateway, so a URI spelled through a symlink still resolves to
|
|
327
|
+
* the document keyed by its real path rather than stranding at `0` (which
|
|
328
|
+
* would silently weaken the conflict gate). Optional-chained on `textDocument`
|
|
329
|
+
* so a fixture that omits it does not throw; real Langium documents always
|
|
330
|
+
* populate it.
|
|
331
|
+
*/
|
|
332
|
+
readDocumentVersion(uri) {
|
|
333
|
+
return this.sharedServices.model.ModelService.getDocument(uri)?.textDocument?.version ?? 0;
|
|
334
|
+
}
|
|
335
|
+
/** Re-read every registered secondary's version from the document store. */
|
|
336
|
+
refreshSecondaryVersions() {
|
|
337
|
+
for (const uri of [...this._secondaryVersions.keys()]) {
|
|
338
|
+
this._secondaryVersions.set(uri, this.readDocumentVersion(uri));
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* Re-capture the source root from the current Langium document,
|
|
343
|
+
* replacing any orphaned root. A rebuild between an earlier
|
|
344
|
+
* {@link setSourceRoot} and the current read can swap the AST out
|
|
345
|
+
* from under us; downstream consumers (GModel factories, action
|
|
346
|
+
* handlers) must see the root the freshly built document carries.
|
|
347
|
+
*/
|
|
348
|
+
refreshSourceRoot() {
|
|
349
|
+
if (!this._sourceUri) {
|
|
350
|
+
return;
|
|
351
|
+
}
|
|
352
|
+
const document = this.sharedServices.model.ModelService.getDocument(this._sourceUri);
|
|
353
|
+
// `parseResult.value` is the grammar's entry-rule root for a given URI
|
|
354
|
+
// (even on parse errors), so we cast to `TRoot` rather than runtime-guard
|
|
355
|
+
// it — the same cast the encoder makes on `parseResult.value`. The
|
|
356
|
+
// load-bearing check is the identity test that skips an unchanged root.
|
|
357
|
+
const root = document?.parseResult.value;
|
|
358
|
+
if (root !== undefined && root !== this._sourceRoot) {
|
|
359
|
+
this.setSourceRoot(this._sourceUri, root);
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* Wait until the captured document reaches `state`, then run
|
|
364
|
+
* {@link onReadyRefreshed} so consumers see a fresh AST. Wraps the
|
|
365
|
+
* wait in {@link Tracer.time} for observability.
|
|
366
|
+
*/
|
|
367
|
+
async ready(state) {
|
|
368
|
+
await this.tracer.time(`Wait for state '${DocumentState[state]}'`, () => this.readyWithTimeout(state), 'debug');
|
|
369
|
+
await this.onReadyRefreshed();
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* Race `ModelService.waitForDocumentState` against
|
|
373
|
+
* {@link readyTimeoutMs}. If the timeout fires but the document has
|
|
374
|
+
* already reached `state` silently (Langium build-phase event race),
|
|
375
|
+
* log a warning and resolve; otherwise raise
|
|
376
|
+
* {@link ModelReadyTimeoutError} via {@link buildReadyTimeoutError}.
|
|
377
|
+
*/
|
|
378
|
+
async readyWithTimeout(state) {
|
|
379
|
+
const uri = this._sourceUri;
|
|
380
|
+
const stopwatch = this.sharedServices.Clock.stopwatch();
|
|
381
|
+
let timer;
|
|
382
|
+
const timeout = new Promise((resolve, reject) => {
|
|
383
|
+
timer = this.sharedServices.Clock.setTimer(() => {
|
|
384
|
+
const elapsed = Math.round(stopwatch.elapsedMs);
|
|
385
|
+
// Via the canonicalizing gateway (see `readDocumentVersion`), so a
|
|
386
|
+
// symlinked `_sourceUri` is not reported as a hard timeout.
|
|
387
|
+
const doc = this.sharedServices.model.ModelService.getDocument(uri);
|
|
388
|
+
if (doc && doc.state >= state) {
|
|
389
|
+
this.logger.warn(`Missed '${DocumentState[state]}' notification after ${elapsed}ms; document is already at state ` +
|
|
390
|
+
`'${DocumentState[doc.state]}'. Likely a Langium build-phase event race.`);
|
|
391
|
+
resolve();
|
|
392
|
+
}
|
|
393
|
+
else {
|
|
394
|
+
reject(this.buildReadyTimeoutError(state, elapsed));
|
|
395
|
+
}
|
|
396
|
+
}, this.readyTimeoutMs);
|
|
397
|
+
});
|
|
398
|
+
try {
|
|
399
|
+
await Promise.race([this.sharedServices.model.ModelService.waitForDocumentState(uri, state), timeout]);
|
|
400
|
+
}
|
|
401
|
+
finally {
|
|
402
|
+
timer?.dispose();
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
/**
|
|
406
|
+
* Hook for post-{@link ready} work. Default refreshes the captured
|
|
407
|
+
* source root via {@link refreshSourceRoot} so submission handlers and
|
|
408
|
+
* GModel factories see the AST the now-ready document carries.
|
|
409
|
+
* Adopters whose AST is immutable between build phases override to a
|
|
410
|
+
* no-op.
|
|
411
|
+
*/
|
|
412
|
+
async onReadyRefreshed() {
|
|
413
|
+
this.refreshSourceRoot();
|
|
414
|
+
}
|
|
415
|
+
/**
|
|
416
|
+
* Build the {@link ModelReadyTimeoutError} thrown by
|
|
417
|
+
* {@link readyWithTimeout}. Reports the workspace-relative path plus the
|
|
418
|
+
* document builder's current build-status snapshot, both via framework
|
|
419
|
+
* methods — so adopters that override `WorkspaceManager.wsRelativePath` /
|
|
420
|
+
* `DocumentBuilder.formatBuildStatus` for richer output get it here without
|
|
421
|
+
* touching this method. Override only to change the error shape itself.
|
|
422
|
+
*/
|
|
423
|
+
buildReadyTimeoutError(state, elapsed) {
|
|
424
|
+
const workspace = this.sharedServices.workspace;
|
|
425
|
+
const shortPath = workspace.WorkspaceManager.wsRelativePath(this._sourceUri);
|
|
426
|
+
const status = workspace.DocumentBuilder.formatBuildStatus(URI.parse(this._sourceUri));
|
|
427
|
+
return new ModelReadyTimeoutError(shortPath, DocumentState[state], elapsed, status);
|
|
428
|
+
}
|
|
429
|
+
};
|
|
430
|
+
__decorate([
|
|
431
|
+
inject(HydraniumTypes.SharedCoreServices),
|
|
432
|
+
__metadata("design:type", Object)
|
|
433
|
+
], AbstractHydraniumGlspState.prototype, "sharedServices", void 0);
|
|
434
|
+
__decorate([
|
|
435
|
+
inject(HydraniumTypes.ConflictResolver),
|
|
436
|
+
__metadata("design:type", Object)
|
|
437
|
+
], AbstractHydraniumGlspState.prototype, "conflictResolver", void 0);
|
|
438
|
+
__decorate([
|
|
439
|
+
inject(HydraniumTypes.Tracer),
|
|
440
|
+
__metadata("design:type", Object)
|
|
441
|
+
], AbstractHydraniumGlspState.prototype, "baseTracer", void 0);
|
|
442
|
+
__decorate([
|
|
443
|
+
inject(HydraniumTypes.DiagramLanguage),
|
|
444
|
+
optional(),
|
|
445
|
+
__metadata("design:type", Object)
|
|
446
|
+
], AbstractHydraniumGlspState.prototype, "diagramLanguage", void 0);
|
|
447
|
+
AbstractHydraniumGlspState = AbstractHydraniumGlspState_1 = __decorate([
|
|
448
|
+
injectable()
|
|
449
|
+
], AbstractHydraniumGlspState);
|
|
450
|
+
export { AbstractHydraniumGlspState };
|
|
451
|
+
//# sourceMappingURL=abstract-hydranium-glsp-state.js.map
|
|
@@ -0,0 +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;AAWtE,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CA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UAAU,EAAE;GACS,0BAA0B,CAsb/C"}
|
|
@@ -0,0 +1,43 @@
|
|
|
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 { type JsonModelState } from '@eclipse-glsp/server';
|
|
10
|
+
import { type AstNode } from '@hydranium/langium';
|
|
11
|
+
import { type MaybePromise } from '@hydranium/protocol';
|
|
12
|
+
import { AbstractHydraniumGlspState } from './abstract-hydranium-glsp-state.js';
|
|
13
|
+
/** Whole-document-text source model: the serialised text of the source root. */
|
|
14
|
+
export interface FullTextSourceModel {
|
|
15
|
+
text: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Editable GLSP state for adopters whose source model is the **whole document
|
|
19
|
+
* text** — the source root serialised to its textual form, round-tripped by
|
|
20
|
+
* re-parsing. The simplest of the framework source-model strategies (the others
|
|
21
|
+
* project a structured transfer model, over one document or several), and the
|
|
22
|
+
* natural starting point for a new adopter.
|
|
23
|
+
*
|
|
24
|
+
* Fully generic — both seams resolve through shared services, so adopters add
|
|
25
|
+
* nothing beyond narrowing `TRoot` and their index:
|
|
26
|
+
* - {@link sourceModel} serialises the source root through the per-URI
|
|
27
|
+
* `serializer.Serializer` reached via `sharedServices.ServiceRegistry`
|
|
28
|
+
* (so multi-grammar workspaces route to the right serializer). `MaybePromise`
|
|
29
|
+
* because serialization may be async; the sync fast path is preserved.
|
|
30
|
+
* - {@link updateSourceModel} pushes the text back through
|
|
31
|
+
* `ModelService.update` (which accepts a raw text payload) and captures the
|
|
32
|
+
* re-parsed root.
|
|
33
|
+
*
|
|
34
|
+
* No `baseline` / conflict reconcile: a whole-document model has exactly one
|
|
35
|
+
* field, so every concurrent edit is a same-field collision and undo / redo
|
|
36
|
+
* degrade to drop-on-divergence. Adopters that need field-level undo use
|
|
37
|
+
* `ReconcilingTransferHydraniumGlspState` instead.
|
|
38
|
+
*/
|
|
39
|
+
export declare class FullTextHydraniumGlspState<TRoot extends AstNode> extends AbstractHydraniumGlspState<TRoot, FullTextSourceModel> implements JsonModelState<FullTextSourceModel> {
|
|
40
|
+
get sourceModel(): MaybePromise<FullTextSourceModel>;
|
|
41
|
+
updateSourceModel(model: FullTextSourceModel): Promise<void>;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=full-text-hydranium-glsp-state.d.ts.map
|
|
@@ -0,0 +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;AACvE,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,GAAG,OAAO,CAAC,IAAI,CAAC;CAQpE"}
|
|
@@ -0,0 +1,60 @@
|
|
|
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
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
10
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
11
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
12
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
13
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
14
|
+
};
|
|
15
|
+
import { injectable } from 'inversify';
|
|
16
|
+
import { URI } from '@hydranium/langium';
|
|
17
|
+
import { isPromiseLike } from '@hydranium/protocol';
|
|
18
|
+
import { AbstractHydraniumGlspState } from './abstract-hydranium-glsp-state.js';
|
|
19
|
+
/**
|
|
20
|
+
* Editable GLSP state for adopters whose source model is the **whole document
|
|
21
|
+
* text** — the source root serialised to its textual form, round-tripped by
|
|
22
|
+
* re-parsing. The simplest of the framework source-model strategies (the others
|
|
23
|
+
* project a structured transfer model, over one document or several), and the
|
|
24
|
+
* natural starting point for a new adopter.
|
|
25
|
+
*
|
|
26
|
+
* Fully generic — both seams resolve through shared services, so adopters add
|
|
27
|
+
* nothing beyond narrowing `TRoot` and their index:
|
|
28
|
+
* - {@link sourceModel} serialises the source root through the per-URI
|
|
29
|
+
* `serializer.Serializer` reached via `sharedServices.ServiceRegistry`
|
|
30
|
+
* (so multi-grammar workspaces route to the right serializer). `MaybePromise`
|
|
31
|
+
* because serialization may be async; the sync fast path is preserved.
|
|
32
|
+
* - {@link updateSourceModel} pushes the text back through
|
|
33
|
+
* `ModelService.update` (which accepts a raw text payload) and captures the
|
|
34
|
+
* re-parsed root.
|
|
35
|
+
*
|
|
36
|
+
* No `baseline` / conflict reconcile: a whole-document model has exactly one
|
|
37
|
+
* field, so every concurrent edit is a same-field collision and undo / redo
|
|
38
|
+
* degrade to drop-on-divergence. Adopters that need field-level undo use
|
|
39
|
+
* `ReconcilingTransferHydraniumGlspState` instead.
|
|
40
|
+
*/
|
|
41
|
+
let FullTextHydraniumGlspState = class FullTextHydraniumGlspState extends AbstractHydraniumGlspState {
|
|
42
|
+
get sourceModel() {
|
|
43
|
+
const serializer = this.sharedServices.ServiceRegistry.getServices(URI.parse(this._sourceUri)).serializer.Serializer;
|
|
44
|
+
const text = serializer.serializeAst(this._sourceRoot);
|
|
45
|
+
return isPromiseLike(text) ? text.then(value => ({ text: value })) : { text };
|
|
46
|
+
}
|
|
47
|
+
async updateSourceModel(model) {
|
|
48
|
+
const document = await this.sharedServices.model.ModelService.update({
|
|
49
|
+
uri: this._sourceUri,
|
|
50
|
+
model: model.text,
|
|
51
|
+
clientId: this.clientId
|
|
52
|
+
});
|
|
53
|
+
this.setSourceRoot(this._sourceUri, document.root);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
FullTextHydraniumGlspState = __decorate([
|
|
57
|
+
injectable()
|
|
58
|
+
], FullTextHydraniumGlspState);
|
|
59
|
+
export { FullTextHydraniumGlspState };
|
|
60
|
+
//# sourceMappingURL=full-text-hydranium-glsp-state.js.map
|
|
@@ -0,0 +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,EAAE,aAAa,EAAqB,MAAM,qBAAqB,CAAC;AACvE,OAAO,EAAE,0BAA0B,EAAE,MAAM,oCAAo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