Пример #1
0
        public CodeEditor.Installation[] PathCallback()
        {
            var res = RiderPathLocator.GetAllRiderPaths()
                      .Select(riderInfo => new CodeEditor.Installation
            {
                Path = riderInfo.Path,
                Name = riderInfo.Presentation
            })
                      .ToList();

            var editorPath = RiderScriptEditor.CurrentEditor;

            if (RiderScriptEditor.IsRiderInstallation(editorPath) &&
                !res.Any(a => a.Path == editorPath) &&
                FileSystemUtil.EditorPathExists(editorPath))
            {
                // External editor manually set from custom location
                var info         = new RiderPathLocator.RiderInfo(editorPath, false);
                var installation = new CodeEditor.Installation
                {
                    Path = info.Path,
                    Name = info.Presentation
                };
                res.Add(installation);
            }

            return(res.ToArray());
        }
Пример #2
0
        static RiderScriptEditor()
        {
            try
            {
                var projectGeneration = new ProjectGeneration();
                var editor            = new RiderScriptEditor(new Discovery(), projectGeneration);
                CodeEditor.Register(editor);

                var path = GetEditorRealPath(CodeEditor.CurrentEditorInstallation);
                if (IsRiderInstallation(path))
                {
                    if (!FileSystemUtil.EditorPathExists(path)) // previously used rider was removed
                    {
                        var newEditor = editor.Installations.Last().Path;
                        CodeEditor.SetExternalScriptEditor(newEditor);
                        path = newEditor;
                    }

                    editor.CreateSolutionIfDoesntExist();
                    if (ShouldLoadEditorPlugin(path))
                    {
                        editor.m_Initiliazer.Initialize(path);
                    }

                    InitProjectFilesWatcher();
                }
            }
            catch (Exception e)
            {
                Debug.LogException(e);
            }
        }
Пример #3
0
        static RiderScriptEditor()
        {
            var projectGeneration = new ProjectGeneration();
            var editor            = new RiderScriptEditor(new Discovery(), projectGeneration);

            CodeEditor.Register(editor);
            if (IsRiderInstallation(CodeEditor.CurrentEditorInstallation))
            {
                editor.CreateIfDoesntExist();
                editor.m_Initiliazer.Initialize(CodeEditor.CurrentEditorInstallation);
            }
        }
Пример #4
0
        static RiderScriptEditor()
        {
            try
            {
                var projectGeneration = new ProjectGeneration.ProjectGeneration();
                var editor            = new RiderScriptEditor(new Discovery(), projectGeneration);
                CodeEditor.Register(editor);
                var path = GetEditorRealPath(CurrentEditor);

                if (IsRiderInstallation(path))
                {
                    RiderPathLocator.RiderInfo[] installations = null;

                    if (!RiderScriptEditorData.instance.initializedOnce)
                    {
                        installations = RiderPathLocator.GetAllRiderPaths().OrderBy(a => a.BuildNumber).ToArray();
                        // is likely outdated
                        if (installations.Any() && installations.All(a => GetEditorRealPath(a.Path) != path))
                        {
                            if (RiderPathLocator.GetIsToolbox(path)) // is toolbox - update
                            {
                                var toolboxInstallations = installations.Where(a => a.IsToolbox).ToArray();
                                if (toolboxInstallations.Any())
                                {
                                    var newEditor = toolboxInstallations.Last().Path;
                                    CodeEditor.SetExternalScriptEditor(newEditor);
                                    path = newEditor;
                                }
                                else
                                {
                                    var newEditor = installations.Last().Path;
                                    CodeEditor.SetExternalScriptEditor(newEditor);
                                    path = newEditor;
                                }
                            }
                            else // is non toolbox - notify
                            {
                                var newEditorName = installations.Last().Presentation;
                                Debug.LogWarning($"Consider updating External Editor in Unity to Rider {newEditorName}.");
                            }
                        }

                        ShowWarningOnUnexpectedScriptEditor(path);
                        RiderScriptEditorData.instance.initializedOnce = true;
                    }

                    if (!FileSystemUtil.EditorPathExists(path)) // previously used rider was removed
                    {
                        if (installations == null)
                        {
                            installations = RiderPathLocator.GetAllRiderPaths().OrderBy(a => a.BuildNumber).ToArray();
                        }
                        if (installations.Any())
                        {
                            var newEditor = installations.Last().Path;
                            CodeEditor.SetExternalScriptEditor(newEditor);
                            path = newEditor;
                        }
                    }
                    RiderScriptEditorData.instance.Init();

                    editor.CreateSolutionIfDoesntExist();
                    if (RiderScriptEditorData.instance.shouldLoadEditorPlugin)
                    {
                        editor.m_Initiliazer.Initialize(path);
                    }

                    InitProjectFilesWatcher();
                }
            }
            catch (Exception e)
            {
                Debug.LogException(e);
            }
        }
