@@ -14,12 +14,16 @@ private newtype TDiagnosticError =
1414 TExtractorError ( ExtractorError e )
1515
1616abstract private class DiagnosticError extends TDiagnosticError {
17- string getMessage ( ) { none ( ) }
17+ abstract string getMessage ( ) ;
1818
19- string toString ( ) { none ( ) }
19+ abstract string toString ( ) ;
2020
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 = ""
2327 }
2428}
2529
@@ -29,10 +33,12 @@ private class DiagnosticCompilerError extends DiagnosticError {
2933 DiagnosticCompilerError ( ) { this = TCompilerError ( c ) }
3034
3135 override string getMessage ( ) {
32- result = "Compiler error" + getLocation ( c . getLocation ( ) ) + ": " + c .getMessage ( )
36+ result = "Compiler error" + this . getLocationMessage ( ) + ": " + c .getMessage ( )
3337 }
3438
3539 override string toString ( ) { result = c .toString ( ) }
40+
41+ override Location getLocation ( ) { result = c .getLocation ( ) }
3642}
3743
3844private class DiagnosticExtractorError extends DiagnosticError {
@@ -45,10 +51,12 @@ private class DiagnosticExtractorError extends DiagnosticError {
4551
4652 override string getMessage ( ) {
4753 result =
48- "Unexpected " + e .getOrigin ( ) + " error" + getLocation ( e . getLocation ( ) ) + ": " + e .getText ( )
54+ "Unexpected " + e .getOrigin ( ) + " error" + this . getLocationMessage ( ) + ": " + e .getText ( )
4955 }
5056
5157 override string toString ( ) { result = e .toString ( ) }
58+
59+ override Location getLocation ( ) { result = e .getLocation ( ) }
5260}
5361
5462from DiagnosticError error
0 commit comments