Beispiel #1
0
        private void OnChanged(object sender, FileSystemEventArgs e)
        {
            var protocolInstancePath = FileSystemPath.Parse(e.FullPath);

            // connect on reload of server
            myLocks.ExecuteOrQueue(myLifetime, "CreateProtocol", () => CreateProtocol(protocolInstancePath, mySolution.GetProtocolSolution()));
        }
Beispiel #2
0
        private void OnDataFileChanged(Pair <IPsiSourceFile, T4FileDataDiff> pair)
        {
            if (pair.First != SourceFile)
            {
                return;
            }

            if (_shellLocks.IsWriteAccessAllowed())
            {
                OnDataFileChanged(pair.Second);
            }
            else
            {
                _shellLocks.ExecuteOrQueue(_lifetime, "T4PsiModuleOnFileDataChanged",
                                           () => _shellLocks.ExecuteWithWriteLock(() => OnDataFileChanged(pair.Second)));
            }
        }
        private void OnChanged(object sender, FileSystemEventArgs e)
        {
            var protocolInstancePath = FileSystemPath.Parse(e.FullPath);

            // connect on reload of server
            if (!myComponentLifetime.IsTerminated)
            {
                myLocks.ExecuteOrQueue(myComponentLifetime, "CreateProtocol",
                                       () => CreateProtocols(protocolInstancePath));
            }
        }
        public static Action ProtectActionFromReEntry(Lifetime lifetime, string name, Action fOnExecute)
        {
            void fOnExecute2()
            {
                IShellLocks shellLocks = Shell.Instance.GetComponent <IShellLocks>();

                shellLocks.ExecuteOrQueue(lifetime, name, () => ReadLockCookie.Execute(fOnExecute));
            }

            return(fOnExecute2);
        }
 private void OnChangeAction(FileSystemChangeDelta delta)
 {
     // connect on reload of server
     if (delta.ChangeType != FileSystemChangeType.ADDED && delta.ChangeType != FileSystemChangeType.CHANGED)
     {
         return;
     }
     if (!myComponentLifetime.IsTerminated)
     {
         myLocks.ExecuteOrQueue(myComponentLifetime, "CreateProtocol",
                                () => CreateProtocols(delta.NewPath));
     }
 }
Beispiel #6
0
        public RiderBackendToUnrealEditor(Lifetime lifetime, IShellLocks locks, IScheduler dispatcher, ILogger logger,
                                          UnrealHost unrealHost, UnrealLinkResolver linkResolver, EditorNavigator editorNavigator,
                                          UnrealPluginDetector pluginDetector)
        {
            myComponentLifetime          = lifetime;
            myLocks                      = locks;
            myConnectionLifetimeProducer = new SequentialLifetimes(lifetime);
            myDispatcher                 = dispatcher;
            myLogger                     = logger;
            myUnrealHost                 = unrealHost;
            myLinkResolver               = linkResolver;
            myEditorNavigator            = editorNavigator;

            myLogger.Info("RiderBackendToUnrealEditor building started");

            pluginDetector.InstallInfoProperty.View(myComponentLifetime, (lt, pluginInfo) =>
            {
                if (pluginInfo == null)
                {
                    return;
                }

                var portDirectoryFullPath = Path.Combine(
                    Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "..",
                    "Local", "Jetbrains", "Rider", "Unreal", "Ports");

                Directory.CreateDirectory(portDirectoryFullPath);

                var watcher = new FileSystemWatcher(portDirectoryFullPath)
                {
                    NotifyFilter = NotifyFilters.LastWrite
                };
                var projects = pluginInfo.ProjectPlugins.Select(it => it.UprojectFilePath.NameWithoutExtension)
                               .ToList();

                FileSystemEventHandler handler = (obj, fileSystemEvent) =>
                {
                    var path = FileSystemPath.Parse(fileSystemEvent.FullPath);
                    if (projects.Contains(path.NameWithoutExtension) && myComponentLifetime.IsAlive)
                    {
                        myLocks.ExecuteOrQueue(myComponentLifetime, "CreateProtocol", () => CreateProtocols(path));
                    }
                };

                watcher.Changed += handler;
                watcher.Created += handler;

                // Check if it's even possible to happen
                lt.Bracket(() => { }, () => { watcher.Dispose(); });

                StartWatcher(watcher);

                foreach (var projectName in projects)
                {
                    var portFileFullPath = Path.Combine(portDirectoryFullPath, projectName);
                    CreateProtocols(FileSystemPath.Parse(portFileFullPath));
                }
            });

            myLogger.Info("RiderBackendToUnrealEditor building finished");
        }
