public async Task <Solution> EncapsulateFieldsAsync( Document document, ImmutableArray <IFieldSymbol> fields, bool updateReferences, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); using (Logger.LogBlock(FunctionId.Renamer_FindRenameLocationsAsync, cancellationToken)) { var solution = document.Project.Solution; var client = await RemoteHostClient.TryGetClientAsync(solution.Workspace, cancellationToken).ConfigureAwait(false); if (client != null) { var fieldSymbolKeys = fields.SelectAsArray(f => SymbolKey.CreateString(f, cancellationToken)); var result = await client.TryInvokeAsync <IRemoteEncapsulateFieldService, ImmutableArray <(DocumentId, ImmutableArray <TextChange>)> >( solution, (service, solutionInfo, cancellationToken) => service.EncapsulateFieldsAsync(solutionInfo, document.Id, fieldSymbolKeys, updateReferences, cancellationToken), callbackTarget : null, cancellationToken).ConfigureAwait(false); if (!result.HasValue) { return(solution); } return(await RemoteUtilities.UpdateSolutionAsync( solution, result.Value, cancellationToken).ConfigureAwait(false)); } } return(await EncapsulateFieldsInCurrentProcessAsync( document, fields, updateReferences, cancellationToken).ConfigureAwait(false)); }
public async Task <ConflictResolution> RehydrateAsync( Solution oldSolution, CancellationToken cancellationToken ) { if (ErrorMessage != null) { return(new ConflictResolution(ErrorMessage)); } Contract.ThrowIfNull(Resolution); var newSolutionWithoutRenamedDocument = await RemoteUtilities .UpdateSolutionAsync(oldSolution, Resolution.DocumentTextChanges, cancellationToken) .ConfigureAwait(false); return(new ConflictResolution( oldSolution, newSolutionWithoutRenamedDocument, Resolution.ReplacementTextValid, Resolution.RenamedDocument, Resolution.DocumentIds, Resolution.RelatedLocations, Resolution.DocumentToModifiedSpansMap, Resolution.DocumentToComplexifiedSpansMap, Resolution.DocumentToRelatedLocationsMap )); }