/// <summary> /// Create a tagger that does error 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 spell check on the view's edit buffer (and multiple views could have that buffer open simultaneously so // only create one instance of the spell checker. if ((buffer == textView.TextBuffer) && (typeof(T) == typeof(IErrorTag))) { ErrorHighLightChecker errorChecker = buffer.Properties.GetOrCreateSingletonProperty(typeof(ErrorHighLightChecker), () => new ErrorHighLightChecker(this, textView, buffer)); tagger = new ErrorHighLightTagger(errorChecker) as ITagger <T>; } return(tagger); }
internal void AddTagger(ErrorHighLightTagger tagger) { _activeTaggers.Add(tagger); if (_activeTaggers.Count == 1) { // First tagger created ... start doing stuff. _buffer.ChangedLowPriority += this.OnBufferChange; _provider.AddSpellChecker(this); this.KickUpdate(); } }
internal void RemoveTagger(ErrorHighLightTagger 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 // spell checking for that buffer. _buffer.ChangedLowPriority -= this.OnBufferChange; _provider.RemoveSpellChecker(this); _isDisposed = true; _buffer.Properties.RemoveProperty(typeof(ErrorHighLightChecker)); } }