diff options
| author | Rémi Verschelde <rverschelde@gmail.com> | 2023-08-04 16:59:23 +0200 |
|---|---|---|
| committer | Rémi Verschelde <rverschelde@gmail.com> | 2023-08-04 16:59:23 +0200 |
| commit | c236503b759d9ace36706207aaf0e3196caf5239 (patch) | |
| tree | 0ad51f054c210c85f35db5b13fb5984c681f9622 /modules | |
| parent | e605a1d9848d2cfa1b192cac0812b394d824c412 (diff) | |
| parent | 7f8e3ab5cd694be6fefb46280544f9dd0b083a38 (diff) | |
| download | redot-engine-c236503b759d9ace36706207aaf0e3196caf5239.tar.gz | |
Merge pull request #79958 from van800/master-rider-path-locator-fleet
Delegate opening files for Rider to the RiderPathLocator NuGet package
Diffstat (limited to 'modules')
4 files changed, 25 insertions, 44 deletions
diff --git a/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs b/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs index cdf0a344d4..618d255938 100644 --- a/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs +++ b/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs @@ -280,7 +280,7 @@ namespace GodotTools case ExternalEditorId.Rider: { string scriptPath = ProjectSettings.GlobalizePath(script.ResourcePath); - RiderPathManager.OpenFile(GodotSharpDirs.ProjectSlnPath, scriptPath, line); + RiderPathManager.OpenFile(GodotSharpDirs.ProjectSlnPath, scriptPath, line + 1, col); return Error.Ok; } case ExternalEditorId.MonoDevelop: @@ -540,7 +540,7 @@ namespace GodotTools settingsHintStr += $",Visual Studio:{(int)ExternalEditorId.VisualStudio}" + $",MonoDevelop:{(int)ExternalEditorId.MonoDevelop}" + $",Visual Studio Code:{(int)ExternalEditorId.VsCode}" + - $",JetBrains Rider:{(int)ExternalEditorId.Rider}" + + $",JetBrains Rider and Fleet:{(int)ExternalEditorId.Rider}" + $",Custom:{(int)ExternalEditorId.CustomEditor}"; } else if (OS.IsMacOS) @@ -548,14 +548,14 @@ namespace GodotTools settingsHintStr += $",Visual Studio:{(int)ExternalEditorId.VisualStudioForMac}" + $",MonoDevelop:{(int)ExternalEditorId.MonoDevelop}" + $",Visual Studio Code:{(int)ExternalEditorId.VsCode}" + - $",JetBrains Rider:{(int)ExternalEditorId.Rider}" + + $",JetBrains Rider and Fleet:{(int)ExternalEditorId.Rider}" + $",Custom:{(int)ExternalEditorId.CustomEditor}"; } else if (OS.IsUnixLike) { settingsHintStr += $",MonoDevelop:{(int)ExternalEditorId.MonoDevelop}" + $",Visual Studio Code:{(int)ExternalEditorId.VsCode}" + - $",JetBrains Rider:{(int)ExternalEditorId.Rider}" + + $",JetBrains Rider and Fleet:{(int)ExternalEditorId.Rider}" + $",Custom:{(int)ExternalEditorId.CustomEditor}"; } diff --git a/modules/mono/editor/GodotTools/GodotTools/GodotTools.csproj b/modules/mono/editor/GodotTools/GodotTools/GodotTools.csproj index 4a0b7f9bed..56ae37b4dd 100644 --- a/modules/mono/editor/GodotTools/GodotTools/GodotTools.csproj +++ b/modules/mono/editor/GodotTools/GodotTools/GodotTools.csproj @@ -28,7 +28,7 @@ </PropertyGroup> <ItemGroup> <PackageReference Include="JetBrains.Annotations" Version="2019.1.3.0" ExcludeAssets="runtime" PrivateAssets="all" /> - <PackageReference Include="JetBrains.Rider.PathLocator" Version="1.0.1" /> + <PackageReference Include="JetBrains.Rider.PathLocator" Version="1.0.4" /> <PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" PrivateAssets="All" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.1" /> <Reference Include="GodotSharp"> diff --git a/modules/mono/editor/GodotTools/GodotTools/Ides/Rider/RiderLocatorEnvironment.cs b/modules/mono/editor/GodotTools/GodotTools/Ides/Rider/RiderLocatorEnvironment.cs index 7e08d8c01d..61c1581281 100644 --- a/modules/mono/editor/GodotTools/GodotTools/Ides/Rider/RiderLocatorEnvironment.cs +++ b/modules/mono/editor/GodotTools/GodotTools/Ides/Rider/RiderLocatorEnvironment.cs @@ -48,4 +48,9 @@ public class RiderLocatorEnvironment : IRiderLocatorEnvironment else GD.PushError(message, e); } + + public void Verbose(string message, Exception e = null) + { + // do nothing, since IDK how to write only to the log, without spamming the output + } } diff --git a/modules/mono/editor/GodotTools/GodotTools/Ides/Rider/RiderPathManager.cs b/modules/mono/editor/GodotTools/GodotTools/Ides/Rider/RiderPathManager.cs index 5c09f1f83a..0d77b8999a 100644 --- a/modules/mono/editor/GodotTools/GodotTools/Ides/Rider/RiderPathManager.cs +++ b/modules/mono/editor/GodotTools/GodotTools/Ides/Rider/RiderPathManager.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.IO; using System.Linq; using Godot; @@ -11,10 +10,13 @@ namespace GodotTools.Ides.Rider public static class RiderPathManager { private static readonly RiderPathLocator RiderPathLocator; + private static readonly RiderFileOpener RiderFileOpener; static RiderPathManager() { - RiderPathLocator = new RiderPathLocator(new RiderLocatorEnvironment()); + var riderLocatorEnvironment = new RiderLocatorEnvironment(); + RiderPathLocator = new RiderPathLocator(riderLocatorEnvironment); + RiderFileOpener = new RiderFileOpener(riderLocatorEnvironment); } public static readonly string EditorPathSettingName = "dotnet/editor/editor_path_optional"; @@ -46,7 +48,7 @@ namespace GodotTools.Ides.Rider } var riderPath = (string)editorSettings.GetSetting(EditorPathSettingName); - if (IsRiderAndExists(riderPath)) + if (File.Exists(riderPath)) { Globals.EditorDef(EditorPathSettingName, riderPath); return; @@ -63,12 +65,6 @@ namespace GodotTools.Ides.Rider } } - public static bool IsExternalEditorSetToRider(EditorSettings editorSettings) - { - return editorSettings.HasSetting(EditorPathSettingName) && - IsRider((string)editorSettings.GetSetting(EditorPathSettingName)); - } - public static bool IsRider(string path) { if (string.IsNullOrEmpty(path)) @@ -84,49 +80,29 @@ namespace GodotTools.Ides.Rider private static string CheckAndUpdatePath(string riderPath) { - if (IsRiderAndExists(riderPath)) + if (File.Exists(riderPath)) { return riderPath; } - var editorSettings = GodotSharpEditor.Instance.GetEditorInterface().GetEditorSettings(); - var paths = RiderPathLocator.GetAllRiderPaths(); - - if (!paths.Any()) + var allInfos = RiderPathLocator.GetAllRiderPaths(); + if (allInfos.Length == 0) return null; - - string newPath = paths.Last().Path; + var riderInfos = allInfos.Where(info => IsRider(info.Path)).ToArray(); + string newPath = riderInfos.Length > 0 + ? riderInfos[riderInfos.Length - 1].Path + : allInfos[allInfos.Length - 1].Path; + var editorSettings = GodotSharpEditor.Instance.GetEditorInterface().GetEditorSettings(); editorSettings.SetSetting(EditorPathSettingName, newPath); Globals.EditorDef(EditorPathSettingName, newPath); return newPath; } - private static bool IsRiderAndExists(string riderPath) - { - return !string.IsNullOrEmpty(riderPath) && IsRider(riderPath) && new FileInfo(riderPath).Exists; - } - - public static void OpenFile(string slnPath, string scriptPath, int line) + public static void OpenFile(string slnPath, string scriptPath, int line, int column) { string pathFromSettings = GetRiderPathFromSettings(); string path = CheckAndUpdatePath(pathFromSettings); - - var args = new List<string>(); - args.Add(slnPath); - if (line >= 0) - { - args.Add("--line"); - args.Add((line + 1).ToString()); // https://github.com/JetBrains/godot-support/issues/61 - } - args.Add(scriptPath); - try - { - Utils.OS.RunProcess(path, args); - } - catch (Exception e) - { - GD.PushError($"Error when trying to run code editor: JetBrains Rider. Exception message: '{e.Message}'"); - } + RiderFileOpener.OpenFile(path, slnPath, scriptPath, line, column); } } } |
