public void AddInspectorHighlighting()

in resharper/resharper-unity/src/Unity.Rider/Common/CSharp/Daemon/CodeInsights/UnityCodeInsightFieldUsageProvider.cs [118:228]


        public void AddInspectorHighlighting(IHighlightingConsumer consumer, ICSharpDeclaration element,
            ITypeOwner? declaredElement, string baseDisplayName, string baseTooltip, string moreText, IconModel iconModel,
            IEnumerable<BulbMenuItem> items, List<CodeVisionEntryExtraActionModel> extraActions)
        {
            if(declaredElement == null)
                return;

            var solution = element.GetSolution();
            Assertion.Assert(solution.Locks.IsReadAccessAllowed(), "ReadLock required");

            var containingType = declaredElement.GetContainingType();
            var type = declaredElement.Type;
            
            if (containingType == null)
            {
                base.AddHighlighting(consumer, element, declaredElement, baseDisplayName, baseTooltip, moreText, iconModel, items, extraActions);
                return;
            }

            var (guidN, propertyNames) = GetAssetGuidAndPropertyName(solution, declaredElement, containingType);
            if (guidN == null || propertyNames.Length == 0)
            {
                base.AddHighlighting(consumer, element, declaredElement, baseDisplayName, baseTooltip, moreText, iconModel, items, extraActions);
                return;
            }

            var guid = guidN.Value;

            var presentationType = GetUnityPresentationType(type);

            if (!myDeferredCacheController.CompletedOnce.Value || ShouldShowUnknownPresentation(presentationType))
            {
                base.AddHighlighting(consumer, element, declaredElement, baseDisplayName, baseTooltip, moreText, iconModel, items, extraActions);
                return;
            }

            if (presentationType == UnityPresentationType.UnityEvent)
            {
                var count = myUnityEventsElementContainer.GetUsageCountForEvent(declaredElement, out var estimated);
                var text = NounUtilEx.ToEmptyPluralOrSingularQuick(count, estimated,
                    Strings.UnityCodeInsightFieldUsageProvider_AddInspectorHighlighting_No_methods,
                    Strings.UnityCodeInsightFieldUsageProvider_AddInspectorHighlighting_method,
                    Strings.UnityCodeInsightFieldUsageProvider_AddInspectorHighlighting_methods);

                consumer.AddHighlighting(new UnityInspectorCodeInsightsHighlighting(element.GetNameDocumentRange(),
                    text, GetTooltip(count, estimated, false), Strings.UnityCodeInsightFieldUsageProvider_AddInspectorHighlighting_CapitalChar_Method, this,
                    declaredElement, iconModel, presentationType));
                return;
            }

            IVariableInitializer? initializer = element switch
            {
                IFieldDeclaration fieldDeclaration => fieldDeclaration.Initial,
                IPropertyDeclaration propertyDeclaration => propertyDeclaration.Initial,
                _ => null
            };

            var initValue = (initializer as IExpressionInitializer)?.Value?.ConstantValue;
            var initValueUnityPresentation = GetUnitySerializedPresentation(presentationType, initValue);

            int changesCount;
            var isEstimated = false;
            var isUniqueChange = false;
            var displayName = string.Empty;

            if (myInspectorValuesContainer.IsIndexResultEstimated(guid, containingType, propertyNames))
            {
                changesCount = myInspectorValuesContainer.GetAffectedFiles(guid, propertyNames) -  myInspectorValuesContainer.GetAffectedFilesWithSpecificValue(guid, propertyNames, initValueUnityPresentation);
                displayName = string.Format(Strings.UnityCodeInsightFieldUsageProvider_AddInspectorHighlighting_Changed_in__0___assets, changesCount);
                isEstimated = true;
            }
            else
            {
                changesCount = 0;
                var initValueCount = myInspectorValuesContainer.GetValueCount(guid, propertyNames, initValueUnityPresentation);

                if (initValueCount == 0 && myInspectorValuesContainer.GetUniqueValuesCount(guid, propertyNames) == 1) // only modified value
                {
                    isUniqueChange = true;
                    var value  = myInspectorValuesContainer.GetUniqueValueDifferTo(guid, propertyNames, null);
                    displayName = value.GetPresentation(solution, declaredElement, false);
                }
                else if (initValueCount > 0 && myInspectorValuesContainer.GetUniqueValuesCount(guid, propertyNames) == 2)
                {
                    isUniqueChange = true;
                    // original value & only one modified value
                    var anotherValueWithLocation = myInspectorValuesContainer.GetUniqueValueDifferTo(guid, propertyNames, initValueUnityPresentation);
                    displayName = anotherValueWithLocation.GetPresentation(solution, declaredElement, false);
                }

                if (string.IsNullOrEmpty(displayName) || displayName.Equals("..."))
                {
                    changesCount = myInspectorValuesContainer.GetAffectedFiles(guid, propertyNames) -
                                   myInspectorValuesContainer.GetAffectedFilesWithSpecificValue(guid, propertyNames,
                                       initValueUnityPresentation);
                    if (changesCount == 0)
                    {
                        displayName = Strings.UnityCodeInsightFieldUsageProvider_AddInspectorHighlighting_Unchanged;
                    }
                    else
                    {
                        var word = NounUtil.ToPluralOrSingularQuick(changesCount, Strings.UnityCodeInsightFieldUsageProvider_AddInspectorHighlighting_asset, Strings.UnityCodeInsightFieldUsageProvider_AddInspectorHighlighting_assets);
                        displayName = string.Format(Strings.UnityCodeInsightFieldUsageProvider_AddInspectorHighlighting_Changed_in__0___1_, changesCount, word);
                    }
                }
            }

            consumer.AddHighlighting(new UnityInspectorCodeInsightsHighlighting(element.GetNameDocumentRange(),
                displayName, GetTooltip(changesCount, isEstimated, isUniqueChange), Strings.UnityCodeInsightFieldUsageProvider_AddInspectorHighlighting_Property_Inspector_values, this,
                declaredElement, iconModel, presentationType));
        }