use of com.google.javascript.jscomp.parsing.parser.trees.TypeNameTree in project closure-compiler by google.
the class Parser method parseTypeName.
private TypeNameTree parseTypeName() {
SourcePosition start = getTreeStartLocation();
// for 'void'.
IdentifierToken token = eatIdOrKeywordAsId();
return new TypeNameTree(getTreeLocation(start), buildIdentifierPath(token));
}
use of com.google.javascript.jscomp.parsing.parser.trees.TypeNameTree in project closure-compiler by google.
the class Parser method parseTypeReference.
private ParseTree parseTypeReference() {
SourcePosition start = getTreeStartLocation();
TypeNameTree typeName = parseTypeName();
if (!peek(TokenType.OPEN_ANGLE)) {
return typeName;
}
return parseTypeArgumentList(start, typeName);
}
use of com.google.javascript.jscomp.parsing.parser.trees.TypeNameTree 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