зеркало из https://github.com/dotnet/razor.git
Remove code document parameter and just use document snapshot
This commit is contained in:
Родитель
7470352912
Коммит
7d5b2060c6
|
@ -24,9 +24,10 @@ internal sealed class RazorComponentDefinitionService(
|
|||
ILoggerFactory loggerFactory)
|
||||
: AbstractRazorComponentDefinitionService(componentSearchEngine, documentMappingService, loggerFactory.GetOrCreateLogger<RazorComponentDefinitionService>())
|
||||
{
|
||||
protected override ValueTask<SyntaxTree> GetCSharpSyntaxTreeAsync(IDocumentSnapshot documentSnapshot, RazorCodeDocument codeDocument, CancellationToken cancellationToken)
|
||||
protected override async ValueTask<SyntaxTree> GetCSharpSyntaxTreeAsync(IDocumentSnapshot documentSnapshot, CancellationToken cancellationToken)
|
||||
{
|
||||
var codeDocument = await documentSnapshot.GetGeneratedOutputAsync().ConfigureAwait(false);
|
||||
var csharpText = codeDocument.GetCSharpSourceText();
|
||||
return new(CSharpSyntaxTree.ParseText(csharpText, cancellationToken: cancellationToken));
|
||||
return CSharpSyntaxTree.ParseText(csharpText, cancellationToken: cancellationToken);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ internal abstract class AbstractRazorComponentDefinitionService(
|
|||
_logger.LogInformation($"Attempting to get definition from an attribute directly.");
|
||||
|
||||
var originCodeDocument = await documentSnapshot.GetGeneratedOutputAsync().ConfigureAwait(false);
|
||||
var syntaxTree = await GetCSharpSyntaxTreeAsync(documentSnapshot, originCodeDocument, cancellationToken).ConfigureAwait(false);
|
||||
var syntaxTree = await GetCSharpSyntaxTreeAsync(documentSnapshot, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
var range = await RazorComponentDefinitionHelpers
|
||||
.TryGetPropertyRangeAsync(originCodeDocument, syntaxTree, attributeDescriptor.GetPropertyName(), _documentMappingService, _logger, cancellationToken)
|
||||
|
@ -89,5 +89,5 @@ internal abstract class AbstractRazorComponentDefinitionService(
|
|||
return VsLspFactory.DefaultRange;
|
||||
}
|
||||
|
||||
protected abstract ValueTask<SyntaxTree> GetCSharpSyntaxTreeAsync(IDocumentSnapshot documentSnapshot, RazorCodeDocument codeDocument, CancellationToken cancellationToken);
|
||||
protected abstract ValueTask<SyntaxTree> GetCSharpSyntaxTreeAsync(IDocumentSnapshot documentSnapshot, CancellationToken cancellationToken);
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ using System.Diagnostics;
|
|||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Razor;
|
||||
using Microsoft.AspNetCore.Razor.Language;
|
||||
using Microsoft.CodeAnalysis.Razor.DocumentMapping;
|
||||
using Microsoft.CodeAnalysis.Razor.GoToDefinition;
|
||||
using Microsoft.CodeAnalysis.Razor.Logging;
|
||||
|
@ -27,7 +26,7 @@ internal sealed class RazorComponentDefinitionService(
|
|||
{
|
||||
private readonly IFilePathService _filePathService = filePathService;
|
||||
|
||||
protected override async ValueTask<SyntaxTree> GetCSharpSyntaxTreeAsync(IDocumentSnapshot documentSnapshot, RazorCodeDocument codeDocument, CancellationToken cancellationToken)
|
||||
protected override async ValueTask<SyntaxTree> GetCSharpSyntaxTreeAsync(IDocumentSnapshot documentSnapshot, CancellationToken cancellationToken)
|
||||
{
|
||||
Debug.Assert(documentSnapshot is RemoteDocumentSnapshot, "This method only works on document snapshots created in the OOP process");
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче