public Comment toComment() { return new Comment(value, line); }
@Override public String apply(Comment input) { return input.getValue(); } }).toList();
public Range getLineRange() { int first; if (getComments().size() > 0) { first = getComments().get(0).getLine(); } else { first = getFirstNonCommentLine(); } return new Range(first, getLine()); }
private void printComments(List<Comment> comments, String indent) { for (Comment comment : comments) { out.println(indent + comment.getValue()); } }
@Override public void step(Step step) { if (lineOffset != 0 && isPreview) { int newLine = step.getLine().intValue() + lineOffset.intValue(); featureLineOffset.put(step.getLine().intValue(), newLine); step = new Step(step.getComments(), step.getKeyword(), step.getName(), newLine, step.getRows(), step.getDocString()); } if (step.getRows() != null && step.getRows().get(0) != null && !step.getRows().get(0).getComments().isEmpty()) { String filePathFromComment = getExtractFilePathFromComment(step.getRows().get(0).getComments().get(0).getValue()); Resource sourceResource = getSourceResource(filePathFromComment); if (sourceResource != null) { step = loadAndReplaceSteps(step, filePathFromComment, sourceResource); } } super.step(step); prettyFormatter.step(step); }
@Override public void comment(String comment, Integer line) { stash.comment(new Comment(comment, line)); }
buffer.append(comment.getValue()); buffer.append("\n"); rowHeight++;
private List<Comment> comments(Map o) { List<Comment> comments = new ArrayList<Comment>(); if (o.containsKey("comments")) { for (Object e : ((List) o.get("comments"))) { Map map = (Map) e; comments.add(new Comment(getString(map, "value"), getInt(map, "line"))); } } return comments; }
@Override public void examples(Examples examples) { ExamplesTableRow cells = examples.getRows().isEmpty() ? null : examples.getRows().get(0); if (cells != null && lineOffset != 0 && isPreview && cells.getComments().isEmpty()) { int newLine = cells.getLine() + lineOffset.intValue(); featureLineOffset.put(cells.getLine(), newLine); List<ExamplesTableRow> rows = examples.getRows(); List<ExamplesTableRow> newRows = new ArrayList<ExamplesTableRow>(); for (ExamplesTableRow examplesTableRow : rows) { featureLineOffset.put(examplesTableRow.getLine(), examplesTableRow.getLine() + lineOffset); ExamplesTableRow tableRow = new ExamplesTableRow(examplesTableRow.getComments(), examplesTableRow.getCells(), examplesTableRow.getLine() + lineOffset, examplesTableRow.getId()); newRows.add(tableRow); } examples.setRows(newRows); } if (cells != null && !cells.getComments().isEmpty()) { String filePathFromComment = getExtractFilePathFromComment(cells.getComments().get(0).getValue()); Resource sourceResource = getSourceResource(filePathFromComment); if (sourceResource != null) { loadAndReplaceExamples(examples, cells, filePathFromComment, sourceResource); } } super.examples(examples); prettyFormatter.examples(examples); }
List<String> values = data.getValues().get(lineNumInResource); String valueComment = String.format("# %s:%d", filePathFromComment, lineNumInResource + 1); Comment comment = new Comment(valueComment, lineNumInResource); List<Comment> comments = Lists.newArrayList(comment); int newLineNum = tableRowHeader.getLine() + lineNumOffset;
private Step loadAndReplaceSteps(Step step, String filePathFromComment, Resource sourceResource) { DataReader dataReader; try { InputStream inputStream = sourceResource.getInputStream(); dataReader = DataReaderFactory.create(sourceResource.getFilename()); DataDTO data = dataReader.readTable(inputStream); List<DataTableRow> rows = Lists.newArrayList(); for (Integer lineNum : data.getValues().keySet()) { List<String> cells = Lists.newArrayList(data.getValues().get(lineNum)); String valueComment = String.format("# %s:%d", filePathFromComment, lineNum + 1); Comment comment = new Comment(valueComment, lineNum); List<Comment> comments = Lists.newArrayList(comment); int newLineNum = step.getLine() + 2; if (isPreview) { newLineNum += lineOffset; } DataTableRow row = new DataTableRow(comments, cells, newLineNum + 1); rows.add(row); lineOffset += 2; } // re-calculate lineOffset lineOffset = lineOffset - step.getRows().size() - 1; step = new Step(step.getComments(), step.getKeyword(), step.getName(), step.getLine(), rows, step.getDocString()); } catch (InstantiationException | IllegalAccessException | IOException e) { throw Throwables.propagate(e); } return step; }