public override bool Walk(VariableDeclaration node) {
     _scope.AddLocatedVariable(node.Name, node, _curUnit);
     return base.Walk(node);
 }
        public override bool Walk(VariableDeclaration node)
        {
            if (node != null)
            {
                if (node.Parent is LexicalDeclaration)
                {
                    // ES6 let or const declaration. Only add to the current lexical scope.
                    CurrentLexicalScope.LexicallyDeclaredNames.Add(node);
                }
                else
                {
                    // must be var or const (mozilla-style). Add to both the lexical scope
                    // and the variable scope. The variable scope will actually use this node
                    // to create a field; the lexical stack will just use it to detect conflicts
                    // with lex-decls
                    CurrentLexicalScope.VarDeclaredNames.Add(node);
                    CurrentVariableScope.VarDeclaredNames.Add(node);
                }

                if (node.Initializer != null)
                {
                    // recurse the initializer
                    node.Initializer.Walk(this);
                }
            }
            return false;
        }
예제 #3
0
 public override bool Walk(VariableDeclaration node) { AddNode(node); return true; }
예제 #4
0
        private void FormatVariableDeclaration(VariableDeclaration curDecl) {
            if (curDecl.HasInitializer) {
                ReplaceFollowingWhiteSpace(
                    curDecl.GetNameSpan(_tree.LocationResolver).End,
                    _options.SpaceBeforeAndAfterBinaryOperator ? " " : ""
                );

                ReplacePreceedingWhiteSpace(
                    curDecl.Initializer.GetStartIndex(_tree.LocationResolver),
                    _options.SpaceBeforeAndAfterBinaryOperator ? " " : ""
                );

                curDecl.Initializer.Walk(this);

                ReplaceFollowingWhiteSpace(
                    curDecl.Initializer.GetEndIndex(_tree.LocationResolver),
                    ""
                );
            }
        }