Search in sources :

Example 61 with SourcePosition

use of com.google.javascript.jscomp.parsing.parser.util.SourcePosition in project closure-compiler by google.

the class Parser method parseEnumDeclaration.

private ParseTree parseEnumDeclaration() {
    SourcePosition start = getTreeStartLocation();
    eat(TokenType.ENUM);
    IdentifierToken name = eatId();
    eat(TokenType.OPEN_CURLY);
    ImmutableList<ParseTree> members = parseEnumMembers();
    eat(TokenType.CLOSE_CURLY);
    return new EnumDeclarationTree(getTreeLocation(start), name, members);
}
Also used : SourcePosition(com.google.javascript.jscomp.parsing.parser.util.SourcePosition) EnumDeclarationTree(com.google.javascript.jscomp.parsing.parser.trees.EnumDeclarationTree) ParseTree(com.google.javascript.jscomp.parsing.parser.trees.ParseTree)

Example 62 with SourcePosition

use of com.google.javascript.jscomp.parsing.parser.util.SourcePosition in project closure-compiler by google.

the class Parser method parseAmbientDeclaration.

private ParseTree parseAmbientDeclaration() {
    SourcePosition start = getTreeStartLocation();
    eat(TokenType.DECLARE);
    ParseTree declare = parseAmbientDeclarationHelper();
    return new AmbientDeclarationTree(getTreeLocation(start), declare);
}
Also used : AmbientDeclarationTree(com.google.javascript.jscomp.parsing.parser.trees.AmbientDeclarationTree) SourcePosition(com.google.javascript.jscomp.parsing.parser.util.SourcePosition) ParseTree(com.google.javascript.jscomp.parsing.parser.trees.ParseTree)

Example 63 with SourcePosition

use of com.google.javascript.jscomp.parsing.parser.util.SourcePosition in project closure-compiler by google.

the class Parser method parseTypeAlias.

private ParseTree parseTypeAlias() {
    SourcePosition start = getTreeStartLocation();
    eat(TokenType.TYPE);
    IdentifierToken alias = eatId();
    eat(TokenType.EQUAL);
    ParseTree original = parseType();
    eatPossibleImplicitSemiColon();
    return new TypeAliasTree(getTreeLocation(start), alias, original);
}
Also used : SourcePosition(com.google.javascript.jscomp.parsing.parser.util.SourcePosition) TypeAliasTree(com.google.javascript.jscomp.parsing.parser.trees.TypeAliasTree) ParseTree(com.google.javascript.jscomp.parsing.parser.trees.ParseTree)

Example 64 with SourcePosition

use of com.google.javascript.jscomp.parsing.parser.util.SourcePosition in project closure-compiler by google.

the class Parser method parsePatternRest.

private ParseTree parsePatternRest(PatternKind patternKind) {
    SourcePosition start = getTreeStartLocation();
    eat(TokenType.SPREAD);
    ParseTree patternAssignmentTarget = parseRestAssignmentTarget(patternKind);
    return new AssignmentRestElementTree(getTreeLocation(start), patternAssignmentTarget);
}
Also used : SourcePosition(com.google.javascript.jscomp.parsing.parser.util.SourcePosition) AssignmentRestElementTree(com.google.javascript.jscomp.parsing.parser.trees.AssignmentRestElementTree) ParseTree(com.google.javascript.jscomp.parsing.parser.trees.ParseTree)

Example 65 with SourcePosition

use of com.google.javascript.jscomp.parsing.parser.util.SourcePosition in project closure-compiler by google.

the class Parser method parseRecordTypeExpression.

private ParseTree parseRecordTypeExpression() {
    SourcePosition start = getTreeStartLocation();
    ParseTree typeExpression;
    if (peek(TokenType.OPEN_CURLY)) {
        eat(TokenType.OPEN_CURLY);
        typeExpression = new RecordTypeTree(getTreeLocation(start), parseInterfaceElements());
        eat(TokenType.CLOSE_CURLY);
    } else {
        typeExpression = parseTypeQuery();
    }
    return typeExpression;
}
Also used : SourcePosition(com.google.javascript.jscomp.parsing.parser.util.SourcePosition) RecordTypeTree(com.google.javascript.jscomp.parsing.parser.trees.RecordTypeTree) ParseTree(com.google.javascript.jscomp.parsing.parser.trees.ParseTree)

Aggregations

SourcePosition (com.google.javascript.jscomp.parsing.parser.util.SourcePosition)112 ParseTree (com.google.javascript.jscomp.parsing.parser.trees.ParseTree)81 ImmutableList (com.google.common.collect.ImmutableList)15 BinaryOperatorTree (com.google.javascript.jscomp.parsing.parser.trees.BinaryOperatorTree)13 FormalParameterListTree (com.google.javascript.jscomp.parsing.parser.trees.FormalParameterListTree)7 FunctionDeclarationTree (com.google.javascript.jscomp.parsing.parser.trees.FunctionDeclarationTree)6 DefaultParameterTree (com.google.javascript.jscomp.parsing.parser.trees.DefaultParameterTree)5 ArgumentListTree (com.google.javascript.jscomp.parsing.parser.trees.ArgumentListTree)4 BlockTree (com.google.javascript.jscomp.parsing.parser.trees.BlockTree)4 IdentifierExpressionTree (com.google.javascript.jscomp.parsing.parser.trees.IdentifierExpressionTree)4 MissingPrimaryExpressionTree (com.google.javascript.jscomp.parsing.parser.trees.MissingPrimaryExpressionTree)4 OptionalMemberExpressionTree (com.google.javascript.jscomp.parsing.parser.trees.OptionalMemberExpressionTree)4 OptionalMemberLookupExpressionTree (com.google.javascript.jscomp.parsing.parser.trees.OptionalMemberLookupExpressionTree)4 ArrayLiteralExpressionTree (com.google.javascript.jscomp.parsing.parser.trees.ArrayLiteralExpressionTree)3 GenericTypeListTree (com.google.javascript.jscomp.parsing.parser.trees.GenericTypeListTree)3 ObjectLiteralExpressionTree (com.google.javascript.jscomp.parsing.parser.trees.ObjectLiteralExpressionTree)3 OptChainCallExpressionTree (com.google.javascript.jscomp.parsing.parser.trees.OptChainCallExpressionTree)3 TemplateLiteralExpressionTree (com.google.javascript.jscomp.parsing.parser.trees.TemplateLiteralExpressionTree)3 VariableDeclarationTree (com.google.javascript.jscomp.parsing.parser.trees.VariableDeclarationTree)3 FormatString (com.google.errorprone.annotations.FormatString)2