Skip to content

Commit

Permalink
Analysis looks for the pulls it needs, but still can't do anything wi…
Browse files Browse the repository at this point in the history
…th them.
  • Loading branch information
CodyRay committed Feb 7, 2016
1 parent 55bcd97 commit 6b670dc
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions SemDiff.Core/Analysis.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
using Microsoft.CodeAnalysis.Diagnostics;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace SemDiff.Core
{
Expand All @@ -15,7 +17,7 @@ public class Analysis
/// </summary>
public static IEnumerable<DetectedFalsePositive> ForFalsePositive(Repo repo, SyntaxTree tree, string filePath)
{
var pulls = repo.GetRemoteChanges();
var pulls = GetPulls(repo, filePath);
throw new NotImplementedException();
}

Expand All @@ -24,8 +26,33 @@ public static IEnumerable<DetectedFalsePositive> ForFalsePositive(Repo repo, Syn
/// </summary>
public static IEnumerable<DetectedFalseNegative> ForFalseNegative(Repo repo, SemanticModel semanticModel)
{
var pulls = repo.GetRemoteChanges();
var baseClassPath = ""; //TODO: find using semantic model
var pulls = GetPulls(repo, baseClassPath);
throw new NotImplementedException();
}

internal static string GetRelativePath(string localDirectory, string filePath)
{
var local = Path.GetFullPath(localDirectory);
var file = Path.GetFullPath(filePath);
if (file.StartsWith(local))
{
return file.Substring(local.Length);
}
else
{
return null;
}
}

internal static IEnumerable<Tuple<RemoteFile, RemoteChanges>> GetPulls(Repo repo, string lookForFile)
{
var relativePath = GetRelativePath(repo.LocalDirectory, lookForFile);
if (string.IsNullOrWhiteSpace(relativePath))
{
return Enumerable.Empty<Tuple<RemoteFile, RemoteChanges>>();
}
return repo.GetRemoteChanges().SelectMany(p => p.Files.Select(f => new { n = f.Filename, f, p })).Where(a => a.n == relativePath).Select(a => Tuple.Create(a.f, a.p)).ToList();
}
}
}

0 comments on commit 6b670dc

Please sign in to comment.