async Task <Document> ToRefAsync(Document document, ForEachStatementSyntax forEachStatementSyntax, bool isReadOnly, CancellationToken cancellationToken)
        {
            var newForEachStatementSyntax = forEachStatementSyntax.ToRef(isReadOnly);

            var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);

            if (root is null)
            {
                throw new NullReferenceException();
            }

            root = root.ReplaceNode(forEachStatementSyntax, newForEachStatementSyntax);

            return(document.WithSyntaxRoot(root));
        }