Search in sources :

Example 1 with DynamicImportTree

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

the class Parser method parseDynamicImportExpression.

// https://tc39.github.io/proposal-dynamic-import
private DynamicImportTree parseDynamicImportExpression() {
    SourcePosition start = getTreeStartLocation();
    eat(TokenType.IMPORT);
    if (peek(TokenType.QUESTION_DOT)) {
        // import?.() not allowed
        reportError("Optional chaining is forbidden in import?.");
    }
    eat(TokenType.OPEN_PAREN);
    ParseTree argument = parseAssignmentExpression();
    eat(TokenType.CLOSE_PAREN);
    recordFeatureUsed(Feature.DYNAMIC_IMPORT);
    return new DynamicImportTree(getTreeLocation(start), argument);
}
Also used : SourcePosition(com.google.javascript.jscomp.parsing.parser.util.SourcePosition) DynamicImportTree(com.google.javascript.jscomp.parsing.parser.trees.DynamicImportTree) ParseTree(com.google.javascript.jscomp.parsing.parser.trees.ParseTree)

Aggregations

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