Search in sources :

Example 1 with GetAccessorTree

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

the class Parser method parseGetAccessor.

private ParseTree parseGetAccessor(PartialClassElement partial) {
    eatPredefinedString(PredefinedName.GET);
    if (peekPropertyName(0)) {
        Token propertyName = eatObjectLiteralPropertyName();
        eat(TokenType.OPEN_PAREN);
        eat(TokenType.CLOSE_PAREN);
        BlockTree body = parseFunctionBody();
        recordFeatureUsed(Feature.GETTER);
        return new GetAccessorTree(getTreeLocation(partial.start), propertyName, partial.isStatic, body);
    } else {
        ParseTree property = parseComputedPropertyName();
        eat(TokenType.OPEN_PAREN);
        eat(TokenType.CLOSE_PAREN);
        BlockTree body = parseFunctionBody();
        recordFeatureUsed(Feature.GETTER);
        return new ComputedPropertyGetterTree(getTreeLocation(partial.start), property, partial.isStatic, body);
    }
}
Also used : GetAccessorTree(com.google.javascript.jscomp.parsing.parser.trees.GetAccessorTree) ComputedPropertyGetterTree(com.google.javascript.jscomp.parsing.parser.trees.ComputedPropertyGetterTree) BlockTree(com.google.javascript.jscomp.parsing.parser.trees.BlockTree) ParseTree(com.google.javascript.jscomp.parsing.parser.trees.ParseTree)

Aggregations

BlockTree (com.google.javascript.jscomp.parsing.parser.trees.BlockTree)1 ComputedPropertyGetterTree (com.google.javascript.jscomp.parsing.parser.trees.ComputedPropertyGetterTree)1 GetAccessorTree (com.google.javascript.jscomp.parsing.parser.trees.GetAccessorTree)1 ParseTree (com.google.javascript.jscomp.parsing.parser.trees.ParseTree)1