protected boolean tokenEndsAtEndOfLine(TokenSourceWithStateV4<TState> lexer, Token token) { CharStream charStream = lexer.getInputStream(); if (charStream != null) { int nextCharIndex = token.getStopIndex() + 1; if (nextCharIndex >= charStream.size()) { return true; } int c = charStream .getText(Interval.of(token.getStopIndex() + 1, token.getStopIndex() + 1)) .charAt(0); return c == '\r' || c == '\n'; } if (token.getStopIndex() + 1 >= snapshot.length()) { return true; } char c = snapshot.subSequence(token.getStopIndex() + 1, token.getStopIndex() + 1).charAt(0); return c == '\r' || c == '\n'; /*int line = snapshot.findLineNumber(token.getStopIndex() + 1); int lineStart = snapshot.findLineFromOffset(line).getStart().getOffset(); int nextLineStart = snapshot.findLineFromOffset(line + 1).getStart().getOffset(); int lineEnd = nextLineStart - 1; if (lineEnd > 0 && lineEnd > lineStart) { char c = snapshot.charAt(lineEnd - 1); if (c == '\r' || c == '\n') { lineEnd--; } } return lineEnd <= token.getStopIndex() + 1 && nextLineStart >= token.getStopIndex() + 1;*/ }