@Override public boolean consume(CodeReader code, TokenQueue output) { if (code.popTo(matcher, tmpBuilder) > 0) { // see SONAR-2499 Cursor previousCursor = code.getPreviousCursor(); if (normalizationValue != null) { output.add(new Token(normalizationValue, previousCursor.getLine(), previousCursor.getColumn())); } else { output.add(new Token(tmpBuilder.toString(), previousCursor.getLine(), previousCursor.getColumn())); } // Godin: note that other channels use method delete in order to do the same thing tmpBuilder.setLength(0); return true; } return false; }
previousCursor = getCursor().clone(); for (int i = 0; i < matcher.end(); i++) { appendable.append((char) pop()); + "' at line " + getCursor().getLine() + " and column " + getCursor().getColumn() + ", because it led to a stack overflow error." + " This error may be due to an inefficient use of alternations - see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5050507", e);
/** * Note that this constructor will read everything from reader and will close it. */ protected CodeBuffer(Reader initialCodeReader, CodeReaderConfiguration configuration) { Reader reader = null; try { lastChar = -1; cursor = new Cursor(); tabWidth = configuration.getTabWidth(); /* Setup the filters on the reader */ reader = initialCodeReader; for (CodeReaderFilter<?> codeReaderFilter : configuration.getCodeReaderFilters()) { reader = new Filter(reader, codeReaderFilter, configuration); } buffer = IOUtils.toCharArray(reader); } catch (IOException e) { throw new ChannelException(e.getMessage(), e); } finally { IOUtils.closeQuietly(reader); } }
@Override public boolean consume(CodeReader code, TokenQueue output) { if (code.popTo(matcher, tmpBuilder) > 0) { // see SONAR-2499 Cursor previousCursor = code.getPreviousCursor(); if (normalizationValue != null) { output.add(new Token(normalizationValue, previousCursor.getLine(), previousCursor.getColumn())); } else { output.add(new Token(tmpBuilder.toString(), previousCursor.getLine(), previousCursor.getColumn())); } // Godin: note that other channels use method delete in order to do the same thing tmpBuilder.setLength(0); return true; } return false; }
/** * @deprecated in 2.2, use {@link #popTo(Matcher matcher, Appendable appendable)} instead */ @Deprecated public final void popTo(EndMatcher matcher, Appendable appendable) { previousCursor = getCursor().clone(); try { do { appendable.append((char) pop()); } while (!matcher.match(peek()) && peek() != -1); } catch (IOException e) { throw new ChannelException(e.getMessage(), e); } }
@Override public Cursor clone() { Cursor clone = new Cursor(); clone.column = column; clone.line = line; return clone; } }