From a3f1e6872f4f768d14899a1e70bbdc14f32e478d Mon Sep 17 00:00:00 2001 From: Kristóf Marussy Date: Sun, 20 Aug 2023 19:41:32 +0200 Subject: feat: improve semantics error reporting Also makes model seeds cancellable to reduce server load during semantic analysis. --- subprojects/frontend/src/editor/EditorStore.ts | 39 +++++++++++++++++--------- 1 file changed, 26 insertions(+), 13 deletions(-) (limited to 'subprojects/frontend/src/editor/EditorStore.ts') diff --git a/subprojects/frontend/src/editor/EditorStore.ts b/subprojects/frontend/src/editor/EditorStore.ts index c79f6ec1..563725bb 100644 --- a/subprojects/frontend/src/editor/EditorStore.ts +++ b/subprojects/frontend/src/editor/EditorStore.ts @@ -29,6 +29,7 @@ import type PWAStore from '../PWAStore'; import getLogger from '../utils/getLogger'; import type XtextClient from '../xtext/XtextClient'; +import EditorErrors from './EditorErrors'; import LintPanelStore from './LintPanelStore'; import SearchPanelStore from './SearchPanelStore'; import createEditorState from './createEditorState'; @@ -54,15 +55,22 @@ export default class EditorStore { readonly lintPanel: LintPanelStore; + readonly delayedErrors: EditorErrors; + showLineNumbers = false; disposed = false; + analyzing = false; + + semanticsError: string | undefined; + semantics: unknown = {}; constructor(initialValue: string, pwaStore: PWAStore) { this.id = nanoid(); this.state = createEditorState(initialValue, this); + this.delayedErrors = new EditorErrors(this); this.searchPanel = new SearchPanelStore(this); this.lintPanel = new LintPanelStore(this); (async () => { @@ -82,6 +90,7 @@ export default class EditorStore { state: observable.ref, client: observable.ref, view: observable.ref, + semantics: observable.ref, searchPanel: false, lintPanel: false, contentAssist: false, @@ -215,19 +224,6 @@ export default class EditorStore { this.doCommand(nextDiagnostic); } - get highestDiagnosticLevel(): Diagnostic['severity'] | undefined { - if (this.errorCount > 0) { - return 'error'; - } - if (this.warningCount > 0) { - return 'warning'; - } - if (this.infoCount > 0) { - return 'info'; - } - return undefined; - } - updateSemanticHighlighting(ranges: IHighlightRange[]): void { this.dispatch(setSemanticHighlighting(ranges)); } @@ -284,12 +280,29 @@ export default class EditorStore { return true; } + analysisStarted() { + this.analyzing = true; + } + + analysisCompleted(semanticAnalysisSkipped = false) { + this.analyzing = false; + if (semanticAnalysisSkipped) { + this.semanticsError = undefined; + } + } + + setSemanticsError(semanticsError: string) { + this.semanticsError = semanticsError; + } + setSemantics(semantics: unknown) { + this.semanticsError = undefined; this.semantics = semantics; } dispose(): void { this.client?.dispose(); + this.delayedErrors.dispose(); this.disposed = true; } } -- cgit v1.2.3-70-g09d2