private bool TryInitializeRenameTrackingCommitter(CancellationToken cancellationToken) { SourceText text; StateMachine stateMachine; if (_document.TryGetText(out text)) { var textBuffer = text.Container.GetTextBuffer(); if (textBuffer.Properties.TryGetProperty(typeof(StateMachine), out stateMachine)) { TrackingSession trackingSession; if (!stateMachine.CanInvokeRename(out trackingSession, cancellationToken: cancellationToken)) { // The rename tracking could be dismissed while a codefix is still cached // in the lightbulb. If this happens, do not perform the rename requested // and instead let the user know their fix will not be applied. _document.Project.Solution.Workspace.Services.GetService <INotificationService>() ?.SendNotification(EditorFeaturesResources.TheRenameTrackingSessionWasCancelledAndIsNoLongerAvailable, severity: NotificationSeverity.Error); return(false); } var snapshotSpan = stateMachine.TrackingSession.TrackingSpan.GetSpan(stateMachine.Buffer.CurrentSnapshot); var newName = snapshotSpan.GetText(); var displayText = string.Format(EditorFeaturesResources.RenameTo, stateMachine.TrackingSession.OriginalName, newName); _renameTrackingCommitter = new RenameTrackingCommitter(stateMachine, snapshotSpan, _refactorNotifyServices, _undoHistoryRegistry, displayText); return(true); } } return(false); }
private bool TryInitializeRenameTrackingCommitter(CancellationToken cancellationToken) { if (_document.TryGetText(out var text)) { var textBuffer = text.Container.GetTextBuffer(); if (textBuffer.Properties.TryGetProperty(typeof(StateMachine), out StateMachine stateMachine)) { if (!stateMachine.CanInvokeRename(out var trackingSession, cancellationToken: cancellationToken)) { // The rename tracking could be dismissed while a codefix is still cached // in the lightbulb. If this happens, do not perform the rename requested // and instead let the user know their fix will not be applied. _document.Project.Solution.Workspace.Services.GetService<INotificationService>() ?.SendNotification(EditorFeaturesResources.The_rename_tracking_session_was_cancelled_and_is_no_longer_available, severity: NotificationSeverity.Error); return false; } var snapshotSpan = stateMachine.TrackingSession.TrackingSpan.GetSpan(stateMachine.Buffer.CurrentSnapshot); var newName = snapshotSpan.GetText(); var displayText = string.Format(EditorFeaturesResources.Rename_0_to_1, stateMachine.TrackingSession.OriginalName, newName); _renameTrackingCommitter = new RenameTrackingCommitter(stateMachine, snapshotSpan, _refactorNotifyServices, _undoHistoryRegistry, displayText); return true; } } return false; }
public RenameTrackingCommitterOperation(RenameTrackingCommitter committer) { _committer = committer; }
public RenameTrackingCommitterOperation(RenameTrackingCommitter committer, IThreadingContext threadingContext) { _committer = committer; _threadingContext = threadingContext; }
public RenameTrackingCommitterOperation(RenameTrackingCommitter committer) =>