Refactor
This commit is contained in:
@@ -12,16 +12,6 @@ namespace SharpIDE.Godot.Features.BottomPanel;
|
|||||||
|
|
||||||
public partial class BottomPanelManager : Panel
|
public partial class BottomPanelManager : Panel
|
||||||
{
|
{
|
||||||
public SharpIdeSolutionModel? Solution
|
|
||||||
{
|
|
||||||
get;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
field = value;
|
|
||||||
_problemsPanel.Solution = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private RunPanel _runPanel = null!;
|
private RunPanel _runPanel = null!;
|
||||||
private DebugPanel _debugPanel = null!;
|
private DebugPanel _debugPanel = null!;
|
||||||
private BuildPanel _buildPanel = null!;
|
private BuildPanel _buildPanel = null!;
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ using Microsoft.CodeAnalysis;
|
|||||||
using ObservableCollections;
|
using ObservableCollections;
|
||||||
using R3;
|
using R3;
|
||||||
using SharpIDE.Application.Features.Analysis;
|
using SharpIDE.Application.Features.Analysis;
|
||||||
using SharpIDE.Application.Features.SolutionDiscovery;
|
|
||||||
using SharpIDE.Application.Features.SolutionDiscovery.VsPersistence;
|
using SharpIDE.Application.Features.SolutionDiscovery.VsPersistence;
|
||||||
using SharpIDE.Godot.Features.Common;
|
using SharpIDE.Godot.Features.Common;
|
||||||
|
|
||||||
@@ -18,8 +17,10 @@ public partial class ProblemsPanel : Control
|
|||||||
public Texture2D ErrorIcon { get; set; } = null!;
|
public Texture2D ErrorIcon { get; set; } = null!;
|
||||||
[Export]
|
[Export]
|
||||||
public Texture2D CsprojIcon { get; set; } = null!;
|
public Texture2D CsprojIcon { get; set; } = null!;
|
||||||
|
|
||||||
|
private SharpIdeSolutionModel? _solution;
|
||||||
|
|
||||||
public SharpIdeSolutionModel? Solution { get; set; }
|
[Inject] private readonly SharpIdeSolutionAccessor _sharpIdeSolutionAccessor = null!;
|
||||||
|
|
||||||
private Tree _tree = null!;
|
private Tree _tree = null!;
|
||||||
private TreeItem _rootItem = null!;
|
private TreeItem _rootItem = null!;
|
||||||
@@ -33,16 +34,16 @@ public partial class ProblemsPanel : Control
|
|||||||
_tree.ItemActivated += TreeOnItemActivated;
|
_tree.ItemActivated += TreeOnItemActivated;
|
||||||
_rootItem = _tree.CreateItem();
|
_rootItem = _tree.CreateItem();
|
||||||
_rootItem.SetText(0, "Problems");
|
_rootItem.SetText(0, "Problems");
|
||||||
Observable.EveryValueChanged(this, manager => manager.Solution)
|
|
||||||
.Where(s => s is not null)
|
|
||||||
.Subscribe(s =>
|
|
||||||
{
|
|
||||||
_projects.RemoveRange(_projects);
|
|
||||||
_projects.AddRange(s!.AllProjects);
|
|
||||||
}).AddTo(this);
|
|
||||||
BindToTree(_projects);
|
BindToTree(_projects);
|
||||||
|
_ = Task.GodotRun(AsyncReady);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task AsyncReady()
|
||||||
|
{
|
||||||
|
await _sharpIdeSolutionAccessor.SolutionReadyTcs.Task;
|
||||||
|
_solution = _sharpIdeSolutionAccessor.SolutionModel;
|
||||||
|
_projects.AddRange(_solution!.AllProjects);
|
||||||
|
}
|
||||||
|
|
||||||
public void BindToTree(ObservableHashSet<SharpIdeProjectModel> list)
|
public void BindToTree(ObservableHashSet<SharpIdeProjectModel> list)
|
||||||
{
|
{
|
||||||
@@ -195,14 +196,13 @@ public partial class ProblemsPanel : Control
|
|||||||
var parentTreeItem = selected.GetParent();
|
var parentTreeItem = selected.GetParent();
|
||||||
var projectContainer = parentTreeItem.GetMetadata(0).As<RefCountedContainer<SharpIdeProjectModel>?>();
|
var projectContainer = parentTreeItem.GetMetadata(0).As<RefCountedContainer<SharpIdeProjectModel>?>();
|
||||||
if (projectContainer is null) return;
|
if (projectContainer is null) return;
|
||||||
OpenDocumentContainingDiagnostic(diagnostic.Diagnostic);
|
OpenDocumentContainingDiagnostic(diagnostic);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OpenDocumentContainingDiagnostic(Diagnostic diagnostic)
|
private void OpenDocumentContainingDiagnostic(SharpIdeDiagnostic diagnostic)
|
||||||
{
|
{
|
||||||
var fileLinePositionSpan = diagnostic.Location.GetMappedLineSpan();
|
var file = _solution!.AllFiles[diagnostic.FilePath];
|
||||||
var file = Solution!.AllFiles[fileLinePositionSpan.Path];
|
var linePosition = new SharpIdeFileLinePosition(diagnostic.Span.Start.Line, diagnostic.Span.Start.Character);
|
||||||
var linePosition = new SharpIdeFileLinePosition(fileLinePositionSpan.StartLinePosition.Line, fileLinePositionSpan.StartLinePosition.Character);
|
|
||||||
GodotGlobalEvents.Instance.FileExternallySelected.InvokeParallelFireAndForget(file, linePosition);
|
GodotGlobalEvents.Instance.FileExternallySelected.InvokeParallelFireAndForget(file, linePosition);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -152,7 +152,6 @@ public partial class IdeRoot : Control
|
|||||||
_sharpIdeSolutionAccessor.SolutionReadyTcs.SetResult();
|
_sharpIdeSolutionAccessor.SolutionReadyTcs.SetResult();
|
||||||
_solutionExplorerPanel.SolutionModel = solutionModel;
|
_solutionExplorerPanel.SolutionModel = solutionModel;
|
||||||
_codeEditorPanel.Solution = solutionModel;
|
_codeEditorPanel.Solution = solutionModel;
|
||||||
_bottomPanelManager.Solution = solutionModel;
|
|
||||||
_searchWindow.Solution = solutionModel;
|
_searchWindow.Solution = solutionModel;
|
||||||
_searchAllFilesWindow.Solution = solutionModel;
|
_searchAllFilesWindow.Solution = solutionModel;
|
||||||
_fileExternalChangeHandler.SolutionModel = solutionModel;
|
_fileExternalChangeHandler.SolutionModel = solutionModel;
|
||||||
|
|||||||
Reference in New Issue
Block a user