Ejemplo n.º 1
0
        public void MatchLinesByWords(int[] matches, IReadOnlyList <string> wmLines1, IReadOnlyList <string> wmLines2)
        {
            foreach (var(range1, range2) in LineMatching.UnmatchedRanges(matches, wmLines2.Count))
            {
                if (range1.length == 0 || range2.length == 0)
                {
                    continue;
                }

                int[] match = Match(wmLines1.Slice(range1), wmLines2.Slice(range2));
                for (int i = 0; i < match.Length; i++)
                {
                    if (match[i] >= 0)
                    {
                        matches[range1.start + i] = range2.start + match[i];
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public List <Patch> Diff(int numContextLines = DefaultContext)
        {
            if (matches == null)
            {
                Match();
            }

            var p = new Patch {
                diffs = LineMatching.MakeDiffList(matches, lines1, lines2)
            };

            p.RecalculateLength();
            p.Trim(numContextLines);
            if (p.length1 == 0)
            {
                return(new List <Patch>());
            }

            return(p.Split(numContextLines));
        }
Ejemplo n.º 3
0
 public List <Diff> Diff(IReadOnlyList <string> lines1, IReadOnlyList <string> lines2) => LineMatching.MakeDiffList(Match(lines1, lines2), lines1, lines2);