/// <summary> /// Factory method for class <see cref="ForEachStatementASTWalker"/>. /// </summary> /// <param name="node"><see cref="CSharpSyntaxNode"/> Used to initialize the walker.</param> /// <param name="semanticModel">The semantic model.</param> /// <returns></returns> public static ForEachStatementASTWalker Create(CSharpSyntaxNode node, SemanticModel semanticModel = null) { ForEachStatement helper = new ForEachStatement(node as ForEachStatementSyntax); var statement = ForEachStatementTranslationUnit.Create(); return(new ForEachStatementASTWalker(node, statement, semanticModel)); }
/// <summary> /// Initializes a new instance of the <see cref="ForEachStatementASTWalker"/> class. /// </summary> /// <param name="node"></param> /// <param name="conditionalStatement"></param> /// <param name="semanticModel">The semantic model.</param> protected ForEachStatementASTWalker(CSharpSyntaxNode node, ForEachStatementTranslationUnit forEachStatement, SemanticModel semanticModel) : base(node, semanticModel) { var statementSyntaxNode = node as ForEachStatementSyntax; if (statementSyntaxNode == null) { throw new ArgumentException( string.Format("Specified node is not of type {0}", typeof(ForStatementSyntax).Name)); } if (forEachStatement == null) { throw new ArgumentNullException(nameof(forEachStatement)); } // Node assigned in base, no need to assign it here this.statement = forEachStatement; // Going through parts in the statement and filling the translation unit with initial data this.VisitNode(statementSyntaxNode, 0); }