Esempio n. 1
0
        private static async Task <GraphNode> GetOrCreateNodeForNamespaceAsync(Graph graph, INamespaceSymbol symbol, Solution solution, CancellationToken cancellationToken)
        {
            var id = await GraphNodeIdCreation.GetIdForNamespaceAsync(symbol, solution, cancellationToken).ConfigureAwait(false);

            var node = graph.Nodes.GetOrCreate(id);

            node.AddCategory(CodeNodeCategories.Namespace);

            return(node);
        }
Esempio n. 2
0
        private static async Task <GraphNode> GetOrCreateNodeForLocalVariableAsync(Graph graph, ISymbol localSymbol, Solution solution, CancellationToken cancellationToken)
        {
            var id = await GraphNodeIdCreation.GetIdForLocalVariableAsync(localSymbol, solution, cancellationToken).ConfigureAwait(false);

            var node = graph.Nodes.GetOrCreate(id);

            node.AddCategory(NodeCategories.LocalExpression);

            return(node);
        }
Esempio n. 3
0
        private static async Task <GraphNode> GetOrCreateNodeForNamedTypeAsync(Graph graph, INamedTypeSymbol namedType, Solution solution, CancellationToken cancellationToken)
        {
            var id = await GraphNodeIdCreation.GetIdForTypeAsync(namedType, solution, cancellationToken).ConfigureAwait(false);

            var    node = graph.Nodes.GetOrCreate(id);
            string iconGroupName;

            switch (namedType.TypeKind)
            {
            case TypeKind.Class:
                node.AddCategory(CodeNodeCategories.Class);
                iconGroupName = "Class";
                break;

            case TypeKind.Delegate:
                node.AddCategory(CodeNodeCategories.Delegate);
                iconGroupName = "Delegate";
                break;

            case TypeKind.Enum:
                node.AddCategory(CodeNodeCategories.Enum);
                iconGroupName = "Enum";
                break;

            case TypeKind.Interface:
                node.AddCategory(CodeNodeCategories.Interface);
                iconGroupName = "Interface";
                break;

            case TypeKind.Module:
                node.AddCategory(CodeNodeCategories.Module);
                iconGroupName = "Module";
                break;

            case TypeKind.Struct:
                node.AddCategory(CodeNodeCategories.Struct);
                iconGroupName = "Struct";
                break;

            case TypeKind.Error:
                node.AddCategory(CodeNodeCategories.Type);
                iconGroupName = "Error";
                break;

            default:
                throw ExceptionUtilities.UnexpectedValue(namedType.TypeKind);
            }

            node[DgmlNodeProperties.Icon]        = IconHelper.GetIconName(iconGroupName, namedType.DeclaredAccessibility);
            node[RoslynGraphProperties.TypeKind] = namedType.TypeKind;

            return(node);
        }
Esempio n. 4
0
        private static async Task <GraphNode> GetOrCreateNodeForEventAsync(Graph graph, IEventSymbol eventSymbol, Solution solution, CancellationToken cancellationToken)
        {
            var id = await GraphNodeIdCreation.GetIdForMemberAsync(eventSymbol, solution, cancellationToken).ConfigureAwait(false);

            var node = graph.Nodes.GetOrCreate(id);

            node.AddCategory(CodeNodeCategories.Event);

            node[DgmlNodeProperties.Icon]        = IconHelper.GetIconName("Event", eventSymbol.DeclaredAccessibility);
            node[RoslynGraphProperties.TypeKind] = eventSymbol.ContainingType.TypeKind;

            return(node);
        }
Esempio n. 5
0
        private static async Task <GraphNode> GetOrCreateNodeForParameterAsync(Graph graph, IParameterSymbol parameterSymbol, Solution solution, CancellationToken cancellationToken)
        {
            var id = await GraphNodeIdCreation.GetIdForParameterAsync(parameterSymbol, solution, cancellationToken).ConfigureAwait(false);

            var node = graph.Nodes.GetOrCreate(id);

            node.AddCategory(CodeNodeCategories.Parameter);

            node.SetValue <bool>(Properties.IsByReference, parameterSymbol.RefKind == RefKind.Ref);
            node.SetValue <bool>(Properties.IsOut, parameterSymbol.RefKind == RefKind.Out);
            node.SetValue <bool>(Properties.IsParameterArray, parameterSymbol.IsParams);

            return(node);
        }
Esempio n. 6
0
        public GraphNode AddNodeForDocument(Document document)
        {
            using (_gate.DisposableWait())
            {
                var id = GraphNodeIdCreation.GetIdForDocument(document);

                var node = _graph.Nodes.GetOrCreate(id, Path.GetFileName(document.FilePath), CodeNodeCategories.ProjectItem);

                _nodeToContextDocumentMap[node] = document;
                _nodeToContextProjectMap[node]  = document.Project;

                _createdNodes.Add(node);

                return(node);
            }
        }
Esempio n. 7
0
        private static async Task <GraphNode> GetOrCreateNodeForFieldAsync(Graph graph, IFieldSymbol field, Solution solution, CancellationToken cancellationToken)
        {
            var id = await GraphNodeIdCreation.GetIdForMemberAsync(field, solution, cancellationToken).ConfigureAwait(false);

            var node = graph.Nodes.GetOrCreate(id);

            node.AddCategory(CodeNodeCategories.Field);

            if (field.ContainingType.TypeKind == TypeKind.Enum)
            {
                node[DgmlNodeProperties.Icon] = IconHelper.GetIconName("EnumMember", field.DeclaredAccessibility);
            }
            else
            {
                node[DgmlNodeProperties.Icon] = IconHelper.GetIconName("Field", field.DeclaredAccessibility);
            }

            return(node);
        }
Esempio n. 8
0
        private static async Task <GraphNode> GetOrCreateNodeForMethodAsync(Graph graph, IMethodSymbol method, Solution solution, CancellationToken cancellationToken)
        {
            var id = await GraphNodeIdCreation.GetIdForMemberAsync(method, solution, cancellationToken).ConfigureAwait(false);

            var node = graph.Nodes.GetOrCreate(id);

            node.AddCategory(CodeNodeCategories.Method);

            var isOperator = method.MethodKind == MethodKind.UserDefinedOperator || method.MethodKind == MethodKind.Conversion;

            node[DgmlNodeProperties.Icon] = isOperator
                ? IconHelper.GetIconName("Operator", method.DeclaredAccessibility)
                : IconHelper.GetIconName("Method", method.DeclaredAccessibility);

            node[RoslynGraphProperties.TypeKind]   = method.ContainingType.TypeKind;
            node[RoslynGraphProperties.MethodKind] = method.MethodKind;

            return(node);
        }