Skip to content

Commit

Permalink
Use the exact file copy operation that matched instead of guessing ra…
Browse files Browse the repository at this point in the history
…ndomly
  • Loading branch information
KirillOsenkov committed Aug 1, 2024
1 parent a714006 commit 49b51e1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/StructuredLogger/Analyzers/FileCopyMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,13 @@ private void TryExplainSingleFileCopy(Project project, string filePath, IList<Se

private void TryExplainSingleFileCopy(FileData fileData, IList<SearchResult> resultSet)
{
var fileCopyInfo = fileData.Incoming.FirstOrDefault() ?? fileData.Outgoing.FirstOrDefault();
var singleResult = resultSet.Single();

var fileCopyInfo =
singleResult.AssociatedFileCopy ??
fileData.Incoming.FirstOrDefault() ??
fileData.Outgoing.FirstOrDefault();

var project = fileCopyInfo.Project;

var sourceFilePath = fileData.FilePath;
Expand Down Expand Up @@ -473,6 +479,7 @@ private void GetResults(FileData fileData, IList<SearchResult> resultSet, NodeQu

var message = incoming.FileCopyOperation.Message;
var result = new SearchResult(message);
result.AssociatedFileCopy = incoming;
result.AddMatch(message.Text, matchText);
result.RootFolder = "Incoming";
resultSet.Add(result);
Expand All @@ -491,6 +498,7 @@ private void GetResults(FileData fileData, IList<SearchResult> resultSet, NodeQu

var message = outgoing.FileCopyOperation.Message;
var result = new SearchResult(message);
result.AssociatedFileCopy = outgoing;
result.AddMatch(message.Text, matchText);
result.RootFolder = "Outgoing";
resultSet.Add(result);
Expand Down
2 changes: 2 additions & 0 deletions src/StructuredLogger/Search/SearchResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public class SearchResult

public string RootFolder { get; set; }

public FileCopyInfo AssociatedFileCopy { get; set; }

public static SearchResult EmptyQueryMatch { get; } = new SearchResult();

public SearchResult()
Expand Down

0 comments on commit 49b51e1

Please sign in to comment.