Search in sources :

Example 1 with NamespaceDeclarationTree

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

the class Parser method parseNamespaceDeclaration.

private NamespaceDeclarationTree parseNamespaceDeclaration(boolean isAmbient) {
    SourcePosition start = getTreeStartLocation();
    if (eatOpt(TokenType.MODULE) == null) {
        // Accept "module" or "namespace"
        eat(TokenType.NAMESPACE);
    }
    NamespaceNameTree name = parseNamespaceName();
    eat(TokenType.OPEN_CURLY);
    ImmutableList<ParseTree> elements = isAmbient ? parseAmbientNamespaceElements() : parseNamespaceElements();
    eat(TokenType.CLOSE_CURLY);
    return new NamespaceDeclarationTree(getTreeLocation(start), name, elements);
}
Also used : NamespaceNameTree(com.google.javascript.jscomp.parsing.parser.trees.NamespaceNameTree) SourcePosition(com.google.javascript.jscomp.parsing.parser.util.SourcePosition) NamespaceDeclarationTree(com.google.javascript.jscomp.parsing.parser.trees.NamespaceDeclarationTree) ParseTree(com.google.javascript.jscomp.parsing.parser.trees.ParseTree)

Aggregations

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