public void Refresh()
 {
     _item = _items[_selectedIndex];
     var headerPanel = new WrapPanel
     {
         Orientation = Orientation.Horizontal,
         Children =
         {
             ToTextBlock(_item.PrefixDisplayParts),
         }
     };
     var contentPanel = new StackPanel();
     var docText = _item.DocumentationFactory(CancellationToken.None).ToTextBlock();
     if (docText != null && docText.Inlines.Count > 0)
     {
         contentPanel.Children.Add(docText);
     }
     if (!_item.Parameters.IsDefault)
     {
         for (var index = 0; index < _item.Parameters.Length; index++)
         {
             var param = _item.Parameters[index];
             AddParameterSignatureHelp(index, param, headerPanel, contentPanel);
         }
     }
     headerPanel.Children.Add(ToTextBlock(_item.SuffixDisplayParts));
     CurrentHeader = headerPanel;
     CurrentContent = contentPanel;
 }
Beispiel #2
0
        private static SignatureHelpItem GetBestItem(SignatureHelpItem currentItem, ICollection <SignatureHelpItem> filteredItems, int argumentCount, string name, bool isCaseSensitive)
        {
            while (true)
            {
                // If the current item is still applicable, then just keep it.
                if (filteredItems.Contains(currentItem) && IsApplicable(currentItem, argumentCount, name, isCaseSensitive))
                {
                    return(currentItem);
                }

                // Try to find the first applicable item.  If there is none, then that means the
                // selected parameter was outside the bounds of all methods.  i.e. all methods only
                // went up to 3 parameters, and selected parameter is 3 or higher.  In that case,
                // just pick the very last item as it is closest in parameter count.
                var result = filteredItems.FirstOrDefault(i => IsApplicable(i, argumentCount, name, isCaseSensitive));
                if (result != null)
                {
                    return(result);
                }

                // if we couldn't find a best item, and they provided a name, then try again without
                // a name.
                if (name != null)
                {
                    name = null;
                    continue;
                }

                // If we don't have an item that can take that number of parameters, then just pick
                // the last item.  Or stick with the current item if the last item isn't any better.
                var lastItem = filteredItems.Last();
                if (currentItem.IsVariadic || currentItem.Parameters.Length == lastItem.Parameters.Length)
                {
                    return(currentItem);
                }

                return(lastItem);
            }
        }
 public SignatureHelpSelection(SignatureHelpItem selectedItem, bool userSelected, int?selectedParameter)
 {
     SelectedItem      = selectedItem;
     UserSelected      = userSelected;
     SelectedParameter = selectedParameter;
 }