Пример #1
0
        /// <summary>
        /// Factory method for class <see cref="SwitchStatementASTWalker"/>.
        /// </summary>
        /// <param name="node"><see cref="CSharpSyntaxNode"/> Used to initialize the walker.</param>
        /// <param name="semanticModel">The semantic model.</param>
        /// <returns></returns>
        public static SwitchStatementASTWalker Create(CSharpSyntaxNode node, SemanticModel semanticModel = null)
        {
            SwitchStatement helper = new SwitchStatement(node as SwitchStatementSyntax);

            var statement = SwitchStatementTranslationUnit.Create();

            return(new SwitchStatementASTWalker(node, statement, semanticModel));
        }
Пример #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SwitchStatementASTWalker"/> class.
        /// </summary>
        /// <param name="node"></param>
        /// <param name="conditionalStatement"></param>
        /// <param name="semanticModel">The semantic model.</param>
        protected SwitchStatementASTWalker(CSharpSyntaxNode node, SwitchStatementTranslationUnit SwitchStatement, SemanticModel semanticModel)
            : base(node, semanticModel)
        {
            var statementSyntaxNode = node as SwitchStatementSyntax;

            if (statementSyntaxNode == null)
            {
                throw new ArgumentException(
                          string.Format("Specified node is not of type {0}",
                                        typeof(ForStatementSyntax).Name));
            }

            if (SwitchStatement == null)
            {
                throw new ArgumentNullException(nameof(SwitchStatement));
            }

            // Node assigned in base, no need to assign it here
            this.statement = SwitchStatement;

            // Going through parts in the statement and filling the translation unit with initial data
            this.VisitNode(statementSyntaxNode, 0);
        }