Ejemplo n.º 1
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,
                                         FrontendBackendHost frontendBackendHost,
                                         BackendUnityHost backendUnityHost,
                                         RunViaUnityEditorStrategy runViaUnityEditorStrategy,
                                         UnitySolutionTracker unitySolutionTracker)
            : base(solution, psiModules, symbolCache, idFactory, elementManager, provider, settings, settingsStore,
                   settingsOptimization, settingsCache, cachingService, testParametersProvider)
        {
            // Only in tests
            if (!frontendBackendHost.IsAvailable)
            {
                return;
            }

            myFrontendBackendModel = frontendBackendHost.Model.NotNull("frontendBackendHost.Model != null");
            myBackendUnityHost     = backendUnityHost;
            myUnityEditorStrategy  = runViaUnityEditorStrategy;
            myUnitySolutionTracker = unitySolutionTracker;
        }
 public UnityReferenceSynchronizer(Lifetime lifetime, FrontendBackendHost host, UnityReferencesTracker referencesTracker)
 {
     host.Do(m =>
     {
         referencesTracker.HasUnityReference.Advise(lifetime, res => { m.HasUnityReference.SetValue(res); });
     });
 }
        private void NotifyFrontend(FrontendBackendHost host, UnityVersion unityVersion, Version version)
        {
            host.Do(rd =>
            {
                // if model is there, then ApplicationPath was already set via UnityEditorProtocol, it would be more
                // correct than any counted value
                if (myBackendUnityHost.BackendUnityModel.Value != null)
                {
                    return;
                }

                var info = UnityInstallationFinder.GetApplicationInfo(version, unityVersion);
                if (info == null)
                {
                    return;
                }

                var contentsPath = UnityInstallationFinder.GetApplicationContentsPath(info.Path);
                rd.UnityApplicationData.SetValue(new UnityApplicationData(info.Path.FullPath,
                                                                          contentsPath.FullPath,
                                                                          UnityVersion.VersionToString(info.Version),
                                                                          null, null, null));
                rd.RequiresRiderPackage.Set(UnityVersion.RequiresRiderPackage(info.Version));
            });
        }
 public UnityCodeInsightProvider(FrontendBackendHost frontendBackendHost, UnitySolutionTracker solutionTracker,
                                 BulbMenuComponent bulbMenu, UnitySolutionTracker tracker)
     : base(frontendBackendHost, bulbMenu)
 {
     RelativeOrderings = tracker.IsUnityProject.HasTrueValue()
         ? new CodeLensRelativeOrdering[] { new CodeLensRelativeOrderingBefore(ReferencesCodeInsightsProvider.Id) }
         : new CodeLensRelativeOrdering[] { new CodeLensRelativeOrderingLast() };
 }
 public UnityInstallationSynchronizer(Lifetime lifetime,
                                      FrontendBackendHost frontendBackendHost,
                                      BackendUnityHost backendUnityHost,
                                      UnityVersion unityVersion)
 {
     myBackendUnityHost = backendUnityHost;
     unityVersion.ActualVersionForSolution.Advise(lifetime,
                                                  version => NotifyFrontend(frontendBackendHost, unityVersion, version));
 }
        public RunViaUnityEditorStrategy(ISolution solution,
                                         IUnitTestResultManager unitTestResultManager,
                                         BackendUnityHost backendUnityHost,
                                         NUnitTestProvider unitTestProvider,
                                         IUnitTestElementIdFactory idFactory,
                                         ISolutionSaver riderSolutionSaver,
                                         UnityRefresher unityRefresher,
                                         NotificationsModel notificationsModel,
                                         FrontendBackendHost frontendBackendHost,
                                         ILogger logger,
                                         Lifetime lifetime,
                                         PackageValidator packageValidator,
                                         JetBrains.Application.ActivityTrackingNew.UsageStatistics usageStatistics)
        {
            mySolution = solution;
            myUnitTestResultManager = unitTestResultManager;
            myBackendUnityHost      = backendUnityHost;
            myUnitTestProvider      = unitTestProvider;
            myIDFactory             = idFactory;
            myRiderSolutionSaver    = riderSolutionSaver;
            myUnityRefresher        = unityRefresher;
            myNotificationsModel    = notificationsModel;
            myFrontendBackendHost   = frontendBackendHost;
            myLogger           = logger;
            myLifetime         = lifetime;
            myPackageValidator = packageValidator;
            myUsageStatistics  = usageStatistics;

            myUnityProcessId = new Property <int?>(lifetime, "RunViaUnityEditorStrategy.UnityProcessId");

            myUnityProcessId.ForEachValue_NotNull(lifetime, (lt, processId) =>
            {
                var process = myLogger.CatchIgnore(() => Process.GetProcessById(processId.NotNull()));
                if (process == null)
                {
                    myUnityProcessId.Value = null;
                    return;
                }

                process.EnableRaisingEvents = true;

                void OnProcessExited(object sender, EventArgs a) => myUnityProcessId.Value = null;
                lt.Bracket(() => process.Exited += OnProcessExited, () => process.Exited -= OnProcessExited);

                if (process.HasExited)
                {
                    myUnityProcessId.Value = null;
                }
            });

            myBackendUnityHost.BackendUnityModel.ViewNotNull(lifetime, (lt, model) =>
            {
                // This will set the current value, if it exists
                model.UnityApplicationData.FlowInto(lt, myUnityProcessId, data => data.UnityProcessId);
            });
        }
