private void placeValue(ExpressionInfo expr) {
    String str = expr.getRenderedValue();
    if (str == null) return;

    int startColumn = expr.getAnchor().getColumn();
    if (startColumn < 1) return; // node with invalid source position

    String[] strs = NEWLINE_PATTERN.split(str);
    int endColumn = strs.length == 1 ?
        expr.getAnchor().getColumn() + str.length() : // exclusive
        Integer.MAX_VALUE; // multi-line strings are always placed on new lines

    if (lines.size() == 1) { // we have never placed a value yet
      // let's add an empty line between text and values
      lines.add(new StringBuilder());
      startColumns.add(0);
    }

    for (int i = 1; i < lines.size(); i++)
      if (endColumn < startColumns.get(i)) {
        placeString(lines.get(i), str, startColumn);
        startColumns.set(i, startColumn);
        return;
      } else {
        placeString(lines.get(i), "|", startColumn);
        if (i > 1) // i == 1 is the empty line between text and values, which should stay empty
          startColumns.set(i, startColumn + 1); // + 1: no whitespace required between end of value and "|"
      }

    // value could not be placed on existing lines, so place it on new line(s)
    for (String s : strs) {
      StringBuilder newLine = new StringBuilder();
      lines.add(newLine);
      placeString(newLine, s, startColumn);
      startColumns.add(startColumn);
    }
  }
Creates a string representation of an assertion and its recorded values.

@author Peter Niederwieser
spock-core/src/main/java/org/spockframework/runtime/ExpressionInfoRenderer.java