public static void ComputeRefactorings(RefactoringContext context, ElseClauseSyntax elseClause) { if (context.IsRefactoringEnabled(RefactoringIdentifiers.RemoveConditionFromLastElse) && elseClause.ElseKeyword.Span.Contains(context.Span) && elseClause.Statement?.IsKind(SyntaxKind.IfStatement) == true && ((IfStatementSyntax)elseClause.Statement).Else == null) { context.RegisterRefactoring( "Remove condition", cancellationToken => { return RemoveConditionFromLastElseAsync( context.Document, elseClause, cancellationToken); }); } if (context.IsRefactoringEnabled(RefactoringIdentifiers.AddBraces) && elseClause.Statement?.IsKind(SyntaxKind.IfStatement) == true) { var ifStatement = (IfStatementSyntax)elseClause.Statement; if (ifStatement.IfKeyword.Span.Contains(context.Span) || context.Span.IsBetweenSpans(ifStatement)) { AddBracesRefactoring.RegisterRefactoring(context, ifStatement); } } }
public static void ComputeRefactorings(RefactoringContext context, ElseClauseSyntax elseClause) { if (context.IsRefactoringEnabled(RefactoringDescriptors.RemoveConditionFromLastElse) && context.Span.IsEmptyAndContainedInSpan(elseClause.ElseKeyword)) { RemoveConditionFromLastElseRefactoring.ComputeRefactorings(context, elseClause); } if (context.IsRefactoringEnabled(RefactoringDescriptors.AddBraces) && elseClause.Statement?.Kind() == SyntaxKind.IfStatement) { var ifStatement = (IfStatementSyntax)elseClause.Statement; if (ifStatement.IfKeyword.Span.Contains(context.Span) || context.Span.IsBetweenSpans(ifStatement)) { AddBracesRefactoring.RegisterRefactoring(context, ifStatement); } } }