Example #1
0
 public override void PrintTo(IndentPrinter printer)
 {
     printer.Print(ToString());
     printer.PrintLine($" #{treeHash}");
     printer.IncIndent();
     children.ForEach(x => x.PrintTo(printer));
     printer.DecIndent();
 }
Example #2
0
        private static Matching ComputeMatching(SyntaxNode target, SyntaxNode source)
        {
            var groups      = source.GetSubtrees().GroupBy(t => t.treeHash);
            var sourceTable = new MultiValueDict <int, SyntaxNode>(groups);

            var matching = new Matching();

            foreach (var tree in target.GetSubtrees())
            {
                foreach (var t in sourceTable.GetValues(tree.treeHash)) // `tree.hash = t.hash`
                {
                    if (matching.ContainsValue(tree, t))                // Tree `t` has been visited before.
                    {
                        continue;
                    }

                    // Let's check if `tree` and `t` are really identical.
                    if (tree.IdenticalTo(t)) // We find a match!
                    {
                        // Since `tree` is identical to `t`, so are their subtrees.
                        tree.GetSubtrees()
                        .Zip(t.GetSubtrees(), (t1, t2) => (tree: t1, t: t2))
                        .ToList()
                        .ForEach(pair => matching.Add(pair.tree, pair.t));
                    }
                    else
                    {
                        Log.Debug("Same hash {0} but different trees:", tree.treeHash);
                        var printer = new IndentPrinter();
                        tree.PrintTo(printer);
                        printer.PrintLine("<->");
                        t.PrintTo(printer);
                    }
                }
            }

            return(matching);
        }
Example #3
0
 public override void PrintTo(IndentPrinter printer)
 {
     printer.Print(ToString());
     printer.PrintLine($" #{treeHash}");
 }
Example #4
0
 abstract public void PrintTo(IndentPrinter printer);
Example #5
0
 public override void PrintTo(IndentPrinter printer)
 {
 }
Example #6
0
 public override void PrintTo(IndentPrinter printer)
 {
     oldNode.PrintTo(printer);
     printer.PrintLine("<->");
     newNode.PrintTo(printer);
 }
Example #7
0
 public override void PrintTo(IndentPrinter printer)
 {
     oldNode.PrintTo(printer);
 }