aboutsummaryrefslogtreecommitdiffstats
path: root/subprojects/frontend/src/editor/EditorStore.ts
diff options
context:
space:
mode:
Diffstat (limited to 'subprojects/frontend/src/editor/EditorStore.ts')
-rw-r--r--subprojects/frontend/src/editor/EditorStore.ts47
1 files changed, 34 insertions, 13 deletions
diff --git a/subprojects/frontend/src/editor/EditorStore.ts b/subprojects/frontend/src/editor/EditorStore.ts
index b98f085e..b5989ad1 100644
--- a/subprojects/frontend/src/editor/EditorStore.ts
+++ b/subprojects/frontend/src/editor/EditorStore.ts
@@ -26,9 +26,12 @@ import { makeAutoObservable, observable, runInAction } from 'mobx';
26import { nanoid } from 'nanoid'; 26import { nanoid } from 'nanoid';
27 27
28import type PWAStore from '../PWAStore'; 28import type PWAStore from '../PWAStore';
29import GraphStore from '../graph/GraphStore';
29import getLogger from '../utils/getLogger'; 30import getLogger from '../utils/getLogger';
30import type XtextClient from '../xtext/XtextClient'; 31import type XtextClient from '../xtext/XtextClient';
32import type { SemanticsSuccessResult } from '../xtext/xtextServiceResults';
31 33
34import EditorErrors from './EditorErrors';
32import LintPanelStore from './LintPanelStore'; 35import LintPanelStore from './LintPanelStore';
33import SearchPanelStore from './SearchPanelStore'; 36import SearchPanelStore from './SearchPanelStore';
34import createEditorState from './createEditorState'; 37import createEditorState from './createEditorState';
@@ -54,13 +57,22 @@ export default class EditorStore {
54 57
55 readonly lintPanel: LintPanelStore; 58 readonly lintPanel: LintPanelStore;
56 59
60 readonly delayedErrors: EditorErrors;
61
57 showLineNumbers = false; 62 showLineNumbers = false;
58 63
59 disposed = false; 64 disposed = false;
60 65
66 analyzing = false;
67
68 semanticsError: string | undefined;
69
70 graph: GraphStore;
71
61 constructor(initialValue: string, pwaStore: PWAStore) { 72 constructor(initialValue: string, pwaStore: PWAStore) {
62 this.id = nanoid(); 73 this.id = nanoid();
63 this.state = createEditorState(initialValue, this); 74 this.state = createEditorState(initialValue, this);
75 this.delayedErrors = new EditorErrors(this);
64 this.searchPanel = new SearchPanelStore(this); 76 this.searchPanel = new SearchPanelStore(this);
65 this.lintPanel = new LintPanelStore(this); 77 this.lintPanel = new LintPanelStore(this);
66 (async () => { 78 (async () => {
@@ -75,6 +87,7 @@ export default class EditorStore {
75 })().catch((error) => { 87 })().catch((error) => {
76 log.error('Failed to load XtextClient', error); 88 log.error('Failed to load XtextClient', error);
77 }); 89 });
90 this.graph = new GraphStore();
78 makeAutoObservable<EditorStore, 'client'>(this, { 91 makeAutoObservable<EditorStore, 'client'>(this, {
79 id: false, 92 id: false,
80 state: observable.ref, 93 state: observable.ref,
@@ -213,19 +226,6 @@ export default class EditorStore {
213 this.doCommand(nextDiagnostic); 226 this.doCommand(nextDiagnostic);
214 } 227 }
215 228
216 get highestDiagnosticLevel(): Diagnostic['severity'] | undefined {
217 if (this.errorCount > 0) {
218 return 'error';
219 }
220 if (this.warningCount > 0) {
221 return 'warning';
222 }
223 if (this.infoCount > 0) {
224 return 'info';
225 }
226 return undefined;
227 }
228
229 updateSemanticHighlighting(ranges: IHighlightRange[]): void { 229 updateSemanticHighlighting(ranges: IHighlightRange[]): void {
230 this.dispatch(setSemanticHighlighting(ranges)); 230 this.dispatch(setSemanticHighlighting(ranges));
231 } 231 }
@@ -282,8 +282,29 @@ export default class EditorStore {
282 return true; 282 return true;
283 } 283 }
284 284
285 analysisStarted() {
286 this.analyzing = true;
287 }
288
289 analysisCompleted(semanticAnalysisSkipped = false) {
290 this.analyzing = false;
291 if (semanticAnalysisSkipped) {
292 this.semanticsError = undefined;
293 }
294 }
295
296 setSemanticsError(semanticsError: string) {
297 this.semanticsError = semanticsError;
298 }
299
300 setSemantics(semantics: SemanticsSuccessResult) {
301 this.semanticsError = undefined;
302 this.graph.setSemantics(semantics);
303 }
304
285 dispose(): void { 305 dispose(): void {
286 this.client?.dispose(); 306 this.client?.dispose();
307 this.delayedErrors.dispose();
287 this.disposed = true; 308 this.disposed = true;
288 } 309 }
289} 310}