Beispiel #1
0
        public UnityRefreshTracker(Lifetime lifetime, ISolution solution, UnityRefresher refresher,
                                   UnityEditorProtocol protocolController, DocumentTransactionManager documentTransactionManager, IShellLocks locks,
                                   ILogger logger)
        {
            myLogger = logger;

            if (solution.GetData(ProjectModelExtensions.ProtocolSolutionKey) == null)
            {
                return;
            }

            var groupingEvent = solution.Locks.GroupingEvents.CreateEvent(lifetime, "UnityRefresherOnSaveEvent", TimeSpan.FromMilliseconds(500),
                                                                          Rgc.Invariant, () => refresher.Refresh(false));

            var protocolSolution = solution.GetProtocolSolution();

            protocolSolution.Editors.AfterDocumentInEditorSaved.Advise(lifetime, _ =>
            {
                if (protocolController.UnityModel.Value == null)
                {
                    return;
                }

                myLogger.Verbose("protocolSolution.Editors.AfterDocumentInEditorSaved");
                groupingEvent.FireIncoming();
            });
        }
        public UnityRefreshTracker(Lifetime lifetime, ISolution solution, UnityRefresher refresher,
                                   ILogger logger,
                                   IFileSystemTracker fileSystemTracker,
                                   UnityHost host,
                                   UnitySolutionTracker unitySolutionTracker)
        {
            myRefresher = refresher;
            myLogger    = logger;
            if (solution.GetData(ProjectModelExtensions.ProtocolSolutionKey) == null)
            {
                return;
            }

            unitySolutionTracker.IsUnityProjectFolder.AdviseOnce(lifetime, args =>
            {
                if (!args)
                {
                    return;
                }

                // Rgc.Guarded - beware RIDER-15577
                myGroupingEvent = solution.Locks.GroupingEvents.CreateEvent(lifetime, "UnityRefresherGroupingEvent",
                                                                            TimeSpan.FromMilliseconds(500),
                                                                            Rgc.Guarded, () =>
                {
                    refresher.Refresh(RefreshType.Normal);
                });

                host.PerformModelAction(rd => rd.Refresh.Advise(lifetime, force =>
                {
                    if (force)
                    {
                        refresher.Refresh(RefreshType.ForceRequestScriptReload);
                    }
                    else
                    {
                        myGroupingEvent.FireIncoming();
                    }
                }));
            });

            unitySolutionTracker.IsUnityProject.AdviseOnce(lifetime, args =>
            {
                if (!args)
                {
                    return;
                }

                var protocolSolution = solution.GetProtocolSolution();
                protocolSolution.Editors.AfterDocumentInEditorSaved.Advise(lifetime, _ =>
                {
                    logger.Verbose("protocolSolution.Editors.AfterDocumentInEditorSaved");
                    myGroupingEvent.FireIncoming();
                });

                fileSystemTracker.RegisterPrioritySink(lifetime, FileSystemChange, HandlingPriority.Other);
            });
        }
