This commit is contained in:
DoctorKrolic 2022-02-17 17:35:21 +03:00 коммит произвёл N. Taylor Mullen
Родитель 340ee1728c
Коммит 0fdbf1ed04
11 изменённых файлов: 24 добавлений и 53 удалений

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

@ -76,7 +76,7 @@
<Tooling_MicrosoftCodeAnalysisTestingVersion>1.0.1-beta1.21103.2</Tooling_MicrosoftCodeAnalysisTestingVersion>
<MicrosoftVisualStudioShellPackagesVersion>17.0.31723.112</MicrosoftVisualStudioShellPackagesVersion>
<MicrosoftVisualStudioPackagesVersion>17.0.487</MicrosoftVisualStudioPackagesVersion>
<RoslynPackageVersion>4.2.0-2.22108.10</RoslynPackageVersion>
<RoslynPackageVersion>4.1.0-1.21471.13</RoslynPackageVersion>
<VisualStudioLanguageServerProtocolVersion>17.1.11</VisualStudioLanguageServerProtocolVersion>
</PropertyGroup>
<PropertyGroup Label="Manual">
@ -107,13 +107,13 @@
<MicrosoftVisualStudioLanguageServerProtocolInternalPackageVersion>$(VisualStudioLanguageServerProtocolVersion)</MicrosoftVisualStudioLanguageServerProtocolInternalPackageVersion>
<MicrosoftVisualStudioLiveSharePackageVersion>0.3.1074</MicrosoftVisualStudioLiveSharePackageVersion>
<MicrosoftVisualStudioProjectSystemSDKPackageVersion>16.10.81-pre</MicrosoftVisualStudioProjectSystemSDKPackageVersion>
<MicrosoftVisualStudioRpcContractsVersion>17.0.51</MicrosoftVisualStudioRpcContractsVersion>
<MicrosoftVisualStudioRpcContractsVersion>17.0.50-preview-0001-0001</MicrosoftVisualStudioRpcContractsVersion>
<MicrosoftVisualStudioShell150PackageVersion>$(MicrosoftVisualStudioShellPackagesVersion)</MicrosoftVisualStudioShell150PackageVersion>
<MicrosoftVisualStudioInteropPackageVersion>$(MicrosoftVisualStudioShellPackagesVersion)</MicrosoftVisualStudioInteropPackageVersion>
<MicrosoftVisualStudioTextDataPackageVersion>$(MicrosoftVisualStudioPackagesVersion)</MicrosoftVisualStudioTextDataPackageVersion>
<MicrosoftVisualStudioTextImplementationPackageVersion>$(MicrosoftVisualStudioPackagesVersion)</MicrosoftVisualStudioTextImplementationPackageVersion>
<MicrosoftVisualStudioTextLogicPackageVersion>$(MicrosoftVisualStudioPackagesVersion)</MicrosoftVisualStudioTextLogicPackageVersion>
<MicrosoftVisualStudioThreadingPackageVersion>17.0.64</MicrosoftVisualStudioThreadingPackageVersion>
<MicrosoftVisualStudioThreadingPackageVersion>17.0.63</MicrosoftVisualStudioThreadingPackageVersion>
<MicrosoftVisualStudioWebPackageVersion>16.10.0-preview-1-31008-014</MicrosoftVisualStudioWebPackageVersion>
<MicrosoftVisualStudioValidationPackageVersion>17.0.16-alpha</MicrosoftVisualStudioValidationPackageVersion>
<MicrosoftWebToolsLanguagesHtmlPackageVersion>$(Tooling_HtmlEditorPackageVersion)</MicrosoftWebToolsLanguagesHtmlPackageVersion>
@ -124,12 +124,12 @@
<MonoAddinsPackageVersion>1.3.8</MonoAddinsPackageVersion>
<MonoDevelopSdkPackageVersion>1.0.15</MonoDevelopSdkPackageVersion>
<MoqPackageVersion>4.16.0</MoqPackageVersion>
<NerdbankStreamsPackageVersion>2.8.57</NerdbankStreamsPackageVersion>
<NerdbankStreamsPackageVersion>2.7.74</NerdbankStreamsPackageVersion>
<NuGetSolutionRestoreManagerInteropVersion>4.8.0</NuGetSolutionRestoreManagerInteropVersion>
<OmniSharpExtensionsLanguageServerPackageVersion>0.19.5</OmniSharpExtensionsLanguageServerPackageVersion>
<OmniSharpExtensionsLanguageProtocolPackageVersion>$(OmniSharpExtensionsLanguageServerPackageVersion)</OmniSharpExtensionsLanguageProtocolPackageVersion>
<OmniSharpMSBuildPackageVersion>1.37.13</OmniSharpMSBuildPackageVersion>
<StreamJsonRpcPackageVersion>2.11.14-alpha</StreamJsonRpcPackageVersion>
<StreamJsonRpcPackageVersion>2.8.28</StreamJsonRpcPackageVersion>
<SystemRuntimeInteropServicesRuntimePackageVersion>4.3.0</SystemRuntimeInteropServicesRuntimePackageVersion>
<Tooling_MicrosoftCodeAnalysisAnalyzersPackageVersion>3.3.3</Tooling_MicrosoftCodeAnalysisAnalyzersPackageVersion>
<Tooling_MicrosoftCodeAnalysisNetAnalyzersPackageVersion>6.0.0-preview3.21158.1</Tooling_MicrosoftCodeAnalysisNetAnalyzersPackageVersion>

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

