Esempio n. 1
0
        public ReloadTracker(Lifetime lifetime, ISolution solution, RunManager host, RiderEnvironmentService envService)
        {
            if (solution.GetData(ProjectModelExtensions.ProtocolSolutionKey) == null)
            {
                return;
            }

            host.PerformModelAction((rd => rd.Enable.Advise(lifetime, needEnable =>
            {
                if (needEnable)
                {
                    var enableCommand =
                        PluginInitializer.RegisteredCommandInstances[HotReloadCommands.Enable] as EnvCommandStub;
                    enableCommand.OnExecuted();
                }
                else
                {
                    var disableCommand =
                        PluginInitializer.RegisteredCommandInstances[HotReloadCommands.Disable] as EnvCommandStub;
                    disableCommand.OnExecuted();
                }
            })));

            host.PerformModelAction(rd =>
                                    rd.Reload.Advise(lifetime, savedDoc => { envService.OnDocumentSaved(savedDoc); }));
        }
Esempio n. 2
0
        public UnityNUnitServiceProvider(ISolution solution,
                                         IPsiModules psiModules,
                                         ISymbolCache symbolCache,
                                         IUnitTestElementIdFactory idFactory,
                                         IUnitTestElementManager elementManager,
                                         NUnitTestProvider provider,
                                         IUnitTestingSettings settings,
                                         ISettingsStore settingsStore,
                                         ISettingsOptimization settingsOptimization,
                                         ISettingsCache settingsCache,
                                         UnitTestingCachingService cachingService,
                                         INUnitTestParametersProvider testParametersProvider,
                                         UnityEditorProtocol editorProtocol,
                                         RunViaUnityEditorStrategy runViaUnityEditorStrategy,
                                         UnitySolutionTracker unitySolutionTracker)
            : base(solution, psiModules, symbolCache, idFactory, elementManager, provider, settings, settingsStore,
                   settingsOptimization, settingsCache, cachingService, testParametersProvider)
        {
            if (solution.GetData(ProjectModelExtensions.ProtocolSolutionKey) == null)
            {
                return;
            }

            myRdUnityModel         = solution.GetProtocolSolution().GetRdUnityModel();
            myEditorProtocol       = editorProtocol;
            myUnityEditorStrategy  = runViaUnityEditorStrategy;
            myUnitySolutionTracker = unitySolutionTracker;
        }
Esempio n. 3
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);
            });
        }
Esempio n. 5
0
        public UnityEditorProtocol(Lifetime lifetime, ILogger logger, UnityHost host,
                                   IScheduler dispatcher, IShellLocks locks, ISolution solution, PluginPathsProvider pluginPathsProvider,
                                   ISettingsStore settingsStore, JetBrains.Application.ActivityTrackingNew.UsageStatistics usageStatistics,
                                   UnitySolutionTracker unitySolutionTracker, IThreading threading)
        {
            myComponentLifetime   = lifetime;
            myLogger              = logger;
            myDispatcher          = dispatcher;
            myLocks               = locks;
            mySolution            = solution;
            myPluginPathsProvider = pluginPathsProvider;
            myUsageStatistics     = usageStatistics;
            myThreading           = threading;
            myHost = host;
            myBoundSettingsStore = settingsStore.BindToContextLive(lifetime, ContextRange.Smart(solution.ToDataContext()));
            mySessionLifetimes   = new SequentialLifetimes(lifetime);

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

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

                var solFolder = mySolution.SolutionFilePath.Directory;
                AdviseModelData(lifetime);

                // todo: consider non-Unity Solution with Unity-generated projects
                var protocolInstancePath = solFolder.Combine("Library/ProtocolInstance.json");
                protocolInstancePath.Directory.CreateDirectory();

                var watcher          = new FileSystemWatcher();
                watcher.Path         = protocolInstancePath.Directory.FullPath;
                watcher.NotifyFilter =
                    NotifyFilters.LastAccess |
                    NotifyFilters.LastWrite; //Watch for changes in LastAccess and LastWrite times
                watcher.Filter = protocolInstancePath.Name;

                // Add event handlers.
                watcher.Changed += OnChanged;
                watcher.Created += OnChanged;

                lf.Bracket(() => { }, () =>
                {
                    watcher.Dispose();
                });

                watcher.EnableRaisingEvents = true; // Begin watching.
                // connect on start of Rider
                CreateProtocols(protocolInstancePath);
            });
        }
