Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
30 lines (27 sloc) 1.41 KB
// Copyright (c) Josef Pihrt. All rights reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.CodeAnalysis.CSharp.Syntax;
namespace Roslynator.CSharp.Refactorings
{
internal static class WhileStatementRefactoring
{
public static void ComputeRefactorings(RefactoringContext context, WhileStatementSyntax whileStatement)
{
if (context.IsRefactoringEnabled(RefactoringIdentifiers.ReplaceWhileWithDo)
&& (whileStatement.WhileKeyword.Span.Contains(context.Span)))
{
context.RegisterRefactoring(
"Replace while with do",
cancellationToken => ReplaceWhileWithDoRefactoring.RefactorAsync(context.Document, whileStatement, cancellationToken),
RefactoringIdentifiers.ReplaceWhileWithDo);
}
if (context.IsRefactoringEnabled(RefactoringIdentifiers.ReplaceWhileWithFor)
&& (whileStatement.WhileKeyword.Span.Contains(context.Span)))
{
context.RegisterRefactoring(
ReplaceWhileWithForRefactoring.Title,
cancellationToken => ReplaceWhileWithForRefactoring.RefactorAsync(context.Document, whileStatement, cancellationToken),
RefactoringIdentifiers.ReplaceWhileWithFor);
}
}
}
}
You can’t perform that action at this time.