@ -151,7 +151,7 @@ namespace Microsoft.CodeAnalysis.Razor.Workspaces
// the dynamic file info. The properties service contains the client name and allows the C#
// server to recognize the document.
var documentServiceProvider = associatedEntry.Current.DocumentServiceProvider;
var excerptService = documentServiceProvider.GetService<IRazorDocumentExcerptServiceImplementation>();
var excerptService = documentServiceProvider.GetService<IRazorDocumentExcerptService>();
var mappingService = documentServiceProvider.GetService<IRazorSpanMappingService>();
var emptyContainer = new PromotedDynamicDocumentContainer(
documentUri, propertiesService, excerptService, mappingService, associatedEntry.Current.TextLoader);
@ -411,14 +411,14 @@ namespace Microsoft.CodeAnalysis.Razor.Workspaces
{
private readonly Uri _documentUri;
private readonly IRazorDocumentPropertiesService _documentPropertiesService;
private readonly IRazorDocumentExcerptServiceImplementation _documentExcerptService;
private readonly IRazorDocumentExcerptService _documentExcerptService;
private readonly IRazorSpanMappingService _spanMappingService;
private readonly TextLoader _textLoader;
public PromotedDynamicDocumentContainer(
Uri documentUri,
IRazorDocumentPropertiesService documentPropertiesService,
IRazorDocumentExcerptServiceImplementation documentExcerptService,
IRazorDocumentExcerptService documentExcerptService,
IRazorSpanMappingService spanMappingService,
TextLoader textLoader)
{
@ -451,7 +451,7 @@ namespace Microsoft.CodeAnalysis.Razor.Workspaces
public override IRazorDocumentPropertiesService GetDocumentPropertiesService() => _documentPropertiesService;
public override IRazorDocumentExcerptServiceImplementation GetExcerptService() => _documentExcerptService;
public override IRazorDocumentExcerptService GetExcerptService() => _documentExcerptService;
public override IRazorSpanMappingService GetMappingService() => _spanMappingService;

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

@ -15,16 +15,15 @@ using Microsoft.CodeAnalysis.Text;
namespace Microsoft.CodeAnalysis.Razor
{
internal abstract class DocumentExcerptServiceBase : IRazorDocumentExcerptServiceImplementation
internal abstract class DocumentExcerptServiceBase : IRazorDocumentExcerptService
{
public async Task<RazorExcerptResult?> TryExcerptAsync(
Document document,
TextSpan span,
RazorExcerptMode mode,
RazorClassificationOptionsWrapper options,
CancellationToken cancellationToken)
{
var result = await TryGetExcerptInternalAsync(document, span, (ExcerptModeInternal)mode, options, cancellationToken).ConfigureAwait(false);
var result = await TryGetExcerptInternalAsync(document, span, (ExcerptModeInternal)mode, cancellationToken).ConfigureAwait(false);
return result?.ToExcerptResult();
}
@ -32,7 +31,6 @@ namespace Microsoft.CodeAnalysis.Razor
Document document,
TextSpan span,
ExcerptModeInternal mode,
RazorClassificationOptionsWrapper options,
CancellationToken cancellationToken);
protected TextSpan ChooseExcerptSpan(SourceText text, TextSpan span, ExcerptModeInternal mode)

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

@ -17,7 +17,7 @@ namespace Microsoft.CodeAnalysis.Razor.Workspaces
public abstract IRazorSpanMappingService GetMappingService();
public abstract IRazorDocumentExcerptServiceImplementation GetExcerptService();
public abstract IRazorDocumentExcerptService GetExcerptService();
public abstract IRazorDocumentPropertiesService GetDocumentPropertiesService();
}

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

@ -42,7 +42,6 @@ namespace Microsoft.CodeAnalysis.Razor
Document document,
TextSpan span,
ExcerptModeInternal mode,
RazorClassificationOptionsWrapper options,
CancellationToken cancellationToken)
{
if (_document is null)
@ -79,7 +78,6 @@ namespace Microsoft.CodeAnalysis.Razor
excerptSpan,
generatedDocument,
mappings,
options,
cancellationToken).ConfigureAwait(false);
var excerptText = GetTranslatedExcerptText(razorDocumentText, ref razorDocumentSpan, ref excerptSpan, classifiedSpans);
@ -91,7 +89,6 @@ namespace Microsoft.CodeAnalysis.Razor
TextSpan excerptSpan,
Document generatedDocument,
IReadOnlyList<SourceMapping> mappings,
RazorClassificationOptionsWrapper options,
CancellationToken cancellationToken)
{
var builder = ImmutableArray.CreateBuilder<ClassifiedSpan>();
@ -134,10 +131,9 @@ namespace Microsoft.CodeAnalysis.Razor
//
// However, we'll have to translate it to the the generated document's coordinates to do that.
Debug.Assert(remainingSpan.Contains(primarySpan) && remainingSpan.Start == primarySpan.Start);
var classifiedSecondarySpans = await RazorClassifierAccessor.GetClassifiedSpansAsync(
var classifiedSecondarySpans = await Classifier.GetClassifiedSpansAsync(
generatedDocument,
secondarySpan,
options,
cancellationToken);
// NOTE: The Classifier will only returns spans for things that it understands. That means

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

@ -11,7 +11,7 @@ namespace Microsoft.CodeAnalysis.Razor.Workspaces
private readonly object _lock;
private IRazorSpanMappingService? _spanMappingService;
private IRazorDocumentExcerptServiceImplementation? _documentExcerptService;
private IRazorDocumentExcerptService? _documentExcerptService;
private IRazorDocumentPropertiesService? _documentPropertiesService;
public RazorDocumentServiceProvider()
@ -55,7 +55,7 @@ namespace Microsoft.CodeAnalysis.Razor.Workspaces
return (TService)_spanMappingService;
}
if (serviceType == typeof(IRazorDocumentExcerptServiceImplementation))
if (serviceType == typeof(IRazorDocumentExcerptService))
{
if (_documentExcerptService is null)
{

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

@ -36,7 +36,7 @@ namespace Microsoft.CodeAnalysis.Razor
public override TextLoader GetTextLoader(string filePath) => new GeneratedDocumentTextLoader(_documentSnapshot, filePath);
public override IRazorDocumentExcerptServiceImplementation GetExcerptService()
public override IRazorDocumentExcerptService GetExcerptService()
{
if (_excerptService is null)
{

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

@ -51,7 +51,6 @@ namespace Microsoft.VisualStudio.LanguageServerClient.Razor
Document document,
TextSpan span,
ExcerptModeInternal mode,
RazorClassificationOptionsWrapper options,
CancellationToken cancellationToken)
{
var mappedSpans = await _mappingService.MapSpansAsync(document, new[] { span }, cancellationToken).ConfigureAwait(false);
@ -66,7 +65,6 @@ namespace Microsoft.VisualStudio.LanguageServerClient.Razor
mode,
_documentSnapshot.Snapshot.AsText(),
mappedSpans[0].LinePositionSpan,
options,
cancellationToken).ConfigureAwait(false);
}
@ -76,7 +74,6 @@ namespace Microsoft.VisualStudio.LanguageServerClient.Razor
ExcerptModeInternal mode,
SourceText razorDocumentText,
LinePositionSpan mappedLinePosition,
RazorClassificationOptionsWrapper options,
CancellationToken cancellationToken)
{
var razorDocumentSpan = razorDocumentText.Lines.GetTextSpan(mappedLinePosition);
@ -93,7 +90,6 @@ namespace Microsoft.VisualStudio.LanguageServerClient.Razor
excerptSpan,
span,
generatedDocument,
options,
cancellationToken).ConfigureAwait(false);
var excerptText = GetTranslatedExcerptText(razorDocumentText, ref razorDocumentSpan, ref excerptSpan, classifiedSpans);
@ -106,7 +102,6 @@ namespace Microsoft.VisualStudio.LanguageServerClient.Razor
TextSpan excerptSpan,
TextSpan generatedSpan,
Document generatedDocument,
RazorClassificationOptionsWrapper options,
CancellationToken cancellationToken)
{
var builder = ImmutableArray.CreateBuilder<ClassifiedSpan>();
@ -119,10 +114,9 @@ namespace Microsoft.VisualStudio.LanguageServerClient.Razor
var offsetRazorToGenerated = generatedSpan.Start - razorSpan.Start;
var offsetExcerpt = new TextSpan(excerptSpan.Start + offsetRazorToGenerated, excerptSpan.Length);
var classifiedSecondarySpans = await RazorClassifierAccessor.GetClassifiedSpansAsync(
var classifiedSecondarySpans = await Classifier.GetClassifiedSpansAsync(
generatedDocument,
offsetExcerpt,
options,
cancellationToken);
// Now we have to translate back to the razor document's coordinates.

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

@ -74,7 +74,7 @@ namespace Microsoft.VisualStudio.LanguageServerClient.Razor
private readonly LSPDocumentMappingProvider _lspDocumentMappingProvider;
private readonly LSPDocumentSnapshot _documentSnapshot;
private IRazorSpanMappingService? _mappingService;
private IRazorDocumentExcerptServiceImplementation? _excerptService;
private IRazorDocumentExcerptService? _excerptService;
public override string FilePath => _documentSnapshot.Uri.LocalPath;
@ -103,7 +103,7 @@ namespace Microsoft.VisualStudio.LanguageServerClient.Razor
_documentSnapshot = documentSnapshot;
}
public override IRazorDocumentExcerptServiceImplementation GetExcerptService()
public override IRazorDocumentExcerptService GetExcerptService()
{
if (_excerptService is null)
{

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

@ -7,7 +7,6 @@ using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Classification;
using Microsoft.CodeAnalysis.ExternalAccess.Razor;
using Microsoft.CodeAnalysis.Host;
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
using Xunit;
@ -40,8 +39,7 @@ namespace Microsoft.CodeAnalysis.Razor
var service = CreateExcerptService(primary);
// Act
var options = RazorClassificationOptionsWrapper.Default;
var result = await service.TryGetExcerptInternalAsync(secondary, secondarySpan, ExcerptModeInternal.SingleLine, options, CancellationToken.None);
var result = await service.TryGetExcerptInternalAsync(secondary, secondarySpan, ExcerptModeInternal.SingleLine, CancellationToken.None);
// Assert
Assert.NotNull(result);
@ -118,8 +116,7 @@ namespace Microsoft.CodeAnalysis.Razor
var service = CreateExcerptService(primary);
// Act
var options = RazorClassificationOptionsWrapper.Default;
var result = await service.TryGetExcerptInternalAsync(secondary, secondarySpan, ExcerptModeInternal.SingleLine, options, CancellationToken.None);
var result = await service.TryGetExcerptInternalAsync(secondary, secondarySpan, ExcerptModeInternal.SingleLine, CancellationToken.None);
// Assert
Assert.NotNull(result);
@ -171,8 +168,7 @@ namespace Microsoft.CodeAnalysis.Razor
var service = CreateExcerptService(primary);
// Act
var options = RazorClassificationOptionsWrapper.Default;
var result = await service.TryGetExcerptInternalAsync(secondary, secondarySpan, ExcerptModeInternal.SingleLine, options, CancellationToken.None);
var result = await service.TryGetExcerptInternalAsync(secondary, secondarySpan, ExcerptModeInternal.SingleLine, CancellationToken.None);
// Assert
Assert.NotNull(result);
@ -274,8 +270,7 @@ namespace Microsoft.CodeAnalysis.Razor
var service = CreateExcerptService(primary);
// Act
var options = RazorClassificationOptionsWrapper.Default;
var result = await service.TryGetExcerptInternalAsync(secondary, secondarySpan, ExcerptModeInternal.Tooltip, options, CancellationToken.None);
var result = await service.TryGetExcerptInternalAsync(secondary, secondarySpan, ExcerptModeInternal.Tooltip, CancellationToken.None);
// Assert
Assert.NotNull(result);
@ -383,8 +378,7 @@ namespace Microsoft.CodeAnalysis.Razor
var service = CreateExcerptService(primary);
// Act
var options = RazorClassificationOptionsWrapper.Default;
var result = await service.TryGetExcerptInternalAsync(secondary, secondarySpan, ExcerptModeInternal.Tooltip, options, CancellationToken.None);
var result = await service.TryGetExcerptInternalAsync(secondary, secondarySpan, ExcerptModeInternal.Tooltip, CancellationToken.None);
// Assert
// Verifies that the right part of the primary document will be highlighted.

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

@ -8,7 +8,6 @@ using System.Threading.Tasks;
using Xunit;
using Microsoft.CodeAnalysis.Razor;
using Microsoft.CodeAnalysis.Classification;
using Microsoft.CodeAnalysis.ExternalAccess.Razor;
namespace Microsoft.VisualStudio.LanguageServerClient.Razor
{
@ -36,14 +35,12 @@ namespace Microsoft.VisualStudio.LanguageServerClient.Razor
var mappedLinePositionSpan = razorSourceText.Lines.GetLinePositionSpan(primarySpan);
// Act
var options = RazorClassificationOptionsWrapper.Default;
var result = await excerptService.TryGetExcerptInternalAsync(
generatedDocument,
generatedSpan,
ExcerptModeInternal.SingleLine,
razorSourceText,
mappedLinePositionSpan,
options,
CancellationToken.None);
// Assert
@ -124,14 +121,12 @@ namespace Microsoft.VisualStudio.LanguageServerClient.Razor
var mappedLinePositionSpan = razorSourceText.Lines.GetLinePositionSpan(primarySpan);
// Act
var options = RazorClassificationOptionsWrapper.Default;
var result = await excerptService.TryGetExcerptInternalAsync(
generatedDocument,
generatedSpan,
ExcerptModeInternal.SingleLine,
razorSourceText,
mappedLinePositionSpan,
options,
CancellationToken.None);
// Assert
@ -170,14 +165,12 @@ namespace Microsoft.VisualStudio.LanguageServerClient.Razor
var mappedLinePositionSpan = razorSourceText.Lines.GetLinePositionSpan(primarySpan);
// Act
var options = RazorClassificationOptionsWrapper.Default;
var result = await excerptService.TryGetExcerptInternalAsync(
generatedDocument,
generatedSpan,
ExcerptModeInternal.SingleLine,
razorSourceText,
mappedLinePositionSpan,
options,
CancellationToken.None);
// Assert
@ -217,14 +210,12 @@ namespace Microsoft.VisualStudio.LanguageServerClient.Razor
var mappedLinePositionSpan = razorSourceText.Lines.GetLinePositionSpan(primarySpan);
// Act
var options = RazorClassificationOptionsWrapper.Default;
var result = await excerptService.TryGetExcerptInternalAsync(
generatedDocument,
generatedSpan,
ExcerptModeInternal.Tooltip,
razorSourceText,
mappedLinePositionSpan,
options,
CancellationToken.None);
// Assert
@ -263,14 +254,12 @@ namespace Microsoft.VisualStudio.LanguageServerClient.Razor
var mappedLinePositionSpan = razorSourceText.Lines.GetLinePositionSpan(primarySpan);
// Act
var options = RazorClassificationOptionsWrapper.Default;
var result = await excerptService.TryGetExcerptInternalAsync(
generatedDocument,
generatedSpan,
ExcerptModeInternal.Tooltip,
razorSourceText,
mappedLinePositionSpan,
options,
CancellationToken.None);
// Assert