public UnityUsagesFinderConsumer(AssetHierarchyProcessor assetHierarchyProcessor, IPersistentIndexManager persistentIndexManager,
                                  FileSystemPath solutionDirectoryPath)
 {
     myAssetHierarchyProcessor = assetHierarchyProcessor;
     myPersistentIndexManager  = persistentIndexManager;
     mySolutionDirectoryPath   = solutionDirectoryPath;
 }
 public UnityUsagesFinderConsumer(AssetHierarchyProcessor assetHierarchyProcessor,
                                  [NotNull] AnimatorScriptUsagesElementContainer animatorContainer,
                                  IPersistentIndexManager persistentIndexManager,
                                  FileSystemPath solutionDirectoryPath,
                                  [NotNull] IDeclaredElement declaredElement)
 {
     myAssetHierarchyProcessor = assetHierarchyProcessor;
     myPersistentIndexManager  = persistentIndexManager;
     mySolutionDirectoryPath   = solutionDirectoryPath;
     myAnimatorContainer       = animatorContainer;
     myDeclaredElement         = declaredElement;
 }
        private string GetAttachedGameObjectName(AssetHierarchyProcessor processor, UnityAssetOccurrence occurrence)
        {
            var consumer = new UnityScenePathGameObjectConsumer();

            processor.ProcessSceneHierarchyFromComponentToRoot(occurrence.AttachedElementLocation, consumer, true, true);

            var parts = consumer.NameParts;

            if (parts.Count == 0)
            {
                return("...");
            }
            return(string.Join("/", consumer.NameParts));
        }
 public UnityEditorFindUsageResultCreator(Lifetime lifetime, ISolution solution, SearchDomainFactory searchDomainFactory, IShellLocks locks,
                                          AssetHierarchyProcessor assetHierarchyProcessor, UnityHost unityHost, UnityExternalFilesModuleFactory externalFilesModuleFactory,
                                          UnityEditorProtocol editorProtocol, IPersistentIndexManager persistentIndexManager,
                                          [CanBeNull] RiderBackgroundTaskHost backgroundTaskHost = null)
 {
     myLifetime = lifetime;
     mySolution = solution;
     myLocks    = locks;
     myAssetHierarchyProcessor = assetHierarchyProcessor;
     myBackgroundTaskHost      = backgroundTaskHost;
     myYamlSearchDomain        = searchDomainFactory.CreateSearchDomain(externalFilesModuleFactory.PsiModule);
     myUnityHost              = unityHost;
     myEditorProtocol         = editorProtocol;
     myPersistentIndexManager = persistentIndexManager;
     mySolutionDirectoryPath  = solution.SolutionDirectory;
 }
 public UnityEditorFindUsageResultCreator(Lifetime lifetime, ISolution solution,
                                          SearchDomainFactory searchDomainFactory, IShellLocks locks,
                                          AssetHierarchyProcessor assetHierarchyProcessor,
                                          BackendUnityHost backendUnityHost,
                                          FrontendBackendHost frontendBackendHost,
                                          UnityExternalFilesModuleFactory externalFilesModuleFactory,
                                          IPersistentIndexManager persistentIndexManager,
                                          [NotNull] AnimatorScriptUsagesElementContainer animatorContainer,
                                          [CanBeNull] RiderBackgroundTaskHost backgroundTaskHost = null)
 {
     myLifetime = lifetime;
     mySolution = solution;
     myLocks    = locks;
     myAssetHierarchyProcessor = assetHierarchyProcessor;
     myBackendUnityHost        = backendUnityHost;
     myBackgroundTaskHost      = backgroundTaskHost;
     myYamlSearchDomain        = searchDomainFactory.CreateSearchDomain(externalFilesModuleFactory.PsiModule);
     myFrontendBackendHost     = frontendBackendHost;
     myAnimatorContainer       = animatorContainer;
     myPersistentIndexManager  = persistentIndexManager;
     mySolutionDirectoryPath   = solution.SolutionDirectory;
 }
        private static AssetFindUsagesResultBase CreateRequest(FileSystemPath solutionDirPath,
                                                               AssetHierarchyProcessor assetDocumentHierarchy,
                                                               [NotNull]
                                                               AnimatorScriptUsagesElementContainer animatorContainer,
                                                               LocalReference location, IPsiSourceFile sourceFile,
                                                               [NotNull] IDeclaredElement declaredElement,
                                                               bool needExpand = false)
        {
            if (!GetPathFromAssetFolder(solutionDirPath, sourceFile, out var pathFromAsset, out var fileName, out var extension))
            {
                return(null);
            }

            var path = sourceFile.GetLocation();

            if (path.IsControllerFile() &&
                animatorContainer.GetElementsNames(location, declaredElement, out var names, out var isStateMachine) &&
                names != null)
            {
                return(new AnimatorFindUsagesResult(names,
                                                    isStateMachine ? AnimatorUsageType.StateMachine : AnimatorUsageType.State, needExpand,
                                                    pathFromAsset, fileName, extension));
            }
            if (path.ExtensionWithDot.EndsWith(UnityYamlFileExtensions.AssetFileExtensionWithDot))
            {
                return(new AssetFindUsagesResult(needExpand, pathFromAsset, fileName, extension));
            }

            if (path.IsAnimFile())
            {
                return(new AnimationFindUsagesResult(needExpand, pathFromAsset, fileName, extension));
            }

            var consumer = new UnityScenePathGameObjectConsumer();

            assetDocumentHierarchy.ProcessSceneHierarchyFromComponentToRoot(location, consumer, true, true);

            return(new HierarchyFindUsagesResult(consumer.NameParts.ToArray(), consumer.RootIndexes.ToArray(), needExpand, pathFromAsset, fileName, extension));
        }
        private static AssetFindUsagesResultBase CreateRequest(FileSystemPath solutionDirPath, AssetHierarchyProcessor assetDocumentHierarchy,
                                                               LocalReference location, IPsiSourceFile sourceFile, bool needExpand = false)
        {
            if (!GetPathFromAssetFolder(solutionDirPath, sourceFile, out var pathFromAsset, out var fileName, out var extension))
            {
                return(null);
            }

            if (sourceFile.GetLocation().ExtensionWithDot.EndsWith(UnityYamlFileExtensions.AssetFileExtensionWithDot))
            {
                return(new AssetFindUsagesResult(needExpand, pathFromAsset, fileName, extension));
            }

            var consumer = new UnityScenePathGameObjectConsumer();

            assetDocumentHierarchy.ProcessSceneHierarchyFromComponentToRoot(location, consumer, true, true);

            return(new HierarchyFindUsagesResult(consumer.NameParts.ToArray(), consumer.RootIndexes.ToArray(), needExpand, pathFromAsset, fileName, extension));
        }