Skip to content

Commit

Permalink
Disable symbol search on generated documents (#76027)
Browse files Browse the repository at this point in the history
Fixes #62737
  • Loading branch information
CyrusNajmabadi authored Nov 22, 2024
2 parents 0f18f42 + 0eb7a3e commit 14244f6
Showing 1 changed file with 17 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,18 @@

namespace Microsoft.CodeAnalysis.Remote;

internal sealed class RemoteMissingImportDiscoveryService : BrokeredServiceBase, IRemoteMissingImportDiscoveryService
internal sealed class RemoteMissingImportDiscoveryService(
in BrokeredServiceBase.ServiceConstructionArguments arguments,
RemoteCallback<IRemoteMissingImportDiscoveryService.ICallback> callback)
: BrokeredServiceBase(arguments), IRemoteMissingImportDiscoveryService
{
internal sealed class Factory : FactoryBase<IRemoteMissingImportDiscoveryService, IRemoteMissingImportDiscoveryService.ICallback>
{
protected override IRemoteMissingImportDiscoveryService CreateService(in ServiceConstructionArguments arguments, RemoteCallback<IRemoteMissingImportDiscoveryService.ICallback> callback)
=> new RemoteMissingImportDiscoveryService(arguments, callback);
}

private readonly RemoteCallback<IRemoteMissingImportDiscoveryService.ICallback> _callback;

public RemoteMissingImportDiscoveryService(in ServiceConstructionArguments arguments, RemoteCallback<IRemoteMissingImportDiscoveryService.ICallback> callback)
: base(arguments)
{
_callback = callback;
}
private readonly RemoteCallback<IRemoteMissingImportDiscoveryService.ICallback> _callback = callback;

public ValueTask<ImmutableArray<AddImportFixData>> GetFixesAsync(
Checksum solutionChecksum,
Expand All @@ -42,7 +39,9 @@ public ValueTask<ImmutableArray<AddImportFixData>> GetFixesAsync(
{
return RunServiceAsync(solutionChecksum, async solution =>
{
var document = solution.GetRequiredDocument(documentId);
var document = solution.GetDocument(documentId);
if (document is null)
return [];

var service = document.GetRequiredLanguageService<IAddImportFeatureService>();

Expand All @@ -69,7 +68,9 @@ public ValueTask<ImmutableArray<AddImportFixData>> GetUniqueFixesAsync(
{
return RunServiceAsync(solutionChecksum, async solution =>
{
var document = solution.GetRequiredDocument(documentId);
var document = solution.GetDocument(documentId);
if (document is null)
return [];

var service = document.GetRequiredLanguageService<IAddImportFeatureService>();

Expand All @@ -94,16 +95,13 @@ public ValueTask<ImmutableArray<AddImportFixData>> GetUniqueFixesAsync(
///
/// Ideally we would not need to bounce back to the host for this.
/// </summary>
private sealed class SymbolSearchService : ISymbolSearchService
private sealed class SymbolSearchService(
RemoteCallback<IRemoteMissingImportDiscoveryService.ICallback> callback,
RemoteServiceCallbackId callbackId)
: ISymbolSearchService
{
private readonly RemoteCallback<IRemoteMissingImportDiscoveryService.ICallback> _callback;
private readonly RemoteServiceCallbackId _callbackId;

public SymbolSearchService(RemoteCallback<IRemoteMissingImportDiscoveryService.ICallback> callback, RemoteServiceCallbackId callbackId)
{
_callback = callback;
_callbackId = callbackId;
}
private readonly RemoteCallback<IRemoteMissingImportDiscoveryService.ICallback> _callback = callback;
private readonly RemoteServiceCallbackId _callbackId = callbackId;

public ValueTask<ImmutableArray<PackageWithTypeResult>> FindPackagesWithTypeAsync(string source, string name, int arity, CancellationToken cancellationToken)
=> _callback.InvokeAsync((callback, cancellationToken) => callback.FindPackagesWithTypeAsync(_callbackId, source, name, arity, cancellationToken), cancellationToken);
Expand Down

0 comments on commit 14244f6

Please # to comment.