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 void Complete()
            {
                myShellLocks.Tasks.StartNew(myComponentLifetime, Scheduling.MainGuard, () =>
                {
                    if (myConsumer.Result.Count != 0)
                    {
                        if (myBackendUnityHost.BackendUnityModel.Value == null)
                        {
                            return;
                        }

                        myFrontendBackendHost.Do(a => a.AllowSetForegroundWindow.Start(Unit.Instance).Result
                                                 .AdviseOnce(myComponentLifetime,
                                                             result =>
                        {
                            var model = myBackendUnityHost.BackendUnityModel.Value;
                            if (mySelected != null)
                            {
                                model.ShowUsagesInUnity.Fire(mySelected);
                            }
                            // pass all references to Unity TODO temp workaround, replace with async api
                            model.SendFindUsagesSessionResult.Fire(new FindUsagesSessionResult(myDisplayName, myConsumer.Result.ToArray()));
                        }));
                    }

                    myProgressBarLifetimeDefinition.Terminate();
                });
            }
 public void OnExtraActionClick(CodeInsightsHighlighting highlighting, string actionId, ISolution solution)
 {
     if (actionId.Equals(StartUnityActionId))
     {
         myFrontendBackendHost.Do(model => model.StartUnity());
     }
 }
 public UnityReferenceSynchronizer(Lifetime lifetime, FrontendBackendHost host, UnityReferencesTracker referencesTracker)
 {
     host.Do(m =>
     {
         referencesTracker.HasUnityReference.Advise(lifetime, res => { m.HasUnityReference.SetValue(res); });
     });
 }
Esempio n. 5
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));
        }
        public AssetModeNotification(UnitySolutionTracker solutionTracker, AssetSerializationMode assetSerializationMode, FrontendBackendHost frontendBackendHost)
        {
            if (!solutionTracker.IsUnityProject.HasTrueValue())
            {
                return;
            }

            if (!assetSerializationMode.IsForceText)
            {
                frontendBackendHost.Do(t => t.NotifyAssetModeForceText());
            }
        }
Esempio n. 8
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();
            });
        }
        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);
            });
        }
Esempio n. 10
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));
                });
            });
        }
        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();
            });
        }
Esempio n. 12
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);
                    }
                });
            });
        }
Esempio n. 13
0
 protected override void NotifyYamlParsingDisabled()
 {
     myFrontendBackendHost.Do(t => t.NotifyYamlHugeFiles());
 }
Esempio n. 14
0
 protected override void ShowNotification()
 {
     myFrontendBackendHost.Do(t => t.ShowDeferredCachesProgressNotification());
 }