public void RemoveIssueTagger(IssueTagger tagger) { lock (managers) { taggers.Remove(tagger); daemon.Ready -= tagger.DaemonStarted; foreach (var manager in managers) { manager.RemoveFactory(tagger.Factory); } } }
public void AddIssueTagger(IssueTagger tagger) { lock (managers) { taggers.Add(tagger); daemon.Ready += tagger.DaemonStarted; foreach (var manager in managers) { manager.AddFactory(tagger.Factory); } } }
/// <summary> /// Create a tagger that will track SonarLint issues on the view/buffer combination. /// </summary> public ITagger <T> CreateTagger <T>(ITextView textView, ITextBuffer buffer) where T : ITag { if (!settings.IsActivateMoreEnabled) { return(null); } // Only attempt to track the view's edit buffer. // Multiple views could have that buffer open simultaneously, so only create one instance of the tracker. if (buffer != textView.TextBuffer || typeof(T) != typeof(IErrorTag)) { return(null); } ITextDocument document; if (!TextDocumentFactoryService.TryGetTextDocument(textView.TextDataModel.DocumentBuffer, out document)) { return(null); } var filePath = document.FilePath; var fileExtension = Path.GetExtension(filePath).Replace(".", ""); var contentTypes = ContentTypeRegistryService.ContentTypes .Where(type => FileExtensionRegistryService.GetExtensionsForContentType(type).Any(e => e == fileExtension)) .ToList(); if (contentTypes.Count == 0 && buffer.ContentType != null) { // Fallback on TextBuffer content type contentTypes.Add(buffer.ContentType); } if (!contentTypes.Any(t => t.IsOfType("JavaScript") || t.IsOfType("C/C++"))) { return(null); } lock (taggers) { if (!taggers.ExistsForFile(filePath)) { var tracker = new IssueTagger(dte, this, buffer, document, contentTypes); return(tracker as ITagger <T>); } } return(null); }
public void RemoveTagger(IssueTagger tagger) { Debug.Assert(activeTaggers.Contains(tagger), "Not expecting RemoveTagger to be called for an unregistered 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 // issue tracking for that buffer. document.FileActionOccurred -= SafeOnFileActionOccurred; textBuffer.ChangedLowPriority -= SafeOnBufferChange; textBuffer.Properties.RemoveProperty(typeof(TextBufferIssueTracker)); Provider.RemoveIssueTracker(this); } }
public void AddTagger(IssueTagger tagger) { Debug.Assert(!activeTaggers.Contains(tagger), "Not expecting the tagger to be already registered"); activeTaggers.Add(tagger); if (activeTaggers.Count == 1) { // First tagger created... start doing stuff textBuffer.ChangedLowPriority += SafeOnBufferChange; this.dirtySpans = new NormalizedSnapshotSpanCollection(new SnapshotSpan(currentSnapshot, 0, currentSnapshot.Length)); Provider.AddIssueTracker(this); RequestAnalysis(); } }
public bool TryGetValue(string path, out IssueTagger tracker) { return(trackers.TryGetValue(Key(path), out tracker)); }
public void Remove(IssueTagger tracker) { trackers.Remove(Key(tracker.FilePath)); }
public void Add(IssueTagger tracker) { trackers.Add(Key(tracker.FilePath), tracker); }