public override void AddFrequentlyCalledMethodHighlighting(IHighlightingConsumer consumer, ICSharpDeclaration declaration, string text,
                                                                   string tooltip, DaemonProcessKind kind)
        {
            var isHot = declaration.HasHotIcon(ContextProvider, SettingsStore.BoundSettingsStore, kind);

            if (!isHot)
            {
                return;
            }

            if (RiderIconProviderUtil.IsCodeVisionEnabled(SettingsStore.BoundSettingsStore, myCodeInsightProvider.ProviderId,
                                                          () => { base.AddFrequentlyCalledMethodHighlighting(consumer, declaration, text, tooltip, kind); }, out _))
            {
                IEnumerable <BulbMenuItem> actions;
                if (declaration.DeclaredElement is IMethod method && UnityApi.IsEventFunction(method))
                {
                    actions = GetEventFunctionActions(declaration);
                }
                else
                {
                    if (declaration is IMethodDeclaration methodDeclaration)
                    {
                        var textControl = myTextControlManager.LastFocusedTextControl.Value;
                        var compactList = new CompactList <BulbMenuItem>();
                        var performanceDisableAction =
                            new PerformanceAnalysisDisableByCommentBulbAction(methodDeclaration);
                        var performanceDisableBulbItem = new BulbMenuItem(
                            new IntentionAction.MyExecutableProxi(performanceDisableAction, mySolution, textControl),
                            performanceDisableAction.Text,
                            BulbThemedIcons.ContextAction.Id, BulbMenuAnchors.FirstClassContextItems);
                        compactList.Add(performanceDisableBulbItem);

                        if (!UnityCallGraphUtil.HasAnalysisComment(methodDeclaration, ExpensiveCodeMarksProvider.MarkId,
                                                                   ReSharperControlConstruct.Kind.Restore))
                        {
                            var expensiveBulbAction = new AddExpensiveCommentBulbAction(methodDeclaration);
                            var expensiveBulbItem   = new BulbMenuItem(
                                new IntentionAction.MyExecutableProxi(expensiveBulbAction, mySolution, textControl),
                                expensiveBulbAction.Text,
                                BulbThemedIcons.ContextAction.Id, BulbMenuAnchors.FirstClassContextItems);

                            compactList.Add(expensiveBulbItem);
                        }

                        actions = compactList;
                    }
                    else
                    {
                        actions = EmptyList <BulbMenuItem> .Instance;
                    }
                }

                myCodeInsightProvider.AddHighlighting(consumer, declaration, declaration.DeclaredElement, text, tooltip, text,
                                                      myIconHost.Transform(InsightUnityIcons.InsightHot.Id), actions, RiderIconProviderUtil.GetExtraActions(mySolutionTracker, myBackendUnityHost));
            }
Exemple #2
0
        public static CompactList <IField> GetFieldsByAttribute(this IAttribute attribute)
        {
            var list = new CompactList <IField>();

            foreach (var fieldDeclaration in FieldDeclarationNavigator.GetByAttribute(attribute))
            {
                if (fieldDeclaration.DeclaredElement != null)
                {
                    list.Add(fieldDeclaration.DeclaredElement);
                }
            }
            foreach (var constantDeclaration in ConstantDeclarationNavigator.GetByAttribute(attribute))
            {
                if (constantDeclaration.DeclaredElement != null)
                {
                    list.Add(constantDeclaration.DeclaredElement);
                }
            }

            return(list);
        }
        public IEnumerable <BulbMenuItem> GetBurstActions([NotNull] IMethodDeclaration methodDeclaration, IReadOnlyCallGraphContext context)
        {
            var result      = new CompactList <BulbMenuItem>();
            var textControl = myTextControlManager.LastFocusedTextControl.Value;

            foreach (var bulbProvider in myBulbProviders)
            {
                var menuItems = bulbProvider.GetMenuItems(methodDeclaration, textControl, context);

                foreach (var item in menuItems)
                {
                    result.Add(item);
                }
            }

            return(result);
        }