Esempio n. 6
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 UnityEditorProtocol(Lifetime lifetime, ILogger logger, UnityHost host,
                                   IScheduler dispatcher, IShellLocks locks, ISolution solution, PluginPathsProvider pluginPathsProvider,
                                   ISettingsStore settingsStore, Application.ActivityTrackingNew.UsageStatistics usageStatistics,
                                   UnitySolutionTracker unitySolutionTracker)
        {
            myComponentLifetime   = lifetime;
            myLogger              = logger;
            myDispatcher          = dispatcher;
            myLocks               = locks;
            mySolution            = solution;
            myPluginPathsProvider = pluginPathsProvider;
            myUsageStatistics     = usageStatistics;
            myHost = host;
            myBoundSettingsStore =
                settingsStore.BindToContextLive(lifetime, ContextRange.Smart(solution.ToDataContext()));
            mySessionLifetimes = new SequentialLifetimes(lifetime);
            myUnityModel       = new Property <EditorPluginModel>(lifetime, "unityModelProperty", null)
                                 .EnsureReadonly(myReadonlyToken).EnsureThisThread();

            if (!unitySolutionTracker.IsAbleToEstablishProtocolConnectionWithUnity.Value)
            {
                return;
            }

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

            var solFolder = mySolution.SolutionFilePath.Directory;

            AdviseModelData(lifetime, mySolution.GetProtocolSolution());

            // todo: consider non-Unity Solution with Unity-generated projects
            var protocolInstancePath = solFolder.Combine("Library/ProtocolInstance.json");

            protocolInstancePath.Directory.CreateDirectory();

            var watcher = new FileSystemWatcher();

            watcher.Path         = protocolInstancePath.Directory.FullPath;
            watcher.NotifyFilter =
                NotifyFilters.LastAccess |
                NotifyFilters.LastWrite; //Watch for changes in LastAccess and LastWrite times
            watcher.Filter = protocolInstancePath.Name;

            // Add event handlers.
            watcher.Changed += OnChanged;
            watcher.Created += OnChanged;

            watcher.EnableRaisingEvents = true; // Begin watching.

            // connect on start of Rider
            CreateProtocols(protocolInstancePath);
        }
Esempio n. 8
0
        public UiMinimizerSettings(Lifetime lifetime, ISolution solution, ISettingsStore settingsStore)
        {
            if (solution.GetData(ProjectModelExtensions.ProtocolSolutionKey) == null)
            {
                return;
            }

            var boundStore = settingsStore.BindToContextLive(lifetime, ContextRange.ApplicationWide);
            var hideSolutionConfiguration = boundStore.GetValueProperty(lifetime, (UnitySettings s) => s.HideSolutionConfiguration);
            var rdUnityModel = solution.GetProtocolSolution().GetRdUnityModel();

            BindRdPropertyToProperty(lifetime, rdUnityModel.HideSolutionConfiguration, hideSolutionConfiguration);
        }
        public UnityRefresher(IShellLocks locks, Lifetime lifetime, ISolution solution, UnityEditorProtocol pluginProtocolController)
        {
            myLocks    = locks;
            myLifetime = lifetime;
            mySolution = solution;
            myPluginProtocolController = pluginProtocolController;

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

            myPluginProtocolController.Refresh.Advise(lifetime, Refresh);
        }
Esempio n. 10
0
        public UnityController(UnityEditorProtocol unityEditorProtocol, ISolution solution,
                               Lifetime lifetime, UnitySolutionTracker solutionTracker)
        {
            if (solution.GetData(ProjectModelExtensions.ProtocolSolutionKey) == null)
            {
                return;
            }

            myUnityEditorProtocol = unityEditorProtocol;
            mySolution            = solution;
            myLifetime            = lifetime;
            mySolutionTracker     = solutionTracker;
            myRdUnityModel        = solution.GetProtocolSolution().GetRdUnityModel();
        }
