private void HandleBaseMethodDeclaration(BaseMethodDeclarationSyntax node) { // Roughly, set up a new block context, descent and then pop that context again. _blockGuardInformation = new BlockGuardInformation(_graph); Visit(node.Body); _blockGuardInformation = null; }
private void HandleConditionalBlock(IEnumerable <SyntaxNode> bodyNodes, SyntaxNode validatedGuard = null, SyntaxNode invalidatedGuard = null) { // Roughly, set up a new block context with condition, descent and then pop that context again. _blockGuardInformation = new BlockGuardInformation(_graph, enclosingBlockInfo: _blockGuardInformation, validatedGuard: validatedGuard, invalidatedGuard: invalidatedGuard); foreach (var bodyNode in bodyNodes) { Visit(bodyNode); } _blockGuardInformation = _blockGuardInformation.EnclosingBlockInformation; }
public override void VisitForEachStatement(ForEachStatementSyntax node) { Visit(node.Expression); if (_graph.VariableUseNodes.Contains(node.Identifier)) { // This is a special case required because ForEachStatements require a raw identifier // token (but matches what HandleConditionalBlock does): _blockGuardInformation = new BlockGuardInformation(_graph, enclosingBlockInfo: _blockGuardInformation, validatedGuard: node.Expression, invalidatedGuard: null); VisitVariable(node.Identifier); _blockGuardInformation = _blockGuardInformation.EnclosingBlockInformation; } HandleConditionalBlock(new SyntaxNode[] { node.Statement }, validatedGuard: node.Expression); }