Beispiel #1
0
        /// <summary>
        /// Converts the specified document to a ascci-art syntax tree.
        /// </summary>
        /// <returns>Returns a ASCII tree visualizing the structure of the node and all its child nodes.</returns>
        public static string GetSyntaxTree(MdDocument document)
        {
            if (document == null)
            {
                throw new ArgumentNullException(nameof(document));
            }

            // convert the block into a graph
            var visitor = new GraphBuildingVisitor();

            document.Root.Accept(visitor);

            var rootNode = new AsciiTreeNode(document.GetType().Name);

            if (visitor.RootNode != null)
            {
                rootNode.Children.Add(visitor.RootNode);
            }

            // generate ascii tree
            var treeWriter = new AsciiTreeWriter();

            treeWriter.WriteNode(rootNode);

            // return ascii tree
            return(treeWriter.ToString());
        }
Beispiel #2
0
            private void PushNewNode(object item)
            {
                var name = item.GetType().Name;
                var node = new AsciiTreeNode(name);

                if (RootNode == null)
                {
                    RootNode = node;
                    m_Nodes.Push(RootNode);
                }
                else
                {
                    CurrentNode.Children.Add(node);
                    m_Nodes.Push(node);
                }
            }