Exemplo n.º 1
0
        private void WriteNode(SyntaxNode node)
        {
            WriteIndent();
            Write(node.Kind);
            WriteSeparator();
            Write($"[{node.Position}..{node.EndPosition})::{node.FullWidth}");

            if (node is RazorDirectiveSyntax razorDirective)
            {
                WriteRazorDirective(razorDirective);
            }
            else if (node is MarkupTagHelperElementSyntax tagHelperElement)
            {
                WriteTagHelperElement(tagHelperElement);
            }
            else if (node is MarkupTagHelperAttributeSyntax tagHelperAttribute)
            {
                WriteTagHelperAttributeInfo(tagHelperAttribute.TagHelperAttributeInfo);
            }
            else if (node is MarkupMinimizedTagHelperAttributeSyntax minimizedTagHelperAttribute)
            {
                WriteTagHelperAttributeInfo(minimizedTagHelperAttribute.TagHelperAttributeInfo);
            }
            else if (node is MarkupStartTagSyntax startTag)
            {
                if (startTag.IsMarkupTransition)
                {
                    WriteSeparator();
                    Write("MarkupTransition");
                }
            }
            else if (node is MarkupEndTagSyntax endTag)
            {
                if (endTag.IsMarkupTransition)
                {
                    WriteSeparator();
                    Write("MarkupTransition");
                }
            }

            if (ShouldDisplayNodeContent(node))
            {
                WriteSeparator();
                Write($"[{node.GetContent()}]");
            }

            var annotation = node.GetAnnotations().FirstOrDefault(a => a.Kind == SyntaxConstants.SpanContextKind);

            if (annotation != null && annotation.Data is SpanContext context)
            {
                WriteSpanContext(context);
            }

            if (!_visitedRoot)
            {
                WriteSeparator();
                Write($"[{node.ToFullString()}]");
                _visitedRoot = true;
            }
        }