@Test public void testParseTreePrettyPrintWithCharacterLimit() { List<String> strings = new ArrayList<>(); strings.add("1234"); String string = ParseTreePrettyPrinter.printWithCharacterLimit(strings, 0); assertThat(string, equalTo("1234")); string = ParseTreePrettyPrinter.printWithCharacterLimit(strings, 3); assertThat(string, equalTo("1234")); string = ParseTreePrettyPrinter.printWithCharacterLimit(strings, 4); assertThat(string, equalTo("1234")); strings.add("5678"); string = ParseTreePrettyPrinter.printWithCharacterLimit(strings, 0); assertThat(string, equalTo("1234\n5678")); string = ParseTreePrettyPrinter.printWithCharacterLimit(strings, 1); assertThat(string, equalTo("1234\nand 1 more line(s)")); string = ParseTreePrettyPrinter.printWithCharacterLimit(strings, 5); assertThat(string, equalTo("1234\nand 1 more line(s)")); string = ParseTreePrettyPrinter.printWithCharacterLimit(strings, 6); assertThat(string, equalTo("1234\n5678")); }
static String printWithCharacterLimit(List<String> strings, int maxStringLength) { StringBuilder sb = new StringBuilder(); int effectiveMaxStringLength = maxStringLength <= 0 ? Integer.MAX_VALUE : maxStringLength; ListIterator<String> iter = strings.listIterator(); while (effectiveMaxStringLength > sb.length() && iter.hasNext()) { String string = iter.next(); sb.append(string); if (iter.hasNext()) { sb.append("\n"); } } if (iter.hasNext()) { sb.append("and "); sb.append(strings.size() - iter.nextIndex()); sb.append(" more line(s)"); } return sb.toString(); }
ParseTreePrettyPrinter implements ParseTreeListener { static String printWithCharacterLimit(List<String> strings, int maxStringLength) { StringBuilder sb = new StringBuilder(); int effectiveMaxStringLength = maxStringLength <= 0 ? Integer.MAX_VALUE : maxStringLength; ListIterator<String> iter = strings.listIterator(); while (effectiveMaxStringLength > sb.length() && iter.hasNext()) { String string = iter.next(); sb.append(string); if (iter.hasNext()) { sb.append("\n"); } } if (iter.hasNext()) { sb.append("and "); sb.append(strings.size() - iter.nextIndex()); sb.append(" more line(s)"); } return sb.toString(); } }
ParseTreePrettyPrinter implements ParseTreeListener { static String printWithCharacterLimit(List<String> strings, int maxStringLength) { StringBuilder sb = new StringBuilder(); int effectiveMaxStringLength = maxStringLength <= 0 ? Integer.MAX_VALUE : maxStringLength; ListIterator<String> iter = strings.listIterator(); while (effectiveMaxStringLength > sb.length() && iter.hasNext()) { String string = iter.next(); sb.append(string); if (iter.hasNext()) { sb.append("\n"); } } if (iter.hasNext()) { sb.append("and "); sb.append(strings.size() - iter.nextIndex()); sb.append(" more line(s)"); } return sb.toString(); } private  ParseTreePrettyPrinter(
      ParserRuleContext ctx, BatfishCombinedParser<?, ?> combinedParser, boolean printLineNumbers); }
ParseTreePrettyPrinter implements ParseTreeListener { static String printWithCharacterLimit(List<String> strings, int maxStringLength) { StringBuilder sb = new StringBuilder(); int effectiveMaxStringLength = maxStringLength <= 0 ? Integer.MAX_VALUE : maxStringLength; ListIterator<String> iter = strings.listIterator(); while (effectiveMaxStringLength > sb.length() && iter.hasNext()) { String string = iter.next(); sb.append(string); if (iter.hasNext()) { sb.append("\n"); } } if (iter.hasNext()) { sb.append("and "); sb.append(strings.size() - iter.nextIndex()); sb.append(" more line(s)"); } return sb.toString(); } private  ParseTreePrettyPrinter(
      ParserRuleContext ctx, BatfishCombinedParser<?, ?> combinedParser, boolean printLineNumbers); static ParseTreeSentences getParseTreeSentences(
      ParserRuleContext ctx, BatfishCombinedParser<?, ?> combinedParser, boolean printLineNumbers); static String print(ParserRuleContext ctx, BatfishCombinedParser<?, ?> combinedParser); static String print(
      ParserRuleContext ctx, BatfishCombinedParser<?, ?> combinedParser, boolean printLineNumbers); @Override void enterEveryRule(ParserRuleContext ctx); @Override void exitEveryRule(ParserRuleContext ctx); @Override void visitErrorNode(ErrorNode ctx); @Override void visitTerminal(TerminalNode ctx); }
ParseTreePrettyPrinter implements ParseTreeListener { static String printWithCharacterLimit(List<String> strings, int maxStringLength) { StringBuilder sb = new StringBuilder(); int effectiveMaxStringLength = maxStringLength <= 0 ? Integer.MAX_VALUE : maxStringLength; ListIterator<String> iter = strings.listIterator(); while (effectiveMaxStringLength > sb.length() && iter.hasNext()) { String string = iter.next(); sb.append(string); if (iter.hasNext()) { sb.append("\n"); } } if (iter.hasNext()) { sb.append("and "); sb.append(strings.size() - iter.nextIndex()); sb.append(" more line(s)"); } return sb.toString(); } private  ParseTreePrettyPrinter(
      ParserRuleContext ctx, BatfishCombinedParser<?, ?> combinedParser, boolean printLineNumbers); static ParseTreeSentences getParseTreeSentences(
      ParserRuleContext ctx, BatfishCombinedParser<?, ?> combinedParser, boolean printLineNumbers); static String print(ParserRuleContext ctx, BatfishCombinedParser<?, ?> combinedParser); static String print(
      ParserRuleContext ctx, BatfishCombinedParser<?, ?> combinedParser, boolean printLineNumbers); @Override void enterEveryRule(ParserRuleContext ctx); @Override void exitEveryRule(ParserRuleContext ctx); @Override void visitErrorNode(ErrorNode ctx); @Override void visitTerminal(TerminalNode ctx);  }