当前位置: 首页>>代码示例>>C#>>正文


C# CompletionItem类代码示例

本文整理汇总了C#中CompletionItem的典型用法代码示例。如果您正苦于以下问题:C# CompletionItem类的具体用法?C# CompletionItem怎么用?C# CompletionItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


CompletionItem类属于命名空间,在下文中一共展示了CompletionItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AvalonEditCompletionData

 public AvalonEditCompletionData(CompletionItem item)
 {
     _item = item;
     Text = item.DisplayText;
     Content = item.DisplayText;
     // Image = item.Glyph;
 }
开发者ID:Serg2DFX,项目名称:roslynpad,代码行数:7,代码来源:AvalonEditCompletionData.cs

示例2: Model

        private Model(
            DisconnectedBufferGraph disconnectedBufferGraph,
            IList<CompletionItem> totalItems,
            IList<CompletionItem> filteredItems,
            CompletionItem selectedItem,
            bool isHardSelection,
            bool isUnique,
            bool useSuggestionCompletionMode,
            CompletionItem builder,
            CompletionItem defaultBuilder,
            CompletionTriggerInfo triggerInfo,
            ITrackingPoint commitSpanEndPoint,
            bool dismissIfEmpty)
        {
            Contract.ThrowIfNull(selectedItem);
            Contract.ThrowIfFalse(totalItems.Count != 0, "Must have at least one item.");
            Contract.ThrowIfFalse(filteredItems.Count != 0, "Must have at least one filtered item.");
            Contract.ThrowIfFalse(filteredItems.Contains(selectedItem) || defaultBuilder == selectedItem, "Selected item must be in filtered items.");

            _disconnectedBufferGraph = disconnectedBufferGraph;
            this.TotalItems = totalItems;
            this.FilteredItems = filteredItems;
            this.SelectedItem = selectedItem;
            this.IsHardSelection = isHardSelection;
            this.IsUnique = isUnique;
            this.UseSuggestionCompletionMode = useSuggestionCompletionMode;
            this.Builder = builder;
            this.DefaultBuilder = defaultBuilder;
            this.TriggerInfo = triggerInfo;
            this.CommitTrackingSpanEndPoint = commitSpanEndPoint;
            this.DismissIfEmpty = dismissIfEmpty;
        }
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:32,代码来源:Model.cs

示例3: Model

        private Model(
            DisconnectedBufferGraph disconnectedBufferGraph,
            IList<CompletionItem> totalItems,
            IList<CompletionItem> filteredItems,
            CompletionItem selectedItem,
            ImmutableArray<CompletionItemFilter> completionItemFilters,
            ImmutableDictionary<CompletionItemFilter, bool> filterState,
            IReadOnlyDictionary<CompletionItem, string> completionItemToFilterText,
            bool isHardSelection,
            bool isUnique,
            bool useSuggestionCompletionMode,
            CompletionItem builder,
            CompletionItem defaultBuilder,
            CompletionTriggerInfo triggerInfo,
            ITrackingPoint commitSpanEndPoint,
            bool dismissIfEmpty)
        {
            Contract.ThrowIfFalse(totalItems.Count != 0, "Must have at least one item.");

            _disconnectedBufferGraph = disconnectedBufferGraph;
            this.TotalItems = totalItems;
            this.FilteredItems = filteredItems;
            this.FilterState = filterState;
            this.SelectedItem = selectedItem;
            this.CompletionItemFilters = completionItemFilters;
            this.CompletionItemToFilterText = completionItemToFilterText;
            this.IsHardSelection = isHardSelection;
            this.IsUnique = isUnique;
            this.UseSuggestionCompletionMode = useSuggestionCompletionMode;
            this.Builder = builder;
            this.DefaultBuilder = defaultBuilder;
            this.TriggerInfo = triggerInfo;
            this.CommitTrackingSpanEndPoint = commitSpanEndPoint;
            this.DismissIfEmpty = dismissIfEmpty;
        }
开发者ID:Eyas,项目名称:roslyn,代码行数:35,代码来源:Model.cs

