Search in sources :

Example 1 with NamespaceNameTree

use of com.google.javascript.jscomp.parsing.parser.trees.NamespaceNameTree 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)

Example 2 with NamespaceNameTree

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

the class Parser method parseNamespaceName.

private NamespaceNameTree parseNamespaceName() {
    SourcePosition start = getTreeStartLocation();
    IdentifierToken token = eatId();
    return new NamespaceNameTree(getTreeLocation(start), buildIdentifierPath(token));
}
Also used : NamespaceNameTree(com.google.javascript.jscomp.parsing.parser.trees.NamespaceNameTree) SourcePosition(com.google.javascript.jscomp.parsing.parser.util.SourcePosition)

Aggregations

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