Пример #1
0
        private ImmutableArray <AsyncCompletionData.CompletionFilter> GetFilters(RoslynCompletionItem item)
        {
            var listBuilder = new ArrayBuilder <AsyncCompletionData.CompletionFilter>();

            foreach (var filter in CompletionItemFilter.AllFilters)
            {
                if (filter.Matches(item))
                {
                    if (!s_filterCache.TryGetValue(filter.DisplayText, out var itemFilter))
                    {
                        var imageId = filter.Tags.GetFirstGlyph().GetImageId();
                        itemFilter = new AsyncCompletionData.CompletionFilter(
                            filter.DisplayText,
                            filter.AccessKey.ToString(),
                            new ImageElement(new ImageId(imageId.Guid, imageId.Id), EditorFeaturesResources.Filter_image_element));
                        s_filterCache[filter.DisplayText] = itemFilter;
                    }

                    listBuilder.Add(itemFilter);
                }
            }

            return(listBuilder.ToImmutableAndFree());
        }
 /// <summary>
 /// Constructs a new instance of <see cref="CompletionFilterWithState"/> when selected state is known.
 /// </summary>
 /// <param name="filter">Reference to <see cref="CompletionFilter"/></param>
 /// <param name="isAvailable">Whether this <see cref="CompletionFilter"/> is available</param>
 /// <param name="isSelected">Whether this <see cref="CompletionFilter"/> is selected</param>
 public CompletionFilterWithState(CompletionFilter filter, bool isAvailable, bool isSelected)
 {
     Filter      = filter ?? throw new ArgumentNullException(nameof(filter));
     IsAvailable = isAvailable;
     IsSelected  = isSelected;
 }
 /// <summary>
 /// Constructs a new instance of <see cref="CompletionFilterWithState"/> which is not selected.
 /// </summary>
 /// <param name="filter">Reference to <see cref="CompletionFilter"/></param>
 /// <param name="isAvailable">Whether this <see cref="CompletionFilter"/> is available</param>
 public CompletionFilterWithState(CompletionFilter filter, bool isAvailable)
     : this(filter, isAvailable, isSelected : false)
 {
 }