public static SignatureHelpSession TryCreate(SnapshotPoint triggerPosition, SignatureHelpTriggerInfo triggerInfo, Lazy <ISignatureHelpBroker> signatureHelpBroker, ITextView textView) { var info = SignatureHelpInfo.Create(triggerPosition.Snapshot); if (info == null) { return(null); } if (triggerInfo.TriggerReason == SignatureHelpTriggerReason.TypeCharCommand) { Debug.Assert(triggerInfo.TriggerCharacter != null); if (triggerInfo.TriggerCharacter != null && !info.Value.SignatureHelpService.IsTriggerCharacter(triggerInfo.TriggerCharacter.Value)) { return(null); } } else if (triggerInfo.TriggerReason == SignatureHelpTriggerReason.RetriggerCommand) { if (triggerInfo.TriggerCharacter != null && !info.Value.SignatureHelpService.IsRetriggerCharacter(triggerInfo.TriggerCharacter.Value)) { return(null); } } return(new SignatureHelpSession(info.Value.SignatureHelpService, signatureHelpBroker, textView)); }
bool RestartCore(SnapshotPoint triggerPosition, SignatureHelpTriggerInfo triggerInfo) { var info = SignatureHelpInfo.Create(triggerPosition.Snapshot); if (info == null) { return(false); } Start(info.Value, triggerPosition, triggerInfo); return(true); }
void Start(SignatureHelpInfo info, SnapshotPoint triggerPosition, SignatureHelpTriggerInfo triggerInfo) { CancelFetchItems(); Debug.Assert(cancellationTokenSource == null); cancellationTokenSource = new CancellationTokenSource(); var cancellationTokenSourceTmp = cancellationTokenSource; StartAsync(info, triggerPosition, triggerInfo, cancellationTokenSource.Token) .ContinueWith(t => { var ex = t.Exception; // Free resources if (cancellationTokenSource == cancellationTokenSourceTmp) { CancelFetchItems(); } }, CancellationToken.None, TaskContinuationOptions.None, TaskScheduler.FromCurrentSynchronizationContext()); }
async Task StartAsync(SignatureHelpInfo info, SnapshotPoint triggerPosition, SignatureHelpTriggerInfo triggerInfo, CancellationToken cancellationToken) { // This helps a little to speed up the code ProfileOptimizationHelper.StartProfile("roslyn-sighelp-" + info.SignatureHelpService.Language); var result = await info.SignatureHelpService.GetItemsAsync(info.Document, triggerPosition.Position, triggerInfo, cancellationToken); if (result == null) { Dispose(); return; } if (cancellationToken.IsCancellationRequested) { return; } StartSession(triggerPosition, result); }
async Task StartAsync(SignatureHelpInfo info, SnapshotPoint triggerPosition, SignatureHelpTriggerInfo triggerInfo, CancellationToken cancellationToken) { // This helps a little to speed up the code ProfileOptimizationHelper.StartProfile("roslyn-sighelp-" + info.SignatureHelpService.Language); var result = await info.SignatureHelpService.GetItemsAsync(info.Document, triggerPosition.Position, triggerInfo, cancellationToken); if (result == null) { Dispose(); return; } if (cancellationToken.IsCancellationRequested) return; StartSession(triggerPosition, result); }
void Start(SignatureHelpInfo info, SnapshotPoint triggerPosition, SignatureHelpTriggerInfo triggerInfo) { CancelFetchItems(); Debug.Assert(cancellationTokenSource == null); cancellationTokenSource = new CancellationTokenSource(); var cancellationTokenSourceTmp = cancellationTokenSource; StartAsync(info, triggerPosition, triggerInfo, cancellationTokenSource.Token) .ContinueWith(t => { var ex = t.Exception; // Free resources if (cancellationTokenSource == cancellationTokenSourceTmp) CancelFetchItems(); }, CancellationToken.None, TaskContinuationOptions.None, TaskScheduler.FromCurrentSynchronizationContext()); }