use of com.google.javascript.jscomp.parsing.parser.trees.ObjectRestTree in project closure-compiler by google.
the class Parser method parseObjectPattern.
// Pattern ::= "{" (Field ("," Field)* ","?)? "}" | ...
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.ELLIPSIS)) {
recordFeatureUsed(Feature.OBJECT_PATTERN_REST);
SourcePosition restStart = getTreeStartLocation();
eat(TokenType.ELLIPSIS);
ParseTree patternAssignmentTarget = parseRestAssignmentTarget(kind);
fields.add(new ObjectRestTree(getTreeLocation(restStart), patternAssignmentTarget));
}
eat(TokenType.CLOSE_CURLY);
return new ObjectPatternTree(getTreeLocation(start), fields.build());
}
Aggregations