diff options
author | 2023-08-20 19:41:32 +0200 | |
---|---|---|
committer | 2023-08-20 20:29:02 +0200 | |
commit | a3f1e6872f4f768d14899a1e70bbdc14f32e478d (patch) | |
tree | b2daf0c81724f31ee190f5d63eb42988086dabf2 /subprojects/frontend/src/editor/EditorStore.ts | |
parent | fix: nullary model initialization (diff) | |
download | refinery-a3f1e6872f4f768d14899a1e70bbdc14f32e478d.tar.gz refinery-a3f1e6872f4f768d14899a1e70bbdc14f32e478d.tar.zst refinery-a3f1e6872f4f768d14899a1e70bbdc14f32e478d.zip |
feat: improve semantics error reporting
Also makes model seeds cancellable to reduce server load during semantic
analysis.
Diffstat (limited to 'subprojects/frontend/src/editor/EditorStore.ts')
-rw-r--r-- | subprojects/frontend/src/editor/EditorStore.ts | 39 |
1 files changed, 26 insertions, 13 deletions
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'; | |||
29 | import getLogger from '../utils/getLogger'; | 29 | import getLogger from '../utils/getLogger'; |
30 | import type XtextClient from '../xtext/XtextClient'; | 30 | import type XtextClient from '../xtext/XtextClient'; |
31 | 31 | ||
32 | import EditorErrors from './EditorErrors'; | ||
32 | import LintPanelStore from './LintPanelStore'; | 33 | import LintPanelStore from './LintPanelStore'; |
33 | import SearchPanelStore from './SearchPanelStore'; | 34 | import SearchPanelStore from './SearchPanelStore'; |
34 | import createEditorState from './createEditorState'; | 35 | import createEditorState from './createEditorState'; |
@@ -54,15 +55,22 @@ export default class EditorStore { | |||
54 | 55 | ||
55 | readonly lintPanel: LintPanelStore; | 56 | readonly lintPanel: LintPanelStore; |
56 | 57 | ||
58 | readonly delayedErrors: EditorErrors; | ||
59 | |||
57 | showLineNumbers = false; | 60 | showLineNumbers = false; |
58 | 61 | ||
59 | disposed = false; | 62 | disposed = false; |
60 | 63 | ||
64 | analyzing = false; | ||
65 | |||
66 | semanticsError: string | undefined; | ||
67 | |||
61 | semantics: unknown = {}; | 68 | semantics: unknown = {}; |
62 | 69 | ||
63 | constructor(initialValue: string, pwaStore: PWAStore) { | 70 | constructor(initialValue: string, pwaStore: PWAStore) { |
64 | this.id = nanoid(); | 71 | this.id = nanoid(); |
65 | this.state = createEditorState(initialValue, this); | 72 | this.state = createEditorState(initialValue, this); |
73 | this.delayedErrors = new EditorErrors(this); | ||
66 | this.searchPanel = new SearchPanelStore(this); | 74 | this.searchPanel = new SearchPanelStore(this); |
67 | this.lintPanel = new LintPanelStore(this); | 75 | this.lintPanel = new LintPanelStore(this); |
68 | (async () => { | 76 | (async () => { |
@@ -82,6 +90,7 @@ export default class EditorStore { | |||
82 | state: observable.ref, | 90 | state: observable.ref, |
83 | client: observable.ref, | 91 | client: observable.ref, |
84 | view: observable.ref, | 92 | view: observable.ref, |
93 | semantics: observable.ref, | ||
85 | searchPanel: false, | 94 | searchPanel: false, |
86 | lintPanel: false, | 95 | lintPanel: false, |
87 | contentAssist: false, | 96 | contentAssist: false, |
@@ -215,19 +224,6 @@ export default class EditorStore { | |||
215 | this.doCommand(nextDiagnostic); | 224 | this.doCommand(nextDiagnostic); |
216 | } | 225 | } |
217 | 226 | ||
218 | get highestDiagnosticLevel(): Diagnostic['severity'] | undefined { | ||
219 | if (this.errorCount > 0) { | ||
220 | return 'error'; | ||
221 | } | ||
222 | if (this.warningCount > 0) { | ||
223 | return 'warning'; | ||
224 | } | ||
225 | if (this.infoCount > 0) { | ||
226 | return 'info'; | ||
227 | } | ||
228 | return undefined; | ||
229 | } | ||
230 | |||
231 | updateSemanticHighlighting(ranges: IHighlightRange[]): void { | 227 | updateSemanticHighlighting(ranges: IHighlightRange[]): void { |
232 | this.dispatch(setSemanticHighlighting(ranges)); | 228 | this.dispatch(setSemanticHighlighting(ranges)); |
233 | } | 229 | } |
@@ -284,12 +280,29 @@ export default class EditorStore { | |||
284 | return true; | 280 | return true; |
285 | } | 281 | } |
286 | 282 | ||
283 | analysisStarted() { | ||
284 | this.analyzing = true; | ||
285 | } | ||
286 | |||
287 | analysisCompleted(semanticAnalysisSkipped = false) { | ||
288 | this.analyzing = false; | ||
289 | if (semanticAnalysisSkipped) { | ||
290 | this.semanticsError = undefined; | ||
291 | } | ||
292 | } | ||
293 | |||
294 | setSemanticsError(semanticsError: string) { | ||
295 | this.semanticsError = semanticsError; | ||
296 | } | ||
297 | |||
287 | setSemantics(semantics: unknown) { | 298 | setSemantics(semantics: unknown) { |
299 | this.semanticsError = undefined; | ||
288 | this.semantics = semantics; | 300 | this.semantics = semantics; |
289 | } | 301 | } |
290 | 302 | ||
291 | dispose(): void { | 303 | dispose(): void { |
292 | this.client?.dispose(); | 304 | this.client?.dispose(); |
305 | this.delayedErrors.dispose(); | ||
293 | this.disposed = true; | 306 | this.disposed = true; |
294 | } | 307 | } |
295 | } | 308 | } |