Пример #1
0
        /// <summary>
        /// Called when the syntax walker visits a node.
        /// </summary>
        /// <param name="node"></param>
        public override void Visit(LuaSyntaxNode node)
        {
            if (node != null)
            {
                _recursionDepth++;
                StackGuard.EnsureSufficientExecutionStack(_recursionDepth);

                node.Accept(this);

                _recursionDepth--;
            }
        }
Пример #2
0
        public override LuaSyntaxNode Visit(LuaSyntaxNode node)
        {
            if (node != null)
            {
                if (!_foundOldToken)
                {
                    if (node is SyntaxToken token)
                    {
                        Debug.Assert(token == _oldToken);
                        _foundOldToken = true;
                        return(_newToken); // NB: diagnostic offsets have already been updated (by SyntaxParser.AddSkippedSyntax)
                    }

                    return(UpdateDiagnosticOffset(base.Visit(node), _diagnosticOffsetDelta));
                }
            }

            return(node);
        }
Пример #3
0
 /// <summary>
 /// Called when the walker walks into a node.
 /// </summary>
 /// <param name="node"></param>
 protected override void DefaultVisit(LuaSyntaxNode node)
 {
     foreach (var child in node.ChildNodesAndTokens())
     {
         if (child.IsToken)
         {
             if (Depth >= SyntaxWalkerDepth.Token)
             {
                 Visit((SyntaxToken)child);
             }
         }
         else
         {
             if (Depth >= SyntaxWalkerDepth.Node)
             {
                 Visit((LuaSyntaxNode)child);
             }
         }
     }
 }
Пример #4
0
        public override LuaSyntaxNode Visit(LuaSyntaxNode node)
        {
            if (node != null && !_found)
            {
                _count--;
                if (_count == 0)
                {
                    if (node is SyntaxToken token)
                    {
                        Debug.Assert(token == _oldToken);
                        _found = true;
                        return(_newToken);
                    }

                    _count += CountNonNullSlots(node);
                    return(base.Visit(node));
                }
            }

            return(node);
        }
Пример #5
0
 internal StructuredTriviaSyntax(InternalSyntax.LuaSyntaxNode green, SyntaxNode?parent, int position)
     : base(green, position, parent?.SyntaxTree)
 {
     RoslynDebug.Assert(parent == null || position >= 0);
 }
Пример #6
0
 private static int CountNonNullSlots(LuaSyntaxNode node) =>
 node.ChildNodesAndTokens().Count;