public async Task <WorkspaceEdit> HandleRequestAsync(RenameParams request, ClientCapabilities clientCapabilities, CancellationToken cancellationToken)
        {
            if (request is null)
            {
                throw new ArgumentNullException(nameof(request));
            }

            if (clientCapabilities is null)
            {
                throw new ArgumentNullException(nameof(clientCapabilities));
            }

            if (!_documentManager.TryGetDocument(request.TextDocument.Uri, out var documentSnapshot))
            {
                return(null);
            }

            var projectionResult = await _projectionProvider.GetProjectionAsync(documentSnapshot, request.Position, cancellationToken).ConfigureAwait(false);

            if (projectionResult == null)
            {
                // We only support C# renames for now.
                return(null);
            }

            cancellationToken.ThrowIfCancellationRequested();

            var renameParams = new RenameParams()
            {
                Position     = projectionResult.Position,
                NewName      = request.NewName,
                TextDocument = new TextDocumentIdentifier()
                {
                    Uri = projectionResult.Uri
                }
            };

            var result = await _requestInvoker.ReinvokeRequestOnServerAsync <RenameParams, WorkspaceEdit>(
                Methods.TextDocumentRenameName,
                projectionResult.LanguageKind.ToContainedLanguageContentType(),
                renameParams,
                cancellationToken).ConfigureAwait(false);

            if (result == null)
            {
                return(null);
            }

            cancellationToken.ThrowIfCancellationRequested();

            var remappedResult = await _documentMappingProvider.RemapWorkspaceEditAsync(result, cancellationToken).ConfigureAwait(false);

            return(remappedResult);
        }
        public async Task <WorkspaceEdit?> HandleRequestAsync(RenameParams request, ClientCapabilities clientCapabilities, CancellationToken cancellationToken)
        {
            if (request is null)
            {
                throw new ArgumentNullException(nameof(request));
            }

            if (clientCapabilities is null)
            {
                throw new ArgumentNullException(nameof(clientCapabilities));
            }

            _logger.LogInformation($"Starting request for {request.TextDocument.Uri}.");

            if (!_documentManager.TryGetDocument(request.TextDocument.Uri, out var documentSnapshot))
            {
                _logger.LogWarning($"Failed to find document {request.TextDocument.Uri}.");
                return(null);
            }

            var projectionResult = await _projectionProvider.GetProjectionAsync(
                documentSnapshot,
                request.Position,
                cancellationToken).ConfigureAwait(false);

            if (projectionResult is null)
            {
                return(null);
            }

            cancellationToken.ThrowIfCancellationRequested();

            var renameParams = new RenameParams()
            {
                Position     = projectionResult.Position,
                NewName      = request.NewName,
                TextDocument = new TextDocumentIdentifier()
                {
                    Uri = projectionResult.Uri
                }
            };

            _logger.LogInformation($"Requesting rename for {projectionResult.Uri}.");

            var serverKind         = projectionResult.LanguageKind.ToLanguageServerKind();
            var textBuffer         = serverKind.GetTextBuffer(documentSnapshot);
            var languageServerName = serverKind.ToLanguageServerName();
            var response           = await _requestInvoker.ReinvokeRequestOnServerAsync <RenameParams, WorkspaceEdit>(
                textBuffer,
                Methods.TextDocumentRenameName,
                languageServerName,
                renameParams,
                cancellationToken).ConfigureAwait(false);

            if (!ReinvocationResponseHelper.TryExtractResultOrLog(response, _logger, languageServerName, out var result))
            {
                return(null);
            }

            _logger.LogInformation("Received result, remapping.");

            var remappedResult = await _documentMappingProvider.RemapWorkspaceEditAsync(result, cancellationToken).ConfigureAwait(false);

            _logger.LogInformation("Returned rename result.");
            return(remappedResult);
        }