public static List <ASTSequenceItem> Create(ASTPatternGenerator apg, ParseTree rootNode)
        {
            if (apg == null)
            {
                throw new ArgumentNullException(nameof(apg));
            }

            VB6NodeTree            nodeTree     = new VB6NodeTree(rootNode);
            List <ASTSequenceItem> returnedList = new List <ASTSequenceItem> {
            };

            foreach (var node in nodeTree.GetAllNodes())
            {
                var subtree = new VB6SubTree(nodeTree, node);

                int    depth        = 0;
                string childIndices = "";
                string typePath     = "";

                var paths = nodeTree.GetPath(node).ToList();
                if (paths.Count == 0)
                {
                    continue;
                }

                foreach (IndexedPath path in paths)
                {
                    childIndices += path.ChildIndex + "/";
                    typePath     += path.NodeTypeName + "/";
                    depth++;
                }

                var asi = new ASTSequenceItem {
                    setpos    = returnedList.Count,
                    depth     = depth,
                    childPath = childIndices,
                    token     = paths.Last().Token,
                    typeName  = paths.First().NodeTypeName,
                    pattern   = apg.Lookup(subtree),
                    node      = node
                };
                returnedList.Add(asi);
            }
            return(returnedList);
        }
Beispiel #2
0
        public static List <ImmutableList <IndexedPath> > GetExtendedPathList(ParseTree pnode)
        {
            var         paths    = new List <ImmutableList <IndexedPath> >();
            ParseTree   root     = null;
            VB6NodeTree nodeTree = new VB6NodeTree(pnode);

            var visitorCallback = new VisitorCallback()
            {
                Callback = (node, parent) =>
                {
                    if (root == null)
                    {
                        root = node;
                    }
                    paths.Add(nodeTree.GetPath(node));
                }
            };

            var visitor = new VB6ASTTreeViewGeneratorVisitor(visitorCallback);

            visitor.visit(pnode);
            return(paths);
        }