private TypeNameTree parseTypeName() { SourcePosition start = getTreeStartLocation(); IdentifierToken token = eatIdOrKeywordAsId(); // for 'void'. return new TypeNameTree(getTreeLocation(start), buildIdentifierPath(token)); }
private TypeNameTree parseTypeName() { SourcePosition start = getTreeStartLocation(); IdentifierToken token = eatIdOrKeywordAsId(); // for 'void'. return new TypeNameTree(getTreeLocation(start), buildIdentifierPath(token)); }
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()); }
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()); }