未验证 提交 49f5541b 编写于 作者: J Julien Couvreur 提交者: GitHub

Merge pull request #34076 from CyrusNajmabadi/symbolCancellation

Properly pass along cancellation token when calling OOP service during FAR.
......@@ -28,7 +28,7 @@ internal partial class CodeAnalysisService : IRemoteSymbolFinder
var symbolAndProjectId = await symbolAndProjectIdArg.TryRehydrateAsync(
solution, cancellationToken).ConfigureAwait(false);
var progressCallback = new FindReferencesProgressCallback(this);
var progressCallback = new FindReferencesProgressCallback(this, cancellationToken);
if (!symbolAndProjectId.HasValue)
{
......@@ -61,7 +61,7 @@ public Task FindLiteralReferencesAsync(object value, TypeCode typeCode, Cancella
var convertedType = System.Convert.ChangeType(value, typeCode);
var solution = await GetSolutionAsync(cancellationToken).ConfigureAwait(false);
var progressCallback = new FindLiteralReferencesProgressCallback(this);
var progressCallback = new FindLiteralReferencesProgressCallback(this, cancellationToken);
await SymbolFinder.FindLiteralReferencesInCurrentProcessAsync(
convertedType, solution, progressCallback, cancellationToken).ConfigureAwait(false);
}
......@@ -161,52 +161,56 @@ public Task FindLiteralReferencesAsync(object value, TypeCode typeCode, Cancella
private class FindLiteralReferencesProgressCallback : IStreamingFindLiteralReferencesProgress
{
private readonly CodeAnalysisService _service;
private readonly CancellationToken _cancellationToken;
public FindLiteralReferencesProgressCallback(CodeAnalysisService service)
public FindLiteralReferencesProgressCallback(CodeAnalysisService service, CancellationToken cancellationToken)
{
_service = service;
_cancellationToken = cancellationToken;
}
public Task ReportProgressAsync(int current, int maximum)
=> _service.InvokeAsync(nameof(ReportProgressAsync), new object[] { current, maximum }, CancellationToken.None);
=> _service.InvokeAsync(nameof(ReportProgressAsync), new object[] { current, maximum }, _cancellationToken);
public Task OnReferenceFoundAsync(Document document, TextSpan span)
=> _service.InvokeAsync(nameof(OnReferenceFoundAsync), new object[] { document.Id, span }, CancellationToken.None);
=> _service.InvokeAsync(nameof(OnReferenceFoundAsync), new object[] { document.Id, span }, _cancellationToken);
}
private class FindReferencesProgressCallback : IStreamingFindReferencesProgress
{
private readonly CodeAnalysisService _service;
private readonly CancellationToken _cancellationToken;
public FindReferencesProgressCallback(CodeAnalysisService service)
public FindReferencesProgressCallback(CodeAnalysisService service, CancellationToken cancellationToken)
{
_service = service;
_cancellationToken = cancellationToken;
}
public Task OnStartedAsync()
=> _service.InvokeAsync(nameof(OnStartedAsync), CancellationToken.None);
=> _service.InvokeAsync(nameof(OnStartedAsync), _cancellationToken);
public Task OnCompletedAsync()
=> _service.InvokeAsync(nameof(OnCompletedAsync), CancellationToken.None);
=> _service.InvokeAsync(nameof(OnCompletedAsync), _cancellationToken);
public Task ReportProgressAsync(int current, int maximum)
=> _service.InvokeAsync(nameof(ReportProgressAsync), new object[] { current, maximum }, CancellationToken.None);
=> _service.InvokeAsync(nameof(ReportProgressAsync), new object[] { current, maximum }, _cancellationToken);
public Task OnFindInDocumentStartedAsync(Document document)
=> _service.InvokeAsync(nameof(OnFindInDocumentStartedAsync), new object[] { document.Id }, CancellationToken.None);
=> _service.InvokeAsync(nameof(OnFindInDocumentStartedAsync), new object[] { document.Id }, _cancellationToken);
public Task OnFindInDocumentCompletedAsync(Document document)
=> _service.InvokeAsync(nameof(OnFindInDocumentCompletedAsync), new object[] { document.Id }, CancellationToken.None);
=> _service.InvokeAsync(nameof(OnFindInDocumentCompletedAsync), new object[] { document.Id }, _cancellationToken);
public Task OnDefinitionFoundAsync(SymbolAndProjectId definition)
=> _service.InvokeAsync(nameof(OnDefinitionFoundAsync), new object[] { SerializableSymbolAndProjectId.Dehydrate(definition) }, CancellationToken.None);
=> _service.InvokeAsync(nameof(OnDefinitionFoundAsync), new object[] { SerializableSymbolAndProjectId.Dehydrate(definition) }, _cancellationToken);
public Task OnReferenceFoundAsync(
SymbolAndProjectId definition, ReferenceLocation reference)
{
return _service.InvokeAsync(nameof(OnReferenceFoundAsync),
new object[] { SerializableSymbolAndProjectId.Dehydrate(definition), SerializableReferenceLocation.Dehydrate(reference) },
CancellationToken.None);
_cancellationToken);
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册