void InitializeSignatures(ITrackingSpan applicableToSpan, SignatureHelpResult signatureHelpResult) { Debug.Assert(signatureHelpResult.Items != null); signatures.Clear(); foreach (var item in signatureHelpResult.Items.Items) { bool isSelected = signatureHelpResult.SelectedItem == item; signatures.Add(new Signature(applicableToSpan, item, isSelected, signatureHelpResult.SelectedParameter)); } }
void StartSession(SnapshotPoint triggerPosition, SignatureHelpResult signatureHelpResult) { if (isDisposed || textView.IsClosed) { Dispose(); return; } var triggerPoint = triggerPosition.Snapshot.CreateTrackingPoint(triggerPosition.Position, PointTrackingMode.Negative); var applicableSpan = signatureHelpResult.Items.ApplicableSpan; var trackingSpan = CreateApplicableToSpan(triggerPosition, applicableSpan); InitializeSignatures(trackingSpan, signatureHelpResult); if (session == null) { session = signatureHelpBroker.Value.CreateSignatureHelpSession(textView, triggerPoint, trackCaret: false); session.Dismissed += Session_Dismissed; session.Properties.AddProperty(sigHelpSessionKey, this); } session.Recalculate(); // It's set to null if it got dismissed if (session == null || session.IsDismissed) { Debug.Assert(isDisposed); Dispose(); return; } var selectedSig = signatures.FirstOrDefault(a => a.IsSelected); if (selectedSig != null) session.SelectedSignature = selectedSig; }