public async Task <ImmutableArray <TextChange> > GetFormattingChangesAsync( Document document, TextSpan?textSpan, CancellationToken cancellationToken) { var fallbackOptions = _globalOptions.GetCSharpSyntaxFormattingOptions(); var options = await _indentationManager.GetInferredFormattingOptionsAsync(document, fallbackOptions, explicitFormat : true, cancellationToken).ConfigureAwait(false); var root = await document.GetRequiredSyntaxRootAsync(cancellationToken).ConfigureAwait(false); var span = textSpan ?? new TextSpan(0, root.FullSpan.Length); var formattingSpan = CommonFormattingHelpers.GetFormattingSpan(root, span); var services = document.Project.Solution.Workspace.Services; return(Formatter.GetFormattedTextChanges(root, SpecializedCollections.SingletonEnumerable(formattingSpan), services, options, cancellationToken).ToImmutableArray()); }