/// <summary>
        /// Creates a new <see cref="CompletionItemRules"/> instance--internal for TypeScript.
        /// </summary>
        /// <param name="filterCharacterRules">Rules about which keys typed are used to filter the list of completion items.</param>
        /// <param name="commitCharacterRules">Rules about which keys typed caused the completion item to be committed.</param>
        /// <param name="enterKeyRule">Rule about whether the enter key is passed through to the editor after the selected item has been committed.</param>
        /// <param name="formatOnCommit">True if the modified text should be formatted automatically.</param>
        /// <param name="preselect">True if the related completion item should be initially selected.</param>
        /// <returns></returns>
        internal static CompletionItemRules Create(
            ImmutableArray <CharacterSetModificationRule> filterCharacterRules,
            ImmutableArray <CharacterSetModificationRule> commitCharacterRules,
            EnterKeyRule enterKeyRule,
            bool formatOnCommit,
            bool preselect)
        {
            var matchPriority = preselect ? Completion.MatchPriority.Preselect : Completion.MatchPriority.Default;

            return(CompletionItemRules.Create(filterCharacterRules, commitCharacterRules, enterKeyRule, formatOnCommit, matchPriority));
        }
Beispiel #2
0
 private CompletionItem(
     string displayText,
     string filterText,
     string sortText,
     TextSpan span,
     ImmutableDictionary <string, string> properties,
     Glyph glyph,
     ImmutableArray <string> tags)
 {
     this.DisplayText = displayText ?? "";
     this.FilterText  = filterText ?? this.DisplayText;
     this.SortText    = sortText ?? this.DisplayText;
     this.Span        = span;
     this.Properties  = properties ?? ImmutableDictionary <string, string> .Empty;
     Glyph            = glyph;
     this.Tags        = tags.NullToEmpty();
     this.Rules       = CompletionItemRules.Default;
 }
#pragma warning disable RS0027 // Public API with optional parameter(s) should have the most parameters amongst its public overloads.
        internal static CompletionItem Create(
#pragma warning restore RS0027 // Public API with optional parameter(s) should have the most parameters amongst its public overloads.
            string displayText,
            string filterText = null,
            string sortText   = null,
            ImmutableDictionary <string, string> properties = null,
            Glyph glyph = Glyph.None,
            ImmutableArray <string> tags = default(ImmutableArray <string>),
            CompletionItemRules rules    = null)
        {
            return(new CompletionItem(
                       span: default(TextSpan),
                       displayText: displayText,
                       filterText: filterText,
                       sortText: sortText,
                       properties: properties,
                       glyph: glyph,
                       tags: tags,
                       rules: rules));
        }
        public static CompletionItem Create(
            string displayText,
            CompletionItemRules rules,
            Glyph?glyph = null,
            ImmutableArray <SymbolMarkupToken> description = default(ImmutableArray <SymbolMarkupToken>),
            string sortText       = null,
            string filterText     = null,
            bool showsWarningIcon = false,
            ImmutableDictionary <string, string> properties = null,
            ImmutableArray <string> tags = default(ImmutableArray <string>))
        {
            tags = tags.NullToEmpty();

            //if (glyph != null)
            //{
            //    // put glyph tags first
            //    tags = GlyphTags.GetTags(glyph.Value).AddRange(tags);
            //}

            if (showsWarningIcon)
            {
                tags = tags.Add(CompletionTags.Warning);
            }

            properties = properties ?? ImmutableDictionary <string, string> .Empty;
            if (!description.IsDefault && description.Length > 0)
            {
                properties = properties.Add("Description", EncodeDescription(description));
            }

            return(CompletionItem.Create(
                       displayText: displayText,
                       filterText: filterText,
                       sortText: sortText,
                       properties: properties,
                       glyph: glyph ?? Glyph.None,
                       tags: tags,
                       rules: rules));
        }
 /// <summary>
 /// Creates a copy of this <see cref="CompletionItem"/> with the <see cref="Rules"/> property changed.
 /// </summary>
 public CompletionItem WithRules(CompletionItemRules rules)
 {
     return(With(rules: rules));
 }