1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const diagnostics_1 = require("./diagnostics");
|
4 | class DiagnosticList {
|
5 | constructor(diagnostics = []) {
|
6 | this.diagnostics = diagnostics;
|
7 | this.fatalError = false;
|
8 | if (!Array.isArray(diagnostics)) {
|
9 | throw new TypeError(`diagnostics must be array, not ${typeof diagnostics}`);
|
10 | }
|
11 | }
|
12 | extend(otherDiagnosticList) {
|
13 | this.diagnostics.push(...otherDiagnosticList.diagnostics);
|
14 | if (otherDiagnosticList.fatalError)
|
15 | this.fatalError = true;
|
16 | }
|
17 | push(diagnostic) {
|
18 | if (diagnostic.messageText === undefined ||
|
19 | diagnostic.category === undefined) {
|
20 | throw new TypeError('Diagnostic is missing `messageText` or `category` keys');
|
21 | }
|
22 | this.diagnostics.push(diagnostic);
|
23 | }
|
24 | pushMessage(text) {
|
25 | this.push({
|
26 | messageText: text,
|
27 | category: diagnostics_1.DiagnosticCategory.Message,
|
28 | });
|
29 | }
|
30 | pushWarning(text) {
|
31 | this.push({
|
32 | messageText: text,
|
33 | category: diagnostics_1.DiagnosticCategory.Warning,
|
34 | });
|
35 | }
|
36 | pushError(text) {
|
37 | this.push({
|
38 | messageText: text,
|
39 | category: diagnostics_1.DiagnosticCategory.Error,
|
40 | });
|
41 | }
|
42 | pushFatalError(text) {
|
43 | this.pushError(text);
|
44 | this.fatalError = true;
|
45 | }
|
46 | }
|
47 | exports.default = DiagnosticList;
|