public override AstNode VisitUsingStatement(UsingStatement usingStatement) { var awaitSearch = new AwaitSearchVisitor(null); usingStatement.AcceptVisitor(awaitSearch); var awaiters = awaitSearch.GetAwaitExpressions().ToArray(); UsingStatement node = (UsingStatement)base.VisitUsingStatement(usingStatement) ?? (UsingStatement)usingStatement.Clone(); if (awaiters.Length > 0) { IEnumerable <AstNode> inner = null; var res = node.ResourceAcquisition; var varStat = res as VariableDeclarationStatement; if (varStat != null) { inner = varStat.Variables.Skip(1); res = varStat.Variables.First(); } return(EmitUsing(node, res, inner, varStat)); } return(node); }
protected AstNode[] GetAwaiters(AstNode node) { var awaitSearch = new AwaitSearchVisitor(Emitter); node.AcceptVisitor(awaitSearch); return(awaitSearch.GetAwaitExpressions().ToArray()); }
public override void VisitUsingStatement(UsingStatement usingStatement) { if (Found) { return; } var awaitSearch = new AwaitSearchVisitor(null); usingStatement.AcceptVisitor(awaitSearch); var awaiters = awaitSearch.GetAwaitExpressions().ToArray(); if (awaiters.Length > 0) { Found = true; } base.VisitUsingStatement(usingStatement); }