Esempio n. 11
0
        public UnityPluginProtocolController(Lifetime lifetime, ILogger logger,
                                             IScheduler dispatcher, IShellLocks locks, ISolution solution)
        {
            if (!ProjectExtensions.IsSolutionGeneratedByUnity(solution.SolutionFilePath.Directory))
            {
                return;
            }

            myLifetime         = lifetime;
            myLogger           = logger;
            myDispatcher       = dispatcher;
            myLocks            = locks;
            mySolution         = solution;
            mySessionLifetimes = new SequentialLifetimes(lifetime);

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

            var solFolder = mySolution.SolutionFilePath.Directory;

            AdviseCustomDataFromFrontend(lifetime, mySolution.GetProtocolSolution());

            // todo: consider non-Unity Solution with Unity-generated projects
            var protocolInstancePath = solFolder.Combine("Library/ProtocolInstance.json");

            if (!protocolInstancePath.ExistsFile)
            {
                File.Create(protocolInstancePath.FullPath);
            }

            var watcher = new FileSystemWatcher();

            watcher.Path         = protocolInstancePath.Directory.FullPath;
            watcher.NotifyFilter =
                NotifyFilters.LastAccess |
                NotifyFilters.LastWrite; //Watch for changes in LastAccess and LastWrite times
            watcher.Filter = protocolInstancePath.Name;

            // Add event handlers.
            watcher.Changed += OnChanged;
            watcher.Created += OnChanged;

            watcher.EnableRaisingEvents = true; // Begin watching.

            // connect on start of Rider
            CreateProtocol(protocolInstancePath, mySolution.GetProtocolSolution());
        }
Esempio n. 12
0
        public UnityRefresher(IShellLocks locks, Lifetime lifetime, ISolution solution, UnityEditorProtocol pluginProtocolController, ISettingsStore settingsStore)
        {
            myLocks    = locks;
            myLifetime = lifetime;
            mySolution = solution;
            myPluginProtocolController = pluginProtocolController;

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

            myBoundSettingsStore = settingsStore.BindToContextLive(myLifetime, ContextRange.Smart(solution.ToDataContext()));

            myPluginProtocolController.Refresh.Advise(lifetime, Refresh);
        }
Esempio n. 13
0
        public UnityController(Lifetime lifetime,
                               ISolution solution,
                               BackendUnityHost backendUnityHost,
                               UnityVersion unityVersion)
        {
            if (solution.GetData(ProjectModelExtensions.ProtocolSolutionKey) == null)
            {
                return;
            }

            myBackendUnityHost     = backendUnityHost;
            myUnityVersion         = unityVersion;
            mySolution             = solution;
            myLifetime             = lifetime;
            myFrontendBackendModel = solution.GetProtocolSolution().GetFrontendBackendModel();
        }
Esempio n. 14
0
        public UnityRefresher(IShellLocks locks, Lifetime lifetime, ISolution solution,
                              UnityEditorProtocol editorProtocol, ISettingsStore settingsStore,
                              ILogger logger)
        {
            myLocks          = locks;
            myLifetime       = lifetime;
            mySolution       = solution;
            myEditorProtocol = editorProtocol;
            myLogger         = logger;

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

            myBoundSettingsStore = settingsStore.BindToContextLive(myLifetime, ContextRange.Smart(solution.ToDataContext()));
        }
