Used for semantic errors that occur at compile time not during interpretation. For ST parsing ONLY not group parsing.
| 36 | |
| 37 | |
| 38 | public class STCompiletimeMessage extends STMessage { |
| 39 | /** overall token pulled from group file */ |
| 40 | public Token templateToken; |
| 41 | /** token inside template */ |
| 42 | public Token token; |
| 43 | public String srcName; |
| 44 | |
| 45 | public STCompiletimeMessage(ErrorType error, String srcName, Token templateToken, Token t) { |
| 46 | this(error, srcName, templateToken, t, null); |
| 47 | } |
| 48 | public STCompiletimeMessage(ErrorType error, String srcName, Token templateToken, Token t, Throwable cause) { |
| 49 | this(error, srcName, templateToken, t, cause, null); |
| 50 | } |
| 51 | public STCompiletimeMessage(ErrorType error, |
| 52 | String srcName, |
| 53 | Token templateToken, |
| 54 | Token t, |
| 55 | Throwable cause, Object arg) { |
| 56 | this(error, srcName, templateToken, t, cause, arg, null); |
| 57 | } |
| 58 | public STCompiletimeMessage(ErrorType error, |
| 59 | String srcName, |
| 60 | Token templateToken, |
| 61 | Token t, |
| 62 | Throwable cause, |
| 63 | Object arg, Object arg2) { |
| 64 | super(error, null, cause, arg, arg2); |
| 65 | this.templateToken = templateToken; |
| 66 | this.token = t; |
| 67 | this.srcName = srcName; |
| 68 | } |
| 69 | |
| 70 | @Override |
| 71 | public String toString() { |
| 72 | int line = 0; |
| 73 | int charPos = -1; |
| 74 | if ( token!=null ) { |
| 75 | line = token.getLine(); |
| 76 | charPos = token.getCharPositionInLine(); |
| 77 | // check the input streams - if different then token is embedded in templateToken and we need to adjust the offset |
| 78 | if ( templateToken!=null && !templateToken.getInputStream().equals(token.getInputStream()) ) { |
| 79 | int templateDelimiterSize = 1; |
| 80 | if ( templateToken.getType()==GroupParser.BIGSTRING || templateToken.getType()==GroupParser.BIGSTRING_NO_NL ) { |
| 81 | templateDelimiterSize = 2; |
| 82 | } |
| 83 | line += templateToken.getLine()-1; |
| 84 | charPos += templateToken.getCharPositionInLine()+templateDelimiterSize; |
| 85 | } |
| 86 | } |
| 87 | String filepos = line+":"+charPos; |
| 88 | if ( srcName!=null ) { |
| 89 | return srcName+" "+filepos+": "+String.format(error.message, arg, arg2); |
| 90 | } |
| 91 | return filepos+": "+String.format(error.message, arg, arg2); |
| 92 | } |
| 93 | } |
nothing calls this directly
no outgoing calls
no test coverage detected