Skip to content

Commit 4a33dc1

Browse files
Remove IDocumentMappingService.GetPositionInfoAsync extension method
This method is async just to call DocumentContext.GetCodeDocumentAsync and the only caller has a RazorCodeDocument in hand. So, this method can be removed in favor of the synchronous version.
1 parent b533363 commit 4a33dc1

File tree

2 files changed

+2
-15
lines changed

2 files changed

+2
-15
lines changed

src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Completion/Delegation/DelegatedCompletionListProvider.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,18 +51,15 @@ public DelegatedCompletionListProvider(
5151
Guid correlationId,
5252
CancellationToken cancellationToken)
5353
{
54-
var positionInfo = await _documentMappingService
55-
.GetPositionInfoAsync(documentContext, absoluteIndex, cancellationToken)
56-
.ConfigureAwait(false);
54+
var codeDocument = await documentContext.GetCodeDocumentAsync(cancellationToken).ConfigureAwait(false);
5755

56+
var positionInfo = _documentMappingService.GetPositionInfo(codeDocument, absoluteIndex);
5857
if (positionInfo.LanguageKind == RazorLanguageKind.Razor)
5958
{
6059
// Nothing to delegate to.
6160
return null;
6261
}
6362

64-
var codeDocument = await documentContext.GetCodeDocumentAsync(cancellationToken).ConfigureAwait(false);
65-
6663
TextEdit? provisionalTextEdit = null;
6764
if (DelegatedCompletionHelper.TryGetProvisionalCompletionInfo(codeDocument, completionContext, positionInfo, _documentMappingService, out var provisionalCompletion))
6865
{

src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/DocumentMapping/IDocumentMappingServiceExtensions.cs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,8 @@
55
using System.Diagnostics;
66
using System.Diagnostics.CodeAnalysis;
77
using System.Linq;
8-
using System.Threading;
9-
using System.Threading.Tasks;
108
using Microsoft.AspNetCore.Razor;
119
using Microsoft.AspNetCore.Razor.Language;
12-
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
1310
using Microsoft.CodeAnalysis.Razor.Protocol;
1411
using Microsoft.CodeAnalysis.Text;
1512
using Microsoft.VisualStudio.LanguageServer.Protocol;
@@ -35,13 +32,6 @@ public static bool TryMapToHostDocumentRange(this IDocumentMappingService servic
3532
public static bool TryMapToHostDocumentRange(this IDocumentMappingService service, IRazorGeneratedDocument generatedDocument, Range projectedRange, [NotNullWhen(true)] out Range? originalRange)
3633
=> service.TryMapToHostDocumentRange(generatedDocument, projectedRange, MappingBehavior.Strict, out originalRange);
3734

38-
public static async Task<DocumentPositionInfo> GetPositionInfoAsync(this IDocumentMappingService service, DocumentContext documentContext, int hostDocumentIndex, CancellationToken cancellationToken)
39-
{
40-
var codeDocument = await documentContext.GetCodeDocumentAsync(cancellationToken).ConfigureAwait(false);
41-
42-
return service.GetPositionInfo(codeDocument, hostDocumentIndex);
43-
}
44-
4535
public static DocumentPositionInfo GetPositionInfo(
4636
this IDocumentMappingService service,
4737
RazorCodeDocument codeDocument,

0 commit comments

Comments
 (0)