<commit_before>using JetBrains.ProjectModel;
using JetBrains.ReSharper.Feature.Services.Occurrences;
using JetBrains.ReSharper.Plugins.Unity.Resources.Icons;
using JetBrains.ReSharper.Plugins.Unity.Utils;
using JetBrains.ReSharper.Plugins.Unity.Yaml.Feature.Services.Navigation;
using JetBrains.ReSharper.Psi;
using JetBrains.Rider.Backend.Features.Usages;
using JetBrains.Rider.Backend.Platform.Icons;
using JetBrains.UI.Icons;
using JetBrains.Util;

namespace JetBrains.ReSharper.Plugins.Unity.Yaml.Host.Feature
{
    [SolutionComponent]
    public class UnityAssetRiderUsageGroupingProjectItemProvider : ProjectItemRule.ICustomProjectItemProvider
    {
        private readonly ISolution mySolution;
        private readonly ProjectModelIcons myProjectModelIcons;
        private readonly IconHost myIconHost;

        public UnityAssetRiderUsageGroupingProjectItemProvider(ISolution solution, ProjectModelIcons projectModelIcons, IconHost iconHost)
        {
            mySolution = solution;
            myProjectModelIcons = projectModelIcons;
            myIconHost = iconHost;
        }

        public RdUsageGroupTextAndIcon? GetUsageGroup(IOccurrence occurrence, ProjectItemKind kind, bool takeParent)
        {
            if (occurrence is UnityAssetOccurrence unityAssetOccurrence)
            {
                switch (kind)
                {
                    case ProjectItemKind.PHYSICAL_FILE:
                        var filePath = GetPresentablePath(unityAssetOccurrence.SourceFile.GetLocation());
                        if (filePath != null)
                            return new RdUsageGroupTextAndIcon(filePath, myIconHost.Transform(GetIcon(unityAssetOccurrence.SourceFile)));
                        break;

                    case ProjectItemKind.PHYSICAL_DIRECTORY:
                        var directoryPath = GetPresentablePath(unityAssetOccurrence.SourceFile.GetLocation().Directory);
                        if (directoryPath != null)
                            return new RdUsageGroupTextAndIcon(directoryPath, myIconHost.Transform(myProjectModelIcons.DirectoryIcon));
                        break;
                }
            }

            return null;
        }

        private static IconId GetIcon(IPsiSourceFile sourceFile)
        {
            var location = sourceFile.GetLocation();
            if (location.IsAsset())
                return UnityFileTypeThemedIcons.FileUnityAsset.Id;
            if (location.IsScene())
                return UnityFileTypeThemedIcons.FileUnity.Id;
            if (location.IsPrefab())
                return UnityFileTypeThemedIcons.FileUnityPrefab.Id;
            if (location.IsMeta())
                return UnityFileTypeThemedIcons.FileUnityMeta.Id;
            if (location.IsControllerFile())
                return UnityFileTypeThemedIcons.FileAnimatorController.Id;
            return location.IsAnimFile()
                ? UnityFileTypeThemedIcons.FileAnimationClip.Id
                : UnityFileTypeThemedIcons.FileUnity.Id;
        }

        private string GetPresentablePath(VirtualFileSystemPath assetFile)
        {
            var solutionFolder = mySolution.SolutionFile?.Location.Parent;
            if (solutionFolder != null && solutionFolder.IsPrefixOf(assetFile))
                return assetFile.MakeRelativeTo(solutionFolder).FullPath;
            return null;
        }
    }
}<commit_msg>Do not show misc project node for asset occurrences in find usages toolwindow<commit_after>using JetBrains.ProjectModel;
using JetBrains.ReSharper.Feature.Services.Occurrences;
using JetBrains.ReSharper.Plugins.Unity.Resources.Icons;
using JetBrains.ReSharper.Plugins.Unity.Utils;
using JetBrains.ReSharper.Plugins.Unity.Yaml.Feature.Services.Navigation;
using JetBrains.ReSharper.Psi;
using JetBrains.Rider.Backend.Features.Usages;
using JetBrains.Rider.Backend.Platform.Icons;
using JetBrains.UI.Icons;
using JetBrains.Util;

namespace JetBrains.ReSharper.Plugins.Unity.Yaml.Host.Feature
{
    [SolutionComponent]
    public class UnityAssetRiderUsageGroupingProjectItemProvider : ProjectItemRule.ICustomProjectItemProvider
    {
        private readonly ISolution mySolution;
        private readonly ProjectModelIcons myProjectModelIcons;
        private readonly IconHost myIconHost;

        public UnityAssetRiderUsageGroupingProjectItemProvider(ISolution solution, ProjectModelIcons projectModelIcons, IconHost iconHost)
        {
            mySolution = solution;
            myProjectModelIcons = projectModelIcons;
            myIconHost = iconHost;
        }

        public RdUsageGroupTextAndIcon? GetUsageGroup(IOccurrence occurrence, ProjectItemKind kind, bool takeParent)
        {
            if (occurrence is UnityAssetOccurrence unityAssetOccurrence)
            {
                switch (kind)
                {
                    case ProjectItemKind.PROJECT:
                        return new RdUsageGroupTextAndIcon("", null);
                    case ProjectItemKind.PHYSICAL_FILE:
                        var filePath = GetPresentablePath(unityAssetOccurrence.SourceFile.GetLocation());
                        if (filePath != null)
                            return new RdUsageGroupTextAndIcon(filePath, myIconHost.Transform(GetIcon(unityAssetOccurrence.SourceFile)));
                        break;

                    case ProjectItemKind.PHYSICAL_DIRECTORY:
                        var directoryPath = GetPresentablePath(unityAssetOccurrence.SourceFile.GetLocation().Directory);
                        if (directoryPath != null)
                            return new RdUsageGroupTextAndIcon(directoryPath, myIconHost.Transform(myProjectModelIcons.DirectoryIcon));
                        break;
                }
            }

            return null;
        }

        private static IconId GetIcon(IPsiSourceFile sourceFile)
        {
            var location = sourceFile.GetLocation();
            if (location.IsAsset())
                return UnityFileTypeThemedIcons.FileUnityAsset.Id;
            if (location.IsScene())
                return UnityFileTypeThemedIcons.FileUnity.Id;
            if (location.IsPrefab())
                return UnityFileTypeThemedIcons.FileUnityPrefab.Id;
            if (location.IsMeta())
                return UnityFileTypeThemedIcons.FileUnityMeta.Id;
            if (location.IsControllerFile())
                return UnityFileTypeThemedIcons.FileAnimatorController.Id;
            return location.IsAnimFile()
                ? UnityFileTypeThemedIcons.FileAnimationClip.Id
                : UnityFileTypeThemedIcons.FileUnity.Id;
        }

        private string GetPresentablePath(VirtualFileSystemPath assetFile)
        {
            var solutionFolder = mySolution.SolutionFile?.Location.Parent;
            if (solutionFolder != null && solutionFolder.IsPrefixOf(assetFile))
                return assetFile.MakeRelativeTo(solutionFolder).FullPath;
            return null;
        }
    }
}
{'fraction_non_alphanumeric': 0.06554092730394963, 'fraction_numerical': 0.0, 'mean_word_length': 2.344019138755981, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3234326', 'n_tokens_mistral': 1861, 'n_tokens_neox': 1725, 'n_words': 302}