-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
project.diagnostics.ts
43 lines (36 loc) · 1.37 KB
/
project.diagnostics.ts
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
33
34
35
36
37
38
39
40
41
42
43
import type { IRecognitionException, IToken } from 'chevrotain';
import type { IRange, Range } from './project.location.js';
export type GmlParseError = IRecognitionException & { previousToken?: IToken };
export type DiagnosticSeverity = 'error' | 'warning' | 'info';
export interface DiagnosticCollections {
GLOBAL_SELF: Diagnostic[];
INVALID_OPERATION: Diagnostic[];
JSDOC_MISMATCH: Diagnostic[];
MISSING_EVENT_INHERITED: Diagnostic[];
MISSING_REQUIRED_ARGUMENT: Diagnostic[];
SYNTAX_ERROR: Diagnostic[];
TOO_MANY_ARGUMENTS: Diagnostic[];
UNDECLARED_VARIABLE_REFERENCE: Diagnostic[];
UNDECLARED_GLOBAL_REFERENCE: Diagnostic[];
JSDOC: Diagnostic[];
UNUSED: Diagnostic[];
}
export type DiagnosticCollectionName = keyof DiagnosticCollections;
export class Diagnostic {
readonly $tag = 'diagnostic';
constructor(
readonly message: string,
readonly location: IRange,
readonly severity: DiagnosticSeverity = 'warning',
readonly payload?: any,
) {}
static warn(message: string, location: Range, payload?: any) {
return new Diagnostic(message, location, 'warning', payload);
}
static error(message: string, location: Range, payload?: any) {
return new Diagnostic(message, location, 'error', payload);
}
static info(message: string, location: Range, payload?: any) {
return new Diagnostic(message, location, 'info', payload);
}
}