internal RenameDocumentActionSet( ImmutableArray <RenameDocumentAction> actions, DocumentId documentId, string documentName, ImmutableArray <string> documentFolders, DocumentRenameOptions options) { ApplicableActions = actions; _documentFolders = documentFolders; _documentId = documentId; _documentName = documentName; _options = options; }
internal override async Task <Solution> GetModifiedSolutionAsync(Document document, DocumentRenameOptions options, CancellationToken cancellationToken) { var solution = document.Project.Solution; // Get only types matching the original document name by // passing a document back with the original name. That way // even if the document name changed, we're updating the types // that are the same name as the analysis var matchingTypeDeclaration = await GetMatchingTypeDeclarationAsync( document.WithName(_analysis.OriginalDocumentName), cancellationToken).ConfigureAwait(false); if (matchingTypeDeclaration is object) { var semanticModel = await document.GetRequiredSemanticModelAsync(cancellationToken).ConfigureAwait(false); var symbol = semanticModel.GetRequiredDeclaredSymbol(matchingTypeDeclaration, cancellationToken); var symbolRenameOptions = new SymbolRenameOptions( RenameOverloads: false, RenameInComments: options.RenameMatchingTypeInComments, RenameInStrings: options.RenameMatchingTypeInStrings, RenameFile: false); solution = await RenameSymbolAsync(solution, symbol, symbolRenameOptions, _analysis.NewSymbolName, cancellationToken).ConfigureAwait(false); } return(solution); }
internal abstract Task <Solution> GetModifiedSolutionAsync(Document document, DocumentRenameOptions options, CancellationToken cancellationToken);
internal override async Task <Solution> GetModifiedSolutionAsync(Document document, DocumentRenameOptions options, CancellationToken cancellationToken) { var changeNamespaceService = document.GetRequiredLanguageService <IChangeNamespaceService>(); var solution = await changeNamespaceService.TryChangeTopLevelNamespacesAsync(document, _analysis.TargetNamespace, cancellationToken).ConfigureAwait(false); // If the solution fails to update fail silently. The user will see no large // negative impact from not doing this modification, and it's possible the document // was too malformed to update any namespaces. return(solution ?? document.Project.Solution); }