private void AnalyzeSyntaxNode(SyntaxNodeAnalysisContext context)
        {
            var switchSection = (SwitchSectionSyntax)context.Node;

            FormatEachStatementOnSeparateLineRefactoring.Analyze(context, switchSection);

            if (AddBreakStatementToSwitchSectionRefactoring.CanRefactor(context, switchSection))
            {
                context.ReportDiagnostic(
                    DiagnosticDescriptors.AddBreakStatementToSwitchSection,
                    switchSection);
            }

            RemoveRedundantDefaultSwitchSectionRefactoring.Analyze(context, switchSection);

            RemoveUnnecessaryCaseLabelRefactoring.Analyze(context, switchSection);

            FormatSwitchSectionStatementOnSeparateLineRefactoring.Analyze(context, switchSection);

            DefaultLabelShouldBeLastLabelInSwitchSectionRefactoring.Analyze(context, switchSection);

            SyntaxList <StatementSyntax> statements = switchSection.Statements;

            if (statements.Count > 1)
            {
                context.ReportDiagnostic(
                    DiagnosticDescriptors.AddBracesToSwitchSectionWithMultipleStatements,
                    Location.Create(switchSection.SyntaxTree, statements.Span));
            }
        }
Пример #2
0
        private void AnalyzeBlock(SyntaxNodeAnalysisContext context)
        {
            var block = (BlockSyntax)context.Node;

            FormatEachStatementOnSeparateLineRefactoring.Analyze(context, block);

            FormatEmptyBlockRefactoring.Analyze(context, block);
        }