private static async Task <Document> UpdateDocumentAsync( Document document, SyntaxNode root, SyntaxNode declaration, UseExpressionBodyHelper helper, bool useExpressionBody, CancellationToken cancellationToken ) { var semanticModel = await document .GetSemanticModelAsync(cancellationToken) .ConfigureAwait(false); var updatedDeclaration = helper.Update(semanticModel, declaration, useExpressionBody); var parent = declaration is AccessorDeclarationSyntax ? declaration.Parent : declaration; RoslynDebug.Assert(parent is object); var updatedParent = parent .ReplaceNode(declaration, updatedDeclaration) .WithAdditionalAnnotations(Formatter.Annotation); var newRoot = root.ReplaceNode(parent, updatedParent); return(document.WithSyntaxRoot(newRoot)); }
private Task <Document> UpdateDocumentAsync( Document document, SyntaxNode root, SyntaxNode declaration, OptionSet options, UseExpressionBodyHelper helper, bool useExpressionBody, CancellationToken cancellationToken) { var updatedDeclaration = helper.Update(declaration, options, useExpressionBody) .WithAdditionalAnnotations(Formatter.Annotation); var newRoot = root.ReplaceNode(declaration, updatedDeclaration); return(Task.FromResult(document.WithSyntaxRoot(newRoot))); }
private Task <Document> UpdateDocumentAsync( Document document, SyntaxNode root, SyntaxNode declaration, OptionSet options, UseExpressionBodyHelper helper, bool useExpressionBody, CancellationToken cancellationToken) { var parseOptions = root.SyntaxTree.Options; var updatedDeclaration = helper.Update(declaration, options, parseOptions, useExpressionBody); var parent = declaration is AccessorDeclarationSyntax ? declaration.Parent : declaration; var updatedParent = parent.ReplaceNode(declaration, updatedDeclaration) .WithAdditionalAnnotations(Formatter.Annotation); var newRoot = root.ReplaceNode(parent, updatedParent); return(Task.FromResult(document.WithSyntaxRoot(newRoot))); }