1
+ import { Node } from "./model/model" ;
1
2
import { Position } from "./model/position" ;
2
3
3
4
export enum IssueType { LEXICAL , SYNTACTIC , SEMANTIC }
4
5
5
6
export enum IssueSeverity { ERROR , WARNING , INFO }
6
7
8
+ export interface IssueArg {
9
+ name : string ;
10
+ value : string ;
11
+ }
12
+
7
13
export class Issue {
8
- type : IssueType ;
9
- message : string ;
10
- severity : IssueSeverity = IssueSeverity . ERROR ;
11
- position ?: Position ;
12
-
13
- constructor ( type : IssueType , message : string , severity : IssueSeverity , position ?: Position ) {
14
- this . type = type ;
15
- this . message = message ;
16
- this . severity = severity ;
17
- this . position = position ;
14
+
15
+ constructor (
16
+ public readonly type : IssueType ,
17
+ public readonly message : string ,
18
+ public readonly severity : IssueSeverity ,
19
+ public readonly position ?: Position ,
20
+ public readonly node ?: Node ,
21
+ public readonly code ?: string ,
22
+ public readonly args : IssueArg [ ] = [ ]
23
+ ) {
24
+ if ( ! position ) {
25
+ this . position = node ?. position ;
26
+ }
18
27
}
19
28
20
- static lexical ( message : string , severity : IssueSeverity = IssueSeverity . ERROR , position ?: Position ) : Issue {
21
- return new Issue ( IssueType . LEXICAL , message , severity , position ) ;
29
+ static lexical ( message : string , severity : IssueSeverity = IssueSeverity . ERROR , position ?: Position ,
30
+ node ?: Node , code ?: string , args : IssueArg [ ] = [ ] ) : Issue {
31
+ return new Issue ( IssueType . LEXICAL , message , severity , position , node , code , args ) ;
22
32
}
23
33
24
- static syntactic ( message : string , severity : IssueSeverity = IssueSeverity . ERROR , position ?: Position ) : Issue {
25
- return new Issue ( IssueType . SYNTACTIC , message , severity , position ) ;
34
+ static syntactic ( message : string , severity : IssueSeverity = IssueSeverity . ERROR , position ?: Position ,
35
+ node ?: Node , code ?: string , args : IssueArg [ ] = [ ] ) : Issue {
36
+ return new Issue ( IssueType . SYNTACTIC , message , severity , position , node , code , args ) ;
26
37
}
27
38
28
- static semantic ( message : string , severity : IssueSeverity = IssueSeverity . ERROR , position ?: Position ) : Issue {
29
- return new Issue ( IssueType . SEMANTIC , message , severity , position ) ;
39
+ static semantic ( message : string , severity : IssueSeverity = IssueSeverity . ERROR , position ?: Position ,
40
+ node ?: Node , code ?: string , args : IssueArg [ ] = [ ] ) : Issue {
41
+ return new Issue ( IssueType . SEMANTIC , message , severity , position , node , code , args ) ;
30
42
}
31
- }
43
+ }
0 commit comments