public InlineRenameSession( IThreadingContext threadingContext, InlineRenameService renameService, Workspace workspace, SnapshotSpan triggerSpan, IInlineRenameInfo renameInfo, IWaitIndicator waitIndicator, ITextBufferAssociatedViewService textBufferAssociatedViewService, ITextBufferFactoryService textBufferFactoryService, IFeatureServiceFactory featureServiceFactory, IEnumerable <IRefactorNotifyService> refactorNotifyServices, IAsynchronousOperationListener asyncListener) : base(threadingContext, assertIsForeground: true) { // This should always be touching a symbol since we verified that upon invocation _renameInfo = renameInfo; _triggerDocument = triggerSpan.Snapshot.GetOpenDocumentInCurrentContextWithChanges(); if (_triggerDocument == null) { throw new InvalidOperationException(EditorFeaturesResources.The_triggerSpan_is_not_included_in_the_given_workspace); } _inlineRenameSessionDurationLogBlock = Logger.LogBlock(FunctionId.Rename_InlineSession, CancellationToken.None); _workspace = workspace; _workspace.WorkspaceChanged += OnWorkspaceChanged; _textBufferFactoryService = textBufferFactoryService; _textBufferAssociatedViewService = textBufferAssociatedViewService; _textBufferAssociatedViewService.SubjectBuffersConnected += OnSubjectBuffersConnected; // Disable completion when an inline rename session starts _featureService = featureServiceFactory.GlobalFeatureService; _completionDisabledToken = _featureService.Disable(PredefinedEditorFeatureNames.Completion, this); _renameService = renameService; _waitIndicator = waitIndicator; _refactorNotifyServices = refactorNotifyServices; _asyncListener = asyncListener; _triggerView = textBufferAssociatedViewService.GetAssociatedTextViews(triggerSpan.Snapshot.TextBuffer).FirstOrDefault(v => v.HasAggregateFocus) ?? textBufferAssociatedViewService.GetAssociatedTextViews(triggerSpan.Snapshot.TextBuffer).First(); _optionSet = renameInfo.ForceRenameOverloads ? workspace.Options.WithChangedOption(RenameOptions.RenameOverloads, true) : workspace.Options; this.ReplacementText = triggerSpan.GetText(); _baseSolution = _triggerDocument.Project.Solution; this.UndoManager = workspace.Services.GetService <IInlineRenameUndoManager>(); _debuggingWorkspaceService = workspace.Services.GetService <IDebuggingWorkspaceService>(); _debuggingWorkspaceService.BeforeDebuggingStateChanged += OnBeforeDebuggingStateChanged; InitializeOpenBuffers(triggerSpan); }
private IList <Tuple <ITextView, IMappingPoint> > GetCaretPositions() { // Currently, only do this if there's a single view var views = _associatedViewService.GetAssociatedTextViews(_subjectBuffer); var result = new List <Tuple <ITextView, IMappingPoint> >(); foreach (var view in views) { view.Caret.PositionChanged += _caretPositionChangedHandler; var point = view.GetCaretPoint(_subjectBuffer); if (point != null) { result.Add( Tuple.Create( view, view.BufferGraph.CreateMappingPoint( point.Value, PointTrackingMode.Negative ) ) ); } } return(result); }
public InlineRenameSession( InlineRenameService renameService, Workspace workspace, SnapshotSpan triggerSpan, IInlineRenameInfo renameInfo, IWaitIndicator waitIndicator, ITextBufferAssociatedViewService textBufferAssociatedViewService, ITextBufferFactoryService textBufferFactoryService, IEnumerable <IRefactorNotifyService> refactorNotifyServices, IAsynchronousOperationListener asyncListener) : base(assertIsForeground: true) { // This should always be touching a symbol since we verified that upon invocation _renameInfo = renameInfo; _triggerDocument = triggerSpan.Snapshot.GetOpenDocumentInCurrentContextWithChanges(); if (_triggerDocument == null) { throw new InvalidOperationException(EditorFeaturesResources.TheTriggerspanIsNotIncludedInWorkspace); } _inlineRenameSessionDurationLogBlock = Logger.LogBlock(FunctionId.Rename_InlineSession, CancellationToken.None); _workspace = workspace; _workspace.WorkspaceChanged += OnWorkspaceChanged; _textBufferFactoryService = textBufferFactoryService; _textBufferAssociatedViewService = textBufferAssociatedViewService; _textBufferAssociatedViewService.SubjectBuffersConnected += OnSubjectBuffersConnected; _renameService = renameService; _waitIndicator = waitIndicator; _refactorNotifyServices = refactorNotifyServices; _asyncListener = asyncListener; _triggerView = textBufferAssociatedViewService.GetAssociatedTextViews(triggerSpan.Snapshot.TextBuffer).FirstOrDefault(v => v.HasAggregateFocus) ?? textBufferAssociatedViewService.GetAssociatedTextViews(triggerSpan.Snapshot.TextBuffer).First(); _optionSet = workspace.Options; this.ReplacementText = triggerSpan.GetText(); _baseSolution = _triggerDocument.Project.Solution; this.UndoManager = workspace.Services.GetService <IInlineRenameUndoManager>(); InitializeOpenBuffers(triggerSpan); }
public IEnumerable <ITagSpan <IClassificationTag> > GetTags(NormalizedSnapshotSpanCollection spans) { using (Logger.LogBlock(FunctionId.Tagger_SyntacticClassification_TagComputer_GetTags, CancellationToken.None)) { if (!_cachedTaggableStatus.HasValue) { if (!_isClassificationOnlyWorkspace) { _cachedTaggableStatus = true; } else { var wpfTextViews = _associatedViewService.GetAssociatedTextViews(_subjectBuffer); if (wpfTextViews.Any()) { _cachedTaggableStatus = _viewSupportsClassificationServiceOpt?.CanClassifyViews(wpfTextViews.Cast <ITextView>()) ?? true; } } } if (_cachedTaggableStatus == false) { return(SpecializedCollections.EmptyEnumerable <ITagSpan <IClassificationTag> >()); } if (spans.Count > 0) { var classifiedSpans = ClassificationUtilities.GetOrCreateClassifiedSpanList(); foreach (var span in spans) { AddClassifiedSpans(_editorClassificationService, span, classifiedSpans); } return(ClassificationUtilities.ConvertAndReturnList(_typeMap, spans[0].Snapshot, classifiedSpans)); } return(SpecializedCollections.EmptyEnumerable <ITagSpan <IClassificationTag> >()); } }
public InlineRenameSession( InlineRenameService renameService, Workspace workspace, SnapshotSpan triggerSpan, IInlineRenameInfo renameInfo, IWaitIndicator waitIndicator, ITextBufferAssociatedViewService textBufferAssociatedViewService, ITextBufferFactoryService textBufferFactoryService, IEnumerable<IRefactorNotifyService> refactorNotifyServices, IAsynchronousOperationListener asyncListener) : base(assertIsForeground: true) { // This should always be touching a symbol since we verified that upon invocation _renameInfo = renameInfo; _triggerDocument = triggerSpan.Snapshot.GetOpenDocumentInCurrentContextWithChanges(); if (_triggerDocument == null) { throw new InvalidOperationException(EditorFeaturesResources.The_triggerSpan_is_not_included_in_the_given_workspace); } _inlineRenameSessionDurationLogBlock = Logger.LogBlock(FunctionId.Rename_InlineSession, CancellationToken.None); _workspace = workspace; _workspace.WorkspaceChanged += OnWorkspaceChanged; _textBufferFactoryService = textBufferFactoryService; _textBufferAssociatedViewService = textBufferAssociatedViewService; _textBufferAssociatedViewService.SubjectBuffersConnected += OnSubjectBuffersConnected; _renameService = renameService; _waitIndicator = waitIndicator; _refactorNotifyServices = refactorNotifyServices; _asyncListener = asyncListener; _triggerView = textBufferAssociatedViewService.GetAssociatedTextViews(triggerSpan.Snapshot.TextBuffer).FirstOrDefault(v => v.HasAggregateFocus) ?? textBufferAssociatedViewService.GetAssociatedTextViews(triggerSpan.Snapshot.TextBuffer).First(); _optionSet = renameInfo.ForceRenameOverloads ? workspace.Options.WithChangedOption(RenameOptions.RenameOverloads, true) : workspace.Options; this.ReplacementText = triggerSpan.GetText(); _baseSolution = _triggerDocument.Project.Solution; this.UndoManager = workspace.Services.GetService<IInlineRenameUndoManager>(); _editAndContinueWorkspaceService = workspace.Services.GetService<IEditAndContinueWorkspaceService>(); _editAndContinueWorkspaceService.BeforeDebuggingStateChanged += OnBeforeDebuggingStateChanged; InitializeOpenBuffers(triggerSpan); }
public InlineRenameSession( IThreadingContext threadingContext, InlineRenameService renameService, Workspace workspace, SnapshotSpan triggerSpan, IInlineRenameInfo renameInfo, SymbolRenameOptions options, bool previewChanges, IUIThreadOperationExecutor uiThreadOperationExecutor, ITextBufferAssociatedViewService textBufferAssociatedViewService, ITextBufferFactoryService textBufferFactoryService, IFeatureServiceFactory featureServiceFactory, IEnumerable <IRefactorNotifyService> refactorNotifyServices, IAsynchronousOperationListener asyncListener) { // This should always be touching a symbol since we verified that upon invocation _threadingContext = threadingContext; _renameInfo = renameInfo; _triggerSpan = triggerSpan; _triggerDocument = triggerSpan.Snapshot.GetOpenDocumentInCurrentContextWithChanges(); if (_triggerDocument == null) { throw new InvalidOperationException(EditorFeaturesResources.The_triggerSpan_is_not_included_in_the_given_workspace); } _inlineRenameSessionDurationLogBlock = Logger.LogBlock(FunctionId.Rename_InlineSession, CancellationToken.None); _workspace = workspace; _workspace.WorkspaceChanged += OnWorkspaceChanged; _textBufferFactoryService = textBufferFactoryService; _textBufferAssociatedViewService = textBufferAssociatedViewService; _textBufferAssociatedViewService.SubjectBuffersConnected += OnSubjectBuffersConnected; // Disable completion when an inline rename session starts _featureService = featureServiceFactory.GlobalFeatureService; _completionDisabledToken = _featureService.Disable(PredefinedEditorFeatureNames.Completion, this); RenameService = renameService; _uiThreadOperationExecutor = uiThreadOperationExecutor; _refactorNotifyServices = refactorNotifyServices; _asyncListener = asyncListener; _triggerView = textBufferAssociatedViewService.GetAssociatedTextViews(triggerSpan.Snapshot.TextBuffer).FirstOrDefault(v => v.HasAggregateFocus) ?? textBufferAssociatedViewService.GetAssociatedTextViews(triggerSpan.Snapshot.TextBuffer).First(); _options = options; _previewChanges = previewChanges; _initialRenameText = triggerSpan.GetText(); this.ReplacementText = _initialRenameText; _baseSolution = _triggerDocument.Project.Solution; this.UndoManager = workspace.Services.GetService <IInlineRenameUndoManager>(); if (_renameInfo is IInlineRenameInfoWithFileRename renameInfoWithFileRename) { FileRenameInfo = renameInfoWithFileRename.GetFileRenameInfo(); } else { FileRenameInfo = InlineRenameFileRenameInfo.NotAllowed; } InitializeOpenBuffers(triggerSpan); }