rename class

This commit is contained in:
Matt Parker
2025-10-17 19:46:08 +10:00
parent 2a80a65738
commit 4652c66269
4 changed files with 24 additions and 6 deletions

View File

@@ -17,6 +17,9 @@ public class GlobalEvents
public FileSystemWatcherInternal FileSystemWatcherInternal { get; } = new(); public FileSystemWatcherInternal FileSystemWatcherInternal { get; } = new();
} }
/// <summary>
/// All file system events for files we have filtered for, e.g. excluding bin/obj folders. Does not filter out events triggered by us
/// </summary>
public class FileSystemWatcherInternal public class FileSystemWatcherInternal
{ {
public EventWrapper<string, Task> DirectoryCreated { get; } = new(_ => Task.CompletedTask); public EventWrapper<string, Task> DirectoryCreated { get; } = new(_ => Task.CompletedTask);

View File

@@ -1,12 +1,14 @@
using SharpIDE.Application.Features.Events; using SharpIDE.Application.Features.Analysis;
using SharpIDE.Application.Features.Evaluation;
using SharpIDE.Application.Features.Events;
using SharpIDE.Application.Features.SolutionDiscovery.VsPersistence; using SharpIDE.Application.Features.SolutionDiscovery.VsPersistence;
namespace SharpIDE.Application.Features.FileWatching; namespace SharpIDE.Application.Features.FileWatching;
public class IdeFileChangeHandler public class IdeFileExternalChangeHandler
{ {
public SharpIdeSolutionModel SolutionModel { get; set; } = null!; public SharpIdeSolutionModel SolutionModel { get; set; } = null!;
public IdeFileChangeHandler() public IdeFileExternalChangeHandler()
{ {
GlobalEvents.Instance.FileSystemWatcherInternal.FileChanged.Subscribe(OnFileChanged); GlobalEvents.Instance.FileSystemWatcherInternal.FileChanged.Subscribe(OnFileChanged);
} }
@@ -27,5 +29,18 @@ public class IdeFileChangeHandler
} }
Console.WriteLine($"IdeFileChangeHandler: Changed - {filePath}"); Console.WriteLine($"IdeFileChangeHandler: Changed - {filePath}");
await sharpIdeFile.FileContentsChangedExternallyFromDisk.InvokeParallelAsync(); await sharpIdeFile.FileContentsChangedExternallyFromDisk.InvokeParallelAsync();
if (sharpIdeFile.IsCsprojFile)
{
await HandleCsprojChanged(filePath);
}
}
private async Task HandleCsprojChanged(string filePath)
{
var project = SolutionModel.AllProjects.SingleOrDefault(p => p.FilePath == filePath);
if (project is null) return;
await ProjectEvaluation.ReloadProject(filePath);
await RoslynAnalysis.ReloadProject(project);
await RoslynAnalysis.UpdateSolutionDiagnostics();
} }
} }

View File

@@ -50,7 +50,7 @@ public partial class IdeRoot : Control
Singletons.FileWatcher?.Dispose(); Singletons.FileWatcher?.Dispose();
Singletons.FileWatcher = new IdeFileWatcher(); Singletons.FileWatcher = new IdeFileWatcher();
Singletons.FileManager = new IdeFileManager(); Singletons.FileManager = new IdeFileManager();
Singletons.FileChangeHandler = new IdeFileChangeHandler(); Singletons.FileExternalChangeHandler = new IdeFileExternalChangeHandler();
} }
public override void _Ready() public override void _Ready()
@@ -127,7 +127,7 @@ public partial class IdeRoot : Control
_bottomPanelManager.Solution = solutionModel; _bottomPanelManager.Solution = solutionModel;
_searchWindow.Solution = solutionModel; _searchWindow.Solution = solutionModel;
_searchAllFilesWindow.Solution = solutionModel; _searchAllFilesWindow.Solution = solutionModel;
Singletons.FileChangeHandler.SolutionModel = solutionModel; Singletons.FileExternalChangeHandler.SolutionModel = solutionModel;
Callable.From(_solutionExplorerPanel.RepopulateTree).CallDeferred(); Callable.From(_solutionExplorerPanel.RepopulateTree).CallDeferred();
RoslynAnalysis.StartSolutionAnalysis(solutionModel); RoslynAnalysis.StartSolutionAnalysis(solutionModel);
Singletons.FileWatcher.StartWatching(solutionModel); Singletons.FileWatcher.StartWatching(solutionModel);

View File

@@ -12,6 +12,6 @@ public static class Singletons
public static BuildService BuildService { get; set; } = null!; public static BuildService BuildService { get; set; } = null!;
public static IdeFileWatcher FileWatcher { get; set; } = null!; public static IdeFileWatcher FileWatcher { get; set; } = null!;
public static IdeFileManager FileManager { get; set; } = null!; public static IdeFileManager FileManager { get; set; } = null!;
public static IdeFileChangeHandler FileChangeHandler { get; set; } = null!; public static IdeFileExternalChangeHandler FileExternalChangeHandler { get; set; } = null!;
public static AppState AppState { get; set; } = null!; public static AppState AppState { get; set; } = null!;
} }