Exemple #1
0
        public async Task <SerializableConflictResolution> DehydrateAsync(
            CancellationToken cancellationToken
            )
        {
            if (ErrorMessage != null)
            {
                return(new SerializableConflictResolution(ErrorMessage, resolution: null));
            }

            var documentTextChanges = await RemoteUtilities
                                      .GetDocumentTextChangesAsync(
                OldSolution,
                _newSolutionWithoutRenamedDocument,
                cancellationToken
                )
                                      .ConfigureAwait(false);

            return(new SerializableConflictResolution(
                       errorMessage: null,
                       new SuccessfulConflictResolution(
                           ReplacementTextValid,
                           _renamedDocument,
                           DocumentIds,
                           RelatedLocations,
                           documentTextChanges,
                           _documentToModifiedSpansMap,
                           _documentToComplexifiedSpansMap,
                           _documentToRelatedLocationsMap
                           )
                       ));
        }
Exemple #2
0
        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));
        }
Exemple #3
0
        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
                       ));
        }
        public async Task <SerializableConflictResolution> DehydrateAsync(CancellationToken cancellationToken)
        {
            if (ErrorMessage != null)
            {
                return new SerializableConflictResolution {
                           ErrorMessage = ErrorMessage
                }
            }
            ;

            var documentTextChanges = await RemoteUtilities.GetDocumentTextChangesAsync(OldSolution, _newSolutionWithoutRenamedDocument, cancellationToken).ConfigureAwait(false);

            return(new SerializableConflictResolution
            {
                ReplacementTextValid = ReplacementTextValid,
                RenamedDocument = _renamedDocument,
                DocumentIds = DocumentIds.ToArray(),
                RelatedLocations = RelatedLocations.Select(loc => SerializableRelatedLocation.Dehydrate(loc)).ToArray(),
                DocumentTextChanges = documentTextChanges,
                DocumentToModifiedSpansMap = _documentToModifiedSpansMap.Select(kvp => (kvp.Key, kvp.Value)).ToArray(),
                DocumentToComplexifiedSpansMap = _documentToComplexifiedSpansMap.Select(kvp => (kvp.Key, kvp.Value.SelectAsArray(s => SerializableComplexifiedSpan.Dehydrate(s)))).ToArray(),
                DocumentToRelatedLocationsMap = _documentToRelatedLocationsMap.Select(kvp => (kvp.Key, kvp.Value.SelectAsArray(s => SerializableRelatedLocation.Dehydrate(s)))).ToArray(),
            });