@@ -14,12 +14,16 @@ private newtype TDiagnosticError =
14
14
TExtractorError ( ExtractorError e )
15
15
16
16
abstract private class DiagnosticError extends TDiagnosticError {
17
- string getMessage ( ) { none ( ) }
17
+ abstract string getMessage ( ) ;
18
18
19
- string toString ( ) { none ( ) }
19
+ abstract string toString ( ) ;
20
20
21
- string getLocation ( Location l ) {
22
- if l .getFile ( ) .fromSource ( ) then result = " in " + l .getFile ( ) else result = ""
21
+ abstract Location getLocation ( ) ;
22
+
23
+ string getLocationMessage ( ) {
24
+ if getLocation ( ) .getFile ( ) .fromSource ( )
25
+ then result = " in " + getLocation ( ) .getFile ( )
26
+ else result = ""
23
27
}
24
28
}
25
29
@@ -29,10 +33,12 @@ private class DiagnosticCompilerError extends DiagnosticError {
29
33
DiagnosticCompilerError ( ) { this = TCompilerError ( c ) }
30
34
31
35
override string getMessage ( ) {
32
- result = "Compiler error" + getLocation ( c . getLocation ( ) ) + ": " + c .getMessage ( )
36
+ result = "Compiler error" + this . getLocationMessage ( ) + ": " + c .getMessage ( )
33
37
}
34
38
35
39
override string toString ( ) { result = c .toString ( ) }
40
+
41
+ override Location getLocation ( ) { result = c .getLocation ( ) }
36
42
}
37
43
38
44
private class DiagnosticExtractorError extends DiagnosticError {
@@ -45,10 +51,12 @@ private class DiagnosticExtractorError extends DiagnosticError {
45
51
46
52
override string getMessage ( ) {
47
53
result =
48
- "Unexpected " + e .getOrigin ( ) + " error" + getLocation ( e . getLocation ( ) ) + ": " + e .getText ( )
54
+ "Unexpected " + e .getOrigin ( ) + " error" + this . getLocationMessage ( ) + ": " + e .getText ( )
49
55
}
50
56
51
57
override string toString ( ) { result = e .toString ( ) }
58
+
59
+ override Location getLocation ( ) { result = e .getLocation ( ) }
52
60
}
53
61
54
62
from DiagnosticError error
0 commit comments