private ParseTree parseObjectPattern(PatternKind kind) {
    SourcePosition start = getTreeStartLocation();
    ImmutableList.Builder<ParseTree> fields = ImmutableList.builder();
    eat(TokenType.OPEN_CURLY);
    while (peekObjectPatternField()) {
      fields.add(parseObjectPatternField(kind));

      if (peek(TokenType.COMMA)) {
        // Consume the comma separator
        eat(TokenType.COMMA);
      } else {
        // Otherwise we must be done
        break;
      }
    }
    if (peek(TokenType.SPREAD)) {
      recordFeatureUsed(Feature.OBJECT_PATTERN_REST);
      fields.add(parsePatternRest(kind));
    }
    eat(TokenType.CLOSE_CURLY);
    return new ObjectPatternTree(getTreeLocation(start), fields.build());
  }
private ParseTree parseObjectPattern ( PatternKind kind ) { SourcePosition start = getTreeStartLocation ( ) ; ImmutableList . Builder < ParseTree > fields = ImmutableList . builder ( ) ; eat ( TokenType . OPEN_CURLY ) ; while ( peekObjectPatternField ( ) ) { fields . add ( parseObjectPatternField ( kind ) ) ; if ( peek ( TokenType . COMMA ) ) { eat ( TokenType . COMMA ) ; } else { break ; } } if ( peek ( TokenType . SPREAD ) ) { recordFeatureUsed ( Feature . OBJECT_PATTERN_REST ) ; fields . add ( parsePatternRest ( kind ) ) ; } eat ( TokenType . CLOSE_CURLY ) ; return new ObjectPatternTree ( getTreeLocation ( start ) , fields . build ( ) ) ; }
Pattern ::= "{" (Field ("," Field)* ","?)? "}" | ...