protected static bool IsSnippetItem(CompletionItem item) => item.Tags.Contains(WellKnownTags.Snippet);
protected virtual int CompareMatches(PatternMatch match1, PatternMatch match2, CompletionItem item1, CompletionItem item2) { return(match1.CompareTo(match2)); }
protected static bool IsKeywordItem(CompletionItem item) => item.Tags.Contains(WellKnownTags.Keyword);
public void PresentItems( ITrackingSpan triggerSpan, IList <RoslynCompletion.CompletionItem> completionItems, RoslynCompletion.CompletionItem selectedItem, RoslynCompletion.CompletionItem suggestionModeItem, bool suggestionMode, bool isSoftSelected, ImmutableArray <CompletionItemFilter> completionItemFilters, string filterText) { AssertIsForeground(); // check if this update is still relevant if (_textView.IsClosed || _isDismissed) { return; } if (triggerSpan != null) { _completionSet.SetTrackingSpan(triggerSpan); } _ignoreSelectionStatusChangedEvent = true; try { _completionSet.SetCompletionItems( completionItems, selectedItem, suggestionModeItem, suggestionMode, isSoftSelected, completionItemFilters, filterText); } finally { _ignoreSelectionStatusChangedEvent = false; } if (_editorSessionOpt == null) { // We're tracking the caret. Don't have the editor do it. // Map the span instead of a point to avoid affinity problems. _editorSessionOpt = _completionBroker.CreateCompletionSession( _textView, triggerSpan.GetStartTrackingPoint(PointTrackingMode.Negative), trackCaret: false); if (_textView is IDebuggerTextView debugTextView && !debugTextView.IsImmediateWindow) { debugTextView.HACK_StartCompletionSession(_editorSessionOpt); } _editorSessionOpt.Dismissed += (s, e) => OnEditorSessionDismissed(); // So here's the deal. We cannot create the editor session and give it the right // items (even though we know what they are). Instead, the session will call // back into the ICompletionSourceProvider (which is us) to get those values. It // will pass itself along with the calls back into ICompletionSourceProvider. // So, in order to make that connection work, we add properties to the session // so that we can call back into ourselves, get the items and add it to the // session. _editorSessionOpt.Properties.AddProperty(Key, this); _editorSessionOpt.Start(); } // Call so that the editor will refresh the completion text to embolden. _editorSessionOpt?.Match(); }
public static bool IsObjectCreationCompletionItem(this CompletionItem item) => GetProviderName(item) == ObjectCreationCompletionProvider;
/// <summary> /// Determines if the items are similar enough they should be represented by a single item in the list. /// </summary> protected virtual bool ItemsMatch(CompletionItem item, CompletionItem existingItem) { return(item.Span == existingItem.Span && item.SortText == existingItem.SortText); }
public override Task <CompletionDescription> GetDescriptionAsync(Document document, CompletionItem item, CancellationToken cancellationToken = default(CancellationToken)) { var provider = GetProvider(item); if (provider != null) { return(provider.GetDescriptionAsync(document, item, cancellationToken)); } else { return(Task.FromResult(CompletionDescription.Empty)); } }
protected virtual bool IsFilterCharacterCore(CompletionItem completionItem, char ch, string textTypedSoFar) { return(false); }
protected virtual bool SendEnterThroughToEditorCore(CompletionItem completionItem, string textTypedSoFar, OptionSet options) { return(false); }
protected virtual TextChange GetTextChangeCore(CompletionItem selectedItem, char?ch = null, string textTypedSoFar = null) { return(new TextChange(selectedItem.FilterSpan, selectedItem.DisplayText)); }
protected virtual bool IsCommitCharacterCore(CompletionItem completionItem, char ch, string textTypedSoFar) { return(s_defaultCommitCharacters.Contains(ch)); }
/// <summary> /// Returns true if item1 and item2 are similar enough that only one should be shown in the completion list; otherwise, false. /// </summary> public virtual bool ItemsMatch(CompletionItem item1, CompletionItem item2) { return(item1.FilterSpan == item2.FilterSpan && item1.SortText == item2.SortText); }
/// <summary> /// Called by completion engine when a completion item is committed. Completion rules can /// use this information to affect future calls to MatchesFilterText or IsBetterFilterMatch. /// </summary> public virtual void CompletionItemCommitted(CompletionItem item) { _completionService.CompletionItemCommitted(item); }
/// <summary> /// Returns true if the completion item should be "soft" selected, or false if it should be "hard" /// selected. /// </summary> public virtual bool ShouldSoftSelectItem(CompletionItem item, string filterText, CompletionTriggerInfo triggerInfo) { return(filterText.Length == 0 && !item.Preselect); }
/// <summary> /// Creates a copy of this <see cref="CompletionList"/> with the <see cref="SuggestionModeItem"/> property changed. /// </summary> public CompletionList WithSuggestionModeItem(CompletionItem suggestionModeItem) { return(With(suggestionModeItem: suggestionModeItem)); }
public override async Task <CompletionChange> GetChangeAsync(Document document, CompletionItem item, char?commitKey = null, CancellationToken cancellationToken = default(CancellationToken)) { var change = (await GetTextChangeAsync(document, item, commitKey, cancellationToken).ConfigureAwait(false)) ?? new TextChange(item.Span, item.DisplayText); return(CompletionChange.Create(change)); }
public static bool HasDescription(CompletionItem item) => item.Properties.ContainsKey(DescriptionProperty);
public virtual Task <TextChange?> GetTextChangeAsync(Document document, CompletionItem selectedItem, char?ch, CancellationToken cancellationToken) { return(GetTextChangeAsync(selectedItem, ch, cancellationToken)); }
/// <summary> /// Determines which of two items should represent the matching pair. /// </summary> protected virtual CompletionItem GetBetterItem(CompletionItem item, CompletionItem existingItem) { // the item later in the sort order (determined by provider order) wins? return(item); }
protected virtual Task <TextChange?> GetTextChangeAsync(CompletionItem selectedItem, char?ch, CancellationToken cancellationToken) { return(Task.FromResult <TextChange?>(null)); }
internal void OnCompletionItemCommitted(RoslynCompletion.CompletionItem completionItem) { AssertIsForeground(); this.ItemCommitted?.Invoke(this, new CompletionItemEventArgs(completionItem)); }
protected static bool IsKeywordItem(CompletionItem item) { return(item.Tags.Contains(CompletionTags.Keyword)); }
internal static string GetProviderName(this CompletionItem item) => (string)_getProviderName.GetValue(item);
protected static bool IsSnippetItem(CompletionItem item) { return(item.Tags.Contains(CompletionTags.Snippet)); }
public (ImmutableArray <CompletionFilter> filters, int data) GetFiltersAndAddToSet(RoslynCompletionItem item) { var listBuilder = new ArrayBuilder <CompletionFilter>(); var vectorForSingleItem = new BitVector32(); if (item.Flags.IsExpanded()) { listBuilder.Add(Expander); vectorForSingleItem[s_expanderMask] = _vector[s_expanderMask] = true; } foreach (var tag in item.Tags) { if (s_filterMap.TryGetValue(tag, out var filterWithMask)) { listBuilder.Add(filterWithMask.Filter); vectorForSingleItem[filterWithMask.Mask] = _vector[filterWithMask.Mask] = true; } } return(listBuilder.ToImmutableAndFree(), vectorForSingleItem.Data); }
/// <summary> /// Gets the description of the item. /// </summary> /// <param name="document">This will be the original document that /// <paramref name="item"/> was created against.</param> /// <param name="item">The item to get the description for.</param> /// <param name="options">Completion options</param> /// <param name="displayOptions">Display options</param> /// <param name="cancellationToken"></param> internal virtual async Task <CompletionDescription?> GetDescriptionAsync(Document document, CompletionItem item, CompletionOptions options, SymbolDescriptionOptions displayOptions, CancellationToken cancellationToken = default) { var provider = GetProvider(item, document.Project); if (provider is null) { return(CompletionDescription.Empty); } // We don't need SemanticModel here, just want to make sure it won't get GC'd before CompletionProviders are able to get it. (document, var semanticModel) = await GetDocumentWithFrozenPartialSemanticsAsync(document, cancellationToken).ConfigureAwait(false); var description = await provider.GetDescriptionAsync(document, item, options, displayOptions, cancellationToken).ConfigureAwait(false); GC.KeepAlive(semanticModel); return(description); }