Пример #1
0
    public virtual Differences VisitTry(Try try1, Try try2){
      Differences differences = new Differences(try1, try2);
      if (try1 == null || try2 == null){
        if (try1 != try2) differences.NumberOfDifferences++; else differences.NumberOfSimilarities++;
        return differences;
      }
      Try changes = (Try)try2.Clone();
      Try deletions = (Try)try2.Clone();
      Try insertions = (Try)try2.Clone();

      CatchList catchChanges, catchDeletions, catchInsertions;
      Differences diff = this.VisitCatchList(try1.Catchers, try2.Catchers, out catchChanges, out catchDeletions, out catchInsertions);
      if (diff == null){Debug.Assert(false); return differences;}
      changes.Catchers = catchChanges;
      deletions.Catchers = catchDeletions;
      insertions.Catchers = catchInsertions;
      differences.NumberOfDifferences += diff.NumberOfDifferences;
      differences.NumberOfSimilarities += diff.NumberOfSimilarities;

      FaultHandlerList faultChanges, faultDeletions, faultInsertions;
      diff = this.VisitFaultHandlerList(try1.FaultHandlers, try2.FaultHandlers, out faultChanges, out faultDeletions, out faultInsertions);
      if (diff == null){Debug.Assert(false); return differences;}
      changes.FaultHandlers = faultChanges;
      deletions.FaultHandlers = faultDeletions;
      insertions.FaultHandlers = faultInsertions;
      differences.NumberOfDifferences += diff.NumberOfDifferences;
      differences.NumberOfSimilarities += diff.NumberOfSimilarities;

      FilterList filterChanges, filterDeletions, filterInsertions;
      diff = this.VisitFilterList(try1.Filters, try2.Filters, out filterChanges, out filterDeletions, out filterInsertions);
      if (diff == null){Debug.Assert(false); return differences;}
      changes.Filters = filterChanges;
      deletions.Filters = filterDeletions;
      insertions.Filters = filterInsertions;
      differences.NumberOfDifferences += diff.NumberOfDifferences;
      differences.NumberOfSimilarities += diff.NumberOfSimilarities;

      diff = this.VisitFinally(try1.Finally, try2.Finally);
      if (diff == null){Debug.Assert(false); return differences;}
      changes.Finally = diff.Changes as Finally;
      deletions.Finally = diff.Deletions as Finally;
      insertions.Finally = diff.Insertions as Finally;
      Debug.Assert(diff.Changes == changes.Finally && diff.Deletions == deletions.Finally && diff.Insertions == insertions.Finally);
      differences.NumberOfDifferences += diff.NumberOfDifferences;
      differences.NumberOfSimilarities += diff.NumberOfSimilarities;

      diff = this.VisitBlock(try1.TryBlock, try2.TryBlock);
      if (diff == null){Debug.Assert(false); return differences;}
      changes.TryBlock = diff.Changes as Block;
      deletions.TryBlock = diff.Deletions as Block;
      insertions.TryBlock = diff.Insertions as Block;
      Debug.Assert(diff.Changes == changes.TryBlock && diff.Deletions == deletions.TryBlock && diff.Insertions == insertions.TryBlock);
      differences.NumberOfDifferences += diff.NumberOfDifferences;
      differences.NumberOfSimilarities += diff.NumberOfSimilarities;

      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 Statement VisitTry(Try Try)
 {
     if (Try == null) return null;
     return base.VisitTry((Try)Try.Clone());
 }