public virtual Differences VisitCompilationUnitSnippet(CompilationUnitSnippet snippet1, CompilationUnitSnippet snippet2){
      Differences differences = new Differences(snippet1, snippet2);
      if (snippet1 == null || snippet2 == null){
        if (snippet1 != snippet2) differences.NumberOfDifferences++; else differences.NumberOfSimilarities++;
        return differences;
      }
      CompilationUnitSnippet changes = (CompilationUnitSnippet)snippet2.Clone();
      CompilationUnitSnippet deletions = (CompilationUnitSnippet)snippet2.Clone();
      CompilationUnitSnippet insertions = (CompilationUnitSnippet)snippet2.Clone();

      if (snippet1.SourceContext.Document == null || snippet2.SourceContext.Document == null){
        if (snippet1.SourceContext.Document == snippet2.SourceContext.Document) differences.NumberOfSimilarities++; else differences.NumberOfDifferences++;
      }else if (snippet1.SourceContext.Document.Name == snippet2.SourceContext.Document.Name) 
        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;
    }
Example #2
0
 public override CompilationUnit VisitCompilationUnitSnippet(CompilationUnitSnippet snippet)
 {
     if (snippet == null) return null;
     return base.VisitCompilationUnitSnippet((CompilationUnitSnippet)snippet.Clone());
 }