diff options
Diffstat (limited to 'subprojects/frontend/src/xtext/UpdateService.ts')
-rw-r--r-- | subprojects/frontend/src/xtext/UpdateService.ts | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/subprojects/frontend/src/xtext/UpdateService.ts b/subprojects/frontend/src/xtext/UpdateService.ts index 1ac722e1..d1246d5e 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 | ||
27 | const UPDATE_TIMEOUT_MS = 500; | 28 | const UPDATE_TIMEOUT_MS = 500; |
@@ -341,4 +342,42 @@ export default class UpdateService { | |||
341 | } | 342 | } |
342 | return { cancelled: false, data: parsedOccurrencesResult }; | 343 | return { cancelled: false, data: parsedOccurrencesResult }; |
343 | } | 344 | } |
345 | |||
346 | async startModelGeneration(): Promise< | ||
347 | CancellableResult<ModelGenerationStartedResult> | ||
348 | > { | ||
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 | }); | ||
364 | if (isConflictResult(data)) { | ||
365 | return { cancelled: true }; | ||
366 | } | ||
367 | const parsedResult = ModelGenerationStartedResult.parse(data); | ||
368 | return { cancelled: false, data: parsedResult }; | ||
369 | } | ||
370 | |||
371 | async cancelModelGeneration(): Promise<CancellableResult<unknown>> { | ||
372 | log.debug('Cancelling model generation'); | ||
373 | const data = await this.webSocketClient.send({ | ||
374 | resource: this.resourceName, | ||
375 | serviceType: 'modelGeneration', | ||
376 | cancel: true, | ||
377 | }); | ||
378 | if (isConflictResult(data)) { | ||
379 | return { cancelled: true }; | ||
380 | } | ||
381 | return { cancelled: false, data }; | ||
382 | } | ||
344 | } | 383 | } |