コード例 #1
0
        public override async Task <QuickInfoItem> GetQuickInfoAsync(Document document, int position, CancellationToken cancellationToken)
        {
            var extensionManager = _workspace.Services.GetService <IExtensionManager>();

            // returns the first non-empty quick info found (based on provider order)
            foreach (var provider in GetProviders())
            {
                try
                {
                    if (!extensionManager.IsDisabled(provider))
                    {
                        var context = new QuickInfoContext(document, position, cancellationToken);

                        var info = await provider.GetQuickInfoAsync(context).ConfigureAwait(false);

                        if (info != null)
                        {
                            return(info);
                        }
                    }
                }
                catch (OperationCanceledException)
                {
                    throw;
                }
                catch (Exception e) when(extensionManager.CanHandleException(provider, e))
                {
                    extensionManager.HandleException(provider, e);
                }
            }

            return(null);
        }
コード例 #2
0
        public override async Task <QuickInfoItem> GetQuickInfoAsync(QuickInfoContext context)
        {
            var document          = context.Document;
            var position          = context.Position;
            var cancellationToken = context.CancellationToken;

            var tree = await document.GetSyntaxTreeAsync(cancellationToken).ConfigureAwait(false);

            var token = await tree.GetTouchingTokenAsync(position, cancellationToken, findInsideTrivia : true).ConfigureAwait(false);

            var info = await GetQuickInfoAsync(document, token, position, cancellationToken).ConfigureAwait(false);

            if (info == null && ShouldCheckPreviousToken(token))
            {
                var previousToken = token.GetPreviousToken();
                info = await GetQuickInfoAsync(document, previousToken, position, cancellationToken).ConfigureAwait(false);
            }

            return(info);
        }
コード例 #3
0
ファイル: QuickInfoProvider.cs プロジェクト: stark-lang/stark
 /// <summary>
 /// Gets the <see cref="QuickInfoItem"/> for the position.
 /// </summary>
 /// <returns>The <see cref="QuickInfoItem"/> or null if no item is available.</returns>
 public abstract Task <QuickInfoItem> GetQuickInfoAsync(QuickInfoContext context);