本文整理汇总了C#中Microsoft.CodeAnalysis.Completion.CompletionTriggerInfo类的典型用法代码示例。如果您正苦于以下问题:C# CompletionTriggerInfo类的具体用法?C# CompletionTriggerInfo怎么用?C# CompletionTriggerInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CompletionTriggerInfo类属于Microsoft.CodeAnalysis.Completion命名空间,在下文中一共展示了CompletionTriggerInfo类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: GetItemsWorkerAsync
protected override async Task<IEnumerable<CompletionItem>> GetItemsWorkerAsync(Document document, int position, CompletionTriggerInfo triggerInfo, CancellationToken cancellationToken)
{
return await document.GetUnionResultsFromDocumentAndLinks(
UnionCompletionItemComparer.Instance,
async (doc, ct) => await GetSpeculativeTCompletions(doc, position, ct).ConfigureAwait(false),
cancellationToken).ConfigureAwait(false);
}
开发者ID:noahstein,项目名称:roslyn,代码行数:7,代码来源:SpeculativeTCompletionProvider.cs
示例2: 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
示例3: GetItemsWorkerAsync
protected override async Task<IEnumerable<CompletionItem>> GetItemsWorkerAsync(Document document, int position, CompletionTriggerInfo triggerInfo, CancellationToken cancellationToken)
{
var tree = await document.GetSyntaxTreeAsync(cancellationToken).ConfigureAwait(false);
if (tree.IsInNonUserCode(position, cancellationToken))
{
return null;
}
var targetToken = tree.FindTokenOnLeftOfPosition(position, cancellationToken).GetPreviousTokenIfTouchingWord(position);
if (targetToken.IsKind(SyntaxKind.AliasKeyword) && targetToken.Parent.IsKind(SyntaxKind.ExternAliasDirective))
{
var compilation = await document.GetCSharpCompilationAsync(cancellationToken).ConfigureAwait(false);
var aliases = compilation.ExternalReferences.SelectMany(r => r.Properties.Aliases).ToSet();
if (aliases.Any())
{
var root = await tree.GetRootAsync(cancellationToken).ConfigureAwait(false);
var usedAliases = root.ChildNodes().OfType<ExternAliasDirectiveSyntax>().Where(e => !e.Identifier.IsMissing).Select(e => e.Identifier.ValueText);
aliases.RemoveRange(usedAliases);
aliases.Remove(MetadataReferenceProperties.GlobalAlias);
var textChangeSpan = CompletionUtilities.GetTextChangeSpan(await document.GetTextAsync(cancellationToken).ConfigureAwait(false), position);
return aliases.Select(e =>
new CompletionItem(this, e, textChangeSpan, glyph: Glyph.Namespace));
}
}
return SpecializedCollections.EmptyEnumerable<CompletionItem>();
}
开发者ID:ehsansajjad465,项目名称:roslyn,代码行数:29,代码来源:ExternAliasCompletionProvider.cs
示例4: 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
示例5: GetCompletionListAsync
/// <summary>
/// Returns the <see cref="CompletionList"/> for the specified <paramref name="position"/>
/// in the <paramref name="document"/>.
/// </summary>
public static Task<CompletionList> GetCompletionListAsync(
Document document,
int position,
CompletionTriggerInfo triggerInfo,
OptionSet options = null,
IEnumerable<CompletionListProvider> providers = null,
CancellationToken cancellationToken = default(CancellationToken))
{
if (document == null)
{
throw new ArgumentNullException(nameof(document));
}
var completionService = document.GetLanguageService<ICompletionService>();
if (completionService != null)
{
options = options ?? document.Project.Solution.Workspace.Options;
providers = providers ?? GetDefaultCompletionListProviders(document);
return completionService.GetCompletionListAsync(document, position, triggerInfo, options, providers, cancellationToken);
}
else
{
if (s_emptyCompletionListTask == null)
{
var value = Task.FromResult(new CompletionList(ImmutableArray<CompletionItem>.Empty));
Interlocked.CompareExchange(ref s_emptyCompletionListTask, value, null);
}
return s_emptyCompletionListTask;
}
}
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:36,代码来源:CompletionService.cs
示例6: IsExclusiveAsync
protected override async Task<bool> IsExclusiveAsync(Document document, int caretPosition, CompletionTriggerInfo triggerInfo, CancellationToken cancellationToken)
{
var syntaxTree = await document.GetSyntaxTreeAsync(cancellationToken).ConfigureAwait(false);
var token = syntaxTree.FindTokenOnLeftOfPosition(caretPosition, cancellationToken)
.GetPreviousTokenIfTouchingWord(caretPosition);
return IsAfterNameColonArgument(token) || IsAfterNameEqualsArgument(token);
}
开发者ID:noahstein,项目名称:roslyn,代码行数:8,代码来源:AttributeNamedParameterCompletionProvider.cs
示例7: GetItemsWorkerAsync
protected override async Task<IEnumerable<CompletionItem>> GetItemsWorkerAsync(Document document, int position, CompletionTriggerInfo triggerInfo, System.Threading.CancellationToken cancellationToken)
{
var tree = await document.GetSyntaxTreeAsync(cancellationToken).ConfigureAwait(false);
if (!tree.IsEntirelyWithinCrefSyntax(position, cancellationToken))
{
return null;
}
var token = tree.FindTokenOnLeftOfPosition(position, cancellationToken);
token = token.GetPreviousTokenIfTouchingWord(position);
if (token.Kind() == SyntaxKind.None)
{
return null;
}
var result = SpecializedCollections.EmptyEnumerable<ISymbol>();
// To get a Speculative SemanticModel (which is much faster), we need to
// walk up to the node the DocumentationTrivia is attached to.
var parentNode = token.GetAncestor<DocumentationCommentTriviaSyntax>().ParentTrivia.Token.Parent;
var semanticModel = await document.GetSemanticModelForNodeAsync(parentNode, cancellationToken).ConfigureAwait(false);
// cref ""|, ""|"", ""a|""
if (token.IsKind(SyntaxKind.DoubleQuoteToken, SyntaxKind.SingleQuoteToken) && token.Parent.IsKind(SyntaxKind.XmlCrefAttribute))
{
result = semanticModel.LookupSymbols(token.SpanStart)
.FilterToVisibleAndBrowsableSymbols(document.ShouldHideAdvancedMembers(), semanticModel.Compilation);
result = result.Concat(GetOperatorsAndIndexers(token, semanticModel, cancellationToken));
}
else if (IsSignatureContext(token))
{
result = semanticModel.LookupNamespacesAndTypes(token.SpanStart)
.FilterToVisibleAndBrowsableSymbols(document.ShouldHideAdvancedMembers(), semanticModel.Compilation);
}
else if (token.IsKind(SyntaxKind.DotToken) && token.Parent.IsKind(SyntaxKind.QualifiedCref))
{
// cref "a.|"
var parent = token.Parent as QualifiedCrefSyntax;
var leftType = semanticModel.GetTypeInfo(parent.Container, cancellationToken).Type;
var leftSymbol = semanticModel.GetSymbolInfo(parent.Container, cancellationToken).Symbol;
var container = leftSymbol ?? leftType;
result = semanticModel.LookupSymbols(token.SpanStart, container: (INamespaceOrTypeSymbol)container)
.FilterToVisibleAndBrowsableSymbols(document.ShouldHideAdvancedMembers(), semanticModel.Compilation);
if (container is INamedTypeSymbol)
{
result = result.Concat(((INamedTypeSymbol)container).InstanceConstructors);
}
}
return await CreateItemsAsync(document.Project.Solution.Workspace, semanticModel,
position, result, token, cancellationToken).ConfigureAwait(false);
}
开发者ID:GloryChou,项目名称:roslyn,代码行数:56,代码来源:CrefCompletionProvider.cs
示例8: GetGroupsAsync
public async Task<IEnumerable<CompletionItemGroup>> GetGroupsAsync(
Document document,
int position,
CompletionTriggerInfo triggerInfo,
IEnumerable<ICompletionProvider> completionProviders,
CancellationToken cancellationToken)
{
var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
return await GetGroupsAsync(document, text, position, triggerInfo, completionProviders, document.Project.Solution.Workspace.Options, cancellationToken).ConfigureAwait(false);
}
开发者ID:GloryChou,项目名称:roslyn,代码行数:10,代码来源:AbstractCompletionService.cs
示例9: GetCompletionList
public override CompletionList GetCompletionList(SourceText text, int position, CompletionTriggerInfo triggerInfo, CancellationToken cancellationToken = default(CancellationToken))
{
var items = this.GetItems(text, position, triggerInfo, cancellationToken);
if (items == null || !items.Any())
{
return null;
}
return new CompletionList(items);
}
开发者ID:rivalinx,项目名称:roslyn,代码行数:10,代码来源:LoadCommandCompletionProvider.cs
示例10: GetItemsWorkerAsync
protected override async Task<IEnumerable<CompletionItem>> GetItemsWorkerAsync(Document document, int position, CompletionTriggerInfo triggerInfo, CancellationToken cancellationToken)
{
var tree = await document.GetSyntaxTreeAsync(cancellationToken).ConfigureAwait(false);
DeclarationModifiers modifiers;
SyntaxToken token;
if (!IsPartialCompletionContext(tree, position, cancellationToken, out modifiers, out token))
{
return null;
}
return await CreatePartialItemsAsync(document, position, modifiers, token, cancellationToken).ConfigureAwait(false);
}
开发者ID:noahstein,项目名称:roslyn,代码行数:13,代码来源:AbstractPartialCompletionProvider.cs
示例11: GetItemsWorkerAsync
protected override async Task<IEnumerable<CompletionItem>> GetItemsWorkerAsync(Document document, int position, CompletionTriggerInfo triggerInfo, CancellationToken cancellationToken)
{
var tree = await document.GetSyntaxTreeAsync(cancellationToken).ConfigureAwait(false);
// first try to get the #r string literal token. If we couldn't, then we're not in a #r
// reference directive and we immediately bail.
SyntaxToken stringLiteral;
if (!TryGetStringLiteralToken(tree, position, out stringLiteral, cancellationToken))
{
return null;
}
var documentPath = document.Project.IsSubmission ? null : document.FilePath;
var textChangeSpan = this.GetTextChangeSpan(stringLiteral, position);
var gacHelper = new GlobalAssemblyCacheCompletionHelper(this, textChangeSpan, itemRules: ItemRules.Instance);
var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
var snapshot = text.FindCorrespondingEditorTextSnapshot();
if (snapshot == null)
{
// Passing null to GetFileSystemDiscoveryService raises an exception.
// Instead, return here since there is no longer snapshot for this document.
return null;
}
var assemblyReferenceResolver = document.Project.CompilationOptions.MetadataReferenceResolver as AssemblyReferenceResolver;
if (assemblyReferenceResolver == null)
{
return null;
}
var metadataFileResolver = assemblyReferenceResolver.PathResolver as MetadataFileReferenceResolver;
if (metadataFileResolver == null)
{
return null;
}
var fileSystemHelper = new FileSystemCompletionHelper(
this, textChangeSpan,
GetFileSystemDiscoveryService(snapshot),
Glyph.OpenFolder,
Glyph.Assembly,
searchPaths: metadataFileResolver.SearchPaths,
allowableExtensions: new[] { ".dll", ".exe" },
exclude: path => path.Contains(","),
itemRules: ItemRules.Instance);
var pathThroughLastSlash = this.GetPathThroughLastSlash(stringLiteral, position);
return gacHelper.GetItems(pathThroughLastSlash, documentPath).Concat(
fileSystemHelper.GetItems(pathThroughLastSlash, documentPath));
}
开发者ID:rjmurillo,项目名称:roslyn,代码行数:51,代码来源:ReferenceDirectiveCompletionProvider.cs
示例12: GetBuilderAsync
protected override async Task<CompletionItem> GetBuilderAsync(Document document, int position, CompletionTriggerInfo triggerInfo, CancellationToken cancellationToken = default(CancellationToken))
{
if (triggerInfo.TriggerReason == CompletionTriggerReason.TypeCharCommand)
{
var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
if (triggerInfo.IsDebugger)
{
// Aggressive Intellisense in the debugger: always show the builder
return CreateEmptyBuilder(text, position);
}
var tree = await document.GetSyntaxTreeAsync(cancellationToken).ConfigureAwait(false);
var token = tree
.FindTokenOnLeftOfPosition(position, cancellationToken)
.GetPreviousTokenIfTouchingWord(position);
if (token.Kind() == SyntaxKind.None)
{
return null;
}
var semanticModel = await document.GetSemanticModelForNodeAsync(token.Parent, cancellationToken).ConfigureAwait(false);
var typeInferrer = document.GetLanguageService<ITypeInferenceService>();
if (IsLambdaExpression(semanticModel, position, token, typeInferrer, cancellationToken))
{
return CreateBuilder(text, position, CSharpFeaturesResources.LambdaExpression, CSharpFeaturesResources.AutoselectDisabledDueToPotentialLambdaDeclaration);
}
else if (IsAnonymousObjectCreation(token))
{
return CreateBuilder(text, position, CSharpFeaturesResources.MemberName, CSharpFeaturesResources.AutoselectDisabledDueToPossibleExplicitlyNamesAnonTypeMemCreation);
}
else if (token.IsPreProcessorExpressionContext())
{
return CreateEmptyBuilder(text, position);
}
else if (IsImplicitArrayCreation(semanticModel, token, position, typeInferrer, cancellationToken))
{
return CreateBuilder(text, position, CSharpFeaturesResources.ImplicitArrayCreation, CSharpFeaturesResources.AutoselectDisabledDueToPotentialImplicitArray);
}
else if (token.IsKindOrHasMatchingText(SyntaxKind.FromKeyword) || token.IsKindOrHasMatchingText(SyntaxKind.JoinKeyword))
{
return CreateBuilder(text, position, CSharpFeaturesResources.RangeVariable, CSharpFeaturesResources.AutoselectDisabledDueToPotentialRangeVariableDecl);
}
}
return null;
}
开发者ID:GeertVL,项目名称:roslyn,代码行数:49,代码来源:CSharpSuggestionModeCompletionProvider.cs
示例13: IsBetterFilterMatch
public bool? IsBetterFilterMatch(CompletionItem item1, CompletionItem item2, string filterText, CompletionTriggerInfo triggerInfo, CompletionFilterReason filterReason)
{
var match1 = _patternMatcher.MatchPatternFirstOrNullable(
_completionService.GetCultureSpecificQuirks(item1.FilterText),
_completionService.GetCultureSpecificQuirks(filterText));
var match2 = _patternMatcher.MatchPatternFirstOrNullable(
_completionService.GetCultureSpecificQuirks(item2.FilterText),
_completionService.GetCultureSpecificQuirks(filterText));
if (match1 != null && match2 != null)
{
var result = match1.Value.CompareTo(match2.Value);
if (result != 0)
{
return result < 0;
}
}
else if (match1 != null)
{
return true;
}
else if (match2 != null)
{
return false;
}
// If they both seemed just as good, but they differ on preselection, then
// item1 is better if it is preselected, otherwise it it worse.
if (item1.Preselect != item2.Preselect)
{
return item1.Preselect;
}
// Prefer things with a keyword glyph, if the filter texts are the same.
if (item1.Glyph != item2.Glyph && item1.FilterText == item2.FilterText)
{
return item1.Glyph == Glyph.Keyword;
}
// They matched on everything, including preselection values. Item1 is better if it
// has a lower MRU index.
var item1MRUIndex = _completionService.GetMRUIndex(item1);
var item2MRUIndex = _completionService.GetMRUIndex(item2);
// The one with the lower index is the better one.
return item1MRUIndex < item2MRUIndex;
}
开发者ID:JinGuoGe,项目名称:roslyn,代码行数:48,代码来源:AbstractCompletionService.CompletionRules.cs
示例14: GetItems
private ImmutableArray<CompletionItem> GetItems(SourceText text, Document document, int position, CompletionTriggerInfo triggerInfo, CancellationToken cancellationToken)
{
var line = text.Lines.GetLineFromPosition(position);
var lineText = text.ToString(TextSpan.FromBounds(line.Start, position));
var match = s_directiveRegex.Match(lineText);
if (!match.Success)
{
return ImmutableArray<CompletionItem>.Empty;
}
var quotedPathGroup = match.Groups[1];
var quotedPath = quotedPathGroup.Value;
var endsWithQuote = PathCompletionUtilities.EndsWithQuote(quotedPath);
if (endsWithQuote && (position >= line.Start + match.Length))
{
return ImmutableArray<CompletionItem>.Empty;
}
var buffer = text.Container.GetTextBuffer();
var snapshot = text.FindCorrespondingEditorTextSnapshot();
if (snapshot == null)
{
return ImmutableArray<CompletionItem>.Empty;
}
var fileSystem = CurrentWorkingDirectoryDiscoveryService.GetService(snapshot);
// TODO: https://github.com/dotnet/roslyn/issues/5263
// Avoid dependency on a specific resolver.
// The search paths should be provided by specialized workspaces:
// - InteractiveWorkspace for interactive window
// - ScriptWorkspace for loose .csx files (we don't have such workspace today)
var searchPaths = (document.Project.CompilationOptions.SourceReferenceResolver as SourceFileResolver)?.SearchPaths ?? ImmutableArray<string>.Empty;
var helper = new FileSystemCompletionHelper(
this,
GetTextChangeSpan(text, position, quotedPathGroup),
fileSystem,
Glyph.OpenFolder,
Glyph.CSharpFile,
searchPaths: searchPaths,
allowableExtensions: new[] { ".csx" },
itemRules: ItemRules.Instance);
var pathThroughLastSlash = this.GetPathThroughLastSlash(text, position, quotedPathGroup);
return helper.GetItems(pathThroughLastSlash, documentPath: null);
}
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:48,代码来源:LoadDirectiveCompletionProvider.cs
示例15: ComputeModel
public void ComputeModel(
ICompletionService completionService,
CompletionTriggerInfo triggerInfo,
IEnumerable<ICompletionProvider> completionProviders,
bool isDebugger)
{
AssertIsForeground();
// If we've already computed a model then we can just ignore this request and not
// generate any tasks.
if (this.Computation.InitialUnfilteredModel != null)
{
return;
}
new ModelComputer(this, completionService, triggerInfo, completionProviders, isDebugger).Do();
}
开发者ID:GeertVL,项目名称:roslyn,代码行数:17,代码来源:Controller.Session_ComputeModel.cs
示例16: CompletionListContext
public CompletionListContext(
Document document,
int position,
CompletionTriggerInfo triggerInfo,
CancellationToken cancellationToken)
{
if (document == null)
{
throw new ArgumentNullException(nameof(document));
}
this.Document = document;
this.Position = position;
this.TriggerInfo = triggerInfo;
this.CancellationToken = cancellationToken;
this._itemsBuilder = ImmutableArray.CreateBuilder<CompletionItem>();
}
开发者ID:noahstein,项目名称:roslyn,代码行数:18,代码来源:CompletionListContext.cs
示例17: GetGroupAsync
public async Task<CompletionItemGroup> GetGroupAsync(Document document, int position, CompletionTriggerInfo triggerInfo, CancellationToken cancellationToken)
{
if (!triggerInfo.IsAugment)
{
return null;
}
var builder = await this.GetBuilderAsync(document, position, triggerInfo, cancellationToken).ConfigureAwait(false);
if (builder == null)
{
return null;
}
return new CompletionItemGroup(
SpecializedCollections.EmptyEnumerable<CompletionItem>(),
builder,
isExclusive: false);
}
开发者ID:GloryChou,项目名称:roslyn,代码行数:18,代码来源:SuggestionModeCompletionProvider.cs
示例18: GetItems
private ImmutableArray<CompletionItem> GetItems(SourceText text, int position, CompletionTriggerInfo triggerInfo, CancellationToken cancellationToken)
{
var line = text.Lines.GetLineFromPosition(position);
var lineText = text.ToString(TextSpan.FromBounds(line.Start, position));
var match = s_directiveRegex.Match(lineText);
if (!match.Success)
{
return ImmutableArray<CompletionItem>.Empty;
}
var quotedPathGroup = match.Groups[1];
var quotedPath = quotedPathGroup.Value;
var endsWithQuote = PathCompletionUtilities.EndsWithQuote(quotedPath);
if (endsWithQuote && (position >= line.Start + match.Length))
{
return ImmutableArray<CompletionItem>.Empty;
}
var buffer = text.Container.GetTextBuffer();
var snapshot = text.FindCorrespondingEditorTextSnapshot();
if (snapshot == null)
{
return ImmutableArray<CompletionItem>.Empty;
}
var fileSystem = PathCompletionUtilities.GetCurrentWorkingDirectoryDiscoveryService(snapshot);
var searchPaths = ImmutableArray.Create<string>(fileSystem.CurrentDirectory);
var helper = new FileSystemCompletionHelper(
this,
GetTextChangeSpan(text, position, quotedPathGroup),
fileSystem,
Glyph.OpenFolder,
Glyph.CSharpFile,
searchPaths: searchPaths,
allowableExtensions: new[] { ".csx" },
itemRules: ItemRules.Instance);
var pathThroughLastSlash = this.GetPathThroughLastSlash(text, position, quotedPathGroup);
return helper.GetItems(pathThroughLastSlash, documentPath: null);
}
开发者ID:rivalinx,项目名称:roslyn,代码行数:43,代码来源:LoadCommandCompletionProvider.cs
示例19: GetItemsWorkerAsync
protected override async Task<IEnumerable<CompletionItem>> GetItemsWorkerAsync(
Document document, int position, CompletionTriggerInfo triggerInfo, CancellationToken cancellationToken)
{
if (document != null && document.SourceCodeKind == SourceCodeKind.Interactive)
{
// the provider might be invoked in non-interactive context:
Workspace ws;
if (Workspace.TryGetWorkspace(document.GetTextAsync(cancellationToken).WaitAndGetResult(cancellationToken).Container, out ws))
{
var workspace = ws as InteractiveWorkspace;
if (workspace != null)
{
var window = workspace.Engine.CurrentWindow;
var tree = await document.GetSyntaxTreeAsync(cancellationToken).ConfigureAwait(false);
if (tree.IsBeforeFirstToken(position, cancellationToken) &&
tree.IsPreProcessorKeywordContext(position, cancellationToken))
{
var textChangeSpan = await this.GetTextChangeSpanAsync(document, position, cancellationToken).ConfigureAwait(false);
var list = new List<CompletionItem>();
IInteractiveWindowCommands commands = window.GetInteractiveCommands();
if (commands != null)
{
foreach (var command in commands.GetCommands())
{
foreach (var commandName in command.Names)
{
list.Add(new CSharpCompletionItem(
workspace, this, commandName, textChangeSpan, c => Task.FromResult(command.Description.ToSymbolDisplayParts()), glyph: Glyph.Intrinsic));
}
}
}
return list;
}
}
}
}
return SpecializedCollections.EmptyEnumerable<CompletionItem>();
}
开发者ID:GloryChou,项目名称:roslyn,代码行数:42,代码来源:ReplCommandCompletionProvider.cs
示例20: GetItemsWorkerAsync
protected override async Task<IEnumerable<CompletionItem>> GetItemsWorkerAsync(Document document, int position, CompletionTriggerInfo triggerInfo, CancellationToken cancellationToken)
{
using (Logger.LogBlock(FunctionId.Completion_SnippetCompletionProvider_GetItemsWorker_CSharp, cancellationToken))
{
var workspace = document.Project.Solution.Workspace;
if (!workspace.CanApplyChange(ApplyChangesKind.ChangeDocument) ||
workspace.Kind == WorkspaceKind.Debugger)
{
return SpecializedCollections.EmptyEnumerable<CompletionItem>();
}
var optionService = workspace.Services.GetService<IOptionService>();
if (!optionService.GetOption(CSharpCompletionOptions.IncludeSnippets))
{
return SpecializedCollections.EmptyEnumerable<CompletionItem>();
}
return await document.GetUnionResultsFromDocumentAndLinks(UnionCompletionItemComparer.Instance, async (d, c) => await GetSnippetsForDocumentAsync(d, position, workspace, c).ConfigureAwait(false), cancellationToken).ConfigureAwait(false);
}
}
开发者ID:GloryChou,项目名称:roslyn,代码行数:20,代码来源:SnippetCompletionProvider.cs
注:本文中的Microsoft.CodeAnalysis.Completion.CompletionTriggerInfo类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论