Add OnAutoInsert delegation target

This commit is contained in:
David Wengier 2022-09-06 13:44:27 +10:00
Родитель 3dbb7adf40
Коммит 31b2fe5815
4 изменённых файлов: 40 добавлений и 0 удалений

Просмотреть файл

@ -42,5 +42,7 @@ namespace Microsoft.AspNetCore.Razor.LanguageServer.Common
public const string RazorSignatureHelpEndpointName = "razor/signatureHelp";
public const string RazorImplementationEndpointName = "razor/implementation";
public const string RazorOnAutoInsertnEndpointName = "razor/onAutoInsert";
}
}

Просмотреть файл

@ -14,6 +14,13 @@ internal record DelegatedPositionParams(
Position ProjectedPosition,
RazorLanguageKind ProjectedKind) : IDelegatedParams;
internal record DelegatedOnAutoInsertParams(
VersionedTextDocumentIdentifier HostDocument,
Position ProjectedPosition,
RazorLanguageKind ProjectedKind,
string Character,
FormattingOptions Options) : IDelegatedParams;
internal record DelegatedRenameParams(
VersionedTextDocumentIdentifier HostDocument,
Position ProjectedPosition,

Просмотреть файл

@ -1083,6 +1083,34 @@ namespace Microsoft.VisualStudio.LanguageServerClient.Razor
return response?.Response;
}
public override async Task<VSInternalDocumentOnAutoInsertResponseItem?> OnAutoInsertAsync(DelegatedOnAutoInsertParams request, CancellationToken cancellationToken)
{
var delegationDetails = await GetProjectedRequestDetailsAsync(request, cancellationToken).ConfigureAwait(false);
if (delegationDetails is null)
{
return default;
}
var onAutoInsertParams = new VSInternalDocumentOnAutoInsertParams
{
TextDocument = new TextDocumentIdentifier()
{
Uri = delegationDetails.Value.ProjectedUri,
},
Position = request.ProjectedPosition,
Character = request.Character,
Options = request.Options
};
var response = await _requestInvoker.ReinvokeRequestOnServerAsync<VSInternalDocumentOnAutoInsertParams, VSInternalDocumentOnAutoInsertResponseItem?>(
delegationDetails.Value.TextBuffer,
VSInternalMethods.OnAutoInsertName,
delegationDetails.Value.LanguageServerName,
onAutoInsertParams,
cancellationToken).ConfigureAwait(false);
return response?.Response;
}
public override Task<VSInternalHover?> HoverAsync(DelegatedPositionParams request, CancellationToken cancellationToken)
=> DelegateTextDocumentPositionRequestAsync<VSInternalHover>(request, Methods.TextDocumentHoverName, cancellationToken);

Просмотреть файл

@ -114,5 +114,8 @@ namespace Microsoft.VisualStudio.LanguageServerClient.Razor
[JsonRpcMethod(RazorLanguageServerCustomMessageTargets.RazorImplementationEndpointName, UseSingleObjectParameterDeserialization = true)]
public abstract Task<ImplementationResult> ImplementationAsync(DelegatedPositionParams request, CancellationToken cancellationToken);
[JsonRpcMethod(RazorLanguageServerCustomMessageTargets.RazorOnAutoInsertnEndpointName, UseSingleObjectParameterDeserialization = true)]
public abstract Task<VSInternalDocumentOnAutoInsertResponseItem?> OnAutoInsertAsync(DelegatedOnAutoInsertParams request, CancellationToken cancellationToken);
}
}