Search in sources :

Example 1 with TypeQueryTree

use of com.google.javascript.jscomp.parsing.parser.trees.TypeQueryTree in project closure-compiler by google.

the class Parser method parseTypeQuery.

private ParseTree parseTypeQuery() {
    SourcePosition start = getTreeStartLocation();
    if (peek(TokenType.TYPEOF)) {
        eat(TokenType.TYPEOF);
        IdentifierToken token = eatId();
        ImmutableList.Builder<String> identifiers = ImmutableList.builder();
        if (token != null) {
            identifiers.add(token.value);
        }
        while (peek(TokenType.PERIOD)) {
            // TypeQueryExpression . IdentifierName
            eat(TokenType.PERIOD);
            token = eatId();
            if (token == null) {
                break;
            }
            identifiers.add(token.value);
        }
        return new TypeQueryTree(getTreeLocation(start), identifiers.build());
    } else {
        return parseTypeReference();
    }
}
Also used : TypeQueryTree(com.google.javascript.jscomp.parsing.parser.trees.TypeQueryTree) ImmutableList(com.google.common.collect.ImmutableList) SourcePosition(com.google.javascript.jscomp.parsing.parser.util.SourcePosition) FormatString(com.google.errorprone.annotations.FormatString)

Aggregations

ImmutableList (com.google.common.collect.ImmutableList)1 FormatString (com.google.errorprone.annotations.FormatString)1 TypeQueryTree (com.google.javascript.jscomp.parsing.parser.trees.TypeQueryTree)1 SourcePosition (com.google.javascript.jscomp.parsing.parser.util.SourcePosition)1