Пример #1
0
        private CompletionItem(
            string displayText,
            string filterText,
            string sortText,
            TextSpan span,
            ImmutableDictionary <string, string> properties,
            ImmutableArray <string> tags,
            CompletionItemRules rules,
            string displayTextPrefix,
            string displayTextSuffix,
            string inlineDescription)
        {
            DisplayText       = displayText ?? "";
            DisplayTextPrefix = displayTextPrefix ?? "";
            DisplayTextSuffix = displayTextSuffix ?? "";
            SortText          = sortText ?? DisplayText;
            InlineDescription = inlineDescription ?? "";
            Span       = span;
            Properties = properties ?? ImmutableDictionary <string, string> .Empty;
            Tags       = tags.NullToEmpty();
            Rules      = rules ?? CompletionItemRules.Default;

            if (!DisplayText.Equals(filterText, StringComparison.Ordinal))
            {
                _filterText = filterText;
            }
        }
Пример #2
0
 public static CompletionItem Create(
     string displayText,
     string filterText,
     string sortText,
     ImmutableDictionary <string, string> properties,
     ImmutableArray <string> tags,
     CompletionItemRules rules,
     string displayTextPrefix,
     string displayTextSuffix,
     string inlineDescription
     )
 {
     return(Create(
                displayText,
                filterText,
                sortText,
                properties,
                tags,
                rules,
                displayTextPrefix,
                displayTextSuffix,
                inlineDescription,
                isComplexTextEdit: false
                ));
 }
 public XmlDocCommentCompletionItem(CompletionListProvider provider,
     TextSpan filterSpan,
     string displayText,
     CompletionItemRules rules)
     : this(provider, filterSpan, displayText, displayText, string.Empty, rules)
 {
 }
        public FileSystemCompletionHelper(
            CompletionListProvider completionProvider,
            TextSpan textChangeSpan,
            ICurrentWorkingDirectoryDiscoveryService fileSystemDiscoveryService,
            Glyph folderGlyph,
            Glyph fileGlyph,
            ImmutableArray<string> searchPaths,
            IEnumerable<string> allowableExtensions,
            Func<string, bool> exclude = null,
            CompletionItemRules itemRules = null)
        {
            Debug.Assert(searchPaths.All(path => PathUtilities.IsAbsolute(path)));

            _completionProvider = completionProvider;
            _textChangeSpan = textChangeSpan;
            _searchPaths = searchPaths;
            _allowableExtensions = allowableExtensions.Select(e => e.ToLowerInvariant()).ToSet();
            _fileSystemDiscoveryService = fileSystemDiscoveryService;
            _folderGlyph = folderGlyph;
            _fileGlyph = fileGlyph;
            _exclude = exclude;
            _itemRules = itemRules;

            _lazyGetDrives = new Lazy<string[]>(() =>
                IOUtilities.PerformIO(Directory.GetLogicalDrives, SpecializedCollections.EmptyArray<string>()));
        }
Пример #5
0
        private CompletionItem(
            CompletionListProvider completionProvider,
            string displayText,
            TextSpan filterSpan,
            Func <CancellationToken, Task <ImmutableArray <SymbolDisplayPart> > > descriptionFactory,
            Glyph?glyph,
            bool hasAsyncDescription,
            string sortText,
            string filterText,
            bool preselect,
            bool isBuilder,
            bool showsWarningIcon,
            bool shouldFormatOnCommit,
            CompletionItemRules rules)
        {
            this.CompletionProvider = completionProvider;
            this.DisplayText        = displayText;
            this.Glyph                = glyph;
            this.SortText             = sortText ?? displayText;
            this.FilterText           = filterText ?? displayText;
            this.Preselect            = preselect;
            this.FilterSpan           = filterSpan;
            this.IsBuilder            = isBuilder;
            this.ShowsWarningIcon     = showsWarningIcon;
            this.ShouldFormatOnCommit = shouldFormatOnCommit;
            this.HasAsyncDescription  = hasAsyncDescription;
            this.Rules                = rules ?? CompletionItemRules.DefaultRules;

            if (descriptionFactory != null)
            {
                this.LazyDescription = new AsyncLazy <ImmutableArray <SymbolDisplayPart> >(descriptionFactory, cacheResult: true);
            }
        }
 public GlobalAssemblyCacheCompletionHelper(
     CompletionProvider completionProvider, 
     TextSpan textChangeSpan, 
     CompletionItemRules itemRules = null)
 {
     _completionProvider = completionProvider;
     _textChangeSpan = textChangeSpan;
     _itemRules = itemRules;
 }
