Beispiel #1
0
        public InlineRenameSessionInfo StartInlineSession(
            Document document,
            TextSpan textSpan,
            CancellationToken cancellationToken)
        {
            if (_activeRenameSession != null)
            {
                throw new InvalidOperationException(EditorFeaturesResources.AnActiveInlineRenameSessionIsActive);
            }

            var editorRenameService = document.GetLanguageService<IEditorInlineRenameService>();
            var renameInfo = editorRenameService.GetRenameInfoAsync(document, textSpan.Start, cancellationToken).WaitAndGetResult(cancellationToken);
            if (!renameInfo.CanRename)
            {
                return new InlineRenameSessionInfo(renameInfo.LocalizedErrorMessage);
            }

            var snapshot = document.GetTextAsync(cancellationToken).WaitAndGetResult(cancellationToken).FindCorrespondingEditorTextSnapshot();
            ActiveSession = new InlineRenameSession(
                this,
                document.Project.Solution.Workspace,
                renameInfo.TriggerSpan.ToSnapshotSpan(snapshot),
                renameInfo,
                _waitIndicator,
                _textBufferAssociatedViewService,
                _textBufferFactoryService,
                _refactorNotifyServices,
                _aggregateListener);

            return new InlineRenameSessionInfo(ActiveSession);
        }
        public DashboardViewModel(InlineRenameSession session)
        {
            Contract.ThrowIfNull(session);
            _session = session;
            _searchText = "Searching...";

            _renameOverloadsVisibility = session.HasRenameOverloads ? Visibility.Visible : Visibility.Collapsed;
            _defaultRenameOverloadFlag = session.OptionSet.GetOption(RenameOptions.RenameOverloads);
            _defaultRenameInStringsFlag = session.OptionSet.GetOption(RenameOptions.RenameInStrings);
            _defaultRenameInCommentsFlag = session.OptionSet.GetOption(RenameOptions.RenameInComments);
            _defaultPreviewChangesFlag = session.OptionSet.GetOption(RenameOptions.PreviewChanges);

            _session.ReferenceLocationsChanged += OnReferenceLocationsChanged;
            _session.ReplacementsComputed += OnReplacementsComputed;
        }
            public OpenTextBufferManager(
                InlineRenameSession session,
                ITextBuffer subjectBuffer,
                Workspace workspace,
                IEnumerable<Document> documents,
                ITextBufferFactoryService textBufferFactoryService)
            {
                _session = session;
                _subjectBuffer = subjectBuffer;
                _baseDocuments = documents;
                _textBufferFactoryService = textBufferFactoryService;
                _subjectBuffer.ChangedLowPriority += OnTextBufferChanged;

                foreach (var view in session._textBufferAssociatedViewService.GetAssociatedTextViews(_subjectBuffer))
                {
                    ConnectToView(view);
                }

                session.UndoManager.CreateStartRenameUndoTransaction(workspace, subjectBuffer, session);

                _isBufferReadOnly = new DynamicReadOnlyRegionQuery((isEdit) => !_session._isApplyingEdit);
                UpdateReadOnlyRegions();
            }
Beispiel #4
0
 public ActiveSessionChangedEventArgs(InlineRenameSession previousSession)
 {
     this.PreviousSession = previousSession;
 }