Exemple #1
0
        public static bool TryCreate(StatementSyntax statement, out IStatementContainer container)
        {
            if (statement == null)
            {
                throw new ArgumentNullException(nameof(statement));
            }

            SyntaxNode parent = statement.Parent;

            switch (parent?.Kind())
            {
            case SyntaxKind.Block:
            {
                container = new BlockStatementContainer((BlockSyntax)parent);
                return(true);
            }

            case SyntaxKind.SwitchSection:
            {
                container = new SwitchSectionStatementContainer((SwitchSectionSyntax)parent);
                return(true);
            }

            default:
            {
                container = null;
                return(false);
            }
            }
        }
Exemple #2
0
        public static bool TryCreate(SyntaxNode nodeWithStatements, out StatementContainer container)
        {
            if (nodeWithStatements == null)
            {
                throw new ArgumentNullException(nameof(nodeWithStatements));
            }

            switch (nodeWithStatements.Kind())
            {
            case SyntaxKind.Block:
            {
                container = new BlockStatementContainer((BlockSyntax)nodeWithStatements);
                return(true);
            }

            case SyntaxKind.SwitchSection:
            {
                container = new SwitchSectionStatementContainer((SwitchSectionSyntax)nodeWithStatements);
                return(true);
            }

            default:
            {
                container = null;
                return(false);
            }
            }
        }
        public static SelectedStatementCollection Create(BlockSyntax block, TextSpan span)
        {
            if (block == null)
            {
                throw new ArgumentNullException(nameof(block));
            }

            var container = new BlockStatementContainer(block);

            return(new SelectedStatementCollection(container, span));
        }