refactor
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
using System.Collections.Specialized;
|
using System.Collections.Specialized;
|
||||||
using Godot;
|
using Godot;
|
||||||
|
using Microsoft.CodeAnalysis;
|
||||||
using ObservableCollections;
|
using ObservableCollections;
|
||||||
using R3;
|
using R3;
|
||||||
using SharpIDE.Application.Features.SolutionDiscovery.VsPersistence;
|
using SharpIDE.Application.Features.SolutionDiscovery.VsPersistence;
|
||||||
@@ -41,35 +42,37 @@ public partial class ProblemsPanel : Control
|
|||||||
{
|
{
|
||||||
var treeItem = _tree.CreateItem(_rootItem);
|
var treeItem = _tree.CreateItem(_rootItem);
|
||||||
treeItem.SetText(0, x.Name);
|
treeItem.SetText(0, x.Name);
|
||||||
var projectDiagnosticsView = x.Diagnostics.CreateView(y =>
|
var projectDiagnosticsView = x.Diagnostics.CreateView(y => new TreeItemContainer());
|
||||||
|
var disposable = projectDiagnosticsView.ObserveChanged()
|
||||||
|
.SubscribeAwait(async (e, ct) => await (e.Action switch
|
||||||
{
|
{
|
||||||
return new TreeItemContainer();
|
NotifyCollectionChangedAction.Add => CreateDiagnosticTreeItem(_tree, treeItem, e),
|
||||||
});
|
NotifyCollectionChangedAction.Remove => FreeDiagnosticTreeItem(e),
|
||||||
var test = projectDiagnosticsView.ObserveChanged()
|
_ => Task.CompletedTask
|
||||||
.SubscribeAwait(async (e, ct) =>
|
}));
|
||||||
{
|
Observable.EveryValueChanged(x, s => s.Diagnostics.Count)
|
||||||
if (e.Action is NotifyCollectionChangedAction.Add)
|
.Subscribe(s => treeItem.Visible = s is not 0);
|
||||||
{
|
return treeItem;
|
||||||
await this.InvokeAsync(() =>
|
|
||||||
{
|
|
||||||
var diagItem = _tree.CreateItem(treeItem);
|
|
||||||
diagItem.SetText(0, e.NewItem.Value.GetMessage());
|
|
||||||
e.NewItem.View.Value = diagItem;
|
|
||||||
});
|
});
|
||||||
|
view.ViewChanged += OnViewChanged;
|
||||||
}
|
}
|
||||||
if (e.Action is NotifyCollectionChangedAction.Remove)
|
|
||||||
|
private async Task FreeDiagnosticTreeItem(ViewChangedEvent<Diagnostic, TreeItemContainer> e)
|
||||||
{
|
{
|
||||||
await this.InvokeAsync(() =>
|
await this.InvokeAsync(() =>
|
||||||
{
|
{
|
||||||
e.OldItem.View.Value?.Free();
|
e.OldItem.View.Value?.Free();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task CreateDiagnosticTreeItem(Tree tree, TreeItem parent, ViewChangedEvent<Diagnostic, TreeItemContainer> e)
|
||||||
|
{
|
||||||
|
await this.InvokeAsync(() =>
|
||||||
|
{
|
||||||
|
var diagItem = tree.CreateItem(parent);
|
||||||
|
diagItem.SetText(0, e.NewItem.Value.GetMessage());
|
||||||
|
e.NewItem.View.Value = diagItem;
|
||||||
});
|
});
|
||||||
Observable.EveryValueChanged(x, s => s.Diagnostics.Count)
|
|
||||||
.Subscribe(s => treeItem.Visible = s is not 0);
|
|
||||||
return treeItem;
|
|
||||||
});
|
|
||||||
view.ViewChanged += OnViewChanged;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void OnViewChanged(in SynchronizedViewChangedEventArgs<SharpIdeProjectModel, TreeItem> eventArgs)
|
private static void OnViewChanged(in SynchronizedViewChangedEventArgs<SharpIdeProjectModel, TreeItem> eventArgs)
|
||||||
|
|||||||
Reference in New Issue
Block a user