sln explorer panel
This commit is contained in:
@@ -13,6 +13,7 @@ public partial class IdeRoot : Control
|
||||
private Button _openSlnButton = null!;
|
||||
private FileDialog _fileDialog = null!;
|
||||
private SharpIdeCodeEdit _sharpIdeCodeEdit = null!;
|
||||
private SolutionExplorerPanel _solutionExplorerPanel = null!;
|
||||
public override void _Ready()
|
||||
{
|
||||
MSBuildLocator.RegisterDefaults();
|
||||
@@ -20,6 +21,7 @@ public partial class IdeRoot : Control
|
||||
_openSlnButton = GetNode<Button>("%OpenSlnButton");
|
||||
_sharpIdeCodeEdit = GetNode<SharpIdeCodeEdit>("%SharpIdeCodeEdit");
|
||||
_fileDialog = GetNode<FileDialog>("%OpenSolutionDialog");
|
||||
_solutionExplorerPanel = GetNode<SolutionExplorerPanel>("%SolutionExplorerPanel");
|
||||
_fileDialog.FileSelected += OnFileSelected;
|
||||
_openSlnButton.Pressed += () => _fileDialog.Visible = true;
|
||||
//_fileDialog.Visible = true;
|
||||
@@ -32,6 +34,8 @@ public partial class IdeRoot : Control
|
||||
{
|
||||
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");
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
[gd_scene load_steps=4 format=3 uid="uid://b2oniigcp5ew5"]
|
||||
[gd_scene load_steps=5 format=3 uid="uid://b2oniigcp5ew5"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bavypuy7b375x" path="res://IdeRoot.cs" id="1_whawi"]
|
||||
[ext_resource type="Script" uid="uid://du2lt7r1p1qfy" path="res://SharpIdeCodeEdit.cs" id="2_qjf5e"]
|
||||
[ext_resource type="FontFile" uid="uid://7jc0nj310cu6" path="res://CascadiaCode.ttf" id="2_rk34b"]
|
||||
[ext_resource type="Script" uid="uid://bai53k7ongbxw" path="res://SolutionExplorerPanel.cs" id="2_tcy02"]
|
||||
|
||||
[node name="IdeRoot" type="Control"]
|
||||
layout_mode = 3
|
||||
@@ -40,15 +41,30 @@ size_flags_vertical = 3
|
||||
custom_minimum_size = Vector2(50, 0)
|
||||
layout_mode = 2
|
||||
|
||||
[node name="HSplitContainer" type="HSplitContainer" parent="VBoxContainer/HBoxContainer"]
|
||||
[node name="VSplitContainer" type="VSplitContainer" parent="VBoxContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
split_offset = 5000
|
||||
|
||||
[node name="HSplitContainer" type="HSplitContainer" parent="VBoxContainer/HBoxContainer/VSplitContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
split_offset = 250
|
||||
|
||||
[node name="SolutionExplorerPanel" type="Panel" parent="VBoxContainer/HBoxContainer/HSplitContainer"]
|
||||
[node name="SolutionExplorerPanel" type="Panel" parent="VBoxContainer/HBoxContainer/VSplitContainer/HSplitContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
script = ExtResource("2_tcy02")
|
||||
|
||||
[node name="SharpIdeCodeEdit" type="CodeEdit" parent="VBoxContainer/HBoxContainer/HSplitContainer"]
|
||||
[node name="Tree" type="Tree" parent="VBoxContainer/HBoxContainer/VSplitContainer/HSplitContainer/SolutionExplorerPanel"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="SharpIdeCodeEdit" type="CodeEdit" parent="VBoxContainer/HBoxContainer/VSplitContainer/HSplitContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
theme_override_colors/current_line_color = Color(0.0588235, 0.0588235, 0.0588235, 1)
|
||||
@@ -64,11 +80,14 @@ auto_brace_completion_enabled = true
|
||||
auto_brace_completion_highlight_matching = true
|
||||
script = ExtResource("2_qjf5e")
|
||||
|
||||
[node name="CodeFixesMenu" type="PopupMenu" parent="VBoxContainer/HBoxContainer/HSplitContainer/SharpIdeCodeEdit"]
|
||||
[node name="CodeFixesMenu" type="PopupMenu" parent="VBoxContainer/HBoxContainer/VSplitContainer/HSplitContainer/SharpIdeCodeEdit"]
|
||||
item_count = 1
|
||||
item_0/text = "Getting Context Actions..."
|
||||
item_0/id = 0
|
||||
|
||||
[node name="Panel" type="Panel" parent="VBoxContainer/HBoxContainer/VSplitContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="OpenSolutionDialog" type="FileDialog" parent="."]
|
||||
unique_name_in_owner = true
|
||||
title = "Open a File"
|
||||
|
||||
102
src/SharpIDE.Godot/SolutionExplorerPanel.cs
Normal file
102
src/SharpIDE.Godot/SolutionExplorerPanel.cs
Normal file
@@ -0,0 +1,102 @@
|
||||
using Godot;
|
||||
using SharpIDE.Application.Features.SolutionDiscovery;
|
||||
using SharpIDE.Application.Features.SolutionDiscovery.VsPersistence;
|
||||
|
||||
namespace SharpIDE.Godot;
|
||||
|
||||
public partial class SolutionExplorerPanel : Panel
|
||||
{
|
||||
public SharpIdeSolutionModel SolutionModel { get; set; } = null!;
|
||||
private Tree _tree = null!;
|
||||
public override void _Ready()
|
||||
{
|
||||
_tree = GetNode<Tree>("Tree");
|
||||
var item = _tree.CreateItem();
|
||||
item.SetText(0, "Solution Explorer");
|
||||
}
|
||||
|
||||
public void RepopulateTree()
|
||||
{
|
||||
_tree.Clear();
|
||||
|
||||
var rootItem = _tree.CreateItem();
|
||||
rootItem.SetText(0, SolutionModel.Name);
|
||||
|
||||
// Add projects directly under solution
|
||||
foreach (var project in SolutionModel.Projects)
|
||||
{
|
||||
AddProjectToTree(rootItem, project);
|
||||
}
|
||||
|
||||
// Add folders under solution
|
||||
foreach (var folder in SolutionModel.Folders)
|
||||
{
|
||||
AddSlnFolderToTree(rootItem, folder);
|
||||
}
|
||||
}
|
||||
|
||||
private void AddSlnFolderToTree(TreeItem parent, SharpIdeSolutionFolder folder)
|
||||
{
|
||||
var folderItem = _tree.CreateItem(parent);
|
||||
folderItem.SetText(0, folder.Name);
|
||||
|
||||
foreach (var project in folder.Projects)
|
||||
{
|
||||
AddProjectToTree(folderItem, project);
|
||||
}
|
||||
|
||||
foreach (var subFolder in folder.Folders)
|
||||
{
|
||||
AddSlnFolderToTree(folderItem, subFolder); // recursion
|
||||
}
|
||||
|
||||
foreach (var sharpIdeFile in folder.Files)
|
||||
{
|
||||
AddFileToTree(folderItem, sharpIdeFile);
|
||||
}
|
||||
}
|
||||
|
||||
private void AddProjectToTree(TreeItem parent, SharpIdeProjectModel project)
|
||||
{
|
||||
var projectItem = _tree.CreateItem(parent);
|
||||
projectItem.SetText(0, project.Name);
|
||||
|
||||
foreach (var sharpIdeFolder in project.Folders)
|
||||
{
|
||||
AddFoldertoTree(projectItem, sharpIdeFolder);
|
||||
}
|
||||
|
||||
foreach (var file in project.Files)
|
||||
{
|
||||
AddFileToTree(projectItem, file);
|
||||
}
|
||||
}
|
||||
|
||||
private void AddFoldertoTree(TreeItem projectItem, SharpIdeFolder sharpIdeFolder)
|
||||
{
|
||||
var folderItem = _tree.CreateItem(projectItem);
|
||||
folderItem.SetText(0, sharpIdeFolder.Name);
|
||||
|
||||
foreach (var subFolder in sharpIdeFolder.Folders)
|
||||
{
|
||||
AddFoldertoTree(folderItem, subFolder); // recursion
|
||||
}
|
||||
|
||||
foreach (var file in sharpIdeFolder.Files)
|
||||
{
|
||||
AddFileToTree(folderItem, file);
|
||||
}
|
||||
}
|
||||
|
||||
private void AddFileToTree(TreeItem parent, SharpIdeFile file)
|
||||
{
|
||||
var fileItem = _tree.CreateItem(parent);
|
||||
fileItem.SetText(0, file.Name);
|
||||
}
|
||||
|
||||
|
||||
// Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
}
|
||||
}
|
||||
1
src/SharpIDE.Godot/SolutionExplorerPanel.cs.uid
Normal file
1
src/SharpIDE.Godot/SolutionExplorerPanel.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://bai53k7ongbxw
|
||||
Reference in New Issue
Block a user