private VariableDeclarationTree parseVariableDeclaration( final TokenType binding, Expression expressionIn) { SourcePosition start = getTreeStartLocation(); ParseTree lvalue; ParseTree typeAnnotation = null; if (peekPatternStart()) { lvalue = parsePattern(PatternKind.INITIALIZER); } else { lvalue = parseIdentifierExpression(); if (peek(TokenType.COLON)) { typeAnnotation = parseTypeAnnotation(); } } ParseTree initializer = null; if (peek(TokenType.EQUAL)) { initializer = parseInitializer(expressionIn); } else if (expressionIn != Expression.NO_IN) { // NOTE(blickly): this is a bit of a hack, declarations outside of for statements allow "in", // and by chance, also must have initializers for const/destructuring. Vanilla for loops // also require intializers, but are handled separately in checkVanillaForInitializers maybeReportNoInitializer(binding, lvalue); } return new VariableDeclarationTree(getTreeLocation(start), lvalue, typeAnnotation, initializer); }
private VariableDeclarationTree parseVariableDeclaration( final TokenType binding, Expression expressionIn) { SourcePosition start = getTreeStartLocation(); ParseTree lvalue; ParseTree typeAnnotation = null; if (peekPatternStart()) { lvalue = parsePattern(PatternKind.INITIALIZER); } else { lvalue = parseIdentifierExpression(); if (peek(TokenType.COLON)) { typeAnnotation = parseTypeAnnotation(); } } ParseTree initializer = null; if (peek(TokenType.EQUAL)) { initializer = parseInitializer(expressionIn); } else if (expressionIn != Expression.NO_IN) { // NOTE(blickly): this is a bit of a hack, declarations outside of for statements allow "in", // and by chance, also must have initializers for const/destructuring. Vanilla for loops // also require intializers, but are handled separately in checkVanillaForInitializers maybeReportNoInitializer(binding, lvalue); } return new VariableDeclarationTree(getTreeLocation(start), lvalue, typeAnnotation, initializer); }