public SarifLocationTextMarkerTagger( ITextView textView, ITextBuffer textBuffer, IPersistentSpanFactory persistentSpanFactory, ITextViewCaretListenerService <ITextMarkerTag> textViewCaretListenerService, ISarifErrorListEventSelectionService sarifErrorListEventSelectionService) { ThreadHelper.ThrowIfNotOnUIThread(); if (!SdkUIUtilities.TryGetFileNameFromTextBuffer(textBuffer, out this.filePath)) { throw new ArgumentException("Always expect to be able to get file name from text buffer.", nameof(textBuffer)); } this.TextBuffer = textBuffer; this.persistentSpanFactory = persistentSpanFactory; this.sarifErrorListEventSelectionService = sarifErrorListEventSelectionService; // Subscribe to the SARIF error item being selected from the error list // so we can properly filter the tags being shown in the editor // to the currently selected item. this.sarifErrorListEventSelectionService.SelectedItemChanged += this.SelectedSarifItemChanged; // Subscribe to the caret position so we can send enter and exit notifications // to the tags so they can decide potentially change their colors. textViewCaretListenerService.CreateListener(textView, this); }
/// <summary> /// Initializes a new instance of the <see cref="SarifExplorerWindow"/> class. /// </summary> public SarifExplorerWindow() : base(null) { ThreadHelper.ThrowIfNotOnUIThread(); this.Caption = Resources.SarifExplorerCaption; // This is the user control hosted by the tool window; Note that, even if this class implements IDisposable, // we are not calling Dispose on this object. This is because ToolWindowPane calls Dispose on // the object returned by the Content property. this.Content = new SarifToolWindowControl(); this.Control.Loaded += this.Control_Loaded; this.Control.Unloaded += this.Control_Unloaded; var componentModel = (IComponentModel)AsyncPackage.GetGlobalService(typeof(SComponentModel)); if (componentModel != null) { this.sarifErrorListEventSelectionService = componentModel.GetService <ISarifErrorListEventSelectionService>(); this.textViewCaretListenerService = componentModel.GetService <ITextViewCaretListenerService <ITextMarkerTag> >(); } }