コード例 #1
0
    public virtual Differences VisitLocalDeclaration(LocalDeclaration localDeclaration1, LocalDeclaration localDeclaration2){
      Differences differences = new Differences(localDeclaration1, localDeclaration2);
      if (localDeclaration1 == null || localDeclaration2 == null){
        if (localDeclaration1 != localDeclaration2) differences.NumberOfDifferences++; else differences.NumberOfSimilarities++;
        return differences;
      }
      LocalDeclaration changes = (LocalDeclaration)localDeclaration2.Clone();
      LocalDeclaration deletions = (LocalDeclaration)localDeclaration2.Clone();
      LocalDeclaration insertions = (LocalDeclaration)localDeclaration2.Clone();

      Differences diff = this.VisitExpression(localDeclaration1.InitialValue, localDeclaration2.InitialValue);
      if (diff == null){Debug.Assert(false); return differences;}
      changes.InitialValue = diff.Changes as Expression;
      deletions.InitialValue = diff.Deletions as Expression;
      insertions.InitialValue = diff.Insertions as Expression;
      Debug.Assert(diff.Changes == changes.InitialValue && diff.Deletions == deletions.InitialValue && diff.Insertions == insertions.InitialValue);
      differences.NumberOfDifferences += diff.NumberOfDifferences;
      differences.NumberOfSimilarities += diff.NumberOfSimilarities;

      diff = this.VisitIdentifier(localDeclaration1.Name, localDeclaration2.Name);
      if (diff == null){Debug.Assert(false); return differences;}
      changes.Name = diff.Changes as Identifier;
      deletions.Name = diff.Deletions as Identifier;
      insertions.Name = diff.Insertions as Identifier;
      Debug.Assert(diff.Changes == changes.Name && diff.Deletions == deletions.Name && diff.Insertions == insertions.Name);
      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
ファイル: Duplicator.cs プロジェクト: hnlshzx/DotNetOpenAuth
 public override LocalDeclaration VisitLocalDeclaration(LocalDeclaration localDeclaration)
 {
     if (localDeclaration == null) return null;
     return base.VisitLocalDeclaration((LocalDeclaration)localDeclaration.Clone());
 }