public async Task <ImmutableArray <ValueTrackedItem> > TrackValueSourceAsync( Solution solution, ValueTrackedItem previousTrackedItem, CancellationToken cancellationToken) { using var logger = Logger.LogBlock(FunctionId.ValueTracking_TrackValueSource, cancellationToken, LogLevel.Information); var project = solution.GetRequiredProject(previousTrackedItem.DocumentId.ProjectId); var client = await RemoteHostClient.TryGetClientAsync(project, cancellationToken).ConfigureAwait(false); if (client != null) { var dehydratedItem = SerializableValueTrackedItem.Dehydrate(solution, previousTrackedItem, cancellationToken); var result = await client.TryInvokeAsync <IRemoteValueTrackingService, ImmutableArray <SerializableValueTrackedItem> >( solution, (service, solutionInfo, cancellationToken) => service.TrackValueSourceAsync(solutionInfo, dehydratedItem, cancellationToken), cancellationToken).ConfigureAwait(false); if (!result.HasValue) { return(ImmutableArray <ValueTrackedItem> .Empty); } return(await result.Value.SelectAsArrayAsync( (item, cancellationToken) => item.RehydrateAsync(solution, cancellationToken), cancellationToken).ConfigureAwait(false)); } var progressTracker = new ValueTrackingProgressCollector(); await ValueTracker.TrackValueSourceAsync(solution, previousTrackedItem, progressTracker, cancellationToken).ConfigureAwait(false); return(progressTracker.GetItems()); }
public async Task <ImmutableArray <ValueTrackedItem> > TrackValueSourceAsync( Solution solution, ValueTrackedItem previousTrackedItem, CancellationToken cancellationToken) { using var logger = Logger.LogBlock(FunctionId.ValueTracking_TrackValueSource, cancellationToken, LogLevel.Information); var project = solution.GetRequiredProject(previousTrackedItem.DocumentId.ProjectId); var client = await RemoteHostClient.TryGetClientAsync(project, cancellationToken).ConfigureAwait(false); if (client != null) { var dehydratedItem = SerializableValueTrackedItem.Dehydrate(solution, previousTrackedItem, cancellationToken); var result = await client.TryInvokeAsync <IRemoteValueTrackingService, ImmutableArray <SerializableValueTrackedItem> >( solution, (service, solutionInfo, cancellationToken) => service.TrackValueSourceAsync(solutionInfo, dehydratedItem, cancellationToken), cancellationToken).ConfigureAwait(false); if (!result.HasValue) { return(ImmutableArray <ValueTrackedItem> .Empty); } using var _ = PooledObjects.ArrayBuilder <ValueTrackedItem> .GetInstance(out var builder); foreach (var item in result.Value) { var rehydratedItem = await item.RehydrateAsync(solution, cancellationToken).ConfigureAwait(false); if (rehydratedItem is null) { throw new InvalidOperationException(); } builder.Add(rehydratedItem); } return(builder.ToImmutable()); } var progressTracker = new ValueTrackingProgressCollector(); await ValueTracker.TrackValueSourceAsync(solution, previousTrackedItem, progressTracker, cancellationToken).ConfigureAwait(false); return(progressTracker.GetItems()); }
public async Task <ImmutableArray <ValueTrackedItem> > TrackValueSourceAsync( TextSpan selection, Document document, CancellationToken cancellationToken) { using var logger = Logger.LogBlock(FunctionId.ValueTracking_TrackValueSource, cancellationToken, LogLevel.Information); var client = await RemoteHostClient.TryGetClientAsync(document.Project, cancellationToken).ConfigureAwait(false); if (client != null) { var solution = document.Project.Solution; var result = await client.TryInvokeAsync <IRemoteValueTrackingService, ImmutableArray <SerializableValueTrackedItem> >( solution, (service, solutionInfo, cancellationToken) => service.TrackValueSourceAsync(solutionInfo, selection, document.Id, cancellationToken), cancellationToken).ConfigureAwait(false); if (!result.HasValue) { return(ImmutableArray <ValueTrackedItem> .Empty); } using var _ = PooledObjects.ArrayBuilder <ValueTrackedItem> .GetInstance(out var builder); foreach (var item in result.Value) { var rehydratedItem = await item.RehydrateAsync(document.Project.Solution, cancellationToken).ConfigureAwait(false); Contract.ThrowIfNull(rehydratedItem); builder.Add(rehydratedItem); } return(builder.ToImmutable()); } var progressTracker = new ValueTrackingProgressCollector(); await ValueTracker.TrackValueSourceAsync(selection, document, progressTracker, cancellationToken).ConfigureAwait(false); return(progressTracker.GetItems()); }