Search in sources :

Example 1 with InterfaceDeclarationTree

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

the class Parser method parseInterfaceDeclaration.

private ParseTree parseInterfaceDeclaration() {
    SourcePosition start = getTreeStartLocation();
    eat(TokenType.INTERFACE);
    IdentifierToken name = eatId();
    GenericTypeListTree generics = maybeParseGenericTypes();
    ImmutableList.Builder<ParseTree> superTypes = ImmutableList.builder();
    if (peek(TokenType.EXTENDS)) {
        eat(TokenType.EXTENDS);
        ParseTree type = parseType();
        superTypes.add(type);
        while (peek(TokenType.COMMA)) {
            eat(TokenType.COMMA);
            type = parseType();
            if (type != null) {
                superTypes.add(type);
            }
        }
    }
    eat(TokenType.OPEN_CURLY);
    ImmutableList<ParseTree> elements = parseInterfaceElements();
    eat(TokenType.CLOSE_CURLY);
    return new InterfaceDeclarationTree(getTreeLocation(start), name, generics, superTypes.build(), elements);
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) SourcePosition(com.google.javascript.jscomp.parsing.parser.util.SourcePosition) GenericTypeListTree(com.google.javascript.jscomp.parsing.parser.trees.GenericTypeListTree) InterfaceDeclarationTree(com.google.javascript.jscomp.parsing.parser.trees.InterfaceDeclarationTree) ParseTree(com.google.javascript.jscomp.parsing.parser.trees.ParseTree)

Aggregations

ImmutableList (com.google.common.collect.ImmutableList)1 GenericTypeListTree (com.google.javascript.jscomp.parsing.parser.trees.GenericTypeListTree)1 InterfaceDeclarationTree (com.google.javascript.jscomp.parsing.parser.trees.InterfaceDeclarationTree)1 ParseTree (com.google.javascript.jscomp.parsing.parser.trees.ParseTree)1 SourcePosition (com.google.javascript.jscomp.parsing.parser.util.SourcePosition)1