public static ProjectReferenceItem[] FindAssetsReferences(FilterItem[] assets, bool ignoreClearOption, bool showResults)
        {
            if (UserSettings.References.selectedFindClearsProjectResults && !ignoreClearOption)
            {
                SearchResultsStorage.ProjectReferencesLastSearched  = new FilterItem[0];
                SearchResultsStorage.ProjectReferencesSearchResults = new ProjectReferenceItem[0];
            }

            var lastSearched = SearchResultsStorage.ProjectReferencesLastSearched;
            var newItem      = false;

            foreach (var asset in assets)
            {
                newItem |= CSFilterTools.TryAddNewItemToFilters(ref lastSearched, asset);
            }

            if (assets.Length == 1)
            {
                ProjectReferencesTab.AutoSelectPath = assets[0].value;
            }

            if (newItem)
            {
                return(FindAssetsReferences(lastSearched, assets, showResults));
            }

            //ReferencesTab.AutoShowExistsNotification = true;
            MaintainerWindow.ShowAssetReferences();

            return(SearchResultsStorage.ProjectReferencesSearchResults);
        }
        public static ProjectReferenceItem[] FindAssetsReferences(FilterItem[] allTargetAssets, FilterItem[] newTargetAssets, bool showResults = true)
        {
            var results = new List <ProjectReferenceItem>();

            ConjunctionInfoList.Clear();

            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh(ImportAssetOptions.ForceSynchronousImport);

            try
            {
                var sw = Stopwatch.StartNew();

                CSEditorTools.lastRevealSceneOpenResult = null;
                EntryGenerator.ResetCachedObjects();

                var searchCanceled = LookForAssetsReferences(allTargetAssets, results);
                sw.Stop();

                EditorUtility.ClearProgressBar();

                if (!searchCanceled)
                {
                    var resultsCount = results.Count;
                    if (resultsCount <= 1)
                    {
                        ProjectReferencesTab.AutoSelectPath = null;
                        MaintainerWindow.ShowNotification("Nothing found!");
                    }
                    else
                    {
                        if (newTargetAssets != null && newTargetAssets.Length > 0)
                        {
                            var found = false;
                            foreach (var result in results)
                            {
                                if (result.depth == 0 && CSFilterTools.IsValueMatchesAnyFilter(result.assetPath, newTargetAssets))
                                {
                                    found = true;
                                    break;
                                }
                            }

                            if (!found)
                            {
                                ProjectReferencesTab.AutoSelectPath = null;
                                MaintainerWindow.ShowNotification("Nothing found!");
                            }
                            else
                            {
                                MaintainerWindow.ClearNotification();
                            }
                        }
                        else
                        {
                            MaintainerWindow.ClearNotification();
                        }
                    }

                    Debug.Log(Maintainer.LogPrefix + ReferencesFinder.ModuleName + " results: " + (resultsCount - 1) +
                              " items found in " + sw.Elapsed.TotalSeconds.ToString("0.000", CultureInfo.InvariantCulture) +
                              " seconds.");
                }
                else
                {
                    Debug.Log(Maintainer.LogPrefix + ReferencesFinder.ModuleName + "Search canceled by user!");
                }
            }
            catch (Exception e)
            {
                Debug.LogError(Maintainer.LogPrefix + ReferencesFinder.ModuleName + ": " + e);
                EditorUtility.ClearProgressBar();
            }

            SaveLastSearched(results);

            EntryGenerator.ResetCachedObjects();
            SearchResultsStorage.ProjectReferencesSearchResults = results.ToArray();

            if (showResults)
            {
                MaintainerWindow.ShowAssetReferences();
            }

            return(results.ToArray());
        }