Skip to content

Commit

Permalink
Revert "Revert breaking commit"
Browse files Browse the repository at this point in the history
  • Loading branch information
DoctorKrolic authored and NTaylorMullen committed Feb 22, 2022
1 parent d017604 commit 44098de
Show file tree
Hide file tree
Showing 11 changed files with 53 additions and 24 deletions.
10 changes: 5 additions & 5 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -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.1.0-1.21471.13</RoslynPackageVersion>
<RoslynPackageVersion>4.2.0-2.22108.10</RoslynPackageVersion>
<VisualStudioLanguageServerProtocolVersion>17.1.11</VisualStudioLanguageServerProtocolVersion>
</PropertyGroup>
<PropertyGroup Label="Manual">
Expand Down Expand Up @@ -107,13 +107,13 @@
<MicrosoftVisualStudioLanguageServerProtocolInternalPackageVersion>$(VisualStudioLanguageServerProtocolVersion)</MicrosoftVisualStudioLanguageServerProtocolInternalPackageVersion>
<MicrosoftVisualStudioLiveSharePackageVersion>0.3.1074</MicrosoftVisualStudioLiveSharePackageVersion>
<MicrosoftVisualStudioProjectSystemSDKPackageVersion>16.10.81-pre</MicrosoftVisualStudioProjectSystemSDKPackageVersion>
<MicrosoftVisualStudioRpcContractsVersion>17.0.50-preview-0001-0001</MicrosoftVisualStudioRpcContractsVersion>
<MicrosoftVisualStudioRpcContractsVersion>17.0.51</MicrosoftVisualStudioRpcContractsVersion>
<MicrosoftVisualStudioShell150PackageVersion>$(MicrosoftVisualStudioShellPackagesVersion)</MicrosoftVisualStudioShell150PackageVersion>
<MicrosoftVisualStudioInteropPackageVersion>$(MicrosoftVisualStudioShellPackagesVersion)</MicrosoftVisualStudioInteropPackageVersion>
<MicrosoftVisualStudioTextDataPackageVersion>$(MicrosoftVisualStudioPackagesVersion)</MicrosoftVisualStudioTextDataPackageVersion>
<MicrosoftVisualStudioTextImplementationPackageVersion>$(MicrosoftVisualStudioPackagesVersion)</MicrosoftVisualStudioTextImplementationPackageVersion>
<MicrosoftVisualStudioTextLogicPackageVersion>$(MicrosoftVisualStudioPackagesVersion)</MicrosoftVisualStudioTextLogicPackageVersion>
<MicrosoftVisualStudioThreadingPackageVersion>17.0.63</MicrosoftVisualStudioThreadingPackageVersion>
<MicrosoftVisualStudioThreadingPackageVersion>17.0.64</MicrosoftVisualStudioThreadingPackageVersion>
<MicrosoftVisualStudioWebPackageVersion>16.10.0-preview-1-31008-014</MicrosoftVisualStudioWebPackageVersion>
<MicrosoftVisualStudioValidationPackageVersion>17.0.16-alpha</MicrosoftVisualStudioValidationPackageVersion>
<MicrosoftWebToolsLanguagesHtmlPackageVersion>$(Tooling_HtmlEditorPackageVersion)</MicrosoftWebToolsLanguagesHtmlPackageVersion>
Expand All @@ -124,12 +124,12 @@
<MonoAddinsPackageVersion>1.3.8</MonoAddinsPackageVersion>
<MonoDevelopSdkPackageVersion>1.0.15</MonoDevelopSdkPackageVersion>
<MoqPackageVersion>4.16.0</MoqPackageVersion>
<NerdbankStreamsPackageVersion>2.7.74</NerdbankStreamsPackageVersion>
<NerdbankStreamsPackageVersion>2.8.57</NerdbankStreamsPackageVersion>
<NuGetSolutionRestoreManagerInteropVersion>4.8.0</NuGetSolutionRestoreManagerInteropVersion>
<OmniSharpExtensionsLanguageServerPackageVersion>0.19.5</OmniSharpExtensionsLanguageServerPackageVersion>
<OmniSharpExtensionsLanguageProtocolPackageVersion>$(OmniSharpExtensionsLanguageServerPackageVersion)</OmniSharpExtensionsLanguageProtocolPackageVersion>
<OmniSharpMSBuildPackageVersion>1.37.13</OmniSharpMSBuildPackageVersion>
<StreamJsonRpcPackageVersion>2.8.28</StreamJsonRpcPackageVersion>
<StreamJsonRpcPackageVersion>2.11.14-alpha</StreamJsonRpcPackageVersion>
<SystemRuntimeInteropServicesRuntimePackageVersion>4.3.0</SystemRuntimeInteropServicesRuntimePackageVersion>
<Tooling_MicrosoftCodeAnalysisAnalyzersPackageVersion>3.3.3</Tooling_MicrosoftCodeAnalysisAnalyzersPackageVersion>
<Tooling_MicrosoftCodeAnalysisNetAnalyzersPackageVersion>6.0.0-preview3.21158.1</Tooling_MicrosoftCodeAnalysisNetAnalyzersPackageVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public void PromoteBackgroundDocument(Uri documentUri, IRazorDocumentPropertiesS
// 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<IRazorDocumentExcerptService>();
var excerptService = documentServiceProvider.GetService<IRazorDocumentExcerptServiceImplementation>();
var mappingService = documentServiceProvider.GetService<IRazorSpanMappingService>();
var emptyContainer = new PromotedDynamicDocumentContainer(
documentUri, propertiesService, excerptService, mappingService, associatedEntry.Current.TextLoader);
Expand Down Expand Up @@ -411,14 +411,14 @@ private class PromotedDynamicDocumentContainer : DynamicDocumentContainer
{
private readonly Uri _documentUri;
private readonly IRazorDocumentPropertiesService _documentPropertiesService;
private readonly IRazorDocumentExcerptService _documentExcerptService;
private readonly IRazorDocumentExcerptServiceImplementation _documentExcerptService;
private readonly IRazorSpanMappingService _spanMappingService;
private readonly TextLoader _textLoader;

public PromotedDynamicDocumentContainer(
Uri documentUri,
IRazorDocumentPropertiesService documentPropertiesService,
IRazorDocumentExcerptService documentExcerptService,
IRazorDocumentExcerptServiceImplementation documentExcerptService,
IRazorSpanMappingService spanMappingService,
TextLoader textLoader)
{
Expand Down Expand Up @@ -451,7 +451,7 @@ public PromotedDynamicDocumentContainer(

public override IRazorDocumentPropertiesService GetDocumentPropertiesService() => _documentPropertiesService;

public override IRazorDocumentExcerptService GetExcerptService() => _documentExcerptService;
public override IRazorDocumentExcerptServiceImplementation GetExcerptService() => _documentExcerptService;

public override IRazorSpanMappingService GetMappingService() => _spanMappingService;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,24 @@

namespace Microsoft.CodeAnalysis.Razor
{
internal abstract class DocumentExcerptServiceBase : IRazorDocumentExcerptService
internal abstract class DocumentExcerptServiceBase : IRazorDocumentExcerptServiceImplementation
{
public async Task<RazorExcerptResult?> TryExcerptAsync(
Document document,
TextSpan span,
RazorExcerptMode mode,
RazorClassificationOptionsWrapper options,
CancellationToken cancellationToken)
{
var result = await TryGetExcerptInternalAsync(document, span, (ExcerptModeInternal)mode, cancellationToken).ConfigureAwait(false);
var result = await TryGetExcerptInternalAsync(document, span, (ExcerptModeInternal)mode, options, cancellationToken).ConfigureAwait(false);
return result?.ToExcerptResult();
}

internal abstract Task<ExcerptResultInternal?> TryGetExcerptInternalAsync(
Document document,
TextSpan span,
ExcerptModeInternal mode,
RazorClassificationOptionsWrapper options,
CancellationToken cancellationToken);

protected TextSpan ChooseExcerptSpan(SourceText text, TextSpan span, ExcerptModeInternal mode)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ internal abstract class DynamicDocumentContainer

public abstract IRazorSpanMappingService GetMappingService();

public abstract IRazorDocumentExcerptService GetExcerptService();
public abstract IRazorDocumentExcerptServiceImplementation GetExcerptService();

public abstract IRazorDocumentPropertiesService GetDocumentPropertiesService();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public RazorDocumentExcerptService(DocumentSnapshot document, IRazorSpanMappingS
Document document,
TextSpan span,
ExcerptModeInternal mode,
RazorClassificationOptionsWrapper options,
CancellationToken cancellationToken)
{
if (_document is null)
Expand Down Expand Up @@ -78,6 +79,7 @@ public RazorDocumentExcerptService(DocumentSnapshot document, IRazorSpanMappingS
excerptSpan,
generatedDocument,
mappings,
options,
cancellationToken).ConfigureAwait(false);

var excerptText = GetTranslatedExcerptText(razorDocumentText, ref razorDocumentSpan, ref excerptSpan, classifiedSpans);
Expand All @@ -89,6 +91,7 @@ public RazorDocumentExcerptService(DocumentSnapshot document, IRazorSpanMappingS
TextSpan excerptSpan,
Document generatedDocument,
IReadOnlyList<SourceMapping> mappings,
RazorClassificationOptionsWrapper options,
CancellationToken cancellationToken)
{
var builder = ImmutableArray.CreateBuilder<ClassifiedSpan>();
Expand Down Expand Up @@ -131,9 +134,10 @@ public RazorDocumentExcerptService(DocumentSnapshot document, IRazorSpanMappingS
//
// 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 Classifier.GetClassifiedSpansAsync(
var classifiedSecondarySpans = await RazorClassifierAccessor.GetClassifiedSpansAsync(
generatedDocument,
secondarySpan,
options,
cancellationToken);

// NOTE: The Classifier will only returns spans for things that it understands. That means
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ internal class RazorDocumentServiceProvider : IRazorDocumentServiceProvider, IRa
private readonly object _lock;

private IRazorSpanMappingService? _spanMappingService;
private IRazorDocumentExcerptService? _documentExcerptService;
private IRazorDocumentExcerptServiceImplementation? _documentExcerptService;
private IRazorDocumentPropertiesService? _documentPropertiesService;

public RazorDocumentServiceProvider()
Expand Down Expand Up @@ -55,7 +55,7 @@ public RazorDocumentServiceProvider(DynamicDocumentContainer? documentContainer)
return (TService)_spanMappingService;
}

if (serviceType == typeof(IRazorDocumentExcerptService))
if (serviceType == typeof(IRazorDocumentExcerptServiceImplementation))
{
if (_documentExcerptService is null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public DefaultDynamicDocumentContainer(DocumentSnapshot documentSnapshot)

public override TextLoader GetTextLoader(string filePath) => new GeneratedDocumentTextLoader(_documentSnapshot, filePath);

public override IRazorDocumentExcerptService GetExcerptService()
public override IRazorDocumentExcerptServiceImplementation GetExcerptService()
{
if (_excerptService is null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ internal CSharpDocumentExcerptService()
Document document,
TextSpan span,
ExcerptModeInternal mode,
RazorClassificationOptionsWrapper options,
CancellationToken cancellationToken)
{
var mappedSpans = await _mappingService.MapSpansAsync(document, new[] { span }, cancellationToken).ConfigureAwait(false);
Expand All @@ -65,6 +66,7 @@ internal CSharpDocumentExcerptService()
mode,
_documentSnapshot.Snapshot.AsText(),
mappedSpans[0].LinePositionSpan,
options,
cancellationToken).ConfigureAwait(false);
}

Expand All @@ -74,6 +76,7 @@ internal CSharpDocumentExcerptService()
ExcerptModeInternal mode,
SourceText razorDocumentText,
LinePositionSpan mappedLinePosition,
RazorClassificationOptionsWrapper options,
CancellationToken cancellationToken)
{
var razorDocumentSpan = razorDocumentText.Lines.GetTextSpan(mappedLinePosition);
Expand All @@ -90,6 +93,7 @@ internal CSharpDocumentExcerptService()
excerptSpan,
span,
generatedDocument,
options,
cancellationToken).ConfigureAwait(false);

var excerptText = GetTranslatedExcerptText(razorDocumentText, ref razorDocumentSpan, ref excerptSpan, classifiedSpans);
Expand All @@ -102,6 +106,7 @@ internal CSharpDocumentExcerptService()
TextSpan excerptSpan,
TextSpan generatedSpan,
Document generatedDocument,
RazorClassificationOptionsWrapper options,
CancellationToken cancellationToken)
{
var builder = ImmutableArray.CreateBuilder<ClassifiedSpan>();
Expand All @@ -114,9 +119,10 @@ internal CSharpDocumentExcerptService()
var offsetRazorToGenerated = generatedSpan.Start - razorSpan.Start;
var offsetExcerpt = new TextSpan(excerptSpan.Start + offsetRazorToGenerated, excerptSpan.Length);

var classifiedSecondarySpans = await Classifier.GetClassifiedSpansAsync(
var classifiedSecondarySpans = await RazorClassifierAccessor.GetClassifiedSpansAsync(
generatedDocument,
offsetExcerpt,
options,
cancellationToken);

// Now we have to translate back to the razor document's coordinates.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ private class CSharpVirtualDocumentContainer : DynamicDocumentContainer
private readonly LSPDocumentMappingProvider _lspDocumentMappingProvider;
private readonly LSPDocumentSnapshot _documentSnapshot;
private IRazorSpanMappingService? _mappingService;
private IRazorDocumentExcerptService? _excerptService;
private IRazorDocumentExcerptServiceImplementation? _excerptService;

public override string FilePath => _documentSnapshot.Uri.LocalPath;

Expand Down Expand Up @@ -103,7 +103,7 @@ public CSharpVirtualDocumentContainer(LSPDocumentMappingProvider lspDocumentMapp
_documentSnapshot = documentSnapshot;
}

public override IRazorDocumentExcerptService GetExcerptService()
public override IRazorDocumentExcerptServiceImplementation GetExcerptService()
{
if (_excerptService is null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
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;
Expand Down Expand Up @@ -39,7 +40,8 @@ public async Task TryGetExcerptInternalAsync_SingleLine_CanClassifyCSharp()
var service = CreateExcerptService(primary);

// Act
var result = await service.TryGetExcerptInternalAsync(secondary, secondarySpan, ExcerptModeInternal.SingleLine, CancellationToken.None);
var options = RazorClassificationOptionsWrapper.Default;
var result = await service.TryGetExcerptInternalAsync(secondary, secondarySpan, ExcerptModeInternal.SingleLine, options, CancellationToken.None);

// Assert
Assert.NotNull(result);
Expand Down Expand Up @@ -116,7 +118,8 @@ public async Task TryGetExcerptInternalAsync_SingleLine_CanClassifyCSharp_Implic
var service = CreateExcerptService(primary);

// Act
var result = await service.TryGetExcerptInternalAsync(secondary, secondarySpan, ExcerptModeInternal.SingleLine, CancellationToken.None);
var options = RazorClassificationOptionsWrapper.Default;
var result = await service.TryGetExcerptInternalAsync(secondary, secondarySpan, ExcerptModeInternal.SingleLine, options, CancellationToken.None);

// Assert
Assert.NotNull(result);
Expand Down Expand Up @@ -168,7 +171,8 @@ public async Task TryGetExcerptInternalAsync_SingleLine_CanClassifyCSharp_Comple
var service = CreateExcerptService(primary);

// Act
var result = await service.TryGetExcerptInternalAsync(secondary, secondarySpan, ExcerptModeInternal.SingleLine, CancellationToken.None);
var options = RazorClassificationOptionsWrapper.Default;
var result = await service.TryGetExcerptInternalAsync(secondary, secondarySpan, ExcerptModeInternal.SingleLine, options, CancellationToken.None);

// Assert
Assert.NotNull(result);
Expand Down Expand Up @@ -270,7 +274,8 @@ public async Task TryGetExcerptInternalAsync_MultiLine_CanClassifyCSharp()
var service = CreateExcerptService(primary);

// Act
var result = await service.TryGetExcerptInternalAsync(secondary, secondarySpan, ExcerptModeInternal.Tooltip, CancellationToken.None);
var options = RazorClassificationOptionsWrapper.Default;
var result = await service.TryGetExcerptInternalAsync(secondary, secondarySpan, ExcerptModeInternal.Tooltip, options, CancellationToken.None);

// Assert
Assert.NotNull(result);
Expand Down Expand Up @@ -378,7 +383,8 @@ public async Task TryGetExcerptInternalAsync_MultiLine_Boundaries_CanClassifyCSh
var service = CreateExcerptService(primary);

// Act
var result = await service.TryGetExcerptInternalAsync(secondary, secondarySpan, ExcerptModeInternal.Tooltip, CancellationToken.None);
var options = RazorClassificationOptionsWrapper.Default;
var result = await service.TryGetExcerptInternalAsync(secondary, secondarySpan, ExcerptModeInternal.Tooltip, options, CancellationToken.None);

// Assert
// Verifies that the right part of the primary document will be highlighted.
Expand Down
Loading

0 comments on commit 44098de

Please sign in to comment.