예제 #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);
            }
            }
        }
예제 #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(SwitchSectionSyntax switchSection, TextSpan span)
        {
            if (switchSection == null)
            {
                throw new ArgumentNullException(nameof(switchSection));
            }

            var container = new SwitchSectionStatementContainer(switchSection);

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