コード例 #1
0
        /// <summary>
        /// Constructs <see cref="CompletionPresentationViewModel"/>
        /// </summary>
        /// <param name="items">Completion items to display with their highlighted spans</param>
        /// <param name="filters">Completion filters with their available and selected state</param>
        /// <param name="selectedItemIndex">Controls which item is selected. Use -1 in suggestion mode</param>
        /// <param name="applicableToSpan">Span pertinent to the completion session</param>
        /// <param name="useSoftSelection">Controls whether selected item should be soft selected. Default is <c>false</c></param>
        /// <param name="displaySuggestionItem">Controls whether suggestion mode item is visible. Default is <c>false</c></param>
        /// <param name="selectSuggestionItem">Controls whether suggestion mode item is selected. Default is <c>false</c></param>
        /// <param name="suggestionItem">Suggestion mode item to display. Default is <c>null</c></param>
        /// <param name="suggestionItemOptions">How to present the suggestion mode item. This is required because completion may be in suggestion mode even if there is no explicit suggestion mode item</param>
        public CompletionPresentationViewModel(
            ImmutableArray <CompletionItemWithHighlight> items,
            ImmutableArray <CompletionFilterWithState> filters,
            int selectedItemIndex,
            ITrackingSpan applicableToSpan,
            bool useSoftSelection,
            bool displaySuggestionItem,
            bool selectSuggestionItem,
            CompletionItem suggestionItem,
            SuggestionItemOptions suggestionItemOptions)
        {
            if (selectedItemIndex < -1)
            {
                throw new ArgumentOutOfRangeException(nameof(selectedItemIndex), "Selected index value must be greater than or equal to 0, or -1 to indicate no selection");
            }
            if (items.IsDefault)
            {
                throw new ArgumentException("Array must be initialized", nameof(items));
            }
            if (filters.IsDefault)
            {
                throw new ArgumentException("Array must be initialized", nameof(filters));
            }

            Items                 = items;
            Filters               = filters;
            ApplicableToSpan      = applicableToSpan ?? throw new NullReferenceException(nameof(applicableToSpan));
            UseSoftSelection      = useSoftSelection;
            DisplaySuggestionItem = displaySuggestionItem;
            SelectSuggestionItem  = selectSuggestionItem;
            SelectedItemIndex     = selectedItemIndex;
            SuggestionItem        = suggestionItem;
            SuggestionItemOptions = suggestionItemOptions ?? throw new NullReferenceException(nameof(suggestionItemOptions));
        }
コード例 #2
0
 /// <summary>
 /// Constructs <see cref="CompletionContext"/> with specified <see cref="CompletionItem"/>s,
 /// with recommendation to use suggestion mode and to use regular selection.
 /// </summary>
 /// <param name="items">Available completion items</param>
 /// <param name="suggestionItemOptions">Suggestion item options, or null to not use suggestion mode. Default is <c>null</c></param>
 public CompletionContext(
     ImmutableArray <CompletionItem> items,
     SuggestionItemOptions suggestionItemOptions)
     : this(items,
            suggestionItemOptions,
            selectionHint : InitialSelectionHint.RegularSelection,
            filters : default)
 {
 }
コード例 #3
0
 /// <summary>
 /// Constructs <see cref="CompletionContext"/> with specified <see cref="CompletionItem"/>s,
 /// with recommendation to use suggestion mode item and to use a specific selection mode.
 /// </summary>
 /// <param name="items">Available completion items</param>
 /// <param name="suggestionItemOptions">Suggestion mode options, or null to not use suggestion mode. Default is <c>null</c></param>
 /// <param name="selectionHint">Recommended selection mode. Suggestion mode automatically sets soft selection Default is <c>InitialSelectionHint.RegularSelection</c></param>
 public CompletionContext(
     ImmutableArray <CompletionItem> items,
     SuggestionItemOptions suggestionItemOptions,
     InitialSelectionHint selectionHint)
 {
     if (items.IsDefault)
     {
         throw new ArgumentException("Array must be initialized", nameof(items));
     }
     Items                 = items;
     SelectionHint         = selectionHint;
     SuggestionItemOptions = suggestionItemOptions;
 }
コード例 #4
0
 /// <summary>
 /// Constructs <see cref="CompletionContext"/> with specified <see cref="CompletionItem"/>s,
 /// with recommendation to use suggestion mode and to use regular selection.
 /// </summary>
 /// <param name="items">Available completion items</param>
 /// <param name="suggestionItemOptions">Suggestion item options, or null to not use suggestion mode. Default is <c>null</c></param>
 public CompletionContext(
     ImmutableArray <CompletionItem> items,
     SuggestionItemOptions suggestionItemOptions)
     : this(items, suggestionItemOptions, InitialSelectionHint.RegularSelection)
 {
 }