Ejemplo n.º 7
0
        public RiderUnityYamlDisableStrategy(Lifetime lifetime, ISolution solution, SolutionCaches solutionCaches,
                                             IApplicationWideContextBoundSettingStore settingsStore,
                                             AssetIndexingSupport assetIndexingSupport, FrontendBackendHost frontendBackendHost)
            : base(lifetime, solution, solutionCaches, settingsStore, assetIndexingSupport)
        {
            myFrontendBackendHost = frontendBackendHost;

            myFrontendBackendHost.Do(t =>
                                     t.EnableYamlParsing.Advise(lifetime, _ => assetIndexingSupport.IsEnabled.Value = true));
        }
        public static Action ProcessDataContext(
            Lifetime lifetime,
            [NotNull, ContextKey(typeof(ContextHighlighterPsiFileView.ContextKey))] IPsiDocumentRangeView psiDocumentRangeView,
            FrontendBackendHost frontendBackendHost,
            UnityApi unityApi)
        {
            var unityName = GetUnityName(psiDocumentRangeView, unityApi);

            // This is called only if the process finished while the context is still valid
            return(() => frontendBackendHost.Do(rd => rd.ExternalDocContext.Value = unityName));
        }
Ejemplo n.º 9
0
        public UnityPluginInstaller(
            Lifetime lifetime,
            ILogger logger,
            ISolution solution,
            IShellLocks shellLocks,
            UnityPluginDetector detector,
            NotificationsModel notifications,
            IApplicationWideContextBoundSettingStore settingsStore,
            PluginPathsProvider pluginPathsProvider,
            UnityVersion unityVersion,
            FrontendBackendHost frontendBackendHost,
            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.BoundSettingsStore;
            myQueue = new ProcessingQueue(myShellLocks, myLifetime);

            frontendBackendHost.Do(frontendBackendModel =>
            {
                frontendBackendModel.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();
            });
        }
