javatests/com/google/fhir/protogen/ProtoFilePrinterTest.java
/**
   * Collapse statements spread across multiple lines into single lines. These statements are
   * typically field definitions, along with annotations, and may be well over the maximum line
   * length allowed by the style guide.
   */
Collapse statements spread across multiple lines into single lines. These statements are
typically field definitions, along with annotations, and may be well over the maximum line
length allowed by the style guide.
Collapse statements spread across multiple lines into single lines . These statements are typically field definitions along with annotations and may be well over the maximum line length allowed by the style guide .
private SortedMap<java.lang.Integer, String> collapseStatements(
      SortedMap<java.lang.Integer, String> input) {
    TreeMap<java.lang.Integer, String> result = new TreeMap<>();
    Iterator<Map.Entry<java.lang.Integer, String>> iter = input.entrySet().iterator();
    while (iter.hasNext()) {
      Map.Entry<java.lang.Integer, String> current = iter.next();
      String value = current.getValue();
      if (!value.trim().isEmpty() && !value.trim().startsWith("//")) {
        while (!value.endsWith(";") && iter.hasNext()) {
          String next = iter.next().getValue().trim();
          if (!next.isEmpty()) {
            value = value + (value.endsWith("[") || next.startsWith("]") ? "" : " ") + next;
          }
        }
      }
      if (value.contains("End of auto-generated messages.")) {
        return result;
      }
      value = value.replaceAll("\\s\\s+", " ");
      if (!value.isEmpty()) {
        result.put(current.getKey(), value);
      }
    }
    return result;
  }
private SortedMap < java . lang . Integer , String > collapseStatements ( SortedMap < java . lang . Integer , String > input ) { TreeMap < java . lang . Integer , String > result = new TreeMap < > ( ) ; Iterator < Map . Entry < java . lang . Integer , String > > iter = input . entrySet ( ) . iterator ( ) ; while ( iter . hasNext ( ) ) { Map . Entry < java . lang . Integer , String > current = iter . next ( ) ; String value = current . getValue ( ) ; if ( ! value . trim ( ) . isEmpty ( ) && ! value . trim ( ) . startsWith ( "//" ) ) { while ( ! value . endsWith ( ";" ) && iter . hasNext ( ) ) { String next = iter . next ( ) . getValue ( ) . trim ( ) ; if ( ! next . isEmpty ( ) ) { value = value + ( value . endsWith ( "[" ) || next . startsWith ( "]" ) ? "" : " " ) + next ; } } } if ( value . contains ( "End of auto-generated messages." ) ) { return result ; } value = value . replaceAll ( "\\s\\s+" , " " ) ; if ( ! value . isEmpty ( ) ) { result . put ( current . getKey ( ) , value ) ; } } return result ; }
Collapse statements spread across multiple lines into single lines.
Collapse statements spread across multiple lines into single lines .
// Merge until we see the closing ';'