Пример #5
0
        static RiderScriptEditor()
        {
            try
            {
                // todo: make ProjectGeneration lazy
                var projectGeneration = new ProjectGeneration.ProjectGeneration();
                var editor            = new RiderScriptEditor(new Discovery(), projectGeneration);
                CodeEditor.Register(editor);
                var path = GetEditorRealPath(CurrentEditor);

                if (IsRiderInstallation(path))
                {
                    RiderPathLocator.RiderInfo[] installations = null;

                    if (!RiderScriptEditorData.instance.initializedOnce)
                    {
                        installations = RiderPathLocator.GetAllRiderPaths().OrderBy(a => a.BuildNumber).ToArray();
                        // is likely outdated
                        if (installations.Any() && installations.All(a => GetEditorRealPath(a.Path) != path))
                        {
                            if (RiderPathLocator.GetIsToolbox(path)) // is toolbox - update
                            {
                                var toolboxInstallations = installations.Where(a => a.IsToolbox).ToArray();
                                if (toolboxInstallations.Any())
                                {
                                    var newEditor = toolboxInstallations.Last().Path;
                                    CodeEditor.SetExternalScriptEditor(newEditor);
                                    path = newEditor;
                                }
                                else
                                {
                                    var newEditor = installations.Last().Path;
                                    CodeEditor.SetExternalScriptEditor(newEditor);
                                    path = newEditor;
                                }
                            }
                            else // is non toolbox - notify
                            {
                                var newEditorName = installations.Last().Presentation;
                                Debug.LogWarning($"Consider updating External Editor in Unity to Rider {newEditorName}.");
                            }
                        }

                        ShowWarningOnUnexpectedScriptEditor(path);
                        RiderScriptEditorData.instance.initializedOnce = true;
                    }

                    if (!FileSystemUtil.EditorPathExists(path)) // previously used rider was removed
                    {
                        if (installations == null)
                        {
                            installations = RiderPathLocator.GetAllRiderPaths().OrderBy(a => a.BuildNumber).ToArray();
                        }
                        if (installations.Any())
                        {
                            var newEditor = installations.Last().Path;
                            CodeEditor.SetExternalScriptEditor(newEditor);
                            path = newEditor;
                        }
                    }

                    RiderScriptEditorData.instance.Init();

                    editor.CreateSolutionIfDoesntExist();
                    if (RiderScriptEditorData.instance.shouldLoadEditorPlugin)
                    {
                        editor.m_Initiliazer.Initialize(path);
                    }

                    RiderFileSystemWatcher.InitWatcher(
                        Directory.GetCurrentDirectory(), "*.*", (sender, args) =>
                    {
                        var extension = Path.GetExtension(args.Name);
                        if (extension == ".sln" || extension == ".csproj")
                        {
                            RiderScriptEditorData.instance.hasChanges = true;
                        }
                    });

                    RiderFileSystemWatcher.InitWatcher(
                        Path.Combine(Directory.GetCurrentDirectory(), "Library"),
                        "EditorOnlyScriptingUserSettings.json",
                        (sender, args) => { RiderScriptEditorData.instance.hasChanges = true; });

                    RiderFileSystemWatcher.InitWatcher(
                        Path.Combine(Directory.GetCurrentDirectory(), "Packages"),
                        "manifest.json", (sender, args) => { RiderScriptEditorData.instance.hasChanges = true; });

                    // can't switch to non-deprecated api, because UnityEditor.Build.BuildPipelineInterfaces.processors is internal
#pragma warning disable 618
                    EditorUserBuildSettings.activeBuildTargetChanged += () =>
#pragma warning restore 618
                    {
                        RiderScriptEditorData.instance.hasChanges = true;
                    };
                }
            }
            catch (Exception e)
            {
                Debug.LogException(e);
            }
        }
Пример #6
0
        static RiderScriptEditor()
        {
            try
            {
                var projectGeneration = new ProjectGeneration();
                var editor            = new RiderScriptEditor(new Discovery(), projectGeneration);
                CodeEditor.Register(editor);
                var path = GetEditorRealPath(CodeEditor.CurrentEditorInstallation);

                if (IsRiderInstallation(path))
                {
                    if (!RiderScriptEditorData.instance.InitializedOnce)
                    {
                        var installations = editor.Installations;
                        // is toolbox and outdated - update
                        if (installations.Any() && RiderPathLocator.IsToolbox(path) && installations.All(a => a.Path != path))
                        {
                            var toolboxInstallations = installations.Where(a => a.Name.Contains("(JetBrains Toolbox)")).ToArray();
                            if (toolboxInstallations.Any())
                            {
                                var newEditor = toolboxInstallations.Last().Path;
                                CodeEditor.SetExternalScriptEditor(newEditor);
                                path = newEditor;
                            }
                            else
                            {
                                var newEditor = installations.Last().Path;
                                CodeEditor.SetExternalScriptEditor(newEditor);
                                path = newEditor;
                            }
                        }

                        // exists, is non toolbox and outdated - notify
                        if (installations.Any() && FileSystemUtil.EditorPathExists(path) && installations.All(a => a.Path != path))
                        {
                            var newEditorName = installations.Last().Name;
                            Debug.LogWarning($"Consider updating External Editor in Unity to Rider {newEditorName}.");
                        }

                        ShowWarningOnUnexpectedScriptEditor(path);
                        RiderScriptEditorData.instance.InitializedOnce = true;
                    }

                    if (!FileSystemUtil.EditorPathExists(path)) // previously used rider was removed
                    {
                        var installations = editor.Installations;
                        if (installations.Any())
                        {
                            var newEditor = installations.Last().Path;
                            CodeEditor.SetExternalScriptEditor(newEditor);
                            path = newEditor;
                        }
                    }
                    RiderScriptEditorData.instance.Init();

                    editor.CreateSolutionIfDoesntExist();
                    if (RiderScriptEditorData.instance.shouldLoadEditorPlugin)
                    {
                        editor.m_Initiliazer.Initialize(path);
                    }

                    InitProjectFilesWatcher();
                }
            }
            catch (Exception e)
            {
                Debug.LogException(e);
            }
        }