public virtual Differences VisitComprehension(Comprehension comprehension1, Comprehension comprehension2){
      Differences differences = new Differences(comprehension1, comprehension2);
      if (comprehension1 == null || comprehension2 == null){
        if (comprehension1 != comprehension2) differences.NumberOfDifferences++; else differences.NumberOfSimilarities++;
        return differences;
      }
      Comprehension changes = (Comprehension)comprehension2.Clone();
      Comprehension deletions = (Comprehension)comprehension2.Clone();
      Comprehension insertions = (Comprehension)comprehension2.Clone();

      ExpressionList exprChanges, exprDeletions, exprInsertions;
      Differences diff = this.VisitExpressionList(comprehension1.BindingsAndFilters, comprehension2.BindingsAndFilters, out exprChanges, out exprDeletions, out exprInsertions);
      if (diff == null){Debug.Assert(false); return differences;}
      changes.BindingsAndFilters = exprChanges;
      deletions.BindingsAndFilters = exprDeletions;
      insertions.BindingsAndFilters = exprInsertions;
      differences.NumberOfDifferences += diff.NumberOfDifferences;
      differences.NumberOfSimilarities += diff.NumberOfSimilarities;

      diff = this.VisitExpressionList(comprehension1.Elements, comprehension2.Elements, out exprChanges, out exprDeletions, out exprInsertions);
      if (diff == null){Debug.Assert(false); return differences;}
      changes.Elements = exprChanges;
      deletions.Elements = exprDeletions;
      insertions.Elements = exprInsertions;
      differences.NumberOfDifferences += diff.NumberOfDifferences;
      differences.NumberOfSimilarities += diff.NumberOfSimilarities;

      if (comprehension1.Mode == comprehension2.Mode) differences.NumberOfSimilarities++; else differences.NumberOfDifferences++;

      if (differences.NumberOfDifferences == 0){
        differences.Changes = null;
        differences.Deletions = null;
        differences.Insertions = null;
      }else{
        differences.Changes = changes;
        differences.Deletions = deletions;
        differences.Insertions = insertions;
      }
      return differences;
    }
示例#2
0
 public override Expression VisitComprehension(Comprehension Comprehension)
 {
     if (Comprehension == null) return null;
     return base.VisitComprehension((Comprehension)Comprehension.Clone());
 }