internal void BeginSession( EventHookupCommandHandler eventHookupCommandHandler, ITextView textView, ITextBuffer subjectBuffer, IAsynchronousOperationListener asyncListener, Mutex testSessionHookupMutex) { CurrentSession = new EventHookupSession(this, eventHookupCommandHandler, textView, subjectBuffer, asyncListener, testSessionHookupMutex); }
internal void BeginSession( EventHookupCommandHandler eventHookupCommandHandler, ITextView textView, ITextBuffer subjectBuffer, AggregateAsynchronousOperationListener asyncListener, Mutex testSessionHookupMutex) { CurrentSession = new EventHookupSession(this, eventHookupCommandHandler, textView, subjectBuffer, asyncListener, testSessionHookupMutex); }
internal void EventHookupFoundInSession(EventHookupSession analyzedSession) { AssertIsForeground(); var caretPoint = analyzedSession.TextView.GetCaretPoint(analyzedSession.SubjectBuffer); // only generate tooltip if it is not already shown (_toolTipPresenter == null) // Ensure the analyzed session matches the current session and that the caret is still // in the session's tracking span. if (_toolTipPresenter == null && CurrentSession == analyzedSession && caretPoint.HasValue && analyzedSession.TrackingSpan.GetSpan(CurrentSession.TextView.TextSnapshot).Contains(caretPoint.Value)) { // Create a tooltip presenter that stays alive, even when the user types, without tracking the mouse. _toolTipPresenter = this._toolTipService.CreatePresenter(analyzedSession.TextView, new ToolTipParameters(trackMouse: false, ignoreBufferChange: true)); // tooltips text is: Program_MyEvents; (Press TAB to insert) // GetEventNameTask() gets back the event name, only needs to add a semicolon after it. var textRuns = new[] { new ClassifiedTextRun(ClassificationTypeNames.MethodName, analyzedSession.GetEventNameTask.Result, ClassifiedTextRunStyle.UseClassificationFont), new ClassifiedTextRun(ClassificationTypeNames.Punctuation, ";", ClassifiedTextRunStyle.UseClassificationFont), new ClassifiedTextRun(ClassificationTypeNames.Text, CSharpEditorResources.Press_TAB_to_insert), }; var content = new[] { new ClassifiedTextElement(textRuns) }; _toolTipPresenter.StartOrUpdate(analyzedSession.TrackingSpan, content); // For test purposes only! TEST_MostRecentToolTipContent = content; // Watch all text buffer changes & caret moves while this event hookup session is active analyzedSession.TextView.TextSnapshot.TextBuffer.Changed += TextBuffer_Changed; CurrentSession.Dismissed += () => { analyzedSession.TextView.TextSnapshot.TextBuffer.Changed -= TextBuffer_Changed; }; analyzedSession.TextView.Caret.PositionChanged += Caret_PositionChanged; CurrentSession.Dismissed += () => { analyzedSession.TextView.Caret.PositionChanged -= Caret_PositionChanged; }; } }
internal void EventHookupFoundInSession(EventHookupSession analyzedSession) { AssertIsForeground(); var caretPoint = analyzedSession.TextView.GetCaretPoint(analyzedSession.SubjectBuffer); // Ensure the analyzed session matches the current session and that the caret is still // in the session's tracking span. if (CurrentSession == analyzedSession && QuickInfoSession == null && caretPoint.HasValue && analyzedSession.TrackingSpan.GetSpan(CurrentSession.TextView.TextSnapshot).Contains(caretPoint.Value)) { QuickInfoSession = _quickInfoBroker.CreateQuickInfoSession(analyzedSession.TextView, analyzedSession.TrackingPoint, trackMouse: false); // Special indicator that this quick info session was created by event hookup, // which is used when deciding whether and how to display the session QuickInfoSession.Properties.AddProperty(typeof(EventHookupSessionManager), this); QuickInfoSession.Properties.AddProperty(QuickInfoUtilities.EventHookupKey, "EventHookup"); // Watch all text buffer changes & caret moves while this quick info session is // active analyzedSession.TextView.TextSnapshot.TextBuffer.Changed += TextBuffer_Changed; CurrentSession.Dismissed += () => { analyzedSession.TextView.TextSnapshot.TextBuffer.Changed -= TextBuffer_Changed; }; analyzedSession.TextView.Caret.PositionChanged += Caret_PositionChanged; CurrentSession.Dismissed += () => { analyzedSession.TextView.Caret.PositionChanged -= Caret_PositionChanged; }; QuickInfoSession.Start(); // HACK! Workaround for VS dismissing quick info sessions on buffer changed events. // This must happen after the QuickInfoSession is started. if (_prematureDismissalPreventer != null) { _prematureDismissalPreventer.HACK_EnsureQuickInfoSessionNotDismissedPrematurely(analyzedSession.TextView); QuickInfoSession.Dismissed += (s, e) => { _prematureDismissalPreventer.HACK_OnQuickInfoSessionDismissed(analyzedSession.TextView); }; } } }