Esempio n. 15
0
        public BackendUnityProtocol(Lifetime lifetime, ILogger logger,
                                    BackendUnityHost backendUnityHost, FrontendBackendHost frontendBackendHost,
                                    IScheduler dispatcher, IShellLocks locks, ISolution solution,
                                    IApplicationWideContextBoundSettingStore settingsStore,
                                    UnitySolutionTracker unitySolutionTracker,
                                    UnityVersion unityVersion, NotificationsModel notificationsModel,
                                    IHostProductInfo hostProductInfo, IFileSystemTracker fileSystemTracker)
        {
            myPluginInstallations = new JetHashSet <FileSystemPath>();

            myLifetime            = lifetime;
            myLogger              = logger;
            myBackendUnityHost    = backendUnityHost;
            myDispatcher          = dispatcher;
            myLocks               = locks;
            mySolution            = solution;
            myUnityVersion        = unityVersion;
            myNotificationsModel  = notificationsModel;
            myHostProductInfo     = hostProductInfo;
            myFrontendBackendHost = frontendBackendHost;
            myBoundSettingsStore  = settingsStore.BoundSettingsStore;
            mySessionLifetimes    = new SequentialLifetimes(lifetime);

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

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

                var solFolder = mySolution.SolutionDirectory;

                // todo: consider non-Unity Solution with Unity-generated projects
                var protocolInstancePath = solFolder.Combine("Library/ProtocolInstance.json");
                fileSystemTracker.AdviseFileChanges(lf, protocolInstancePath, OnProtocolInstanceJsonChange);

                // connect on start of Rider
                CreateProtocol(protocolInstancePath);
            });
        }
        public UnityEditorProtocol(Lifetime lifetime, ILogger logger, UnityHost host,
                                   IScheduler dispatcher, IShellLocks locks, ISolution solution,
                                   ISettingsStore settingsStore, JetBrains.Application.ActivityTrackingNew.UsageStatistics usageStatistics,
                                   UnitySolutionTracker unitySolutionTracker, IThreading threading,
                                   UnityVersion unityVersion, NotificationsModel notificationsModel,
                                   IHostProductInfo hostProductInfo, IFileSystemTracker fileSystemTracker)
        {
            myPluginInstallations = new JetHashSet <FileSystemPath>();

            myComponentLifetime  = lifetime;
            myLogger             = logger;
            myDispatcher         = dispatcher;
            myLocks              = locks;
            mySolution           = solution;
            myUsageStatistics    = usageStatistics;
            myThreading          = threading;
            myUnityVersion       = unityVersion;
            myNotificationsModel = notificationsModel;
            myHostProductInfo    = hostProductInfo;
            myHost = host;
            myBoundSettingsStore = settingsStore.BindToContextLive(lifetime, ContextRange.Smart(solution.ToDataContext()));
            mySessionLifetimes   = new SequentialLifetimes(lifetime);

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

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

                var solFolder = mySolution.SolutionDirectory;
                AdviseModelData(lifetime);

                // todo: consider non-Unity Solution with Unity-generated projects
                var protocolInstancePath = solFolder.Combine("Library/ProtocolInstance.json");
                fileSystemTracker.AdviseFileChanges(lf, protocolInstancePath, OnChangeAction);
                // connect on start of Rider
                CreateProtocols(protocolInstancePath);
            });
        }
        public UnityRefresher(IShellLocks locks, Lifetime lifetime, ISolution solution,
                              BackendUnityHost backendUnityHost,
                              IApplicationWideContextBoundSettingStore settingsStore,
                              ILogger logger, UnityVersion unityVersion)
        {
            myLocks            = locks;
            myLifetime         = lifetime;
            mySolution         = solution;
            myBackendUnityHost = backendUnityHost;
            myLogger           = logger;
            myUnityVersion     = unityVersion;

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

            myBoundSettingsStore = settingsStore.BoundSettingsStore;
        }
Esempio n. 18
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);
            });
        }
Esempio n. 19
0
        public UnityNUnitServiceProvider(ISolution solution, IPsiModules psiModules, ISymbolCache symbolCache,
                                         IUnitTestElementIdFactory idFactory, IUnitTestElementManager elementManager, NUnitTestProvider provider,
                                         ISettingsStore settingsStore, ISettingsOptimization settingsOptimization, ISettingsCache settingsCache,
                                         UnitTestingCachingService cachingService, IDotNetCoreSdkResolver dotNetCoreSdkResolver,
                                         UnityEditorProtocol editorProtocol,
                                         RunViaUnityEditorStrategy runViaUnityEditorStrategy,
                                         NUnitOutOfProcessUnitTestRunStrategy nUnitOutOfProcessUnitTestRunStrategy)
            : base(solution, psiModules, symbolCache, idFactory, elementManager, provider, settingsStore,
                   settingsOptimization, settingsCache, cachingService, dotNetCoreSdkResolver, nUnitOutOfProcessUnitTestRunStrategy)
        {
            if (solution.GetData(ProjectModelExtensions.ProtocolSolutionKey) == null)
            {
                return;
            }

            myRdUnityModel = solution.GetProtocolSolution().GetRdUnityModel();

            myEditorModel         = editorProtocol.UnityModel;
            myUnityEditorStrategy = runViaUnityEditorStrategy;
        }