public SelectionTracking(OpenTextBufferManager openTextBufferManager) { _openTextBufferManager = openTextBufferManager; _anchor = null; _anchorSpan = default; _active = null; _activeSpan = default; var textView = openTextBufferManager.ActiveTextView; if (textView == null) { return; } var selection = textView.Selection; var snapshot = openTextBufferManager._subjectBuffer.CurrentSnapshot; var containingSpans = openTextBufferManager._referenceSpanToLinkedRenameSpanMap.Select(kvp => { // GetSpanInView() can return an empty collection if the tracking span isn't mapped to anything // in the current view, specifically a `@model SomeModelClass` directive in a Razor file. var ss = textView.GetSpanInView(kvp.Value.TrackingSpan.GetSpan(snapshot)).FirstOrDefault(); if (ss != default && (ss.IntersectsWith(selection.ActivePoint.Position) || ss.IntersectsWith(selection.AnchorPoint.Position))) { return(Tuple.Create(kvp.Key, ss)); }
private bool TryPopulateOpenTextBufferManagerForBuffer(ITextBuffer buffer) { AssertIsForeground(); VerifyNotDismissed(); if (_workspace.Kind == WorkspaceKind.Interactive) { Debug.Assert(buffer.GetRelatedDocuments().Count() == 1); Debug.Assert( buffer.IsReadOnly(0) == buffer.IsReadOnly( VisualStudio.Text.Span.FromBounds(0, buffer.CurrentSnapshot.Length) ) ); // All or nothing. if (buffer.IsReadOnly(0)) { return(false); } } if (!_openTextBuffers.ContainsKey(buffer) && buffer.SupportsRename()) { _openTextBuffers[buffer] = new OpenTextBufferManager( this, buffer, _workspace, _textBufferFactoryService ); return(true); } return(_openTextBuffers.ContainsKey(buffer)); }
private bool TryPopulateOpenTextBufferManagerForBuffer(ITextBuffer buffer, IEnumerable <Document> documents) { AssertIsForeground(); VerifyNotDismissed(); if (_workspace.Kind == WorkspaceKind.Interactive) { Debug.Assert(documents.Count() == 1); // No linked files. Debug.Assert(buffer.IsReadOnly(0) == buffer.IsReadOnly(Span.FromBounds(0, buffer.CurrentSnapshot.Length))); // All or nothing. if (buffer.IsReadOnly(0)) { return(false); } } var documentSupportsFeatureService = _workspace.Services.GetService <IDocumentSupportsFeatureService>(); if (!_openTextBuffers.ContainsKey(buffer) && documents.All(d => documentSupportsFeatureService.SupportsRename(d))) { _openTextBuffers[buffer] = new OpenTextBufferManager(this, buffer, _workspace, documents, _textBufferFactoryService); return(true); } return(_openTextBuffers.ContainsKey(buffer)); }
private void CreateOpenTextBufferManagerForBuffer(ITextBuffer buffer, IEnumerable <Document> documents) { AssertIsForeground(); VerifyNotDismissed(); if (!_openTextBuffers.ContainsKey(buffer)) { _openTextBuffers[buffer] = new OpenTextBufferManager(this, buffer, _workspace, documents, _textBufferFactoryService); } }
private bool TryPopulateOpenTextBufferManagerForBuffer(ITextBuffer buffer, IEnumerable <Document> documents) { AssertIsForeground(); VerifyNotDismissed(); var documentSupportsRefactoringService = _workspace.Services.GetService <IDocumentSupportsSuggestionService>(); if (!_openTextBuffers.ContainsKey(buffer) && documents.All(d => documentSupportsRefactoringService.SupportsRename(d))) { _openTextBuffers[buffer] = new OpenTextBufferManager(this, buffer, _workspace, documents, _textBufferFactoryService); return(true); } return(_openTextBuffers.ContainsKey(buffer)); }
public SelectionTracking(OpenTextBufferManager openTextBufferManager) { _openTextBufferManager = openTextBufferManager; _anchor = null; _anchorSpan = default(TextSpan); _active = null; _activeSpan = default(TextSpan); var textView = openTextBufferManager.ActiveTextview; if (textView == null) { return; } var selection = textView.Selection; var snapshot = openTextBufferManager._subjectBuffer.CurrentSnapshot; var containingSpans = openTextBufferManager._referenceSpanToLinkedRenameSpanMap.Select(kvp => { var ss = textView.GetSpanInView(kvp.Value.TrackingSpan.GetSpan(snapshot)).Single(); if (ss.IntersectsWith(selection.ActivePoint.Position) || ss.IntersectsWith(selection.AnchorPoint.Position)) { return(Tuple.Create(kvp.Key, ss)); } else { return(null); } }).WhereNotNull(); foreach (var tuple in containingSpans) { if (tuple.Item2.IntersectsWith(selection.AnchorPoint.Position)) { _anchor = tuple.Item2.End - selection.AnchorPoint.Position; _anchorSpan = tuple.Item1; } if (tuple.Item2.IntersectsWith(selection.ActivePoint.Position)) { _active = tuple.Item2.End - selection.ActivePoint.Position; _activeSpan = tuple.Item1; } } }
internal bool TryGetBufferManager(ITextBuffer buffer, out OpenTextBufferManager bufferManager) => _openTextBuffers.TryGetValue(buffer, out bufferManager);
internal bool TryGetBufferManager(ITextBuffer buffer, out OpenTextBufferManager bufferManager) { return(_openTextBuffers.TryGetValue(buffer, out bufferManager)); }
public SelectionTracking(OpenTextBufferManager openTextBufferManager) { _openTextBufferManager = openTextBufferManager; _anchor = null; _anchorSpan = default(TextSpan); _active = null; _activeSpan = default(TextSpan); var textView = openTextBufferManager.ActiveTextview; if (textView == null) { return; } var selection = textView.Selection; var snapshot = openTextBufferManager._subjectBuffer.CurrentSnapshot; var containingSpans = openTextBufferManager._referenceSpanToLinkedRenameSpanMap.Select(kvp => { var ss = textView.GetSpanInView(kvp.Value.TrackingSpan.GetSpan(snapshot)).Single(); if (ss.IntersectsWith(selection.ActivePoint.Position) || ss.IntersectsWith(selection.AnchorPoint.Position)) { return Tuple.Create(kvp.Key, ss); } else { return null; } }).WhereNotNull(); foreach (var tuple in containingSpans) { if (tuple.Item2.IntersectsWith(selection.AnchorPoint.Position)) { _anchor = tuple.Item2.End - selection.AnchorPoint.Position; _anchorSpan = tuple.Item1; } if (tuple.Item2.IntersectsWith(selection.ActivePoint.Position)) { _active = tuple.Item2.End - selection.ActivePoint.Position; _activeSpan = tuple.Item1; } } }
internal bool TryGetBufferManager(ITextBuffer buffer, out OpenTextBufferManager bufferManager) { return _openTextBuffers.TryGetValue(buffer, out bufferManager); }
private bool TryPopulateOpenTextBufferManagerForBuffer(ITextBuffer buffer, IEnumerable<Document> documents) { AssertIsForeground(); VerifyNotDismissed(); if (_workspace.Kind == WorkspaceKind.Interactive) { Debug.Assert(documents.Count() == 1); // No linked files. Debug.Assert(buffer.IsReadOnly(0) == buffer.IsReadOnly(Span.FromBounds(0, buffer.CurrentSnapshot.Length))); // All or nothing. if (buffer.IsReadOnly(0)) { return false; } } var documentSupportsFeatureService = _workspace.Services.GetService<IDocumentSupportsFeatureService>(); if (!_openTextBuffers.ContainsKey(buffer) && documents.All(d => documentSupportsFeatureService.SupportsRename(d))) { _openTextBuffers[buffer] = new OpenTextBufferManager(this, buffer, _workspace, documents, _textBufferFactoryService); return true; } return _openTextBuffers.ContainsKey(buffer); }
private bool TryPopulateOpenTextBufferManagerForBuffer(ITextBuffer buffer, IEnumerable<Document> documents) { AssertIsForeground(); VerifyNotDismissed(); var documentSupportsRefactoringService = _workspace.Services.GetService<IDocumentSupportsSuggestionService>(); if (!_openTextBuffers.ContainsKey(buffer) && documents.All(d => documentSupportsRefactoringService.SupportsRename(d))) { _openTextBuffers[buffer] = new OpenTextBufferManager(this, buffer, _workspace, documents, _textBufferFactoryService); return true; } return _openTextBuffers.ContainsKey(buffer); }
public SelectionTracking(OpenTextBufferManager openTextBufferManager) { _openTextBufferManager = openTextBufferManager; _anchor = null; _anchorSpan = default(TextSpan); _active = null; _activeSpan = default(TextSpan); var textView = openTextBufferManager.ActiveTextview; if (textView == null) { return; } var selection = textView.Selection; var snapshot = openTextBufferManager._subjectBuffer.CurrentSnapshot; var containingSpans = openTextBufferManager._referenceSpanToLinkedRenameSpanMap.Select(kvp => { // GetSpanInView() can return an empty collection if the tracking span isn't mapped to anything // in the current view, specifically a `@model SomeModelClass` directive in a Razor file. var ss = textView.GetSpanInView(kvp.Value.TrackingSpan.GetSpan(snapshot)).FirstOrDefault(); if (ss != default(SnapshotSpan) && (ss.IntersectsWith(selection.ActivePoint.Position) || ss.IntersectsWith(selection.AnchorPoint.Position))) { return Tuple.Create(kvp.Key, ss); } else { return null; } }).WhereNotNull(); foreach (var tuple in containingSpans) { if (tuple.Item2.IntersectsWith(selection.AnchorPoint.Position)) { _anchor = tuple.Item2.End - selection.AnchorPoint.Position; _anchorSpan = tuple.Item1; } if (tuple.Item2.IntersectsWith(selection.ActivePoint.Position)) { _active = tuple.Item2.End - selection.ActivePoint.Position; _activeSpan = tuple.Item1; } } }
private void CreateOpenTextBufferManagerForBuffer(ITextBuffer buffer, IEnumerable<Document> documents) { AssertIsForeground(); VerifyNotDismissed(); if (!_openTextBuffers.ContainsKey(buffer)) { _openTextBuffers[buffer] = new OpenTextBufferManager(this, buffer, _workspace, documents, _textBufferFactoryService); } }