示例4: GetChangeAsync

        public override async Task<CompletionChange> GetChangeAsync(Document document, CompletionItem item, char? commitKey = default(char?), CancellationToken cancellationToken = default(CancellationToken))
        {
            var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
            var newDocument = await DetermineNewDocumentAsync(item, text, cancellationToken).ConfigureAwait(false);

            var newText = await newDocument.GetTextAsync(cancellationToken).ConfigureAwait(false);
            var newRoot = await newDocument.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);

            int? newPosition = null;

            // Attempt to find the inserted node and move the caret appropriately
            if (newRoot != null)
            {
                var caretTarget = newRoot.GetAnnotatedNodesAndTokens(_annotation).FirstOrNullable();
                if (caretTarget != null)
                {
                    var targetPosition = GetTargetCaretPosition(caretTarget.Value.AsNode());

                    // Something weird happened and we failed to get a valid position.
                    // Bail on moving the caret.
                    if (targetPosition > 0 && targetPosition <= newText.Length)
                    {
                        newPosition = targetPosition;
                    }
                }
            }

            var changes = await newDocument.GetTextChangesAsync(document, cancellationToken).ConfigureAwait(false);
            return CompletionChange.Create(ImmutableArray.CreateRange(changes), newPosition, includesCommitCharacter: true);
        }
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:30,代码来源:AbstractMemberInsertingCompletionProvider.cs

示例5: GetTextChange

        public override TextChange GetTextChange(CompletionItem selectedItem, char? ch = null, string textTypedSoFar = null)
        {
            var displayText = selectedItem.DisplayText;

            if (ch != null)
            {
                // If user types a space, do not complete the " =" (space and equals) at the end of a named parameter. The
                // typed space character will be passed through to the editor, and they can then type the '='.
                if (ch == ' ' && displayText.EndsWith(SpaceEqualsString, StringComparison.Ordinal))
                {
                    return new TextChange(selectedItem.FilterSpan, displayText.Remove(displayText.Length - SpaceEqualsString.Length));
                }

                // If the user types '=', do not complete the '=' at the end of the named parameter because the typed '=' 
                // will be passed through to the editor.
                if (ch == '=' && displayText.EndsWith(EqualsString, StringComparison.Ordinal))
                {
                    return new TextChange(selectedItem.FilterSpan, displayText.Remove(displayText.Length - EqualsString.Length));
                }

                // If the user types ':', do not complete the ':' at the end of the named parameter because the typed ':' 
                // will be passed through to the editor.
                if (ch == ':' && displayText.EndsWith(ColonString, StringComparison.Ordinal))
                {
                    return new TextChange(selectedItem.FilterSpan, displayText.Remove(displayText.Length - ColonString.Length));
                }
            }

            return new TextChange(selectedItem.FilterSpan, displayText);
        }
开发者ID:GloryChou,项目名称:roslyn,代码行数:30,代码来源:AttributeNamedParameterCompletionProvider.cs

示例6: SetCompletionItems

        public void SetCompletionItems(
            IList<CompletionItem> completionItems,
            CompletionItem selectedItem,
            CompletionItem suggestionModeItem,
            bool suggestionMode,
            bool isSoftSelected,
            ImmutableArray<CompletionItemFilter> completionItemFilters,
            string filterText)
        {
            this.AssertIsForeground();

            // Initialize the completion map to a reasonable default initial size (+1 for the builder)
            CompletionItemMap = CompletionItemMap ?? new Dictionary<CompletionItem, VSCompletion>(completionItems.Count + 1);
            FilterText = filterText;
            SuggestionModeItem = suggestionModeItem;

            this.SetupFilters(completionItemFilters);

            CreateCompletionListBuilder(selectedItem, suggestionModeItem, suggestionMode);
            CreateNormalCompletionListItems(completionItems);

            var selectedCompletionItem = GetVSCompletion(selectedItem);
            VsCompletionSet.SelectionStatus = new CompletionSelectionStatus(
                selectedCompletionItem, 
                isSelected: !isSoftSelected, isUnique: selectedCompletionItem != null);
        }
开发者ID:jkotas,项目名称:roslyn,代码行数:26,代码来源:Roslyn14CompletionSet.cs

示例7: CompletionList

 private CompletionList(TextSpan defaultSpan, ImmutableArray<CompletionItem> items, CompletionRules rules, CompletionItem suggestionModeItem)
 {
     this.DefaultSpan = defaultSpan;
     this.Items = items.IsDefault ? ImmutableArray<CompletionItem>.Empty : items;
     this.Rules = rules ?? CompletionRules.Default;
     this.SuggestionModeItem = suggestionModeItem;
 }
