diff options
author | Kristóf Marussy <kristof@marussy.com> | 2023-09-12 21:59:50 +0200 |
---|---|---|
committer | Kristóf Marussy <kristof@marussy.com> | 2023-09-12 21:59:50 +0200 |
commit | a2a4696fdbd6440269d576aeba7b25b2ea40d9bf (patch) | |
tree | 5cbdf981a51a09fbe162e7748555d213ca518ff4 /subprojects/frontend/src/xtext/XtextClient.ts | |
parent | fix: avoid GLOP error message on stderr (diff) | |
download | refinery-a2a4696fdbd6440269d576aeba7b25b2ea40d9bf.tar.gz refinery-a2a4696fdbd6440269d576aeba7b25b2ea40d9bf.tar.zst refinery-a2a4696fdbd6440269d576aeba7b25b2ea40d9bf.zip |
feat: connect model generator to UI
Diffstat (limited to 'subprojects/frontend/src/xtext/XtextClient.ts')
-rw-r--r-- | subprojects/frontend/src/xtext/XtextClient.ts | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/subprojects/frontend/src/xtext/XtextClient.ts b/subprojects/frontend/src/xtext/XtextClient.ts index 87778084..77980d35 100644 --- a/subprojects/frontend/src/xtext/XtextClient.ts +++ b/subprojects/frontend/src/xtext/XtextClient.ts | |||
@@ -16,6 +16,7 @@ import getLogger from '../utils/getLogger'; | |||
16 | 16 | ||
17 | import ContentAssistService from './ContentAssistService'; | 17 | import ContentAssistService from './ContentAssistService'; |
18 | import HighlightingService from './HighlightingService'; | 18 | import HighlightingService from './HighlightingService'; |
19 | import ModelGenerationService from './ModelGenerationService'; | ||
19 | import OccurrencesService from './OccurrencesService'; | 20 | import OccurrencesService from './OccurrencesService'; |
20 | import SemanticsService from './SemanticsService'; | 21 | import SemanticsService from './SemanticsService'; |
21 | import UpdateService from './UpdateService'; | 22 | import UpdateService from './UpdateService'; |
@@ -40,6 +41,8 @@ export default class XtextClient { | |||
40 | 41 | ||
41 | private readonly semanticsService: SemanticsService; | 42 | private readonly semanticsService: SemanticsService; |
42 | 43 | ||
44 | private readonly modelGenerationService: ModelGenerationService; | ||
45 | |||
43 | constructor( | 46 | constructor( |
44 | private readonly store: EditorStore, | 47 | private readonly store: EditorStore, |
45 | private readonly pwaStore: PWAStore, | 48 | private readonly pwaStore: PWAStore, |
@@ -58,6 +61,10 @@ export default class XtextClient { | |||
58 | this.validationService = new ValidationService(store, this.updateService); | 61 | this.validationService = new ValidationService(store, this.updateService); |
59 | this.occurrencesService = new OccurrencesService(store, this.updateService); | 62 | this.occurrencesService = new OccurrencesService(store, this.updateService); |
60 | this.semanticsService = new SemanticsService(store, this.validationService); | 63 | this.semanticsService = new SemanticsService(store, this.validationService); |
64 | this.modelGenerationService = new ModelGenerationService( | ||
65 | store, | ||
66 | this.updateService, | ||
67 | ); | ||
61 | } | 68 | } |
62 | 69 | ||
63 | start(): void { | 70 | start(): void { |
@@ -75,6 +82,7 @@ export default class XtextClient { | |||
75 | this.highlightingService.onDisconnect(); | 82 | this.highlightingService.onDisconnect(); |
76 | this.validationService.onDisconnect(); | 83 | this.validationService.onDisconnect(); |
77 | this.occurrencesService.onDisconnect(); | 84 | this.occurrencesService.onDisconnect(); |
85 | this.modelGenerationService.onDisconnect(); | ||
78 | } | 86 | } |
79 | 87 | ||
80 | onTransaction(transaction: Transaction): void { | 88 | onTransaction(transaction: Transaction): void { |
@@ -101,7 +109,7 @@ export default class XtextClient { | |||
101 | ); | 109 | ); |
102 | return; | 110 | return; |
103 | } | 111 | } |
104 | if (stateId !== xtextStateId) { | 112 | if (stateId !== xtextStateId && service !== 'modelGeneration') { |
105 | log.error( | 113 | log.error( |
106 | 'Unexpected xtext state id: expected:', | 114 | 'Unexpected xtext state id: expected:', |
107 | xtextStateId, | 115 | xtextStateId, |
@@ -122,6 +130,9 @@ export default class XtextClient { | |||
122 | case 'semantics': | 130 | case 'semantics': |
123 | this.semanticsService.onPush(push); | 131 | this.semanticsService.onPush(push); |
124 | return; | 132 | return; |
133 | case 'modelGeneration': | ||
134 | this.modelGenerationService.onPush(push); | ||
135 | return; | ||
125 | default: | 136 | default: |
126 | throw new Error('Unknown service'); | 137 | throw new Error('Unknown service'); |
127 | } | 138 | } |
@@ -131,6 +142,14 @@ export default class XtextClient { | |||
131 | return this.contentAssistService.contentAssist(context); | 142 | return this.contentAssistService.contentAssist(context); |
132 | } | 143 | } |
133 | 144 | ||
145 | startModelGeneration(): Promise<void> { | ||
146 | return this.modelGenerationService.start(); | ||
147 | } | ||
148 | |||
149 | cancelModelGeneration(): Promise<void> { | ||
150 | return this.modelGenerationService.cancel(); | ||
151 | } | ||
152 | |||
134 | formatText(): void { | 153 | formatText(): void { |
135 | this.updateService.formatText().catch((e) => { | 154 | this.updateService.formatText().catch((e) => { |
136 | log.error('Error while formatting text', e); | 155 | log.error('Error while formatting text', e); |