| 36 | |
| 37 | |
| 38 | public class STLexerMessage extends STMessage { |
| 39 | public String msg; |
| 40 | /** overall token pulled from group file */ |
| 41 | public Token templateToken; |
| 42 | public String srcName; |
| 43 | |
| 44 | public STLexerMessage(String srcName, String msg, Token templateToken, Throwable cause) { |
| 45 | super(ErrorType.LEXER_ERROR, null, cause, null); |
| 46 | this.msg = msg; |
| 47 | this.templateToken = templateToken; |
| 48 | this.srcName = srcName; |
| 49 | } |
| 50 | |
| 51 | @Override |
| 52 | public String toString() { |
| 53 | RecognitionException re = (RecognitionException)cause; |
| 54 | int line = re.line; |
| 55 | int charPos = re.charPositionInLine; |
| 56 | if ( templateToken!=null ) { |
| 57 | int templateDelimiterSize = 1; |
| 58 | if ( templateToken.getType()==GroupParser.BIGSTRING ) { |
| 59 | templateDelimiterSize = 2; |
| 60 | } |
| 61 | line += templateToken.getLine()-1; |
| 62 | charPos += templateToken.getCharPositionInLine()+templateDelimiterSize; |
| 63 | } |
| 64 | |
| 65 | String filepos = line+":"+charPos; |
| 66 | if ( srcName!=null ) { |
| 67 | return srcName+" "+filepos+": "+String.format(error.message, msg); |
| 68 | } |
| 69 | return filepos+": "+String.format(error.message, msg); |
| 70 | } |
| 71 | } |
nothing calls this directly
no outgoing calls
no test coverage detected