Ejemplo n.º 10
0
 public UnityCodeInsightFieldUsageProvider(UnitySolutionTracker unitySolutionTracker,
                                           FrontendBackendHost frontendBackendHost, BulbMenuComponent bulbMenu,
                                           DeferredCacheController deferredCacheController,
                                           AssetInspectorValuesContainer inspectorValuesContainer,
                                           UnityEventsElementContainer unityEventsElementContainer)
     : base(frontendBackendHost, bulbMenu)
 {
     myDeferredCacheController     = deferredCacheController;
     myInspectorValuesContainer    = inspectorValuesContainer;
     myUnityEventsElementContainer = unityEventsElementContainer;
     myActionManager = Shell.Instance.GetComponent <IActionManager>();
     myContexts      = Shell.Instance.GetComponent <DataContexts>();
 }
        public UnityRefreshTracker(Lifetime lifetime, ISolution solution, UnityRefresher refresher,
                                   ILogger logger,
                                   IFileSystemTracker fileSystemTracker,
                                   FrontendBackendHost host,
                                   UnitySolutionTracker unitySolutionTracker)
        {
            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.StartRefresh(RefreshType.Normal);
                });

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

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

                fileSystemTracker.RegisterPrioritySink(lifetime, FileSystemChange, HandlingPriority.Other);
            });
        }
 public UnityUsagesAsyncFinderCallback(LifetimeDefinition progressBarLifetimeDefinition,
                                       Lifetime componentLifetime, UnityUsagesFinderConsumer consumer,
                                       FrontendBackendHost frontendBackendHost,
                                       BackendUnityHost backendUnityHost, IShellLocks shellLocks,
                                       string displayName, AssetFindUsagesResultBase selected,
                                       bool focusUnity)
 {
     myProgressBarLifetimeDefinition = progressBarLifetimeDefinition;
     myComponentLifetime             = componentLifetime;
     myConsumer            = consumer;
     myFrontendBackendHost = frontendBackendHost;
     myBackendUnityHost    = backendUnityHost;
     myShellLocks          = shellLocks;
     myDisplayName         = displayName;
     mySelected            = selected;
 }
Ejemplo n.º 13
0
        private static void BindSettingToProperty <TKeyClass, TEntryMemberType>(
            Lifetime lifetime, ISolution solution, FrontendBackendHost frontendBackendHost,
            IContextBoundSettingsStoreLive boundStore,
            Expression <Func <TKeyClass, TEntryMemberType> > entry,
            Action <FrontendBackendModel, PropertyChangedEventArgs <TEntryMemberType> > action)
        {
            var name    = entry.GetInstanceMemberName();
            var setting = boundStore.Schema.GetScalarEntry(entry);

            boundStore.GetValueProperty <TEntryMemberType>(lifetime, setting, null).Change.Advise_HasNew(lifetime,
                                                                                                         args =>
            {
                solution.Locks.ExecuteOrQueueEx(lifetime, name, () =>
                {
                    frontendBackendHost.Do(m => action(m, args));
                });
            });
        }
Ejemplo n.º 14
0
        public UnitySettingsSynchronizer(Lifetime lifetime, ISolution solution, FrontendBackendHost host,
                                         IApplicationWideContextBoundSettingStore settingsStore)
        {
            var boundStore = settingsStore.BoundSettingsStore;

            BindSettingToProperty(lifetime, solution, host, boundStore,
                                  (UnitySettings s) => s.EnableShaderLabHippieCompletion,
                                  (model, args) => model.BackendSettings.EnableShaderLabHippieCompletion.Value = args.New);

            BindSettingToProperty(lifetime, solution, host, boundStore,
                                  (UnitySettings s) => s.UseUnityYamlMerge,
                                  (model, args) => model.BackendSettings.UseUnityYamlMerge.Value = args.New);
            BindSettingToProperty(lifetime, solution, host, boundStore,
                                  (UnitySettings s) => s.MergeParameters,
                                  (model, args) => model.BackendSettings.MergeParameters.Value = args.New);

            BindSettingToProperty(lifetime, solution, host, boundStore,
                                  (UnitySettings s) => s.EnableDebuggerExtensions,
                                  (model, args) => model.BackendSettings.EnableDebuggerExtensions.Value = args.New);
        }
 public UnityEditorFindUsageResultCreator(Lifetime lifetime, ISolution solution,
                                          SearchDomainFactory searchDomainFactory, IShellLocks locks,
                                          AssetHierarchyProcessor assetHierarchyProcessor,
                                          BackendUnityHost backendUnityHost,
                                          FrontendBackendHost frontendBackendHost,
                                          UnityExternalFilesModuleFactory externalFilesModuleFactory,
                                          IPersistentIndexManager persistentIndexManager,
                                          [CanBeNull] RiderBackgroundTaskHost backgroundTaskHost = null)
 {
     myLifetime = lifetime;
     mySolution = solution;
     myLocks    = locks;
     myAssetHierarchyProcessor = assetHierarchyProcessor;
     myBackendUnityHost        = backendUnityHost;
     myBackgroundTaskHost      = backgroundTaskHost;
     myYamlSearchDomain        = searchDomainFactory.CreateSearchDomain(externalFilesModuleFactory.PsiModule);
     myFrontendBackendHost     = frontendBackendHost;
     myPersistentIndexManager  = persistentIndexManager;
     mySolutionDirectoryPath   = solution.SolutionDirectory;
 }