Пример #7
0
 public static CompletionItem Create(
     string displayText,
     string filterText,
     string sortText,
     ImmutableDictionary <string, string> properties,
     ImmutableArray <string> tags,
     CompletionItemRules rules)
 {
     return(Create(displayText, filterText, sortText, properties, tags, rules, displayTextPrefix: null, displayTextSuffix: null));
 }
Пример #8
0
        /// <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));
        }
 public XmlDocCommentCompletionItem(CompletionListProvider provider,
     TextSpan filterSpan,
     string displayText,
     string beforeCaretText,
     string afterCaretText,
     CompletionItemRules rules)
     : base(provider, displayText, filterSpan, glyph: CodeAnalysis.Glyph.Keyword, rules: rules)
 {
     _beforeCaretText = beforeCaretText;
     _afterCaretText = afterCaretText;
 }
Пример #10
0
#pragma warning disable RS0027 // Public API with optional parameter(s) should have the most parameters amongst its public overloads.
        public 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,
            ImmutableArray <string> tags = default,
            CompletionItemRules rules    = null)
        {
            return(new CompletionItem(
                       span: default,
Пример #11
0
 public static CompletionItem Create(
     string displayText,
     string filterText = null,
     string sortText   = null,
     ImmutableDictionary <string, string> properties = null,
     ImmutableArray <string> tags = default,
     CompletionItemRules rules    = null,
     string displayTextPrefix     = null,
     string displayTextSuffix     = null)
 {
     return(new CompletionItem(
                span: default,
Пример #12
0
        public static CompletionItem Create(
            string displayText,
            TextSpan span,
            Glyph?glyph = null,
            ImmutableArray <SymbolDisplayPart> description = default(ImmutableArray <SymbolDisplayPart>),
            string sortText           = null,
            string filterText         = null,
            bool preselect            = false,
            bool showsWarningIcon     = false,
            bool shouldFormatOnCommit = false,
            bool isArgumentName       = false,
            ImmutableDictionary <string, string> properties = null,
            ImmutableArray <string> tags = default(ImmutableArray <string>),
            CompletionItemRules rules    = null)
        {
            tags = tags.IsDefault ? ImmutableArray <string> .Empty : tags;

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

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

            if (isArgumentName)
            {
                tags = tags.Add(CompletionTags.ArgumentName);
            }

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

            rules = rules ?? CompletionItemRules.Default;
            rules = rules.WithPreselect(preselect)
                    .WithFormatOnCommit(shouldFormatOnCommit);

            return(CompletionItem.Create(
                       displayText: displayText,
                       filterText: filterText,
                       sortText: sortText,
                       span: span,
                       properties: properties,
                       tags: tags,
                       rules: rules));
        }
Пример #13
0
        public static CompletionItem Create(
            string displayText,
            TextSpan span,
            Glyph? glyph = null,
            ImmutableArray<SymbolDisplayPart> description = default(ImmutableArray<SymbolDisplayPart>),
            string sortText = null,
            string filterText = null,
            bool preselect = false,
            bool showsWarningIcon = false,
            bool shouldFormatOnCommit = false,
            bool isArgumentName = false,
            ImmutableDictionary<string, string> properties = null,
            ImmutableArray<string> tags = default(ImmutableArray<string>),
            CompletionItemRules rules = null)
        {
            tags = tags.IsDefault ? ImmutableArray<string>.Empty : tags;

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

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

            if (isArgumentName)
            {
                tags = tags.Add(CompletionTags.ArgumentName);
            }

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

            rules = rules ?? CompletionItemRules.Default;
            rules = rules.WithPreselect(preselect)
                         .WithFormatOnCommit(shouldFormatOnCommit);

            return CompletionItem.Create(
                displayText: displayText,
                filterText: filterText,
                sortText: sortText,
                span: span,
                properties: properties,
                tags: tags,
                rules: rules);
        }
Пример #14
0
 public static CompletionItem Create(
     string displayText,
     CompletionItemRules rules,
     Glyph?glyph = null,
     ImmutableArray <SymbolDisplayPart> description = default,
     string sortText       = null,
     string filterText     = null,
     bool showsWarningIcon = false,
     ImmutableDictionary <string, string> properties = null,
     ImmutableArray <string> tags = default)
 {
     return(Create(
                displayText, displayTextSuffix: string.Empty, rules,
                glyph, description, sortText, filterText, showsWarningIcon, properties, tags, inlineDescription: null));
 }
Пример #15
0
        public static CompletionItem Create(
            string displayText,
            string displayTextSuffix,
            CompletionItemRules rules,
            Glyph?glyph = null,
            ImmutableArray <SymbolDisplayPart> description = default,
            string sortText       = null,
            string filterText     = null,
            bool showsWarningIcon = false,
            ImmutableDictionary <string, string> properties = null,
            ImmutableArray <string> tags = default,
            string inlineDescription     = null,
            string displayTextPrefix     = null,
            bool isComplexTextEdit       = false
            )
        {
            tags = tags.NullToEmpty();

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

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

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

            return(CompletionItem.Create(
                       displayText: displayText,
                       displayTextSuffix: displayTextSuffix,
                       displayTextPrefix: displayTextPrefix,
                       filterText: filterText,
                       sortText: sortText,
                       properties: properties,
                       tags: tags,
                       rules: rules,
                       inlineDescription: inlineDescription,
                       isComplexTextEdit: isComplexTextEdit
                       ));
        }
Пример #16
0
 public CompletionItem(
     CompletionListProvider completionProvider,
     string displayText,
     TextSpan filterSpan,
     Func <CancellationToken, Task <ImmutableArray <SymbolDisplayPart> > > descriptionFactory,
     Glyph?glyph,
     string sortText           = null,
     string filterText         = null,
     bool preselect            = false,
     bool isBuilder            = false,
     bool showsWarningIcon     = false,
     bool shouldFormatOnCommit = false,
     CompletionItemRules rules = null) :
     this(completionProvider, displayText, filterSpan, descriptionFactory, glyph, /*hasAsyncDescription*/ true, sortText,
          filterText, preselect, isBuilder, showsWarningIcon, shouldFormatOnCommit, rules)
 {
 }
Пример #17
0
 private CompletionItem(
     string displayText,
     string filterText,
     string sortText,
     TextSpan span,
     ImmutableDictionary <string, string> properties,
     ImmutableArray <string> tags,
     CompletionItemRules rules)
 {
     this.DisplayText = displayText ?? "";
     this.FilterText  = filterText ?? this.DisplayText;
     this.SortText    = sortText ?? this.DisplayText;
     this.Span        = span;
     this.Properties  = properties ?? ImmutableDictionary <string, string> .Empty;
     this.Tags        = tags.NullToEmpty();
     this.Rules       = rules ?? CompletionItemRules.Default;
 }
Пример #18
0
 public CompletionItem(
     CompletionListProvider completionProvider,
     string displayText,
     TextSpan filterSpan,
     ImmutableArray <SymbolDisplayPart> description = default(ImmutableArray <SymbolDisplayPart>),
     Glyph?glyph               = null,
     string sortText           = null,
     string filterText         = null,
     bool preselect            = false,
     bool isBuilder            = false,
     bool showsWarningIcon     = false,
     bool shouldFormatOnCommit = false,
     CompletionItemRules rules = null)
     : this(completionProvider, displayText, filterSpan,
            description.IsDefault ? (Func <CancellationToken, Task <ImmutableArray <SymbolDisplayPart> > >)null : c => Task.FromResult(description),
            glyph, /*hasAsyncDescription*/ false, sortText, filterText, preselect, isBuilder, showsWarningIcon, shouldFormatOnCommit, rules)
 {
 }
Пример #19
0
 public static CompletionItem Create(
     string displayText,
     string filterText,
     string sortText,
     TextSpan span,
     ImmutableDictionary <string, string> properties,
     ImmutableArray <string> tags,
     CompletionItemRules rules)
 {
     return(new CompletionItem(
                span: span,
                displayText: displayText,
                filterText: filterText,
                sortText: sortText,
                properties: properties,
                tags: tags,
                rules: rules));
 }
        public FileSystemCompletionHelper(
            Glyph folderGlyph,
            Glyph fileGlyph,
            ImmutableArray <string> searchPaths,
            string baseDirectoryOpt,
            ImmutableArray <string> allowableExtensions,
            CompletionItemRules itemRules)
        {
            Debug.Assert(searchPaths.All(path => PathUtilities.IsAbsolute(path)));
            Debug.Assert(baseDirectoryOpt == null || PathUtilities.IsAbsolute(baseDirectoryOpt));

            _searchPaths         = searchPaths;
            _baseDirectoryOpt    = baseDirectoryOpt;
            _allowableExtensions = allowableExtensions;
            _folderGlyph         = folderGlyph;
            _fileGlyph           = fileGlyph;
            _itemRules           = itemRules;
        }
Пример #21
0
 // Constructor kept for back compat.  When we move to our new completion API we can remove this.
 public CompletionItem(
     CompletionListProvider completionProvider,
     string displayText,
     TextSpan filterSpan,
     Func <CancellationToken, Task <ImmutableArray <SymbolDisplayPart> > > descriptionFactory,
     Glyph?glyph,
     string sortText,
     string filterText,
     bool preselect,
     bool isBuilder,
     bool showsWarningIcon,
     bool shouldFormatOnCommit,
     CompletionItemRules rules)
     : this(completionProvider, displayText, filterSpan, descriptionFactory, glyph, sortText,
            filterText, preselect, isBuilder, showsWarningIcon, shouldFormatOnCommit, rules,
            ImmutableArray <CompletionItemFilter> .Empty)
 {
 }
Пример #22
0
        public static CompletionItem Create(
            string displayText,
            Glyph? glyph = null,
            ImmutableArray<SymbolDisplayPart> description = default(ImmutableArray<SymbolDisplayPart>),
            string sortText = null,
            string filterText = null,
            int? matchPriority = null,
            bool showsWarningIcon = false,
            bool shouldFormatOnCommit = false,
            ImmutableDictionary<string, string> properties = null,
            ImmutableArray<string> tags = default(ImmutableArray<string>),
            CompletionItemRules rules = null)
        {
            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));
            }

            rules = rules ?? CompletionItemRules.Default;
            rules = rules.WithMatchPriority(matchPriority.GetValueOrDefault())
                         .WithFormatOnCommit(shouldFormatOnCommit);

            return CompletionItem.Create(
                displayText: displayText,
                filterText: filterText,
                sortText: sortText,
                properties: properties,
                tags: tags,
                rules: rules);
        }
Пример #23
0
        public static CompletionItem Create(
            string displayText,
            Glyph?glyph = null,
            ImmutableArray <SymbolDisplayPart> description = default(ImmutableArray <SymbolDisplayPart>),
            string sortText           = null,
            string filterText         = null,
            int?matchPriority         = null,
            bool showsWarningIcon     = false,
            bool shouldFormatOnCommit = false,
            ImmutableDictionary <string, string> properties = null,
            ImmutableArray <string> tags = default(ImmutableArray <string>),
            CompletionItemRules rules    = null)
        {
            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));
            }

            rules = rules ?? CompletionItemRules.Default;
            rules = rules.WithMatchPriority(matchPriority.GetValueOrDefault())
                    .WithFormatOnCommit(shouldFormatOnCommit);

            return(CompletionItem.Create(
                       displayText: displayText,
                       filterText: filterText,
                       sortText: sortText,
                       properties: properties,
                       tags: tags,
                       rules: rules));
        }
Пример #24
0
 /// <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));
 }
Пример #25
0
 public GlobalAssemblyCacheCompletionHelper(CompletionListProvider completionProvider, TextSpan textChangeSpan, Microsoft.CodeAnalysis.Completion.CompletionItemRules itemRules = null)
 {
     _completionProvider = completionProvider;
     _textChangeSpan     = textChangeSpan;
     _itemRules          = itemRules;
 }