run panel and run menu v1

This commit is contained in:
Matt Parker
2025-08-25 18:15:11 +10:00
parent 01844228ef
commit 26ac3e5724
11 changed files with 223 additions and 26 deletions

View File

@@ -1,11 +1,11 @@
using System;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Godot;
using Microsoft.Build.Locator;
using SharpIDE.Application.Features.Analysis;
using SharpIDE.Application.Features.Debugging;
using SharpIDE.Application.Features.SolutionDiscovery.VsPersistence;
using SharpIDE.Godot.Features.Run;
namespace SharpIDE.Godot;
@@ -15,39 +15,62 @@ public partial class IdeRoot : Control
private FileDialog _fileDialog = null!;
private SharpIdeCodeEdit _sharpIdeCodeEdit = null!;
private SolutionExplorerPanel _solutionExplorerPanel = null!;
private RunPanel _runPanel = null!;
private MenuButton _runMenuButton = null!;
public override void _Ready()
{
MSBuildLocator.RegisterDefaults();
_openSlnButton = GetNode<Button>("%OpenSlnButton");
_runMenuButton = GetNode<MenuButton>("%RunMenuButton");
var popup = _runMenuButton.GetPopup();
popup.HideOnItemSelection = false;
_sharpIdeCodeEdit = GetNode<SharpIdeCodeEdit>("%SharpIdeCodeEdit");
_fileDialog = GetNode<FileDialog>("%OpenSolutionDialog");
_solutionExplorerPanel = GetNode<SolutionExplorerPanel>("%SolutionExplorerPanel");
_fileDialog.FileSelected += OnFileSelected;
_runPanel = GetNode<RunPanel>("%RunPanel");
_openSlnButton.Pressed += () => _fileDialog.Visible = true;
//_fileDialog.Visible = true;
var test = new DebuggingService();
_ = test.Test();
OnFileSelected(@"C:\Users\Matthew\Documents\Git\BlazorCodeBreaker\BlazorCodeBreaker.slnx");
}
private async void OnFileSelected(string path)
private void OnFileSelected(string path)
{
try
_ = Task.Run(async () =>
{
GD.Print($"Selected: {path}");
var solutionModel = await VsPersistenceMapper.GetSolutionModel(path);
_solutionExplorerPanel.SolutionModel = solutionModel;
_solutionExplorerPanel.RepopulateTree();
RoslynAnalysis.StartSolutionAnalysis(path);
var infraProject = solutionModel.AllProjects.Single(s => s.Name == "Infrastructure");
var diFile = infraProject.Files.Single(s => s.Name == "DependencyInjection.cs");
await _sharpIdeCodeEdit.SetSharpIdeFile(diFile);
}
catch (Exception e)
{
GD.PrintErr($"Error loading solution: {e.Message}");
GD.PrintErr(e.StackTrace);
}
try
{
GD.Print($"Selected: {path}");
var solutionModel = await VsPersistenceMapper.GetSolutionModel(path);
_solutionExplorerPanel.SolutionModel = solutionModel;
Callable.From(_solutionExplorerPanel.RepopulateTree).CallDeferred();
RoslynAnalysis.StartSolutionAnalysis(path);
var infraProject = solutionModel.AllProjects.Single(s => s.Name == "Infrastructure");
var diFile = infraProject.Files.Single(s => s.Name == "DependencyInjection.cs");
await this.InvokeAsync(async () => await _sharpIdeCodeEdit.SetSharpIdeFile(diFile));
var tasks = solutionModel.AllProjects.Select(p => p.MsBuildEvaluationProjectTask).ToList();
await Task.WhenAll(tasks).ConfigureAwait(false);
var runnableProjects = solutionModel.AllProjects.Where(p => p.IsRunnable).ToList();
await this.InvokeAsync(() =>
{
var popup = _runMenuButton.GetPopup();
foreach (var project in runnableProjects)
{
popup.AddItem(project.Name);
}
_runMenuButton.Disabled = false;
});
//var runnableProject = solutionModel.AllProjects.First(s => s.IsRunnable);
//await this.InvokeAsync(() => _runPanel.NewRunStarted(runnableProject));
}
catch (Exception e)
{
GD.PrintErr($"Error loading solution: {e.Message}");
GD.PrintErr(e.StackTrace);
}
});
}
}