change file to execution stop point
This commit is contained in:
@@ -10,10 +10,11 @@ public class SharpIdeFile : ISharpIdeNode, IChildSharpIdeNode
|
|||||||
public required string Name { get; set; }
|
public required string Name { get; set; }
|
||||||
|
|
||||||
[SetsRequiredMembers]
|
[SetsRequiredMembers]
|
||||||
internal SharpIdeFile(string fullPath, string name, IExpandableSharpIdeNode parent)
|
internal SharpIdeFile(string fullPath, string name, IExpandableSharpIdeNode parent, HashSet<SharpIdeFile> allFiles)
|
||||||
{
|
{
|
||||||
Path = fullPath;
|
Path = fullPath;
|
||||||
Name = name;
|
Name = name;
|
||||||
Parent = parent;
|
Parent = parent;
|
||||||
|
allFiles.Add(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,13 +13,13 @@ public class SharpIdeFolder : ISharpIdeNode, IExpandableSharpIdeNode, IChildShar
|
|||||||
public bool Expanded { get; set; }
|
public bool Expanded { get; set; }
|
||||||
|
|
||||||
[SetsRequiredMembers]
|
[SetsRequiredMembers]
|
||||||
public SharpIdeFolder(DirectoryInfo folderInfo, IExpandableSharpIdeNode parent)
|
public SharpIdeFolder(DirectoryInfo folderInfo, IExpandableSharpIdeNode parent, HashSet<SharpIdeFile> allFiles)
|
||||||
{
|
{
|
||||||
Parent = parent;
|
Parent = parent;
|
||||||
Path = folderInfo.FullName;
|
Path = folderInfo.FullName;
|
||||||
Name = folderInfo.Name;
|
Name = folderInfo.Name;
|
||||||
Files = folderInfo.GetFiles(this);
|
Files = folderInfo.GetFiles(this, allFiles);
|
||||||
Folders = this.GetSubFolders(this);
|
Folders = this.GetSubFolders(this, allFiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SharpIdeFolder()
|
public SharpIdeFolder()
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ public static class TreeMapperV2
|
|||||||
return folder.Files
|
return folder.Files
|
||||||
.Concat(folder.Folders.SelectMany(sub => sub.GetAllFiles()));
|
.Concat(folder.Folders.SelectMany(sub => sub.GetAllFiles()));
|
||||||
}
|
}
|
||||||
public static List<SharpIdeFolder> GetSubFolders(string csprojectPath, SharpIdeProjectModel sharpIdeProjectModel)
|
public static List<SharpIdeFolder> GetSubFolders(string csprojectPath, SharpIdeProjectModel sharpIdeProjectModel, HashSet<SharpIdeFile> allFiles)
|
||||||
{
|
{
|
||||||
var projectDirectory = Path.GetDirectoryName(csprojectPath)!;
|
var projectDirectory = Path.GetDirectoryName(csprojectPath)!;
|
||||||
var rootFolder = new SharpIdeFolder
|
var rootFolder = new SharpIdeFolder
|
||||||
@@ -21,12 +21,12 @@ public static class TreeMapperV2
|
|||||||
Files = [],
|
Files = [],
|
||||||
Folders = []
|
Folders = []
|
||||||
};
|
};
|
||||||
var subFolders = rootFolder.GetSubFolders(sharpIdeProjectModel);
|
var subFolders = rootFolder.GetSubFolders(sharpIdeProjectModel, allFiles);
|
||||||
return subFolders;
|
return subFolders;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static readonly string[] _excludedFolders = ["bin", "obj", "node_modules"];
|
private static readonly string[] _excludedFolders = ["bin", "obj", "node_modules"];
|
||||||
public static List<SharpIdeFolder> GetSubFolders(this SharpIdeFolder folder, IExpandableSharpIdeNode parent)
|
public static List<SharpIdeFolder> GetSubFolders(this SharpIdeFolder folder, IExpandableSharpIdeNode parent, HashSet<SharpIdeFile> allFiles)
|
||||||
{
|
{
|
||||||
var directoryInfo = new DirectoryInfo(folder.Path);
|
var directoryInfo = new DirectoryInfo(folder.Path);
|
||||||
ConcurrentBag<SharpIdeFolder> subFolders = [];
|
ConcurrentBag<SharpIdeFolder> subFolders = [];
|
||||||
@@ -47,20 +47,20 @@ public static class TreeMapperV2
|
|||||||
|
|
||||||
Parallel.ForEach(subFolderInfos, subFolderInfo =>
|
Parallel.ForEach(subFolderInfos, subFolderInfo =>
|
||||||
{
|
{
|
||||||
var subFolder = new SharpIdeFolder(subFolderInfo, parent);
|
var subFolder = new SharpIdeFolder(subFolderInfo, parent, allFiles);
|
||||||
subFolders.Add(subFolder);
|
subFolders.Add(subFolder);
|
||||||
});
|
});
|
||||||
|
|
||||||
return subFolders.ToList();
|
return subFolders.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<SharpIdeFile> GetFiles(string csprojectPath, SharpIdeProjectModel sharpIdeProjectModel)
|
public static List<SharpIdeFile> GetFiles(string csprojectPath, SharpIdeProjectModel sharpIdeProjectModel, HashSet<SharpIdeFile> allFiles)
|
||||||
{
|
{
|
||||||
var projectDirectory = Path.GetDirectoryName(csprojectPath)!;
|
var projectDirectory = Path.GetDirectoryName(csprojectPath)!;
|
||||||
var directoryInfo = new DirectoryInfo(projectDirectory);
|
var directoryInfo = new DirectoryInfo(projectDirectory);
|
||||||
return GetFiles(directoryInfo, sharpIdeProjectModel);
|
return GetFiles(directoryInfo, sharpIdeProjectModel, allFiles);
|
||||||
}
|
}
|
||||||
public static List<SharpIdeFile> GetFiles(this DirectoryInfo directoryInfo, IExpandableSharpIdeNode parent)
|
public static List<SharpIdeFile> GetFiles(this DirectoryInfo directoryInfo, IExpandableSharpIdeNode parent, HashSet<SharpIdeFile> allFiles)
|
||||||
{
|
{
|
||||||
List<FileInfo> fileInfos;
|
List<FileInfo> fileInfos;
|
||||||
try
|
try
|
||||||
@@ -72,7 +72,7 @@ public static class TreeMapperV2
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
return fileInfos.Select(f => new SharpIdeFile(f.FullName, f.Name, parent)
|
return fileInfos.Select(f => new SharpIdeFile(f.FullName, f.Name, parent, allFiles)
|
||||||
{
|
{
|
||||||
Path = f.FullName,
|
Path = f.FullName,
|
||||||
Name = f.Name,
|
Name = f.Name,
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ public class SharpIdeSolutionModel : ISharpIdeNode, IExpandableSharpIdeNode
|
|||||||
public required List<SharpIdeProjectModel> Projects { get; set; }
|
public required List<SharpIdeProjectModel> Projects { get; set; }
|
||||||
public required List<SharpIdeSolutionFolder> Folders { get; set; }
|
public required List<SharpIdeSolutionFolder> Folders { get; set; }
|
||||||
public required HashSet<SharpIdeProjectModel> AllProjects { get; set; }
|
public required HashSet<SharpIdeProjectModel> AllProjects { get; set; }
|
||||||
|
public required HashSet<SharpIdeFile> AllFiles { get; set; }
|
||||||
public bool Expanded { get; set; }
|
public bool Expanded { get; set; }
|
||||||
|
|
||||||
[SetsRequiredMembers]
|
[SetsRequiredMembers]
|
||||||
@@ -41,10 +42,11 @@ public class SharpIdeSolutionModel : ISharpIdeNode, IExpandableSharpIdeNode
|
|||||||
{
|
{
|
||||||
var solutionName = Path.GetFileName(solutionFilePath);
|
var solutionName = Path.GetFileName(solutionFilePath);
|
||||||
AllProjects = [];
|
AllProjects = [];
|
||||||
|
AllFiles = [];
|
||||||
Name = solutionName;
|
Name = solutionName;
|
||||||
FilePath = solutionFilePath;
|
FilePath = solutionFilePath;
|
||||||
Projects = intermediateModel.Projects.Select(s => new SharpIdeProjectModel(s, AllProjects, this)).ToList();
|
Projects = intermediateModel.Projects.Select(s => new SharpIdeProjectModel(s, AllProjects, AllFiles, this)).ToList();
|
||||||
Folders = intermediateModel.SolutionFolders.Select(s => new SharpIdeSolutionFolder(s, AllProjects, this)).ToList();
|
Folders = intermediateModel.SolutionFolders.Select(s => new SharpIdeSolutionFolder(s, AllProjects, AllFiles, this)).ToList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public class SharpIdeSolutionFolder : ISharpIdeNode, IExpandableSharpIdeNode, IChildSharpIdeNode
|
public class SharpIdeSolutionFolder : ISharpIdeNode, IExpandableSharpIdeNode, IChildSharpIdeNode
|
||||||
@@ -57,13 +59,13 @@ public class SharpIdeSolutionFolder : ISharpIdeNode, IExpandableSharpIdeNode, IC
|
|||||||
public required IExpandableSharpIdeNode Parent { get; set; }
|
public required IExpandableSharpIdeNode Parent { get; set; }
|
||||||
|
|
||||||
[SetsRequiredMembers]
|
[SetsRequiredMembers]
|
||||||
internal SharpIdeSolutionFolder(IntermediateSlnFolderModel intermediateModel, HashSet<SharpIdeProjectModel> allProjects, IExpandableSharpIdeNode parent)
|
internal SharpIdeSolutionFolder(IntermediateSlnFolderModel intermediateModel, HashSet<SharpIdeProjectModel> allProjects, HashSet<SharpIdeFile> allFiles, IExpandableSharpIdeNode parent)
|
||||||
{
|
{
|
||||||
Name = intermediateModel.Model.Name;
|
Name = intermediateModel.Model.Name;
|
||||||
Parent = parent;
|
Parent = parent;
|
||||||
Files = intermediateModel.Files.Select(s => new SharpIdeFile(s.FullPath, s.Name, this)).ToList();
|
Files = intermediateModel.Files.Select(s => new SharpIdeFile(s.FullPath, s.Name, this, allFiles)).ToList();
|
||||||
Folders = intermediateModel.Folders.Select(x => new SharpIdeSolutionFolder(x, allProjects, this)).ToList();
|
Folders = intermediateModel.Folders.Select(x => new SharpIdeSolutionFolder(x, allProjects, allFiles, this)).ToList();
|
||||||
Projects = intermediateModel.Projects.Select(x => new SharpIdeProjectModel(x, allProjects, this)).ToList();
|
Projects = intermediateModel.Projects.Select(x => new SharpIdeProjectModel(x, allProjects, allFiles, this)).ToList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public class SharpIdeProjectModel : ISharpIdeNode, IExpandableSharpIdeNode, IChildSharpIdeNode
|
public class SharpIdeProjectModel : ISharpIdeNode, IExpandableSharpIdeNode, IChildSharpIdeNode
|
||||||
@@ -79,13 +81,13 @@ public class SharpIdeProjectModel : ISharpIdeNode, IExpandableSharpIdeNode, IChi
|
|||||||
public required Task<Project> MsBuildEvaluationProjectTask { get; set; }
|
public required Task<Project> MsBuildEvaluationProjectTask { get; set; }
|
||||||
|
|
||||||
[SetsRequiredMembers]
|
[SetsRequiredMembers]
|
||||||
internal SharpIdeProjectModel(IntermediateProjectModel projectModel, HashSet<SharpIdeProjectModel> allProjects, IExpandableSharpIdeNode parent)
|
internal SharpIdeProjectModel(IntermediateProjectModel projectModel, HashSet<SharpIdeProjectModel> allProjects, HashSet<SharpIdeFile> allFiles, IExpandableSharpIdeNode parent)
|
||||||
{
|
{
|
||||||
Parent = parent;
|
Parent = parent;
|
||||||
Name = projectModel.Model.ActualDisplayName;
|
Name = projectModel.Model.ActualDisplayName;
|
||||||
FilePath = projectModel.FullFilePath;
|
FilePath = projectModel.FullFilePath;
|
||||||
Files = TreeMapperV2.GetFiles(projectModel.FullFilePath, this);
|
Files = TreeMapperV2.GetFiles(projectModel.FullFilePath, this, allFiles);
|
||||||
Folders = TreeMapperV2.GetSubFolders(projectModel.FullFilePath, this);
|
Folders = TreeMapperV2.GetSubFolders(projectModel.FullFilePath, this, allFiles);
|
||||||
MsBuildEvaluationProjectTask = ProjectEvaluation.GetProject(projectModel.FullFilePath);
|
MsBuildEvaluationProjectTask = ProjectEvaluation.GetProject(projectModel.FullFilePath);
|
||||||
allProjects.Add(this);
|
allProjects.Add(this);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -107,6 +107,7 @@ public partial class SolutionExplorerPanel : Panel
|
|||||||
var fileItem = _tree.CreateItem(parent);
|
var fileItem = _tree.CreateItem(parent);
|
||||||
fileItem.SetText(0, file.Name);
|
fileItem.SetText(0, file.Name);
|
||||||
var container = new SharpIdeFileGodotContainer { File = file };
|
var container = new SharpIdeFileGodotContainer { File = file };
|
||||||
|
// TODO: Handle ObjectDB instances leaked at exit
|
||||||
fileItem.SetMetadata(0, container);
|
fileItem.SetMetadata(0, container);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ public partial class IdeRoot : Control
|
|||||||
GD.Print($"Selected: {path}");
|
GD.Print($"Selected: {path}");
|
||||||
var solutionModel = await VsPersistenceMapper.GetSolutionModel(path);
|
var solutionModel = await VsPersistenceMapper.GetSolutionModel(path);
|
||||||
_solutionExplorerPanel.SolutionModel = solutionModel;
|
_solutionExplorerPanel.SolutionModel = solutionModel;
|
||||||
|
_sharpIdeCodeEdit.Solution = solutionModel;
|
||||||
Callable.From(_solutionExplorerPanel.RepopulateTree).CallDeferred();
|
Callable.From(_solutionExplorerPanel.RepopulateTree).CallDeferred();
|
||||||
RoslynAnalysis.StartSolutionAnalysis(path);
|
RoslynAnalysis.StartSolutionAnalysis(path);
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ using SharpIDE.Application.Features.Analysis;
|
|||||||
using SharpIDE.Application.Features.Debugging;
|
using SharpIDE.Application.Features.Debugging;
|
||||||
using SharpIDE.Application.Features.Events;
|
using SharpIDE.Application.Features.Events;
|
||||||
using SharpIDE.Application.Features.SolutionDiscovery;
|
using SharpIDE.Application.Features.SolutionDiscovery;
|
||||||
|
using SharpIDE.Application.Features.SolutionDiscovery.VsPersistence;
|
||||||
using SharpIDE.Godot.Features.Run;
|
using SharpIDE.Godot.Features.Run;
|
||||||
using Task = System.Threading.Tasks.Task;
|
using Task = System.Threading.Tasks.Task;
|
||||||
|
|
||||||
@@ -28,6 +29,7 @@ public partial class SharpIdeCodeEdit : CodeEdit
|
|||||||
private int _selectionStartCol;
|
private int _selectionStartCol;
|
||||||
private int _selectionEndCol;
|
private int _selectionEndCol;
|
||||||
|
|
||||||
|
public SharpIdeSolutionModel? Solution { get; set; }
|
||||||
private SharpIdeFile _currentFile = null!;
|
private SharpIdeFile _currentFile = null!;
|
||||||
|
|
||||||
private CustomHighlighter _syntaxHighlighter = new();
|
private CustomHighlighter _syntaxHighlighter = new();
|
||||||
@@ -36,6 +38,7 @@ public partial class SharpIdeCodeEdit : CodeEdit
|
|||||||
private ImmutableArray<(FileLinePositionSpan fileSpan, Diagnostic diagnostic)> _diagnostics = [];
|
private ImmutableArray<(FileLinePositionSpan fileSpan, Diagnostic diagnostic)> _diagnostics = [];
|
||||||
private ImmutableArray<CodeAction> _currentCodeActionsInPopup = [];
|
private ImmutableArray<CodeAction> _currentCodeActionsInPopup = [];
|
||||||
private ExecutionStopInfo? _executionStopInfo;
|
private ExecutionStopInfo? _executionStopInfo;
|
||||||
|
private bool _fileChangingSuppressBreakpointToggleEvent;
|
||||||
|
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
@@ -55,7 +58,12 @@ public partial class SharpIdeCodeEdit : CodeEdit
|
|||||||
|
|
||||||
private async Task OnDebuggerExecutionStopped(ExecutionStopInfo executionStopInfo)
|
private async Task OnDebuggerExecutionStopped(ExecutionStopInfo executionStopInfo)
|
||||||
{
|
{
|
||||||
if (executionStopInfo.FilePath != _currentFile.Path) return; // TODO: handle file switching
|
Guard.Against.Null(Solution, nameof(Solution));
|
||||||
|
if (executionStopInfo.FilePath != _currentFile.Path)
|
||||||
|
{
|
||||||
|
var file = Solution.AllFiles.Single(s => s.Path == executionStopInfo.FilePath);
|
||||||
|
await this.InvokeAsync(async () => await SetSharpIdeFile(file));
|
||||||
|
}
|
||||||
var lineInt = executionStopInfo.Line - 1; // Debugging is 1-indexed, Godot is 0-indexed
|
var lineInt = executionStopInfo.Line - 1; // Debugging is 1-indexed, Godot is 0-indexed
|
||||||
Guard.Against.Negative(lineInt, nameof(lineInt));
|
Guard.Against.Negative(lineInt, nameof(lineInt));
|
||||||
_executionStopInfo = executionStopInfo;
|
_executionStopInfo = executionStopInfo;
|
||||||
@@ -69,6 +77,7 @@ public partial class SharpIdeCodeEdit : CodeEdit
|
|||||||
|
|
||||||
private void OnBreakpointToggled(long line)
|
private void OnBreakpointToggled(long line)
|
||||||
{
|
{
|
||||||
|
if (_fileChangingSuppressBreakpointToggleEvent) return;
|
||||||
var lineInt = (int)line;
|
var lineInt = (int)line;
|
||||||
var breakpointAdded = IsLineBreakpointed(lineInt);
|
var breakpointAdded = IsLineBreakpointed(lineInt);
|
||||||
var lineForDebugger = lineInt + 1; // Godot is 0-indexed, Debugging is 1-indexed
|
var lineForDebugger = lineInt + 1; // Godot is 0-indexed, Debugging is 1-indexed
|
||||||
@@ -157,7 +166,9 @@ public partial class SharpIdeCodeEdit : CodeEdit
|
|||||||
{
|
{
|
||||||
_currentFile = file;
|
_currentFile = file;
|
||||||
var fileContents = await File.ReadAllTextAsync(_currentFile.Path);
|
var fileContents = await File.ReadAllTextAsync(_currentFile.Path);
|
||||||
|
_fileChangingSuppressBreakpointToggleEvent = true;
|
||||||
SetText(fileContents);
|
SetText(fileContents);
|
||||||
|
_fileChangingSuppressBreakpointToggleEvent = false;
|
||||||
var syntaxHighlighting = await RoslynAnalysis.GetDocumentSyntaxHighlighting(_currentFile);
|
var syntaxHighlighting = await RoslynAnalysis.GetDocumentSyntaxHighlighting(_currentFile);
|
||||||
SetSyntaxHighlightingModel(syntaxHighlighting);
|
SetSyntaxHighlightingModel(syntaxHighlighting);
|
||||||
var diagnostics = await RoslynAnalysis.GetDocumentDiagnostics(_currentFile);
|
var diagnostics = await RoslynAnalysis.GetDocumentDiagnostics(_currentFile);
|
||||||
|
|||||||
Reference in New Issue
Block a user