Beispiel #3
0
        public UnityRefreshTracker(Lifetime lifetime, ISolution solution, UnityRefresher refresher, ChangeManager changeManager, UnityPluginProtocolController protocolController,
                                   ILogger logger)
        {
            if (solution.GetData <Solution>(ProjectModelExtensions.ProtocolSolutionKey) == null)
            {
                return;
            }

            var groupingEvent = solution.Locks.GroupingEvents.CreateEvent(lifetime, "UnityRefresherOnSaveEvent", TimeSpan.FromMilliseconds(500),
                                                                          Rgc.Invariant, refresher.Refresh);

            var protocolSolution = solution.GetProtocolSolution();

            protocolSolution.Editors.AfterDocumentInEditorSaved.Advise(lifetime, _ =>
            {
                if (refresher.IsRefreshing)
                {
                    return;
                }
                var isPlay = protocolController.UnityModel?.Play.HasTrueValue();
                if (isPlay == null || (bool)isPlay)
                {
                    return;
                }

                groupingEvent.FireIncoming();
            });

            changeManager.Changed2.Advise(lifetime, args =>
            {
                var changes = args.ChangeMap.GetChanges <ProjectModelChange>();
                if (changes == null)
                {
                    return;
                }

                if (refresher.IsRefreshing)
                {
                    return;
                }

                var hasChange = changes.Any(HasAnyFileChangeRec);
                if (!hasChange)
                {
                    return;
                }

                var isPlay = protocolController.UnityModel?.Play.HasTrueValue();
                if (isPlay == null || (bool)isPlay)
                {
                    return;
                }

                groupingEvent.FireIncoming();
            });
        }
        public UnityPluginInstaller(
            Lifetime lifetime,
            ILogger logger,
            ISolution solution,
            IShellLocks shellLocks,
            UnityPluginDetector detector,
            NotificationsModel notifications,
            ISettingsStore settingsStore,
            PluginPathsProvider pluginPathsProvider,
            UnityVersion unityVersion,
            UnityHost unityHost,
            UnitySolutionTracker unitySolutionTracker,
            UnityRefresher refresher)
        {
            myPluginInstallations = new JetHashSet <FileSystemPath>();

            myLifetime             = lifetime;
            myLogger               = logger;
            mySolution             = solution;
            myShellLocks           = shellLocks;
            myDetector             = detector;
            myNotifications        = notifications;
            myPluginPathsProvider  = pluginPathsProvider;
            myUnityVersion         = unityVersion;
            myUnitySolutionTracker = unitySolutionTracker;
            myRefresher            = refresher;

            myBoundSettingsStore = settingsStore.BindToContextLive(myLifetime, ContextRange.Smart(solution.ToDataContext()));
            myQueue = new ProcessingQueue(myShellLocks, myLifetime);

            unityHost.PerformModelAction(rdUnityModel =>
            {
                rdUnityModel.InstallEditorPlugin.AdviseNotNull(lifetime, x =>
                {
                    myShellLocks.ExecuteOrQueueReadLockEx(myLifetime, "UnityPluginInstaller.InstallEditorPlugin", () =>
                    {
                        var installationInfo = myDetector.GetInstallationInfo(myCurrentVersion);
                        QueueInstall(installationInfo, true);
                    });
                });
            });

            unitySolutionTracker.IsUnityProjectFolder.AdviseOnce(lifetime, args =>
            {
                if (!args)
                {
                    return;
                }
                myShellLocks.ExecuteOrQueueReadLockEx(myLifetime, "IsAbleToEstablishProtocolConnectionWithUnity", InstallPluginIfRequired);
                BindToInstallationSettingChange();
            });
        }
Beispiel #5
0
        public UnityRefreshTracker(Lifetime lifetime, ISolution solution, UnityRefresher refresher,
                                   ILogger logger,
                                   IFileSystemTracker fileSystemTracker,
                                   UnityHost host,
                                   UnitySolutionTracker unitySolutionTracker)
        {
            myRefresher = refresher;
            myLogger    = logger;
            if (solution.GetData(ProjectModelExtensions.ProtocolSolutionKey) == null)
            {
                return;
            }

            unitySolutionTracker.IsUnityProjectFolder.AdviseOnce(lifetime, args =>
            {
                if (!args)
                {
                    return;
                }
                host.PerformModelAction(rd => rd.Refresh.Advise(lifetime, force =>
                {
                    refresher.Refresh(force ? RefreshType.ForceRequestScriptReload : RefreshType.Normal);
                }));
            });

            unitySolutionTracker.IsUnityProject.AdviseOnce(lifetime, args =>
            {
                if (!args)
                {
                    return;
                }

                var protocolSolution = solution.GetProtocolSolution();
                protocolSolution.Editors.AfterDocumentInEditorSaved.Advise(lifetime, _ =>
                {
                    logger.Verbose("protocolSolution.Editors.AfterDocumentInEditorSaved");
                    refresher.Refresh(RefreshType.Normal);
                });

                fileSystemTracker.RegisterPrioritySink(lifetime, FileSystemChange, HandlingPriority.Other);
            });
        }