|
@@ -1,5 +1,4 @@
|
|
using System;
|
|
using System;
|
|
-using System.Collections.Generic;
|
|
|
|
using System.IO;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Linq;
|
|
using Godot;
|
|
using Godot;
|
|
@@ -11,10 +10,13 @@ namespace GodotTools.Ides.Rider
|
|
public static class RiderPathManager
|
|
public static class RiderPathManager
|
|
{
|
|
{
|
|
private static readonly RiderPathLocator RiderPathLocator;
|
|
private static readonly RiderPathLocator RiderPathLocator;
|
|
|
|
+ private static readonly RiderFileOpener RiderFileOpener;
|
|
|
|
|
|
static RiderPathManager()
|
|
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";
|
|
public static readonly string EditorPathSettingName = "dotnet/editor/editor_path_optional";
|
|
@@ -46,7 +48,7 @@ namespace GodotTools.Ides.Rider
|
|
}
|
|
}
|
|
|
|
|
|
var riderPath = (string)editorSettings.GetSetting(EditorPathSettingName);
|
|
var riderPath = (string)editorSettings.GetSetting(EditorPathSettingName);
|
|
- if (IsRiderAndExists(riderPath))
|
|
|
|
|
|
+ if (File.Exists(riderPath))
|
|
{
|
|
{
|
|
Globals.EditorDef(EditorPathSettingName, riderPath);
|
|
Globals.EditorDef(EditorPathSettingName, riderPath);
|
|
return;
|
|
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)
|
|
public static bool IsRider(string path)
|
|
{
|
|
{
|
|
if (string.IsNullOrEmpty(path))
|
|
if (string.IsNullOrEmpty(path))
|
|
@@ -84,49 +80,29 @@ namespace GodotTools.Ides.Rider
|
|
|
|
|
|
private static string CheckAndUpdatePath(string riderPath)
|
|
private static string CheckAndUpdatePath(string riderPath)
|
|
{
|
|
{
|
|
- if (IsRiderAndExists(riderPath))
|
|
|
|
|
|
+ if (File.Exists(riderPath))
|
|
{
|
|
{
|
|
return 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;
|
|
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);
|
|
editorSettings.SetSetting(EditorPathSettingName, newPath);
|
|
Globals.EditorDef(EditorPathSettingName, newPath);
|
|
Globals.EditorDef(EditorPathSettingName, newPath);
|
|
return 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 pathFromSettings = GetRiderPathFromSettings();
|
|
string path = CheckAndUpdatePath(pathFromSettings);
|
|
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);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|