private void AnalyzeStatements([NotNull] ICSharpTreeNode scope, [NotNull] PropertiesAccessContainer referencesContainer) { var visitor = new PropertiesAnalyzerVisitor(referencesContainer, scope, new Dictionary <IReferenceExpression, IEnumerator <ITreeNode> >(ourComparer), new HashSet <IReferenceExpression>(ourComparer)); scope.ProcessThisAndDescendants(visitor); }
protected override void Analyze(ITreeNode node, ElementProblemAnalyzerData data, IHighlightingConsumer consumer) { // container to collect groups of IReferenceExpressions which can be cached var container = new PropertiesAccessContainer(consumer); ICSharpTreeNode scope = null; switch (node) { case ICSharpParametersOwnerDeclaration parametersOwnerDeclaration: var codeBody = parametersOwnerDeclaration.GetCodeBody(); scope = codeBody.BlockBody ?? (ICSharpTreeNode)codeBody.ExpressionBody; break; case ILambdaExpression lambdaExpression: codeBody = lambdaExpression.GetCodeBody(); scope = codeBody.BlockBody ?? (ICSharpTreeNode)codeBody.ExpressionBody; break; case IPropertyDeclaration propertyDeclaration: var initial = propertyDeclaration.Initial; if (initial != null) { scope = initial; } else { foreach (var accessorDeclaration in propertyDeclaration.AccessorDeclarationsEnumerable) { codeBody = accessorDeclaration.GetCodeBody(); var body = codeBody.BlockBody ?? (ICSharpTreeNode)codeBody.ExpressionBody; if (body != null) { AnalyzeStatements(body, container); container.InvalidateCachedValues(); } } } break; default: return; } if (scope == null) { return; } AnalyzeStatements(scope, container); // cache all references which is not invalidated dut to no related expression was found container.InvalidateCachedValues(); }