本文整理汇总了C#中Microsoft.CodeAnalysis.Completion.CompletionTriggerInfo.WithIsAugment方法的典型用法代码示例。如果您正苦于以下问题:C# CompletionTriggerInfo.WithIsAugment方法的具体用法?C# CompletionTriggerInfo.WithIsAugment怎么用?C# CompletionTriggerInfo.WithIsAugment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.CodeAnalysis.Completion.CompletionTriggerInfo
的用法示例。
在下文中一共展示了CompletionTriggerInfo.WithIsAugment方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetGroupsAsync
private async Task<IEnumerable<CompletionItemGroup>> GetGroupsAsync(
Document documentOpt,
SourceText text,
int position,
CompletionTriggerInfo triggerInfo,
IEnumerable<ICompletionProvider> completionProviders,
OptionSet options,
CancellationToken cancellationToken)
{
completionProviders = completionProviders ?? this.GetDefaultCompletionProviders();
var completionProviderToIndex = GetCompletionProviderToIndex(completionProviders);
IEnumerable<ICompletionProvider> triggeredProviders;
switch (triggerInfo.TriggerReason)
{
case CompletionTriggerReason.TypeCharCommand:
triggeredProviders = completionProviders.Where(p => p.IsTriggerCharacter(text, position - 1, options)).ToList();
break;
case CompletionTriggerReason.BackspaceOrDeleteCommand:
triggeredProviders = this.TriggerOnBackspace(text, position, triggerInfo, options)
? completionProviders
: SpecializedCollections.EmptyEnumerable<ICompletionProvider>();
break;
default:
triggeredProviders = completionProviders;
break;
}
// Now, ask all the triggered providers if they can provide a group.
var providersAndGroups = new List<ProviderGroup>();
foreach (var p in triggeredProviders)
{
var g = await GetGroupAsync(p, documentOpt, text, position, triggerInfo, cancellationToken).ConfigureAwait(false);
if (g != null)
{
providersAndGroups.Add(new ProviderGroup { Provider = p, Group = g });
}
}
// See if there was a group provided that was exclusive and had items in it. If so, then
// that's all we'll return.
var firstExclusiveGroup = providersAndGroups.FirstOrDefault(
t => t.Group.IsExclusive && t.Group.Items.Any());
if (firstExclusiveGroup != null)
{
return SpecializedCollections.SingletonEnumerable(firstExclusiveGroup.Group);
}
else
{
// If no exclusive providers provided anything, then go through the remaining
// triggered list and see if any provide items.
var nonExclusiveGroups = providersAndGroups.Where(t => !t.Group.IsExclusive).ToList();
// If we still don't have any items, then we're definitely done.
if (!nonExclusiveGroups.Any(g => g.Group.Items.Any()))
{
return null;
}
// If we do have items, then ask all the other (non exclusive providers) if they
// want to augment the items.
var augmentTriggerInfo = triggerInfo.WithIsAugment(true);
var usedProviders = nonExclusiveGroups.Select(g => g.Provider);
var nonUsedProviders = completionProviders.Except(usedProviders);
var nonUsedNonExclusiveProviders = new List<ProviderGroup>();
foreach (var p in nonUsedProviders)
{
var g = await GetGroupAsync(p, documentOpt, text, position, augmentTriggerInfo, cancellationToken).ConfigureAwait(false);
if (g != null && !g.IsExclusive)
{
nonUsedNonExclusiveProviders.Add(new ProviderGroup { Provider = p, Group = g });
}
}
var allGroups = nonExclusiveGroups.Concat(nonUsedNonExclusiveProviders).ToList();
if (allGroups.Count == 0)
{
return null;
}
// Providers are ordered, but we processed them in our own order. Ensure that the
// groups are properly ordered based on the original providers.
allGroups.Sort((p1, p2) => completionProviderToIndex[p1.Provider] - completionProviderToIndex[p2.Provider]);
return allGroups.Select(g => g.Group);
}
}