This commit is contained in:
David Wengier 2024-07-19 10:52:05 +10:00
Родитель 4670d3ee1b
Коммит 3f524c0b60
3 изменённых файлов: 12 добавлений и 12 удалений

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

@ -16,6 +16,6 @@ internal interface IRemoteUriPresentationService
[DataContract]
public record struct Response(
[property: DataMember(Order = 0)] bool ShouldCallHtml,
[property: DataMember(Order = 0)] bool CallHtml,
[property: DataMember(Order = 1)] TextChange? TextChange);
}

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

@ -37,9 +37,9 @@ internal sealed partial class RemoteUriPresentationService(in ServiceArgs args)
context => GetPresentationAsync(context, span, uris, cancellationToken),
cancellationToken);
private static IRemoteUriPresentationService.Response ShouldCallHtml => new(ShouldCallHtml: true, TextChange: null);
private static IRemoteUriPresentationService.Response DontCallHtml => new(ShouldCallHtml: false, TextChange: null);
private static IRemoteUriPresentationService.Response TextChange(TextChange textChange) => new(ShouldCallHtml: false, TextChange: textChange);
private static IRemoteUriPresentationService.Response CallHtml => new(CallHtml: true, TextChange: null);
private static IRemoteUriPresentationService.Response NoFurtherHandling => new(CallHtml: false, TextChange: null);
private static IRemoteUriPresentationService.Response TextChange(TextChange textChange) => new(CallHtml: false, TextChange: textChange);
private async ValueTask<IRemoteUriPresentationService.Response> GetPresentationAsync(
RemoteDocumentContext context,
@ -51,7 +51,7 @@ internal sealed partial class RemoteUriPresentationService(in ServiceArgs args)
if (!sourceText.TryGetAbsoluteIndex(span.Start.Line, span.Start.Character, out var index))
{
// If the position is invalid then we shouldn't expect to be able to handle a Html response
return DontCallHtml;
return NoFurtherHandling;
}
var codeDocument = await context.GetCodeDocumentAsync(cancellationToken).ConfigureAwait(false);
@ -63,13 +63,13 @@ internal sealed partial class RemoteUriPresentationService(in ServiceArgs args)
// our support for Uri presentation is to insert a Html tag, so we only support Html
// If Roslyn add support in future then this is where it would go.
return DontCallHtml;
return NoFurtherHandling;
}
var razorFileUri = UriPresentationHelper.GetComponentFileNameFromUriPresentationRequest(uris, Logger);
if (razorFileUri is null)
{
return ShouldCallHtml;
return CallHtml;
}
var solution = context.TextDocument.Project.Solution;
@ -79,14 +79,14 @@ internal sealed partial class RemoteUriPresentationService(in ServiceArgs args)
var ids = solution.GetDocumentIdsWithFilePath(uriToFind);
if (ids.Length == 0)
{
return ShouldCallHtml;
return CallHtml;
}
// We assume linked documents would produce the same component tag so just take the first
var otherDocument = solution.GetAdditionalDocument(ids[0]);
if (otherDocument is null)
{
return ShouldCallHtml;
return CallHtml;
}
var otherSnapshot = DocumentSnapshotFactory.GetOrCreate(otherDocument);
@ -94,13 +94,13 @@ internal sealed partial class RemoteUriPresentationService(in ServiceArgs args)
if (descriptor is null)
{
return ShouldCallHtml;
return CallHtml;
}
var tag = descriptor.TryGetComponentTag();
if (tag is null)
{
return ShouldCallHtml;
return CallHtml;
}
return TextChange(new TextChange(span.ToTextSpan(sourceText), tag));

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

@ -90,7 +90,7 @@ internal class CohostUriPresentationEndpoint(
}
// If we didn't get anything from our logic, we might need to go and ask Html, but we also might have determined not to
if (!data.ShouldCallHtml)
if (!data.CallHtml)
{
return null;
}