protected override void ParseSyntaxNode()

in src/Structure/BlockTaggerImpl/CsharpParser.cs [16:57]


        protected override void ParseSyntaxNode(ITextSnapshot snapshot, SyntaxNode parentSyntaxNode, CodeBlock parentCodeBlockNode, CancellationToken token, int level)
        {
            if (token.IsCancellationRequested)
            {
                throw new TaskCanceledException();
            }
            else
            {
                foreach (var childnode in parentSyntaxNode.ChildNodes())
                {
                    BlockType type = BlockType.Unknown;
                    int startPosition = 0;
                    int endPosition = 0;

                    if (TryAsNamespace(childnode, ref type, ref startPosition, ref endPosition) ||
                        TryAsType(childnode, ref type, ref startPosition, ref endPosition) ||
                        TryAsEnum(childnode, ref type, ref startPosition, ref endPosition) ||
                        TryAsSwitch(childnode, ref type, ref startPosition, ref endPosition) ||
                        TryAsSwitchSection(childnode, snapshot, ref type, ref startPosition, ref endPosition) ||
                        TryAsProperty(childnode, ref type, ref startPosition, ref endPosition))
                    {
                        var statementStart = childnode.SpanStart;
                        string statement = StatementFromSpan(snapshot, statementStart, startPosition);

                        CodeBlock child = new CodeBlock(parentCodeBlockNode, type, statement, new SnapshotSpan(snapshot, Span.FromBounds(startPosition, endPosition)), statementStart, level + 1);
                        ParseSyntaxNode(snapshot, childnode, child, token, level + 1);
                    }
                    else if (TryAsBlock(childnode, parentSyntaxNode, ref type, ref startPosition, ref endPosition))
                    {
                        int statementStart = type == BlockType.Unknown ? startPosition : parentSyntaxNode.SpanStart;
                        string statement = StatementFromSpan(snapshot, statementStart, startPosition);

                        CodeBlock child = new CodeBlock(parentCodeBlockNode, type, statement, new SnapshotSpan(snapshot, Span.FromBounds(startPosition, endPosition)), statementStart, level + 1);
                        ParseSyntaxNode(snapshot, childnode, child, token, level + 1);
                    }
                    else
                    {
                        ParseSyntaxNode(snapshot, childnode, parentCodeBlockNode, token, level);
                    }
                }
            }
        }