blob: d68b87a93b137d01ba63e6fb05436566da1fa3a9 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
/*
* SPDX-FileCopyrightText: 2021-2023 The Refinery Authors <https://refinery.tools/>
*
* SPDX-License-Identifier: EPL-2.0
*/
import type EditorStore from '../editor/EditorStore';
import type ValidationService from './ValidationService';
import { SemanticsResult } from './xtextServiceResults';
export default class SemanticsService {
constructor(
private readonly store: EditorStore,
private readonly validationService: ValidationService,
) {}
onPush(push: unknown): void {
const result = SemanticsResult.parse(push);
if ('issues' in result) {
this.validationService.setSemanticsIssues(result.issues);
} else {
this.validationService.setSemanticsIssues([]);
if ('error' in result) {
this.store.setSemanticsError(result.error);
} else {
this.store.setSemantics(result);
}
}
this.store.analysisCompleted();
}
}
|