private CallGraphContextTag GetNodeContext([NotNull] ITreeNode node, [NotNull] ICallGraphContextProvider contextProvider)
        {
            var declaredElement = CallGraphContextProviderEx.ExtractDeclaredElementForProvider(node);

            if (declaredElement == null)
            {
                return(CallGraphContextTag.NONE);
            }

            switch (myProcessKind)
            {
            case DaemonProcessKind.VISIBLE_DOCUMENT:
            {
                if (contextProvider.IsMarkedLocal(declaredElement, myGraphDataElement))
                {
                    return(contextProvider.ContextTag);
                }

                break;
            }

            case DaemonProcessKind.GLOBAL_WARNINGS:
            {
                if (contextProvider.IsMarkedGlobal(declaredElement))
                {
                    return(contextProvider.ContextTag);
                }

                break;
            }
            }

            return(CallGraphContextTag.NONE);
        }
Beispiel #2
0
 public static bool IsMarkedSweaDependent(
     [CanBeNull] this ICallGraphContextProvider contextProvider,
     [CanBeNull] IDeclaredElement declaredElement,
     [CanBeNull] SolutionAnalysisService swea)
 {
     return(IsMarkedSweaDependent(contextProvider, declaredElement, swea?.Configuration));
 }
 public static CallGraphContextElement GetNodeContext(
     [CanBeNull] this ICallGraphContextProvider provider,
     [CanBeNull] ITreeNode treeNode,
     DaemonProcessKind processKind)
 {
     return provider.IsNodeMarked(treeNode, processKind)
         ? provider.Context
         : CallGraphContextElement.NONE;
 }
Beispiel #4
0
        public static bool IsMarkedSweaDependent(
            [CanBeNull] this ICallGraphContextProvider contextProvider,
            [CanBeNull] IDeclaredElement declaredElement,
            [CanBeNull] SolutionAnalysisConfiguration configuration)
        {
            if (contextProvider == null || declaredElement == null || configuration == null)
            {
                return(false);
            }

            return(UnityCallGraphUtil.IsCallGraphReady(configuration)
                ? contextProvider.IsMarkedGlobal(declaredElement)
                : contextProvider.IsMarkedLocal(declaredElement));
        }
        public static Func <CallHierarchyFindResult, bool> GetSimpleFilter(
            ISolution solution,
            ICallGraphContextProvider provider,
            ShowCallsType type)
        {
            switch (type)
            {
            case ShowCallsType.INCOMING:
            {
                return(result =>
                    {
                        solution.Locks.AssertReadAccessAllowed();

                        var referenceElement = result.ReferenceElement;
                        var csharpTreeNode = referenceElement as ICSharpTreeNode;
                        var containing = csharpTreeNode?.GetContainingFunctionLikeDeclarationOrClosure();
                        var declaredElement = containing?.DeclaredElement;

                        return provider.IsMarkedGlobal(declaredElement);
                    });
            }

            case ShowCallsType.OUTGOING:
            {
                return(result =>
                    {
                        solution.Locks.AssertReadAccessAllowed();

                        var referenceElement = result.ReferenceElement;
                        var identifier = referenceElement as ICSharpIdentifier;
                        var referenceExpression = ReferenceExpressionNavigator.GetByNameIdentifier(identifier);
                        var declaredElement = referenceExpression?.Reference.Resolve().DeclaredElement;

                        if (declaredElement == null)
                        {
                            var referenceName = referenceElement as IReferenceName;
                            var objectCreationExpression = ObjectCreationExpressionNavigator.GetByTypeName(referenceName);

                            declaredElement = objectCreationExpression?.Reference?.Resolve().DeclaredElement;
                        }

                        return provider.IsMarkedGlobal(declaredElement);
                    });
            }

            default:
                throw new ArgumentOutOfRangeException(nameof(type), type, null);
            }
        }
        public static bool IsNodeMarked(
            [CanBeNull] this ICallGraphContextProvider provider, 
            [CanBeNull] ITreeNode treeNode,
            DaemonProcessKind processKind)
        {
            if (provider == null)
                return false;

            var mark = false;
            
            switch (treeNode)
            {
                case ICSharpExpression expression:
                    mark = provider.IsCalleeMarked(expression, processKind);
                    break;
                case IDeclaration declaration:
                    mark = provider.HasContext(declaration, processKind);
                    break;
            }

            return mark;
        }
Beispiel #7
0
        public static bool IsMarkedStage(
            [CanBeNull] this ICallGraphContextProvider contextProvider,
            [CanBeNull] IDeclaredElement declaredElement,
            [CanBeNull] IReadOnlyCallGraphContext context)
        {
            if (contextProvider == null || declaredElement == null || context == null)
            {
                return(false);
            }

            switch (context.Kind)
            {
            case DaemonProcessKind.VISIBLE_DOCUMENT:
                return(contextProvider.IsMarkedLocal(declaredElement, context.DataElement));

            case DaemonProcessKind.GLOBAL_WARNINGS:
                return(contextProvider.IsMarkedGlobal(declaredElement));

            default:
                return(false);
            }
        }