update sln diagnostics on type

This commit is contained in:
Matt Parker
2025-09-12 19:28:20 +10:00
parent 1f829314dd
commit 4ee90bff50
2 changed files with 15 additions and 8 deletions

View File

@@ -81,12 +81,7 @@ public static class RoslynAnalysis
_codeFixProviders = _codeFixProviders.DistinctBy(s => s.GetType().Name).ToHashSet();
_codeRefactoringProviders = _codeRefactoringProviders.DistinctBy(s => s.GetType().Name).ToHashSet();
foreach (var project in _sharpIdeSolutionModel.AllProjects)
{
var projectDiagnostics = await GetProjectDiagnostics(project);
project.Diagnostics.Clear();
project.Diagnostics.AddRange(projectDiagnostics);
}
await UpdateSolutionDiagnostics();
foreach (var project in solution.Projects)
{
// foreach (var document in project.Documents)
@@ -112,6 +107,18 @@ public static class RoslynAnalysis
Console.WriteLine("RoslynAnalysis: Analysis completed.");
}
public static async Task UpdateSolutionDiagnostics()
{
await _solutionLoadedTcs.Task;
foreach (var project in _sharpIdeSolutionModel!.AllProjects)
{
var projectDiagnostics = await GetProjectDiagnostics(project);
// TODO: only add and remove diffs
project.Diagnostics.RemoveRange(project.Diagnostics);
project.Diagnostics.AddRange(projectDiagnostics);
}
}
public static async Task<ImmutableArray<Diagnostic>> GetProjectDiagnostics(SharpIdeProjectModel projectModel)
{
await _solutionLoadedTcs.Task;

View File

@@ -63,12 +63,12 @@ public partial class ProblemsPanel : Control
.SubscribeAwait(async (innerEvent, ct) => await (innerEvent.Action switch
{
NotifyCollectionChangedAction.Add => CreateDiagnosticTreeItem(_tree, treeItem, innerEvent),
NotifyCollectionChangedAction.Remove => FreeTreeItem(e.OldItem.View.Value),
NotifyCollectionChangedAction.Remove => FreeTreeItem(innerEvent.OldItem.View.Value),
_ => Task.CompletedTask
})).AddTo(this);
});
}
private async Task CreateDiagnosticTreeItem(Tree tree, TreeItem parent, ViewChangedEvent<Diagnostic, TreeItemContainer> e)
{
await this.InvokeAsync(() =>