aboutsummaryrefslogtreecommitdiffstats
path: root/subprojects/frontend/src/xtext/UpdateService.ts
diff options
context:
space:
mode:
Diffstat (limited to 'subprojects/frontend/src/xtext/UpdateService.ts')
-rw-r--r--subprojects/frontend/src/xtext/UpdateService.ts42
1 files changed, 42 insertions, 0 deletions
diff --git a/subprojects/frontend/src/xtext/UpdateService.ts b/subprojects/frontend/src/xtext/UpdateService.ts
index ee5ebde2..70e79764 100644
--- a/subprojects/frontend/src/xtext/UpdateService.ts
+++ b/subprojects/frontend/src/xtext/UpdateService.ts
@@ -22,6 +22,7 @@ import {
22 FormattingResult, 22 FormattingResult,
23 isConflictResult, 23 isConflictResult,
24 OccurrencesResult, 24 OccurrencesResult,
25 ModelGenerationStartedResult,
25} from './xtextServiceResults'; 26} from './xtextServiceResults';
26 27
27const UPDATE_TIMEOUT_MS = 500; 28const UPDATE_TIMEOUT_MS = 500;
@@ -133,6 +134,7 @@ export default class UpdateService {
133 return; 134 return;
134 } 135 }
135 log.trace('Editor delta', delta); 136 log.trace('Editor delta', delta);
137 this.store.analysisStarted();
136 const result = await this.webSocketClient.send({ 138 const result = await this.webSocketClient.send({
137 resource: this.resourceName, 139 resource: this.resourceName,
138 serviceType: 'update', 140 serviceType: 'update',
@@ -157,6 +159,7 @@ export default class UpdateService {
157 private async updateFullTextExclusive(): Promise<void> { 159 private async updateFullTextExclusive(): Promise<void> {
158 log.debug('Performing full text update'); 160 log.debug('Performing full text update');
159 this.tracker.prepareFullTextUpdateExclusive(); 161 this.tracker.prepareFullTextUpdateExclusive();
162 this.store.analysisStarted();
160 const result = await this.webSocketClient.send({ 163 const result = await this.webSocketClient.send({
161 resource: this.resourceName, 164 resource: this.resourceName,
162 serviceType: 'update', 165 serviceType: 'update',
@@ -339,4 +342,43 @@ export default class UpdateService {
339 } 342 }
340 return { cancelled: false, data: parsedOccurrencesResult }; 343 return { cancelled: false, data: parsedOccurrencesResult };
341 } 344 }
345
346 async startModelGeneration(
347 randomSeed: number,
348 ): Promise<CancellableResult<ModelGenerationStartedResult>> {
349 try {
350 await this.updateOrThrow();
351 } catch (error) {
352 if (error instanceof CancelledError || error instanceof TimeoutError) {
353 return { cancelled: true };
354 }
355 throw error;
356 }
357 log.debug('Starting model generation');
358 const data = await this.webSocketClient.send({
359 resource: this.resourceName,
360 serviceType: 'modelGeneration',
361 requiredStateId: this.xtextStateId,
362 start: true,
363 randomSeed,
364 });
365 if (isConflictResult(data)) {
366 return { cancelled: true };
367 }
368 const parsedResult = ModelGenerationStartedResult.parse(data);
369 return { cancelled: false, data: parsedResult };
370 }
371
372 async cancelModelGeneration(): Promise<CancellableResult<unknown>> {
373 log.debug('Cancelling model generation');
374 const data = await this.webSocketClient.send({
375 resource: this.resourceName,
376 serviceType: 'modelGeneration',
377 cancel: true,
378 });
379 if (isConflictResult(data)) {
380 return { cancelled: true };
381 }
382 return { cancelled: false, data };
383 }
342} 384}