开发者ID:swaroop-sridhar,项目名称:roslyn,代码行数:7,代码来源:CompletionList.cs

示例8: IsCommitCharacter

 public override bool? IsCommitCharacter(CompletionItem completionItem, char ch, string textTypedSoFar)
 {
     // TODO(cyrusn): We could just allow the standard list of completion characters.
     // However, i'd like to see what the experience is like really filtering down to the set
     // of things that is allowable.
     return ch == ' ' || ch == '(' || ch == '{' || ch == '[';
 }
开发者ID:rjmurillo,项目名称:roslyn,代码行数:7,代码来源:ObjectCreationCompletionProvider.ItemRules.cs

示例9: GetDescriptionWorkerAsync

 protected virtual Task<CompletionDescription> GetDescriptionWorkerAsync(
     Document document, CompletionItem item, CancellationToken cancellationToken)
 {
     return CommonCompletionItem.HasDescription(item)
         ? Task.FromResult(CommonCompletionItem.GetDescription(item))
         : Task.FromResult(CompletionDescription.Empty);
 }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:7,代码来源:CommonCompletionProvider.cs

示例10: GetMatch

        private PatternMatch? GetMatch(
            CompletionItem item, string filterText,
            bool includeMatchSpans, CultureInfo culture)
        {
            // If the item has a dot in it (i.e. for something like enum completion), then attempt
            // to match what the user wrote against the last portion of the name.  That way if they
            // write "Bl" and we have "Blub" and "Color.Black", we'll consider hte latter to be a
            // better match as they'll both be prefix matches, and the latter will have a higher
            // priority.

            var lastDotIndex = item.FilterText.LastIndexOf('.');
            if (lastDotIndex >= 0)
            {
                var textAfterLastDot = item.FilterText.Substring(lastDotIndex + 1);
                var match = GetMatchWorker(textAfterLastDot, filterText, includeMatchSpans, culture);
                if (match != null)
                {
                    return match;
                }
            }

            // Didn't have a dot, or the user text didn't match the portion after the dot.
            // Just do a normal check against the entire completion item.
            return GetMatchWorker(item.FilterText, filterText, includeMatchSpans, culture);
        }
开发者ID:panopticoncentral,项目名称:roslyn,代码行数:25,代码来源:CompletionHelper.cs

示例11: TryAddSnippetInvocationPart

        private async Task<ImmutableArray<TaggedText>> TryAddSnippetInvocationPart(
            Document document, CompletionItem item, 
            ImmutableArray<TaggedText> parts, CancellationToken cancellationToken)
        {
            var languageServices = document.Project.LanguageServices;
            var snippetService = languageServices.GetService<ISnippetInfoService>();
            if (snippetService != null)
            {
                var change = await GetTextChangeAsync(document, item, ch: '\t', cancellationToken: cancellationToken).ConfigureAwait(false) ??
                    new TextChange(item.Span, item.DisplayText);
                var insertionText = change.NewText;

                if (snippetService != null && snippetService.SnippetShortcutExists_NonBlocking(insertionText))
                {
                    var note = string.Format(FeaturesResources.Note_colon_Tab_twice_to_insert_the_0_snippet, insertionText);

                    if (parts.Any())
                    {
                        parts = parts.Add(new TaggedText(TextTags.LineBreak, Environment.NewLine));
                    }

                    parts = parts.Add(new TaggedText(TextTags.Text, note));
                }
            }

            return parts;
        }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:27,代码来源:CommonCompletionProvider.cs

