Ejemplo n.º 1
0
        public override bool Walk(ForIn node)
        {
            if (node != null)
            {
                if (node.Collection != null)
                {
                    node.Collection.Walk(this);
                }

                if (node.Variable != null)
                {
                    // if the variable portion of the for-in statement is a lexical
                    // declaration, then we will create the block node for its body right now
                    // and add the declaration. This will prevent the body from deleting
                    // an empty lexical scope.
                    var lexDeclaration = node.Variable as LexicalDeclaration;
                    if (lexDeclaration != null)
                    {
                        // create the scope on the block
                        SetScope(
                            node,
                            new BlockScope(node, CurrentLexicalScope, _errorSink)
                        {
                            IsInWithScope = m_withDepth > 0
                        }
                            );
                        m_lexicalStack.Push(GetScope(node));
                    }
                }

                try
                {
                    if (node.Variable != null)
                    {
                        node.Variable.Walk(this);
                    }

                    if (node.Body != null)
                    {
                        node.Body.Walk(this);
                    }
                }
                finally
                {
                    if (GetScope(node) != null)
                    {
                        Debug.Assert(CurrentLexicalScope == GetScope(node));
                        m_lexicalStack.Pop();
                    }
                }
            }
            return(false);
        }
Ejemplo n.º 2
0
 public override bool Walk(ForIn node) { AddNode(node); return true; }
 public override bool Walk(ForIn node) {
     if (CheckBlock(node.Body)) {
         Span = GetTargetStatement(node).GetSpan(_tree.LocationResolver);
         return false;
     }
     return base.Walk(node);
 }
        public override bool Walk(ForIn node)
        {
            if (node != null)
            {
                if (node.Collection != null)
                {
                    node.Collection.Walk(this);
                }

                if (node.Variable != null)
                {
                    // if the variable portion of the for-in statement is a lexical
                    // declaration, then we will create the block node for its body right now
                    // and add the declaration. This will prevent the body from deleting
                    // an empty lexical scope.
                    var lexDeclaration = node.Variable as LexicalDeclaration;
                    if (lexDeclaration != null)
                    {
                        // create the scope on the block
                        SetScope(
                            node,
                            new BlockScope(node, CurrentLexicalScope, _errorSink)
                            {
                                IsInWithScope = m_withDepth > 0
                            }
                        );
                        m_lexicalStack.Push(GetScope(node));
                    }
                }

                try
                {
                    if (node.Variable != null)
                    {
                        node.Variable.Walk(this);
                    }

                    if (node.Body != null)
                    {
                        node.Body.Walk(this);
                    }
                }
                finally
                {
                    if (GetScope(node) != null)
                    {
                        Debug.Assert(CurrentLexicalScope == GetScope(node));
                        m_lexicalStack.Pop();
                    }
                }
            }
            return false;
        }
Ejemplo n.º 5
0
        public override bool Walk(ForIn node) {
            ReplaceControlFlowWhiteSpace(node, "for".Length);

            ReplacePreceedingWhiteSpace(
                node.Variable.GetStartIndex(_tree.LocationResolver),
                _options.SpaceAfterOpeningAndBeforeClosingNonEmptyParenthesis ? " " : "",
                _openParen
            );
            node.Variable.Walk(this);

            ReplaceFollowingWhiteSpace(
                node.Variable.GetEndIndex(_tree.LocationResolver),
                " "
            );

            ReplacePreceedingWhiteSpace(
                node.Collection.GetStartIndex(_tree.LocationResolver),
                " "
            );

            node.Collection.Walk(this);

            ReplaceFollowingWhiteSpace(
                node.Collection.GetEndIndex(_tree.LocationResolver),
                _options.SpaceAfterOpeningAndBeforeClosingNonEmptyParenthesis ? " " : ""
            );

            WalkFlowControlBlockWithOptionalParens(node.Body, node.Collection.GetEndIndex(_tree.LocationResolver), true);
            return false;
        }