private bool IsRootDeclaration(ITreeNode node,
                                       Func <ICSharpDeclaration, bool> isRootedPredicate,
                                       CallGraphRootMarksProviderId rootMarksProviderId)
        {
            if (!(node is ICSharpDeclaration declaration))
            {
                return(false);
            }
            var declaredElement = declaration.DeclaredElement;

            if (declaredElement == null)
            {
                return(false);
            }
            var isRooted      = isRootedPredicate(declaration);
            var isGlobalStage = myProcessKind == DaemonProcessKind.GLOBAL_WARNINGS;

            if (!isRooted && isGlobalStage)
            {
                var id = myProvider.GetElementId(declaredElement);
                if (!id.HasValue)
                {
                    return(false);
                }
                return(myCallGraphSwaExtensionProvider.IsMarkedByCallGraphRootMarksProvider(
                           rootMarksProviderId, isGlobalStage, id.Value));
            }

            return(isRooted);
        }
        protected override void Analyze(IInvocationExpression expression, IDaemonProcess daemonProcess, DaemonProcessKind kind,
                                        IHighlightingConsumer consumer)
        {
            if (PerformanceCriticalCodeStageUtil.IsInvocationExpensive(expression))
            {
                CreateHiglighting(expression, consumer);
            }
            else if (kind == DaemonProcessKind.GLOBAL_WARNINGS)
            {
                var declaredElement = CallGraphUtil.GetCallee(expression);
                if (declaredElement == null)
                {
                    return;
                }

                var id = myProvider.GetElementId(declaredElement);
                if (!id.HasValue)
                {
                    return;
                }

                if (mySwaExtensionProvider.IsMarkedByCallGraphRootMarksProvider(myExpensiveCodeCallGraphAnalyzer.Id, true, id.Value))
                {
                    CreateHiglighting(expression, consumer);
                }
            }
        }
Exemplo n.º 3
0
        public static bool HasHotIcon(this IDeclaredElement element,
                                      CallGraphSwaExtensionProvider callGraphSwaExtensionProvider, IContextBoundSettingsStore settingsStore,
                                      PerformanceCriticalCodeCallGraphMarksProvider marksProvider, DaemonProcessKind kind, IElementIdProvider provider)
        {
            if (!settingsStore.GetValue((UnitySettings key) => key.EnableIconsForPerformanceCriticalCode))
            {
                return(false);
            }

            if (!settingsStore.GetValue((UnitySettings key) => key.EnablePerformanceCriticalCodeHighlighting))
            {
                return(false);
            }

            var id = provider.GetElementId(element);

            if (!id.HasValue)
            {
                return(false);
            }

            return(callGraphSwaExtensionProvider.IsMarkedByCallGraphRootMarksProvider(marksProvider.Id,
                                                                                      kind == DaemonProcessKind.GLOBAL_WARNINGS, id.Value));
        }
        public virtual bool IsMarked(IDeclaredElement declaredElement, DaemonProcessKind processKind)
        {
            if (IsContextAvailable == false)
            {
                return(false);
            }

            var isGlobalStage = processKind == DaemonProcessKind.GLOBAL_WARNINGS;

            if (!isGlobalStage)
            {
                return(false);
            }

            var id = myElementIdProvider.GetElementId(declaredElement);

            if (!id.HasValue)
            {
                return(false);
            }

            return(myCallGraphSwaExtensionProvider.IsMarkedByCallGraphRootMarksProvider(
                       myMarksProviderBase.Id, isGlobalStage: true, id.Value));
        }