Ejemplo n.º 16
0
 public RiderUnityUsagesNotification(FrontendBackendHost frontendBackendHost, DeferredCacheController controller)
     : base(controller)
 {
     myFrontendBackendHost = frontendBackendHost;
 }
        public AssetModeNotification(UnitySolutionTracker solutionTracker, AssetSerializationMode assetSerializationMode, FrontendBackendHost frontendBackendHost)
        {
            if (!solutionTracker.IsUnityProject.HasTrueValue())
            {
                return;
            }

            if (!assetSerializationMode.IsForceText)
            {
                frontendBackendHost.Do(t => t.NotifyAssetModeForceText());
            }
        }
 protected AbstractUnityCodeInsightProvider(FrontendBackendHost frontendBackendHost, BulbMenuComponent bulbMenu)
 {
     myFrontendBackendHost = frontendBackendHost;
     myBulbMenu            = bulbMenu;
 }
        public GeneratedFileNotification(Lifetime lifetime,
                                         FrontendBackendHost frontendBackendHost,
                                         BackendUnityHost backendUnityHost,
                                         UnitySolutionTracker solutionTracker,
                                         ISolution solution,
                                         AsmDefNameCache asmDefNameCache,
                                         [CanBeNull] TextControlHost textControlHost             = null,
                                         [CanBeNull] SolutionLifecycleHost solutionLifecycleHost = null,
                                         [CanBeNull] NotificationPanelHost notificationPanelHost = null)
        {
            if (solutionLifecycleHost == null)
            {
                return;
            }

            if (!solutionTracker.IsUnityGeneratedProject.Value)
            {
                return;
            }

            var fullStartupFinishedLifetimeDefinition = new LifetimeDefinition(lifetime);

            solutionLifecycleHost.FullStartupFinished.Advise(fullStartupFinishedLifetimeDefinition.Lifetime, _ =>
            {
                textControlHost.ViewHostTextControls(lifetime, (lt, id, host) =>
                {
                    var projectFile = host.ToProjectFile(solution);
                    if (projectFile == null)
                    {
                        return;
                    }

                    if (!projectFile.Location.ExtensionNoDot.Equals("csproj", StringComparison.OrdinalIgnoreCase))
                    {
                        return;
                    }

                    backendUnityHost.BackendUnityModel.ViewNotNull(lt, (modelLifetime, backendUnityModel) =>
                    {
                        var name = projectFile.Location.NameWithoutExtension;

                        IPath path;
                        using (ReadLockCookie.Create())
                        {
                            path = asmDefNameCache.GetPathFor(name)?.TryMakeRelativeTo(solution.SolutionFilePath);
                        }

                        var elements = new LocalList <INotificationPanelHyperlink>();
                        if (path != null)
                        {
                            var strPath = path.Components.Join("/").RemoveStart("../");
                            elements.Add(new NotificationPanelCallbackHyperlink(modelLifetime,
                                                                                "Edit corresponding .asmdef in Unity", false,
                                                                                () =>
                            {
                                frontendBackendHost.Do(t =>
                                {
                                    t.AllowSetForegroundWindow.Start(modelLifetime, Unit.Instance)
                                    .Result.AdviseOnce(modelLifetime, __ =>
                                    {
                                        backendUnityHost.BackendUnityModel.Value?.ShowFileInUnity.Fire(strPath);
                                    });
                                });
                            }));
                        }

                        notificationPanelHost.AddNotificationPanel(modelLifetime, host,
                                                                   new NotificationPanel("This file is generated by Unity. Any changes made will be lost.",
                                                                                         "UnityGeneratedFile", elements.ToArray()));
                    });
                });

                fullStartupFinishedLifetimeDefinition.Terminate();
            });
        }
