Ejemplo n.º 1
0
 /// <summary>
 /// Copy initializes a new instance of the <see cref="TryStatementASTWalker"/> class.
 /// </summary>
 /// <param name="other"></param>
 /// <remarks>
 /// For testability.
 /// </remarks>
 public TryStatementASTWalker(TryStatementASTWalker other)
     : base(other)
 {
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Builds the proper <see cref="StatementASTWalker"/> given the provided <see cref="StatementSyntax"/>.
        /// </summary>
        /// <returns></returns>
        public IASTWalker Build()
        {
            switch (this.node.Kind())
            {
            case SyntaxKind.BreakStatement:
            case SyntaxKind.ContinueStatement:
                return(KeywordStatementASTWalker.Create(this.node, this.semanticModel));

            case SyntaxKind.CheckedStatement:
            case SyntaxKind.DoStatement:
            case SyntaxKind.EmptyStatement:
                return(null);

            case SyntaxKind.ForEachStatement:
                return(ForEachStatementASTWalker.Create(this.node, this.semanticModel));

            case SyntaxKind.ForStatement:
                return(ForStatementASTWalker.Create(this.node, this.semanticModel));

            case SyntaxKind.FixedStatement:
            case SyntaxKind.GlobalStatement:
            case SyntaxKind.GotoCaseStatement:
            case SyntaxKind.GotoDefaultStatement:
            case SyntaxKind.GotoStatement:
                return(null);

            case SyntaxKind.IfStatement:
                return(ConditionalStatementASTWalker.Create(this.node, this.semanticModel));

            case SyntaxKind.LabeledStatement:
                return(null);

            case SyntaxKind.LocalDeclarationStatement:
                return(LocalDeclarationStatementASTWalker.Create(this.node, this.semanticModel));

            case SyntaxKind.ExpressionStatement:
            case SyntaxKind.ReturnStatement:
            case SyntaxKind.ThrowStatement:
                return(ExpressionStatementASTWalker.Create(this.node, this.semanticModel));

            case SyntaxKind.SwitchStatement:
                return(SwitchStatementASTWalker.Create(this.node, this.semanticModel));

            case SyntaxKind.TryStatement:
                return(TryStatementASTWalker.Create(this.node, this.semanticModel));

            case SyntaxKind.UncheckedStatement:
            case SyntaxKind.UsingStatement:
            case SyntaxKind.WhileStatement:
                return(null);

            // Unsupported stuff
            case SyntaxKind.UnsafeStatement:
            case SyntaxKind.LockStatement:
            case SyntaxKind.YieldBreakStatement:
            case SyntaxKind.YieldReturnStatement:
                throw new UnsupportedSyntaxException(this.node);
            }

            throw new InvalidOperationException("Building path reached an invalid non decidible state!");
        }