private int tryToExecuteByID(final DFA dfa, final DFAState s0, final TokenStream input, final int startIndex, final ParserRuleContext outerContext, final NoViableAltException cause) { Token token = cause.getOffendingToken(); CommonToken commonToken; if (token instanceof CommonToken) { commonToken = (CommonToken) token; } else { throw cause; } int previousType = commonToken.getType(); if (previousType > identifierTokenIndex || Token.EOF == token.getType()) { throw cause; } commonToken.setType(identifierTokenIndex); try { return super.execATN(dfa, s0, input, startIndex, outerContext); } catch (NoViableAltException ex) { if (cause.getOffendingToken() == ex.getOffendingToken()) { throw cause; } return tryToExecuteByID(dfa, s0, input, startIndex, outerContext, ex); // CHECKSTYLE:OFF } catch (final Exception ex) { // CHECKSTYLE:ON commonToken.setType(previousType); throw cause; } } }
private void tryToExecuteByID(final Parser recognizer, final InputMismatchException cause) { Token token = cause.getOffendingToken(); CommonToken commonToken; if (token instanceof CommonToken) { commonToken = (CommonToken) token; } else { throw cause; } int previousType = commonToken.getType(); if (previousType > identifierTokenIndex) { return; } commonToken.setType(identifierTokenIndex); try { super.sync(recognizer); } catch (InputMismatchException ex) { if (cause.getOffendingToken() == ex.getOffendingToken()) { commonToken.setType(previousType); throw cause; } tryToExecuteByID(recognizer, ex); // CHECKSTYLE:OFF } catch (final Exception ex) { // CHECKSTYLE:ON commonToken.setType(previousType); throw cause; } } }
@Override public void syntaxError(Recognizer<?, ?> recognizer, Object offendingSymbol, int line, int charPositionInLine, String msg, RecognitionException e) { int fromIndex = getCharIndex(inputContent, line-1, charPositionInLine); CommonToken token = (CommonToken) offendingSymbol; int toIndex; if (token != null && token.getType() != Token.EOF) toIndex = fromIndex + token.getText().length() - 1; else toIndex = fromIndex; errors.add(new Range(fromIndex, toIndex)); }
switch (opToken.getType()) { case CSSParser.EQUALS: { op = Selector.Operator.EQUALS;
switch (opToken.getType()) { case CSSParser.EQUALS: { op = Selector.Operator.EQUALS;
suggestToken.setStart(offendingStart + 1); suggestToken.setStop(offendingStop); suggestToken.setTokenNum(offendingToken.getType()); suggestToken.setTokenSource(offendingSource); suggest.add(suggestToken);
suggestToken.setStart(offendingStart + 1); suggestToken.setStop(offendingStop); suggestToken.setTokenNum(offendingToken.getType()); suggestToken.setTokenSource(offendingSource); suggest.add(suggestToken);