DynamicLineParser extends LookaheadParser { @Override public Report parse(final ReaderFactory reader) throws ParsingException { fileName = reader.getFileName(); return super.parse(reader); } DynamicLineParser(final String regexp, final String script); @Override Report parse(final ReaderFactory reader);  }
@Test void shouldScanAllLinesAndAssignLineNumberAndFileName() { DynamicLineParser parser = new DynamicLineParser("^(.*)$", "return builder.setFileName(fileName).setLineStart(lineNumber).setMessage(matcher.group(1)).buildOptional()"); Report report = parser.parse(createReaderFactory(FILE_NAME)); assertThat(report).hasSize(3); for (int i = 0; i < 3; i++) { assertThat(report.get(i)).hasBaseName(FILE_NAME).hasLineStart(i + 1).hasMessage(String.valueOf(i + 1)); } }