internal void RemoveTagger(DevSkimTagger tagger) { _activeTaggers.Remove(tagger); if (_activeTaggers.Count == 0) { // Last tagger was disposed of. This is means there are no longer any open views on the buffer so we can safely shut down // security checking for that buffer. _buffer.ChangedLowPriority -= this.OnBufferChange; _provider.RemoveSkimChecker(this); _isDisposed = true; _buffer.Properties.RemoveProperty(typeof(SkimChecker)); IDisposable classifierDispose = _classifier as IDisposable; if (classifierDispose != null) { classifierDispose.Dispose(); } _classifier = null; } }
/// <summary> /// Create a tagger that does security checking on the view/buffer combination. /// </summary> public ITagger <T> CreateTagger <T>(ITextView textView, ITextBuffer buffer) where T : ITag { ITagger <T> tagger = null; // Only attempt to security check on the view's edit buffer (and multiple views could have that buffer open simultaneously so // only create one instance of the security checker. if ((buffer == textView.TextBuffer) && (typeof(T) == typeof(IErrorTag))) { var skimChecker = buffer.Properties.GetOrCreateSingletonProperty(typeof(SkimChecker), () => new SkimChecker(this, textView, buffer)); // This is a thin wrapper around the SkimChecker that can be disposed of without shutting down the SkimChecker // (unless it was the last tagger on the skim checker). tagger = new DevSkimTagger(skimChecker) as ITagger <T>; } return(tagger); }
internal void AddTagger(DevSkimTagger tagger) { _activeTaggers.Add(tagger); if (_activeTaggers.Count == 1) { // First tagger created ... start doing stuff. _classifier = _provider.ClassifierAggregatorService.GetClassifier(_buffer); _buffer.ChangedLowPriority += this.OnBufferChange; _dirtySpans = new NormalizedSnapshotSpanCollection(new SnapshotSpan(_currentSnapshot, 0, _currentSnapshot.Length)); _provider.AddSkimChecker(this); this.KickUpdate(); } }