예제 #1
0
        private void UpdateEntitiesFromSource(CancellationToken cancellationToken, IIncrementalProgress progress)
        {
            cancellationToken.ThrowIfCancellationRequested();

            var workspace    = _roslynModelProvider.GetWorkspace();
            var compilations = workspace.CurrentSolution.Projects.Select(i => i.GetCompilationAsync(cancellationToken))
                               .Select(i => i.Result).ToArray();

            foreach (var roslynTypeNode in CurrentRoslynModel.RoslynNodes)
            {
                cancellationToken.ThrowIfCancellationRequested();

                var namedTypeSymbol    = roslynTypeNode.RoslynSymbol;
                var newVersionOfSymbol = FindSymbolInCompilations(namedTypeSymbol, compilations, cancellationToken);

                if (newVersionOfSymbol == null)
                {
                    RemoveNode(roslynTypeNode.Id);
                }
                else
                {
                    var updatedNode = roslynTypeNode.UpdateRoslynSymbol(newVersionOfSymbol);
                    UpdateNode(updatedNode);
                }

                progress?.Report(1);
            }
        }
예제 #2
0
        protected static IEnumerable <RelatedSymbolPair> GetDerivedInterfaces(IRoslynModelProvider roslynModelProvider, INamedTypeSymbol interfaceSymbol)
        {
            var workspace = roslynModelProvider.GetWorkspace();

            return(FindDerivedInterfaces(workspace, interfaceSymbol)
                   .Select(i => new RelatedSymbolPair(interfaceSymbol, i, DirectedRelationshipTypes.Subtype)));
        }
예제 #3
0
        private void UpdateEntitiesFromSource(CancellationToken cancellationToken, IIncrementalProgress progress)
        {
            cancellationToken.ThrowIfCancellationRequested();

            var workspace    = _roslynModelProvider.GetWorkspace();
            var compilations = workspace.CurrentSolution.Projects.Select(i => i.GetCompilationAsync(cancellationToken))
                               .Select(i => i.Result).ToArray();

            foreach (var roslynBasedModelEntity in _model.Entities.OfType <RoslynBasedModelEntity>().ToArray())
            {
                cancellationToken.ThrowIfCancellationRequested();

                var namedTypeSymbol    = roslynBasedModelEntity.RoslynSymbol;
                var newVersionOfSymbol = FindSymbolInCompilations(namedTypeSymbol, compilations, cancellationToken);

                if (newVersionOfSymbol == null)
                {
                    _model.RemoveEntity(roslynBasedModelEntity);
                }
                else
                {
                    _model.UpdateEntity(roslynBasedModelEntity, newVersionOfSymbol);
                }

                progress?.Report(1);
            }
        }
        protected static IEnumerable <RoslynSymbolRelation> GetDerivedInterfaces(
            IRoslynModelProvider roslynModelProvider, INamedTypeSymbol interfaceSymbol)
        {
            var workspace = roslynModelProvider.GetWorkspace();

            return(FindDerivedInterfaces(workspace, interfaceSymbol)
                   .Select(i => new RoslynSymbolRelation(interfaceSymbol, i, EntityRelationTypes.Subtype)));
        }
        protected static IEnumerable <RoslynSymbolRelation> GetImplementingTypes(
            IRoslynModelProvider roslynModelProvider, INamedTypeSymbol interfaceSymbol)
        {
            var workspace = roslynModelProvider.GetWorkspace();

            return(FindImplementingTypes(workspace, interfaceSymbol)
                   .Select(i => new RoslynSymbolRelation(interfaceSymbol, i, RoslynEntityRelationTypes.ImplementerType)));
        }
예제 #6
0
        protected static IEnumerable <RelatedSymbolPair> GetDerivedTypes(IRoslynModelProvider roslynModelProvider, INamedTypeSymbol classSymbol)
        {
            var workspace = roslynModelProvider.GetWorkspace();

            return(SymbolFinder.FindDerivedClassesAsync(classSymbol, workspace.CurrentSolution).Result
                   .Where(i => classSymbol.SymbolEquals(i.BaseType.OriginalDefinition) && i.TypeKind == TypeKind.Class)
                   .Select(i => new RelatedSymbolPair(classSymbol, i, DirectedRelationshipTypes.Subtype)));
        }