private async Task <IEnumerable <RelatedSymbolPair> > GetDerivedInterfacesAsync([NotNull] ISymbol symbol) { var namedTypeSymbol = symbol.Ensure <INamedTypeSymbol>(); var derivedInterfaces = await FindDerivedInterfacesAsync(namedTypeSymbol); return(derivedInterfaces.Select(i => new RelatedSymbolPair(namedTypeSymbol, i, DirectedModelRelationshipTypes.Subtype))); }
private async Task <IEnumerable <RelatedSymbolPair> > GetImplementingTypesAsync([NotNull] ISymbol symbol) { var namedTypeSymbol = symbol.Ensure <INamedTypeSymbol>(); var implementingTypes = await FindImplementingTypesAsync(namedTypeSymbol); return(implementingTypes.Select(i => new RelatedSymbolPair(namedTypeSymbol, i, DirectedModelRelationshipTypes.ImplementerType))); }
private Task <IEnumerable <RelatedSymbolPair> > GetImplementedInterfacesAsync([NotNull] ISymbol symbol) { var namedTypeSymbol = symbol.Ensure <INamedTypeSymbol>(); var result = namedTypeSymbol.Interfaces.Where(i => i.TypeKind == TypeKind.Interface) .Select(i => new RelatedSymbolPair(namedTypeSymbol, i, DirectedModelRelationshipTypes.ImplementedInterface)); return(Task.FromResult(result)); }
private static Task <IEnumerable <RelatedSymbolPair> > GetMembersAsync([NotNull] ISymbol symbol) { var typeSymbol = symbol.Ensure <ITypeSymbol>(); var result = typeSymbol.GetMembers() .Where(IsModeledMember) .Where(IfMethodThenModeledMethod) .Where(IsExplicitlyDeclared) .Select(i => new RelatedSymbolPair(typeSymbol, i, CommonDirectedModelRelationshipTypes.Contained)); return(Task.FromResult(result)); }
private async Task <IEnumerable <RelatedSymbolPair> > GetDerivedTypesAsync([NotNull] ISymbol symbol) { var classSymbol = symbol.Ensure <INamedTypeSymbol>(); var solution = await GetCurrentSolutionAsync(); var derivedClasses = await SymbolFinder.FindDerivedClassesAsync(classSymbol, solution); return(derivedClasses .Where(i => _symbolEqualityComparer.Equals(classSymbol, i.BaseType.OriginalDefinition) && i.TypeKind == TypeKind.Class) .Select(i => new RelatedSymbolPair(classSymbol, i, DirectedModelRelationshipTypes.Subtype))); }
private static Task <IEnumerable <RelatedSymbolPair> > GetBaseTypesAsync([NotNull] ISymbol symbol) { var result = new List <RelatedSymbolPair>(); var typeSymbol = symbol.Ensure <ITypeSymbol>(); var baseSymbol = typeSymbol.BaseType; if (baseSymbol?.TypeKind == TypeKind.Class) { result.Add(new RelatedSymbolPair(typeSymbol, baseSymbol, DirectedModelRelationshipTypes.BaseType)); } return(Task.FromResult((IEnumerable <RelatedSymbolPair>)result)); }
private async Task <IEnumerable <INamedTypeSymbol> > FindDerivedInterfacesAsync([NotNull] ISymbol symbol) { var namedTypeSymbol = symbol.Ensure <INamedTypeSymbol>(); var result = new List <INamedTypeSymbol>(); foreach (var compilation in await GetCompilationsAsync()) { var visitor = new DerivedInterfacesFinderVisitor(namedTypeSymbol, _symbolEqualityComparer); compilation.Assembly?.Accept(visitor); result.AddRange(visitor.DerivedInterfaces); } return(result); }