/// <summary> /// Initializes a new instance with the specified properties. /// </summary> /// <param name="moniker">The unique, non-localized identifier for the /// completion set.</param> /// <param name="displayName">The localized name of the completion set. /// </param> /// <param name="applicableTo">The tracking span to which the /// completions apply.</param> /// <param name="completions">The list of completions.</param> /// <param name="options">The options to use for filtering and /// selecting items.</param> /// <param name="comparer">The comparer to use to order the provided /// completions.</param> public FuzzyCompletionSet(string moniker, string displayName, ITrackingSpan applicableTo, IEnumerable <DynamicallyVisibleCompletion> completions, CompletionOptions options, IComparer <Completion> comparer, Func <string, IEnumerable <DynamicallyVisibleCompletion> > deferredLoadCallback) : base(moniker, displayName, applicableTo, null, null) { _options = options; _initialComparer = comparer; _completions = new BulkObservableCollection <Completion>(); _loadedDeferredCompletionSubsets = new HashSet <string>(StringComparer.OrdinalIgnoreCase); _deferredLoadCallback = deferredLoadCallback; _completions.AddRange(completions .Where(c => c != null && !string.IsNullOrWhiteSpace(c.DisplayText)) .OrderBy(c => c, comparer) ); _comparer = new FuzzyStringMatcher(options.SearchMode); _shouldFilter = options.FilterCompletions; _shouldHideAdvanced = options.HideAdvancedMembers && !_completions.All(IsAdvanced); if (_shouldFilter | _shouldHideAdvanced) { _filteredCompletions = new WritableFilteredObservableCollection <Completion>(_completions); foreach (var c in _completions.Cast <DynamicallyVisibleCompletion>()) { c.Visible = !_shouldHideAdvanced || !IsAdvanced(c); } _filteredCompletions.Filter(IsVisible); } }
/// <summary> /// Initializes a new instance with the specified properties. /// </summary> /// <param name="moniker">The unique, non-localized identifier for the /// completion set.</param> /// <param name="displayName">The localized name of the completion set. /// </param> /// <param name="applicableTo">The tracking span to which the /// completions apply.</param> /// <param name="completions">The list of completions.</param> /// <param name="options">The options to use for filtering and /// selecting items.</param> /// <param name="comparer">The comparer to use to order the provided /// completions.</param> /// <param name="matchInsertionText">If true, matches user input against /// the insertion text; otherwise, uses the display text.</param> public FuzzyCompletionSet( string moniker, string displayName, ITrackingSpan applicableTo, IEnumerable <DynamicallyVisibleCompletion> completions, CompletionOptions options, IComparer <Completion> comparer, bool matchInsertionText = false ) : base(moniker, displayName, applicableTo, null, null) { _matchInsertionText = matchInsertionText; _completions = new BulkObservableCollection <Completion>(); _completions.AddRange(completions .Where(c => c != null && !string.IsNullOrWhiteSpace(c.DisplayText)) .OrderBy(c => c, comparer) ); _comparer = new FuzzyStringMatcher(options.SearchMode); _shouldFilter = options.FilterCompletions; _shouldHideAdvanced = options.HideAdvancedMembers && !_completions.All(IsAdvanced); if (!_completions.Any()) { _completions = null; } if (_completions != null && _shouldFilter | _shouldHideAdvanced) { _filteredCompletions = new FilteredObservableCollection <Completion>(_completions); foreach (var c in _completions.Cast <DynamicallyVisibleCompletion>()) { c.Visible = !_shouldHideAdvanced || !IsAdvanced(c); } _filteredCompletions.Filter(IsVisible); } CommitByDefault = DefaultCommitByDefault; }
/// <summary> /// Initializes a new instance with the specified properties. /// </summary> /// <param name="moniker">The unique, non-localized identifier for the completion set.</param> /// <param name="displayName">The localized name of the completion set.</param> /// <param name="applicableTo">The tracking span to which the completions apply.</param> /// <param name="completions">The list of completions.</param> /// <param name="options">The options to use for filtering and selecting items.</param> /// <param name="comparer">The comparer to use to order the provided completions.</param> /// <param name="matchInsertionText">If true, matches user input against /// the insertion text; otherwise, uses the display text.</param> public FuzzyCompletionSet( string moniker, string displayName, ITrackingSpan applicableTo, IEnumerable<DynamicallyVisibleCompletion> completions, IComparer<Completion> comparer, bool matchInsertionText = false ) : base(moniker, displayName, applicableTo, null, null) { _matchInsertionText = matchInsertionText; _completions = new BulkObservableCollection<Completion>(); _completions.AddRange(completions .Where(c => c != null && !string.IsNullOrWhiteSpace(c.DisplayText)) .OrderBy(c => c, comparer) ); _comparer = new FuzzyStringMatcher(FuzzyMatchMode.Default); #if FALSE _shouldFilter = options.FilterCompletions; _shouldHideAdvanced = options.HideAdvancedMembers && !_completions.All(IsAdvanced); #endif _shouldFilter = true; _shouldHideAdvanced = false; if (_shouldFilter | _shouldHideAdvanced) { _filteredCompletions = new FilteredObservableCollection<Completion>(_completions); foreach (var c in _completions.Cast<DynamicallyVisibleCompletion>()) { c.Visible = !_shouldHideAdvanced || !IsAdvanced(c); } _filteredCompletions.Filter(IsVisible); } }