use of com.google.javascript.jscomp.parsing.parser.trees.UnionTypeTree in project closure-compiler by google.
the class Parser method parseType.
private ParseTree parseType() {
SourcePosition start = getTreeStartLocation();
if (!peekId() && !EnumSet.of(TokenType.VOID, TokenType.OPEN_PAREN, TokenType.OPEN_CURLY, TokenType.TYPEOF).contains(peekType())) {
reportError("Unexpected token '%s' in type expression", peekType());
return new TypeNameTree(getTreeLocation(start), ImmutableList.of("error"));
}
ParseTree typeExpression = parseFunctionTypeExpression();
if (!peek(TokenType.BAR)) {
return typeExpression;
}
ImmutableList.Builder<ParseTree> unionType = ImmutableList.builder();
unionType.add(typeExpression);
do {
eat(TokenType.BAR);
unionType.add(parseArrayTypeExpression());
} while (peek(TokenType.BAR));
return new UnionTypeTree(getTreeLocation(start), unionType.build());
}
Aggregations