Ejemplo n.º 20
0
        public ShaderContextHost(Lifetime lifetime, ISolution solution, IPsiFiles psiFiles,
                                 CppGlobalSymbolCache cppGlobalSymbolCache,
                                 ShaderContextCache shaderContextCache,
                                 ShaderContextDataPresentationCache shaderContextDataPresentationCache, ILogger logger,
                                 [CanBeNull] FrontendBackendHost frontendBackendHost = null,
                                 [CanBeNull] RiderDocumentHost documentHost          = null)
        {
            mySolution             = solution;
            myPsiFiles             = psiFiles;
            myCppGlobalSymbolCache = cppGlobalSymbolCache;
            myDocumentHost         = documentHost;
            myShaderContextCache   = shaderContextCache;
            myShaderContextDataPresentationCache = shaderContextDataPresentationCache;

            if (frontendBackendHost == null || documentHost == null)
            {
                return;
            }

            frontendBackendHost.Do(t =>
            {
                t.RequestShaderContexts.Set((lt, id) =>
                {
                    logger.Verbose("Requesting all shader context for file");
                    using (ReadLockCookie.Create())
                    {
                        var sourceFile = GetSourceFile(id);
                        if (sourceFile == null)
                        {
                            return(Rd.Tasks.RdTask <List <ShaderContextDataBase> > .Successful(
                                       new List <ShaderContextDataBase>()));
                        }
                        var task = new Rd.Tasks.RdTask <List <ShaderContextDataBase> >();
                        RequestShaderContexts(lt, sourceFile, task);

                        return(task);
                    }
                });

                t.ChangeContext.Advise(lifetime, c =>
                {
                    logger.Verbose("Setting new shader context for file");
                    using (ReadLockCookie.Create())
                    {
                        IPsiSourceFile sourceFile = GetSourceFile(c.Target);
                        if (sourceFile == null)
                        {
                            return;
                        }

                        var cppFileLocation = new CppFileLocation(
                            new FileSystemPathWithRange(FileSystemPath.Parse(c.Path), new TextRange(c.Start, c.End)));
                        shaderContextCache.SetContext(sourceFile, cppFileLocation);
                    }
                });

                t.SetAutoShaderContext.Advise(lifetime, id =>
                {
                    using (ReadLockCookie.Create())
                    {
                        IPsiSourceFile sourceFile = GetSourceFile(id);
                        if (sourceFile == null)
                        {
                            return;
                        }
                        shaderContextCache.SetContext(sourceFile, null);
                    }
                });

                t.RequestCurrentContext.Set((lt, id) =>
                {
                    logger.Verbose("Setting current context for file");
                    using (ReadLockCookie.Create())
                    {
                        var sourceFile = GetSourceFile(id);
                        if (sourceFile == null)
                        {
                            return(Rd.Tasks.RdTask <ShaderContextDataBase> .Successful(new AutoShaderContextData()));
                        }

                        var task = new Rd.Tasks.RdTask <ShaderContextDataBase>();
                        RequestCurrentContext(lt, sourceFile, task);
                        return(task);
                    }
                });
            });
        }