public static async Task ComputeRefactoringsAsync(RefactoringContext context, ArgumentListSyntax argumentList) { SeparatedSyntaxList <ArgumentSyntax> arguments = argumentList.Arguments; if (arguments.Count == 0) { return; } await ArgumentParameterNameRefactoring.ComputeRefactoringsAsync(context, argumentList).ConfigureAwait(false); if (context.IsRefactoringEnabled(RefactoringIdentifiers.DuplicateArgument)) { var refactoring = new DuplicateArgumentRefactoring(argumentList); refactoring.ComputeRefactoring(context); } if (context.IsRefactoringEnabled(RefactoringIdentifiers.FormatArgumentList) && (context.Span.IsEmpty || context.Span.IsBetweenSpans(argumentList))) { if (argumentList.IsSingleLine()) { if (arguments.Count > 1) { context.RegisterRefactoring( "Format each argument on a separate line", cancellationToken => { return(FormatArgumentListRefactoring.FormatEachArgumentOnSeparateLineAsync( context.Document, argumentList, cancellationToken)); }); } } else { string title = arguments.Count == 1 ? "Format argument on a single line" : "Format all arguments on a single line"; context.RegisterRefactoring( title, cancellationToken => { return(FormatArgumentListRefactoring.FormatAllArgumentsOnSingleLineAsync( context.Document, argumentList, cancellationToken)); }); } } }
public static async Task ComputeRefactoringsAsync(RefactoringContext context, ArgumentListSyntax argumentList) { SeparatedSyntaxList <ArgumentSyntax> arguments = argumentList.Arguments; if (arguments.Count == 0) { return; } await AddOrRemoveParameterNameRefactoring.ComputeRefactoringsAsync(context, argumentList).ConfigureAwait(false); if (context.IsRefactoringEnabled(RefactoringIdentifiers.DuplicateArgument)) { var refactoring = new DuplicateArgumentRefactoring(argumentList); refactoring.ComputeRefactoring(context); } if (context.IsRefactoringEnabled(RefactoringIdentifiers.FormatArgumentList) && (context.Span.IsEmpty || context.Span.IsBetweenSpans(argumentList))) { if (argumentList.IsSingleLine()) { if (arguments.Count > 1) { context.RegisterRefactoring( "Format arguments on separate lines", cancellationToken => { return(CSharpFormatter.ToMultiLineAsync( context.Document, argumentList, cancellationToken)); }); } } else { context.RegisterRefactoring( "Format arguments on a single line", cancellationToken => { return(CSharpFormatter.ToSingleLineAsync( context.Document, argumentList, cancellationToken)); }); } } }
public static async Task ComputeRefactoringsAsync(RefactoringContext context, ArgumentListSyntax argumentList) { SeparatedSyntaxList <ArgumentSyntax> arguments = argumentList.Arguments; if (!arguments.Any()) { return; } await AddOrRemoveParameterNameRefactoring.ComputeRefactoringsAsync(context, argumentList).ConfigureAwait(false); if (context.IsRefactoringEnabled(RefactoringIdentifiers.DuplicateArgument)) { var refactoring = new DuplicateArgumentRefactoring(argumentList); refactoring.ComputeRefactoring(context, RefactoringIdentifiers.DuplicateArgument); } if (context.IsRefactoringEnabled(RefactoringIdentifiers.FormatArgumentList) && (context.Span.IsEmptyAndContainedInSpanOrBetweenSpans(argumentList))) { if (argumentList.IsSingleLine()) { if (arguments.Count > 1) { context.RegisterRefactoring( "Format arguments on separate lines", ct => SyntaxFormatter.ToMultiLineAsync(context.Document, argumentList, ct), RefactoringIdentifiers.FormatArgumentList); } } else if (argumentList.DescendantTrivia(argumentList.Span).All(f => f.IsWhitespaceOrEndOfLineTrivia())) { context.RegisterRefactoring( "Format arguments on a single line", ct => SyntaxFormatter.ToSingleLineAsync(context.Document, argumentList, ct), RefactoringIdentifiers.FormatArgumentList); } } }
public static async Task ComputeRefactoringsAsync(RefactoringContext context, ArgumentListSyntax argumentList) { SeparatedSyntaxList <ArgumentSyntax> arguments = argumentList.Arguments; if (!arguments.Any()) { return; } await AddOrRemoveArgumentNameRefactoring.ComputeRefactoringsAsync(context, argumentList).ConfigureAwait(false); if (context.IsRefactoringEnabled(RefactoringDescriptors.CopyArgument)) { var refactoring = new CopyArgumentRefactoring(argumentList); refactoring.ComputeRefactoring(context, RefactoringDescriptors.CopyArgument); } if (context.IsRefactoringEnabled(RefactoringDescriptors.WrapArguments) && (context.Span.IsEmptyAndContainedInSpanOrBetweenSpans(argumentList))) { if (argumentList.IsSingleLine()) { if (arguments.Count > 1) { context.RegisterRefactoring( "Wrap arguments", ct => SyntaxFormatter.WrapArgumentsAsync(context.Document, argumentList, ct), RefactoringDescriptors.WrapArguments); } } else if (argumentList.DescendantTrivia(argumentList.Span).All(f => f.IsWhitespaceOrEndOfLineTrivia())) { context.RegisterRefactoring( "Unwrap arguments", ct => SyntaxFormatter.UnwrapExpressionAsync(context.Document, argumentList, ct), RefactoringDescriptors.WrapArguments); } } }