示例12: DetermineNewDocumentAsync

        private async Task<Document> DetermineNewDocumentAsync(CompletionItem completionItem, SourceText sourceText, CancellationToken cancellationToken)
        {
            // The span we're going to replace
            var line = sourceText.Lines[MemberInsertionCompletionItem.GetLine(completionItem)];
            //var line = textSnapshot.GetLineFromLineNumber(MemberInsertionCompletionItem.GetLine(completionItem));

            //var sourceText = textSnapshot.AsText();
            var document = sourceText.GetOpenDocumentInCurrentContextWithChanges();
            Contract.ThrowIfNull(document);

            // Annotate the line we care about so we can find it after adding usings
            var tree = await document.GetSyntaxTreeAsync(cancellationToken).ConfigureAwait(false);
            var token = GetToken(completionItem, tree, cancellationToken);
            var annotatedRoot = tree.GetRoot(cancellationToken).ReplaceToken(token, token.WithAdditionalAnnotations(_otherAnnotation));
            document = document.WithSyntaxRoot(annotatedRoot);

            var memberContainingDocument = await GenerateMemberAndUsingsAsync(document, completionItem, line, cancellationToken).ConfigureAwait(false);

            var insertionRoot = await PrepareTreeForMemberInsertionAsync(memberContainingDocument, cancellationToken).ConfigureAwait(false);
            var insertionText = await GenerateInsertionTextAsync(memberContainingDocument, cancellationToken).ConfigureAwait(false);

            var destinationSpan = ComputeDestinationSpan(insertionRoot, insertionText);

            var finalText = insertionRoot.GetText(sourceText.Encoding).Replace(destinationSpan, insertionText.Trim());

            document = document.WithText(finalText);
            var newRoot = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
            var declaration = GetSyntax(newRoot.FindToken(destinationSpan.End));

            document = document.WithSyntaxRoot(newRoot.ReplaceNode(declaration, declaration.WithAdditionalAnnotations(_annotation)));
            return Formatter.FormatAsync(document, _annotation, cancellationToken: cancellationToken).WaitAndGetResult(cancellationToken);
        }
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:32,代码来源:AbstractMemberInsertingCompletionProvider.cs

示例13: IsCaretOutsideItemBounds

        private bool IsCaretOutsideItemBounds(
            Model model,
            SnapshotPoint caretPoint,
            CompletionItem item,
            Dictionary<TextSpan, string> textSpanToText,
            Dictionary<TextSpan, ViewTextSpan> textSpanToViewSpan)
        {
            // Easy first check.  See if the caret point is before the start of the item.
            if (!textSpanToViewSpan.TryGetValue(item.Span, out var filterSpanInViewBuffer))
            {
                filterSpanInViewBuffer = model.GetViewBufferSpan(item.Span);
                textSpanToViewSpan[item.Span] = filterSpanInViewBuffer;
            }

            if (caretPoint < filterSpanInViewBuffer.TextSpan.Start)
            {
                return true;
            }

            var textSnapshot = caretPoint.Snapshot;

            var currentText = model.GetCurrentTextInSnapshot(item.Span, textSnapshot, textSpanToText);
            var currentTextSpan = new TextSpan(filterSpanInViewBuffer.TextSpan.Start, currentText.Length);

            return !currentTextSpan.IntersectsWith(caretPoint);
        }
开发者ID:GuilhermeSa,项目名称:roslyn,代码行数:26,代码来源:Controller_CaretPositionChanged.cs

示例14: Create

 /// <summary>
 /// Creates a new <see cref="CompletionList"/> instance.
 /// </summary>
 /// <param name="defaultSpan">The span of the syntax element at the caret position when the <see cref="CompletionList"/> was created.</param>
 /// <param name="items">The completion items to present to the user.</param>
 /// <param name="rules">The rules used to control behavior of the completion list shown to the user during typing.</param>
 /// <param name="suggestionModeItem">An optional <see cref="CompletionItem"/> that appears selected in the list presented to the user during suggestion mode.</param>
 /// <returns></returns>
 public static CompletionList Create(
     TextSpan defaultSpan,
     ImmutableArray<CompletionItem> items,
     CompletionRules rules = null,
     CompletionItem suggestionModeItem = null)
 {
     return new CompletionList(defaultSpan, FixItemSpans(items, defaultSpan), rules, suggestionModeItem);
 }
开发者ID:swaroop-sridhar,项目名称:roslyn,代码行数:16,代码来源:CompletionList.cs

示例15:

 void ICompletionSet.SetCompletionItems(
     IList<CompletionItem> completionItems, CompletionItem selectedItem, 
     CompletionItem suggestionModeItem, bool suggestionMode, bool isSoftSelected, ImmutableArray<CompletionItemFilter> completionItemFilters, string filterText)
 {
     _roslynCompletionSet.SetCompletionItems(
         completionItems, selectedItem, suggestionModeItem, suggestionMode,
         isSoftSelected, completionItemFilters, filterText);
 }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:8,代码来源:VisualStudio14CompletionSet.cs


注:本文中的CompletionItem类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。