@hydranium/glsp-server 1.0.0-next.317 → 1.0.0-next.318
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/submission/hydranium-glsp-submission-handler.d.ts +12 -1
- package/lib/submission/hydranium-glsp-submission-handler.d.ts.map +1 -1
- package/lib/submission/hydranium-glsp-submission-handler.js +30 -4
- package/lib/submission/hydranium-glsp-submission-handler.js.map +1 -1
- package/package.json +7 -7
- package/src/submission/hydranium-glsp-submission-handler.ts +26 -5
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* SPDX-License-Identifier: MIT
|
|
8
8
|
********************************************************************************/
|
|
9
|
-
import { type Action, type DirtyStateChangeReason, type GModelRootSchema, type LayoutOperation, ModelSubmissionHandler, type ModelValidator, type SetModelAction } from '@eclipse-glsp/server';
|
|
9
|
+
import { type Action, ClientSessionManager, type DirtyStateChangeReason, type GModelRootSchema, type LayoutOperation, ModelSubmissionHandler, type ModelValidator, type SetModelAction } from '@eclipse-glsp/server';
|
|
10
10
|
import { type AstNode, type DocumentState } from '@hydranium/langium';
|
|
11
11
|
import { type AbstractHydraniumGlspState } from '../state/abstract-hydranium-glsp-state.js';
|
|
12
12
|
/**
|
|
@@ -40,6 +40,7 @@ import { type AbstractHydraniumGlspState } from '../state/abstract-hydranium-gls
|
|
|
40
40
|
*/
|
|
41
41
|
export declare class HydraniumGlspSubmissionHandler<TRoot extends AstNode, TSourceModel = string> extends ModelSubmissionHandler {
|
|
42
42
|
protected modelState: AbstractHydraniumGlspState<TRoot, TSourceModel>;
|
|
43
|
+
protected readonly sessionManager: ClientSessionManager;
|
|
43
44
|
/**
|
|
44
45
|
* Document-state gate awaited before {@link submitModel} delegates to
|
|
45
46
|
* `super.submitModel`. Default {@link IntegrityService.SettledState} so the
|
|
@@ -109,8 +110,18 @@ export declare class HydraniumGlspSubmissionHandler<TRoot extends AstNode, TSour
|
|
|
109
110
|
* Never rejects: GLSP runs it from a debounce that drops the result, so a
|
|
110
111
|
* failure here would go unhandled. A validator that throws is logged as an
|
|
111
112
|
* error, markers that cannot be sent as a warning.
|
|
113
|
+
*
|
|
114
|
+
* GLSP does not cancel that debounce when the session ends, so it also runs
|
|
115
|
+
* for a diagram just closed: that run is skipped, and markers it could not
|
|
116
|
+
* send because the session ended meanwhile are logged for diagnosis only.
|
|
112
117
|
*/
|
|
113
118
|
protected performLiveValidation(validator: ModelValidator): Promise<void>;
|
|
119
|
+
/**
|
|
120
|
+
* Whether the client session this handler serves has ended. By its
|
|
121
|
+
* dispatcher rather than its id: a client that reopens a diagram under the
|
|
122
|
+
* same id gets a new session, which this handler does not serve.
|
|
123
|
+
*/
|
|
124
|
+
protected sessionEnded(): boolean;
|
|
114
125
|
/**
|
|
115
126
|
* Serialise the model-bearing actions of a submission into a comparable
|
|
116
127
|
* signature.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hydranium-glsp-submission-handler.d.ts","sourceRoot":"","sources":["../../src/submission/hydranium-glsp-submission-handler.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EACJ,KAAK,MAAM,EACX,KAAK,sBAAsB,EAC3B,KAAK,gBAAgB,EACrB,KAAK,eAAe,EAGpB,sBAAsB,EACtB,KAAK,cAAc,EAGnB,KAAK,cAAc,EACrB,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEtE,OAAO,EAAE,KAAK,0BAA0B,EAAE,MAAM,2CAA2C,CAAC;AAG5F;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,qBACa,8BAA8B,CAAC,KAAK,SAAS,OAAO,EAAE,YAAY,GAAG,MAAM,CAAE,SAAQ,sBAAsB;IACrH,UAAsC,UAAU,EAAE,0BAA0B,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"hyd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AC,uBAAuB,CAAC,EAAE,MAAM,CAAC;IAE3C,oDAAoD;IACpD,SAAS,CAAC,kBAAkB,CAAC,EAAE;QAAE,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAE3F;;;;;;;;;;;;OAYG;IACH,sBAAsB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAY/C;IAED;;;;;;;;;;;;OAYG;IACH,UAAyB,qBAAqB,CAAC,SAAS,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAoBvF;IAED;;;;OAIG;IACH,SAAS,CAAC,YAAY,IAAI,OAAO,CAEhC;IAED;;;;;;;;;;;;;;;;;;OAkBG;IACH,SAAS,CAAC,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,CAK/C;IAED;;;;OAIG;IACH,UAAmB,mBAAmB,CAAC,OAAO,EAAE,gBAAgB,GAAG,cAAc,CAMhF;IAED,SAAS,CAAC,SAAS,CAAC,MAAM,EAAE,sBAAsB,GAAG,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,CAUvF;IAED;;;;;OAKG;IACH,SAAS,CAAC,gBAAgB,CAAC,IAAI,EAAE,KAAK,GAAG,SAAS,GAAG,MAAM,CAE1D;CACH"}
|
|
@@ -15,7 +15,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
15
15
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
16
16
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
17
17
|
};
|
|
18
|
-
import { MarkersReason, ModelState, ModelSubmissionHandler, SetDirtyStateAction, SetMarkersAction } from '@eclipse-glsp/server';
|
|
18
|
+
import { ClientSessionManager, MarkersReason, ModelState, ModelSubmissionHandler, SetDirtyStateAction, SetMarkersAction } from '@eclipse-glsp/server';
|
|
19
19
|
import { IntegrityService } from '@hydranium/core';
|
|
20
20
|
import { inject, injectable } from 'inversify';
|
|
21
21
|
import { describeErrorWithStack } from '@hydranium/protocol';
|
|
@@ -50,6 +50,7 @@ import { DiagramStatus } from '../state/diagram-status.js';
|
|
|
50
50
|
* URI-tagged tracer), so it carries no log-label field of its own.
|
|
51
51
|
*/
|
|
52
52
|
let HydraniumGlspSubmissionHandler = class HydraniumGlspSubmissionHandler extends ModelSubmissionHandler {
|
|
53
|
+
sessionManager;
|
|
53
54
|
/**
|
|
54
55
|
* Document-state gate awaited before {@link submitModel} delegates to
|
|
55
56
|
* `super.submitModel`. Default {@link IntegrityService.SettledState} so the
|
|
@@ -155,14 +156,27 @@ let HydraniumGlspSubmissionHandler = class HydraniumGlspSubmissionHandler extend
|
|
|
155
156
|
* Never rejects: GLSP runs it from a debounce that drops the result, so a
|
|
156
157
|
* failure here would go unhandled. A validator that throws is logged as an
|
|
157
158
|
* error, markers that cannot be sent as a warning.
|
|
159
|
+
*
|
|
160
|
+
* GLSP does not cancel that debounce when the session ends, so it also runs
|
|
161
|
+
* for a diagram just closed: that run is skipped, and markers it could not
|
|
162
|
+
* send because the session ended meanwhile are logged for diagnosis only.
|
|
158
163
|
*/
|
|
159
164
|
async performLiveValidation(validator) {
|
|
165
|
+
if (this.sessionEnded()) {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
160
168
|
this.modelState.setStatus(DiagramStatus.VALIDATION, { message: 'Validate Model...', severity: 'INFO' });
|
|
161
169
|
try {
|
|
162
170
|
const markers = await validator.validate([this.modelState.root], MarkersReason.LIVE);
|
|
163
|
-
await this.actionDispatcher
|
|
164
|
-
|
|
165
|
-
|
|
171
|
+
await this.actionDispatcher.dispatch(SetMarkersAction.create(markers, { reason: MarkersReason.LIVE })).catch((error) => {
|
|
172
|
+
const message = `Could not send the live-validation markers: ${describeErrorWithStack(error)}`;
|
|
173
|
+
if (this.sessionEnded()) {
|
|
174
|
+
this.modelState.logger.debug(message);
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
this.modelState.logger.warn(message);
|
|
178
|
+
}
|
|
179
|
+
});
|
|
166
180
|
}
|
|
167
181
|
catch (error) {
|
|
168
182
|
this.modelState.logger.error(`Live validation failed: ${describeErrorWithStack(error)}`);
|
|
@@ -171,6 +185,14 @@ let HydraniumGlspSubmissionHandler = class HydraniumGlspSubmissionHandler extend
|
|
|
171
185
|
this.modelState.setStatus(DiagramStatus.VALIDATION, undefined);
|
|
172
186
|
}
|
|
173
187
|
}
|
|
188
|
+
/**
|
|
189
|
+
* Whether the client session this handler serves has ended. By its
|
|
190
|
+
* dispatcher rather than its id: a client that reopens a diagram under the
|
|
191
|
+
* same id gets a new session, which this handler does not serve.
|
|
192
|
+
*/
|
|
193
|
+
sessionEnded() {
|
|
194
|
+
return this.sessionManager.getSession(this.modelState.clientId)?.actionDispatcher !== this.actionDispatcher;
|
|
195
|
+
}
|
|
174
196
|
/**
|
|
175
197
|
* Serialise the model-bearing actions of a submission into a comparable
|
|
176
198
|
* signature.
|
|
@@ -226,6 +248,10 @@ __decorate([
|
|
|
226
248
|
inject(ModelState),
|
|
227
249
|
__metadata("design:type", Function)
|
|
228
250
|
], HydraniumGlspSubmissionHandler.prototype, "modelState", void 0);
|
|
251
|
+
__decorate([
|
|
252
|
+
inject(ClientSessionManager),
|
|
253
|
+
__metadata("design:type", Object)
|
|
254
|
+
], HydraniumGlspSubmissionHandler.prototype, "sessionManager", void 0);
|
|
229
255
|
HydraniumGlspSubmissionHandler = __decorate([
|
|
230
256
|
injectable()
|
|
231
257
|
], HydraniumGlspSubmissionHandler);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hydranium-glsp-submission-handler.js","sourceRoot":"","sources":["../../src/submission/hydranium-glsp-submission-handler.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;;;;;;;;;;AAElF,OAAO,
|
|
1
|
+
{"version":3,"file":"hydranium-glsp-submission-handler.js","sourceRoot":"","sources":["../../src/submission/hydranium-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AAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACjD,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,KAAK,CACzB,wBAAwB,MAAM,IAAI,SAAS,cAAc,KAAK,KAAK;YAChE,gBAAgB,IAAI,EAAE,IAAI,IAAI,MAAM,cAAc,SAAS,KAAK;YAChE,QAAQ,IAAI,CAAC,gBAAgB,CAAC,UAAU,CAAC,IAAI,CAClD,CAAC;IACL,CAAC;IAED;;;;;OAKG;IACO,gBAAgB,CAAC,IAAuB;QAC/C,OAAO,IAAI,EAAE,KAAK,IAAI,MAAM,CAAC;IAChC,CAAC;CACH,CAAA;AAvNwC;IAArC,MAAM,CAAC,UAAU,CAAC;;kEAA+E;AACjD;IAAhD,MAAM,CAAC,oBAAoB,CAAC;;sEAA0D;AAF7E,8BAA8B;IAD1C,UAAU,EAAE;GACA,8BAA8B,CAwN1C"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hydranium/glsp-server",
|
|
3
|
-
"version": "1.0.0-next.
|
|
3
|
+
"version": "1.0.0-next.318",
|
|
4
4
|
"description": "GLSP protocol head for the hydranium framework. Peer of @hydranium/core/lsp and @hydranium/data-server; built on @hydranium/core.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"diagram",
|
|
@@ -70,9 +70,9 @@
|
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
72
|
"@eclipse-glsp/server": "2.7.0",
|
|
73
|
-
"@hydranium/core": "1.0.0-next.
|
|
74
|
-
"@hydranium/langium": "1.0.0-next.
|
|
75
|
-
"@hydranium/protocol": "1.0.0-next.
|
|
73
|
+
"@hydranium/core": "1.0.0-next.318",
|
|
74
|
+
"@hydranium/langium": "1.0.0-next.318",
|
|
75
|
+
"@hydranium/protocol": "1.0.0-next.318",
|
|
76
76
|
"inversify": "6.2.2",
|
|
77
77
|
"reflect-metadata": "0.2.2",
|
|
78
78
|
"rimraf": "^5.0.0",
|
|
@@ -82,9 +82,9 @@
|
|
|
82
82
|
},
|
|
83
83
|
"peerDependencies": {
|
|
84
84
|
"@eclipse-glsp/server": "^2.6.0",
|
|
85
|
-
"@hydranium/core": "1.0.0-next.
|
|
86
|
-
"@hydranium/langium": "1.0.0-next.
|
|
87
|
-
"@hydranium/protocol": "1.0.0-next.
|
|
85
|
+
"@hydranium/core": "1.0.0-next.318",
|
|
86
|
+
"@hydranium/langium": "1.0.0-next.318",
|
|
87
|
+
"@hydranium/protocol": "1.0.0-next.318",
|
|
88
88
|
"inversify": "^6.0.0",
|
|
89
89
|
"reflect-metadata": "^0.2.2",
|
|
90
90
|
"vscode-jsonrpc": "^9.0.0",
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
import {
|
|
11
11
|
type Action,
|
|
12
|
+
ClientSessionManager,
|
|
12
13
|
type DirtyStateChangeReason,
|
|
13
14
|
type GModelRootSchema,
|
|
14
15
|
type LayoutOperation,
|
|
@@ -59,6 +60,7 @@ import { DiagramStatus } from '../state/diagram-status.js';
|
|
|
59
60
|
@injectable()
|
|
60
61
|
export class HydraniumGlspSubmissionHandler<TRoot extends AstNode, TSourceModel = string> extends ModelSubmissionHandler {
|
|
61
62
|
@inject(ModelState) declare protected modelState: AbstractHydraniumGlspState<TRoot, TSourceModel>;
|
|
63
|
+
@inject(ClientSessionManager) protected readonly sessionManager!: ClientSessionManager;
|
|
62
64
|
|
|
63
65
|
/**
|
|
64
66
|
* Document-state gate awaited before {@link submitModel} delegates to
|
|
@@ -176,16 +178,26 @@ export class HydraniumGlspSubmissionHandler<TRoot extends AstNode, TSourceModel
|
|
|
176
178
|
* Never rejects: GLSP runs it from a debounce that drops the result, so a
|
|
177
179
|
* failure here would go unhandled. A validator that throws is logged as an
|
|
178
180
|
* error, markers that cannot be sent as a warning.
|
|
181
|
+
*
|
|
182
|
+
* GLSP does not cancel that debounce when the session ends, so it also runs
|
|
183
|
+
* for a diagram just closed: that run is skipped, and markers it could not
|
|
184
|
+
* send because the session ended meanwhile are logged for diagnosis only.
|
|
179
185
|
*/
|
|
180
186
|
protected override async performLiveValidation(validator: ModelValidator): Promise<void> {
|
|
187
|
+
if (this.sessionEnded()) {
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
181
190
|
this.modelState.setStatus(DiagramStatus.VALIDATION, { message: 'Validate Model...', severity: 'INFO' });
|
|
182
191
|
try {
|
|
183
192
|
const markers = await validator.validate([this.modelState.root], MarkersReason.LIVE);
|
|
184
|
-
await this.actionDispatcher
|
|
185
|
-
|
|
186
|
-
.
|
|
187
|
-
this.modelState.logger.
|
|
188
|
-
|
|
193
|
+
await this.actionDispatcher.dispatch(SetMarkersAction.create(markers, { reason: MarkersReason.LIVE })).catch((error: unknown) => {
|
|
194
|
+
const message = `Could not send the live-validation markers: ${describeErrorWithStack(error)}`;
|
|
195
|
+
if (this.sessionEnded()) {
|
|
196
|
+
this.modelState.logger.debug(message);
|
|
197
|
+
} else {
|
|
198
|
+
this.modelState.logger.warn(message);
|
|
199
|
+
}
|
|
200
|
+
});
|
|
189
201
|
} catch (error: unknown) {
|
|
190
202
|
this.modelState.logger.error(`Live validation failed: ${describeErrorWithStack(error)}`);
|
|
191
203
|
} finally {
|
|
@@ -193,6 +205,15 @@ export class HydraniumGlspSubmissionHandler<TRoot extends AstNode, TSourceModel
|
|
|
193
205
|
}
|
|
194
206
|
}
|
|
195
207
|
|
|
208
|
+
/**
|
|
209
|
+
* Whether the client session this handler serves has ended. By its
|
|
210
|
+
* dispatcher rather than its id: a client that reopens a diagram under the
|
|
211
|
+
* same id gets a new session, which this handler does not serve.
|
|
212
|
+
*/
|
|
213
|
+
protected sessionEnded(): boolean {
|
|
214
|
+
return this.sessionManager.getSession(this.modelState.clientId)?.actionDispatcher !== this.actionDispatcher;
|
|
215
|
+
}
|
|
216
|
+
|
|
196
217
|
/**
|
|
197
218
|
* Serialise the model-bearing actions of a submission into a comparable
|
|
198
219
|
* signature.
|