use of org.antlr.v4.parse.v3TreeGrammarException in project CFLint by cflint.
the class CFLint method syntaxError.
@Override
public void syntaxError(final Recognizer<?, ?> recognizer, final Object offendingSymbol, int line, int charPositionInLine, final String msg, final org.antlr.v4.runtime.RecognitionException e) {
final String file = currentFile == null ? "" : currentFile + "\r\n";
String expression = null;
if (offendingSymbol instanceof Token) {
expression = ((Token) offendingSymbol).getText();
if (expression.length() > 50) {
expression = expression.substring(1, 40) + "...";
}
}
if (currentElement != null) {
if (line == 1) {
line = currentElement.getSource().getRow(currentElement.getBegin());
charPositionInLine = charPositionInLine + currentElement.getSource().getColumn(currentElement.getBegin());
} else {
line = currentElement.getSource().getRow(currentElement.getBegin()) + line - 1;
}
}
if (recognizer instanceof Parser && ((Parser) recognizer).isExpectedToken(CFSCRIPTParser.SEMICOLON)) {
bugs.add(new BugInfo.BugInfoBuilder().setMessageCode("MISSING_SEMI").setFilename(file).setMessage("End of statement(;) expected instead of " + expression).setSeverity("ERROR").setExpression(expression).setLine(line).setColumn(charPositionInLine).build());
} else {
fireCFLintException(e, PARSE_ERROR, file, line, charPositionInLine, "", msg);
}
}
Aggregations