Beispiel #7
0
        public UnrealPluginDetector(Lifetime lifetime, ILogger logger,
                                    CppUE4SolutionDetector solutionDetector, ISolution solution,
                                    IShellLocks locks, ISolutionLoadTasksScheduler scheduler)
        {
            myLifetime          = lifetime;
            InstallInfoProperty =
                new Property <UnrealPluginInstallInfo>(myLifetime, "UnrealPlugin.InstallInfoNotification", null, true);
            myLogger           = logger;
            mySolution         = solution;
            mySolutionDetector = solutionDetector;

            mySolutionDetector.IsUE4Solution_Observable.Change.Advise_When(myLifetime,
                                                                           newValue => newValue == TriBool.True, _ =>
            {
                scheduler.EnqueueTask(new SolutionLoadTask("Find installed RiderLink plugins",
                                                           SolutionLoadTaskKinds.Done,
                                                           () =>
                {
                    myLogger.Info("[UnrealLink]: Looking for RiderLink plugins");
                    myUnrealVersion = mySolutionDetector.Version;

                    if (myUnrealVersion < myMinimalSupportedVersion)
                    {
                        locks.ExecuteOrQueue(myLifetime, "UnrealLink.CheckSupportedVersion",
                                             () =>
                        {
                            var notification =
                                new NotificationModel(
                                    $"Unreal Engine {myMinimalSupportedVersion}+ is required",
                                    $"<html>UnrealLink supports Unreal Engine versions starting with {myMinimalSupportedVersion}<br>" +
                                    "<b>WARNING: Advanced users only</b><br>" +
                                    "You can manually download the latest version of plugin and build It for your version of Unreal Editor<br>" +
                                    RiderContextNotificationHelper.MakeLink(
                                        "https://github.com/JetBrains/UnrealLink/releases/latest",
                                        "Download latest Unreal Editor plugin") +
                                    "</html>",
                                    true,
                                    RdNotificationEntryType.WARN,
                                    new List <NotificationHyperlink>());
                            var notificationsModel = Shell.Instance.GetComponent <NotificationsModel>();
                            notificationsModel.Notification(notification);
                        });
                        return;
                    }

                    var installInfo       = new UnrealPluginInstallInfo();
                    var foundEnginePlugin = TryGetEnginePluginFromSolution(solutionDetector, installInfo);
                    ISet <FileSystemPath> uprojectLocations;
                    using (solution.Locks.UsingReadLock())
                    {
                        var allProjects = mySolution.GetAllProjects();
                        if (solutionDetector.SupportRiderProjectModel ==
                            CppUE4ProjectModelSupportMode.UprojectOpened)
                        {
                            uprojectLocations = allProjects.Where(project =>
                            {
                                if (project.IsMiscProjectItem() || project.IsMiscFilesProject())
                                {
                                    return(false);
                                }

                                var location = project.Location;
                                if (location == null)
                                {
                                    return(false);
                                }

                                if (EXCLUDED_PROJECTS.Contains(location.NameWithoutExtension))
                                {
                                    return(false);
                                }

                                // TODO: drop this ugly check after updating to net211 where Location == "path/to/game.uproject"
                                var isUproject =
                                    location.ExistsFile && location.ExtensionNoDot == UPROJECT_FILE_FORMAT &&
                                    location.NameWithoutExtension == project.Name;
                                return(isUproject || (location / $"{location.Name}.uproject").ExistsFile);
                            }).Select(project =>
                            {
                                var location = project.Location;
                                if (location.ExistsFile)
                                {
                                    return(location);
                                }
                                return(location / $"{location.Name}.uproject");
                            }).ToSet();
                        }
                        else
                        {
                            uprojectLocations = allProjects.SelectMany(project =>
                                                                       project.GetAllProjectFiles(projectFile =>
                            {
                                var location = projectFile.Location;
                                if (location == null || !location.ExistsFile)
                                {
                                    return(false);
                                }

                                return(location.ExtensionNoDot == UPROJECT_FILE_FORMAT &&
                                       location.NameWithoutExtension == project.Name);
                            })).Select(file => file.Location).ToSet();
                        }
                    }

                    myLogger.Info($"[UnrealLink]: Found {uprojectLocations.Count} uprojects");

                    if (!foundEnginePlugin && !uprojectLocations.IsEmpty())
                    {
                        // All projects in the solution are bound to the same engine
                        // So take first project and use it to find Unreal Engine
                        TryGetEnginePluginFromUproject(uprojectLocations.FirstNotNull(), installInfo);
                        foundEnginePlugin = installInfo.EnginePlugin.IsPluginAvailable;
                    }

                    // Gather data about Project plugins
                    foreach (var uprojectLocation in uprojectLocations)
                    {
                        myLogger.Info($"[UnrealLink]: Looking for plugin in {uprojectLocation}");
                        var projectPlugin = GetProjectPluginForUproject(uprojectLocation);
                        if (projectPlugin.IsPluginAvailable)
                        {
                            myLogger.Info(
                                $"[UnrealLink]: found plugin {projectPlugin.UnrealPluginRootFolder}");
                        }

                        installInfo.ProjectPlugins.Add(projectPlugin);
                    }

                    if (foundEnginePlugin)
                    {
                        installInfo.Location = PluginInstallLocation.Engine;
                    }
                    else if (installInfo.ProjectPlugins.Any(description => description.IsPluginAvailable))
                    {
                        installInfo.Location = PluginInstallLocation.Game;
                    }
                    else
                    {
                        installInfo.Location = PluginInstallLocation.NotInstalled;
                    }
                    InstallInfoProperty.SetValue(installInfo);
                }));
            });
        }