Example #1
0
        public void CreateRequestToUnity([NotNull] IDeclaredElement declaredElement, IPsiSourceFile selectedSourceFile, string selectAnchor, bool focusUnity)
        {
            var finder   = mySolution.GetPsiServices().AsyncFinder;
            var consumer = new UnityUsagesFinderConsumer(myUnitySceneDataLocalCache, mySolutionDirectoryPath);

            var selectRequest = (selectedSourceFile == null || selectAnchor == null)
                ? null
                : CreateRequest(mySolutionDirectoryPath, myUnitySceneDataLocalCache, selectAnchor, selectedSourceFile, false);


            var lifetimeDef = myLifetime.CreateNested();
            var pi          = new ProgressIndicator(myLifetime);

            if (myBackgroundTaskHost != null)
            {
                var task = RiderBackgroundTaskBuilder.Create()
                           .WithTitle("Finding usages in Unity for: " + declaredElement.ShortName)
                           .AsIndeterminate()
                           .AsCancelable(() => { pi.Cancel(); })
                           .Build();

                myBackgroundTaskHost.AddNewTask(lifetimeDef.Lifetime, task);
            }

            myLocks.Tasks.StartNew(myLifetime, Scheduling.MainGuard, () =>
            {
                using (ReadLockCookie.Create())
                {
                    finder.FindAsync(new[] { declaredElement }, myYamlSearchDomain,
                                     consumer, SearchPattern.FIND_USAGES, pi,
                                     FinderSearchRoot.Empty, new UnityUsagesAsyncFinderCallback(lifetimeDef, myLifetime, consumer, myUnityHost, myEditorProtocol, myLocks,
                                                                                                declaredElement.ShortName, selectRequest, focusUnity));
                }
            });
        }
        public void CreateRequestToUnity([NotNull] IDeclaredElement declaredElement, LocalReference location, bool focusUnity)
        {
            var finder   = mySolution.GetPsiServices().AsyncFinder;
            var consumer = new UnityUsagesFinderConsumer(myAssetHierarchyProcessor, myAnimatorContainer, myPersistentIndexManager,
                                                         mySolutionDirectoryPath, declaredElement);

            var sourceFile = myPersistentIndexManager[location.OwningPsiPersistentIndex];

            if (sourceFile == null)
            {
                return;
            }

            var selectRequest = CreateRequest(mySolutionDirectoryPath, myAssetHierarchyProcessor, myAnimatorContainer,
                                              location, sourceFile, declaredElement, false);


            var lifetimeDef = myLifetime.CreateNested();
            var pi          = new ProgressIndicator(myLifetime);

            if (myBackgroundTaskHost != null)
            {
                var task = RiderBackgroundTaskBuilder.Create()
                           .WithTitle("Finding usages in Unity for: " + declaredElement.ShortName)
                           .AsIndeterminate()
                           .AsCancelable(() => { pi.Cancel(); })
                           .Build();

                myBackgroundTaskHost.AddNewTask(lifetimeDef.Lifetime, task);
            }

            myLocks.Tasks.StartNew(myLifetime, Scheduling.MainGuard, () =>
            {
                using (ReadLockCookie.Create())
                {
                    finder.FindAsync(new[] { declaredElement }, myYamlSearchDomain,
                                     consumer, SearchPattern.FIND_USAGES, pi,
                                     FinderSearchRoot.Empty, new UnityUsagesAsyncFinderCallback(lifetimeDef, myLifetime, consumer, myFrontendBackendHost, myBackendUnityHost, myLocks,
                                                                                                declaredElement.ShortName, selectRequest, focusUnity));
                }
            });
        }