public RoslynOverloadProvider(SignatureHelpItems signatureHelp) { _signatureHelp = signatureHelp; _items = signatureHelp.Items; if (signatureHelp.SelectedItemIndex != null) { _selectedIndex = signatureHelp.SelectedItemIndex.Value; } }
public async Task <SignatureHelpItems> GetItemsAsync(Document document, int position, SignatureHelpTriggerInfo trigger, CancellationToken cancellationToken) { Microsoft.CodeAnalysis.SignatureHelp.SignatureHelpItems bestItems = null; // TODO(cyrusn): We're calling into extensions, we need to make ourselves resilient // to the extension crashing. foreach (var provider in _providers) { cancellationToken.ThrowIfCancellationRequested(); var currentItems = await provider.GetItemsAsync(document, position, trigger.Inner, cancellationToken).ConfigureAwait(false); if (currentItems != null && currentItems.ApplicableSpan.IntersectsWith(position)) { // If another provider provides sig help items, then only take them if they // start after the last batch of items. i.e. we want the set of items that // conceptually are closer to where the caret position is. This way if you have: // // Foo(new Bar($$ // // Then invoking sig help will only show the items for "new Bar(" and not also // the items for "Foo(..." if (IsBetter(bestItems, currentItems.ApplicableSpan)) { bestItems = currentItems; } } } if (bestItems != null) { var items = new SignatureHelpItems(bestItems); if (items.SelectedItemIndex == null) { var bestItem = GetBestItem(null, items.Items, items.ArgumentCount, items.ArgumentName, isCaseSensitive: true); if (bestItem != null) { items.SelectedItemIndex = items.Items.IndexOf(bestItem); } } return(items); } return(null); }