private static void CollectRemovableMethods(RemovableDeclarationCollector declarationCollector, HashSet <ISymbol> declaredPrivateSymbols) { var methodSymbols = declarationCollector.TypeDeclarations .SelectMany(GetMethodsNodesAndModels) .Select(node => node.SemanticModel.GetDeclaredSymbol(node.SyntaxNode) as IMethodSymbol) .Select(symbol => symbol.PartialDefinitionPart ?? symbol) .Where(method => RemovableDeclarationCollector.IsRemovable(method, maxAccessibility)); declaredPrivateSymbols.UnionWith(methodSymbols); }
private static IEnumerable <SyntaxNodeSymbolSemanticModelTuple <MethodDeclarationSyntax, IMethodSymbol> > CollectRemovableMethods( RemovableDeclarationCollector removableDeclarationCollector) { return(removableDeclarationCollector.TypeDeclarations .SelectMany(container => container.SyntaxNode.DescendantNodes(RemovableDeclarationCollector.IsNodeContainerTypeDeclaration) .OfType <MethodDeclarationSyntax>() .Select(node => new SyntaxNodeSymbolSemanticModelTuple <MethodDeclarationSyntax, IMethodSymbol> { SyntaxNode = node, SemanticModel = container.SemanticModel, Symbol = container.SemanticModel.GetDeclaredSymbol(node) })) .Where(node => node.Symbol != null && !node.Symbol.ReturnsVoid && RemovableDeclarationCollector.IsRemovable(node.Symbol, Accessibility.Private))); }
private static void CollectRemovableMethods(RemovableDeclarationCollector declarationCollector, HashSet <ISymbol> declaredPrivateSymbols) { var methodSymbols = declarationCollector.TypeDeclarations .SelectMany(container => container.SyntaxNode.DescendantNodes(RemovableDeclarationCollector.IsNodeContainerTypeDeclaration) .Where(node => node.IsKind(SyntaxKind.MethodDeclaration) || node.IsKind(SyntaxKind.ConstructorDeclaration)) .Select(node => new SyntaxNodeSemanticModelTuple <SyntaxNode> { SyntaxNode = node, SemanticModel = container.SemanticModel })) .Select(node => node.SemanticModel.GetDeclaredSymbol(node.SyntaxNode) as IMethodSymbol) .Where(method => RemovableDeclarationCollector.IsRemovable(method, maxAccessibility)); declaredPrivateSymbols.UnionWith(methodSymbols); }
private static void CollectRemovableNamedTypes(RemovableDeclarationCollector declarationCollector, HashSet <ISymbol> declaredPrivateSymbols) { var symbols = declarationCollector.TypeDeclarations .SelectMany(container => container.SyntaxNode.DescendantNodes(RemovableDeclarationCollector.IsNodeContainerTypeDeclaration) .Where(node => node.IsKind(SyntaxKind.ClassDeclaration) || node.IsKind(SyntaxKind.InterfaceDeclaration) || node.IsKind(SyntaxKind.StructDeclaration) || node.IsKind(SyntaxKind.DelegateDeclaration)) .Select(node => new SyntaxNodeSemanticModelTuple <SyntaxNode> { SyntaxNode = node, SemanticModel = container.SemanticModel })) .Select(node => node.SemanticModel.GetDeclaredSymbol(node.SyntaxNode)) .Where(symbol => RemovableDeclarationCollector.IsRemovable(symbol, Accessibility.Internal)); declaredPrivateSymbols.UnionWith(symbols); }