Skip to content

Commit

Permalink
Enable double-click to navigate back and forth through the project re…
Browse files Browse the repository at this point in the history
…ference graph
  • Loading branch information
KirillOsenkov committed Aug 21, 2024
1 parent 29c9341 commit 624582b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 8 deletions.
14 changes: 14 additions & 0 deletions src/StructuredLogViewer/Controls/BuildControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2370,6 +2370,13 @@ private bool Invoke(BaseNode treeNode)
searchLogControl.ResultsList.ItemsSource is IEnumerable<BaseNode> results &&
results.Contains(item):
return SearchForFullPath(item.Text);
case Project project when
searchLogControl.SearchText.Contains("$projectreference"):
return SearchForProject(Path.GetFileName(project.ProjectFile));
case ProxyNode proxy when
searchLogControl.SearchText.Contains("$projectreference") &&
proxy.Original is Project originalProject:
return SearchForProject(Path.GetFileName(originalProject.ProjectFile));
case IHasSourceFile hasSourceFile when hasSourceFile.SourceFilePath != null:
int line = 0;
var hasLine = hasSourceFile as IHasLineNumber;
Expand Down Expand Up @@ -2447,6 +2454,13 @@ matcher.Terms[0].Word is string substring &&
return false;
}

private bool SearchForProject(string name)
{
var text = $"$projectreference project({name})";
searchLogControl.SearchText = text;
return true;
}

private bool DisplayEmbeddedFile(Item item)
{
string path = item.Text;
Expand Down
26 changes: 18 additions & 8 deletions src/StructuredLogger/Analyzers/ProjectReferenceGraph.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@ public ProjectReferenceGraph(Build build)
continue;
}

var projectReferences = items.FindChild<AddItem>("ProjectReference");
if (projectReferences == null)
{
continue;
}

if (!references.TryGetValue(projectFile, out var bucket))
{
bucket = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
references[projectFile] = bucket;
}

var projectReferences = items.FindChild<AddItem>("ProjectReference");
if (projectReferences == null)
{
continue;
}

foreach (var projectReference in projectReferences.Children.OfType<Item>())
{
var path = projectReference.Text;
Expand Down Expand Up @@ -130,9 +130,14 @@ TreeNode PopulateReferences(string path)
if (projectResult != null)
{
projectResult.IsExpanded = true;
var result = new SearchResult(projectResult);
resultSet.Add(result);
}
else
{
projectResult = CreateProject(project);
}

var result = new SearchResult(projectResult);
resultSet.Add(result);
}

if (resultSet.Count == 1)
Expand Down Expand Up @@ -167,6 +172,11 @@ TreeNode PopulateReferences(string path)
folder.AddChild(node);
}

if (folder.Children.Count < 10)
{
folder.IsExpanded = true;
}

resultSet.Add(new SearchResult(folder));
}
}
Expand Down

0 comments on commit 624582b

Please sign in to comment.