Search in sources :

Example 1 with IndexSignatureTree

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

the class Parser method parseIndexSignature.

private IndexSignatureTree parseIndexSignature() {
    SourcePosition start = getTreeStartLocation();
    eat(TokenType.OPEN_SQUARE);
    IdentifierToken name = eatIdOrKeywordAsId();
    eat(TokenType.COLON);
    // must be 'string' or 'number'
    ParseTree indexType = parseTypeName();
    eat(TokenType.CLOSE_SQUARE);
    eat(TokenType.COLON);
    ParseTree declaredType = parseType();
    ParseTree nameTree = new MemberVariableTree(getTreeLocation(start), name, false, false, null, indexType);
    return new IndexSignatureTree(getTreeLocation(start), nameTree, declaredType);
}
Also used : IndexSignatureTree(com.google.javascript.jscomp.parsing.parser.trees.IndexSignatureTree) SourcePosition(com.google.javascript.jscomp.parsing.parser.util.SourcePosition) ParseTree(com.google.javascript.jscomp.parsing.parser.trees.ParseTree) ComputedPropertyMemberVariableTree(com.google.javascript.jscomp.parsing.parser.trees.ComputedPropertyMemberVariableTree) MemberVariableTree(com.google.javascript.jscomp.parsing.parser.trees.MemberVariableTree)

Aggregations

ComputedPropertyMemberVariableTree (com.google.javascript.jscomp.parsing.parser.trees.ComputedPropertyMemberVariableTree)1 IndexSignatureTree (com.google.javascript.jscomp.parsing.parser.trees.IndexSignatureTree)1 MemberVariableTree (com.google.javascript.jscomp.parsing.parser.trees.MemberVariableTree)1 ParseTree (com.google.javascript.jscomp.parsing.parser.trees.ParseTree)1 SourcePosition (com.google.javascript.jscomp.parsing.parser.util.SourcePosition)1