Search in sources :

Example 1 with ClassDeclarationTree

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

the class Parser method parseClass.

private ParseTree parseClass(boolean isExpression) {
    SourcePosition start = getTreeStartLocation();
    eat(TokenType.CLASS);
    IdentifierToken name = null;
    if (!isExpression || peekId()) {
        name = eatId();
    }
    ParseTree superClass = null;
    if (peek(TokenType.EXTENDS)) {
        eat(TokenType.EXTENDS);
        superClass = parseExpression();
    }
    eat(TokenType.OPEN_CURLY);
    ImmutableList<ParseTree> elements = parseClassElements();
    eat(TokenType.CLOSE_CURLY);
    return new ClassDeclarationTree(getTreeLocation(start), name, superClass, elements);
}
Also used : SourcePosition(com.google.javascript.jscomp.parsing.parser.util.SourcePosition) ParseTree(com.google.javascript.jscomp.parsing.parser.trees.ParseTree) ClassDeclarationTree(com.google.javascript.jscomp.parsing.parser.trees.ClassDeclarationTree)

Aggregations

ClassDeclarationTree (com.google.javascript.jscomp.parsing.parser.trees.ClassDeclarationTree)1 ParseTree (com.google.javascript.jscomp.parsing.parser.trees.ParseTree)1 SourcePosition (com.google.javascript.jscomp.parsing.parser.util.SourcePosition)1