List of usage examples for org.antlr.v4.runtime IntStream size
int size();
From source file:com.github.jknack.handlebars.internal.HbsErrorReporter.java
License:Apache License
/** * Extract lines./*from w ww . j a v a2s .co m*/ * * @param recognizer A lexer/parser. * @return Source lines */ private String[] lines(final Recognizer<?, ?> recognizer) { IntStream stream = recognizer.getInputStream(); if (stream instanceof CommonTokenStream) { stream = ((CommonTokenStream) stream).getTokenSource().getInputStream(); } final String input; if (stream instanceof CharStream) { input = ((CharStream) stream).getText(new Interval(0, stream.size())); } else { input = stream.toString(); } String[] lines = input.split("\n"); return lines; }