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
7
8
export class Issue {
8
- type : IssueType ;
9
- message : string ;
10
- severity : IssueSeverity = IssueSeverity . ERROR ;
11
- position ?: Position ;
12
9
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 ;
10
+ constructor (
11
+ public readonly type : IssueType ,
12
+ public readonly message : string ,
13
+ public readonly severity : IssueSeverity ,
14
+ public readonly position ?: Position ,
15
+ public readonly node ?: Node ,
16
+ public readonly code ?: string ,
17
+ public readonly args : string [ ] = [ ]
18
+ ) {
19
+ if ( ! position ) {
20
+ this . position = node ?. position ;
21
+ }
18
22
}
19
23
20
- static lexical ( message : string , severity : IssueSeverity = IssueSeverity . ERROR , position ?: Position ) : Issue {
21
- return new Issue ( IssueType . LEXICAL , message , severity , position ) ;
24
+ static lexical ( message : string , severity : IssueSeverity = IssueSeverity . ERROR , position ?: Position ,
25
+ node ?: Node , code ?: string , args : string [ ] = [ ] ) : Issue {
26
+ return new Issue ( IssueType . LEXICAL , message , severity , position , node , code , args ) ;
22
27
}
23
28
24
- static syntactic ( message : string , severity : IssueSeverity = IssueSeverity . ERROR , position ?: Position ) : Issue {
25
- return new Issue ( IssueType . SYNTACTIC , message , severity , position ) ;
29
+ static syntactic ( message : string , severity : IssueSeverity = IssueSeverity . ERROR , position ?: Position ,
30
+ node ?: Node , code ?: string , args : string [ ] = [ ] ) : Issue {
31
+ return new Issue ( IssueType . SYNTACTIC , message , severity , position , node , code , args ) ;
26
32
}
27
33
28
- static semantic ( message : string , severity : IssueSeverity = IssueSeverity . ERROR , position ?: Position ) : Issue {
29
- return new Issue ( IssueType . SEMANTIC , message , severity , position ) ;
34
+ static semantic ( message : string , severity : IssueSeverity = IssueSeverity . ERROR , position ?: Position ,
35
+ node ?: Node , code ?: string , args : string [ ] = [ ] ) : Issue {
36
+ return new Issue ( IssueType . SEMANTIC , message , severity , position , node , code , args ) ;
30
37
}
31
- }
38
+ }
0 commit comments