internal async Task <QuickInfoItem?> GetQuickInfoAsync(SemanticModel semanticModel, int position, SymbolDescriptionOptions options, CancellationToken cancellationToken)
        {
            var extensionManager = _services.WorkspaceServices.GetRequiredService <IExtensionManager>();

            // returns the first non-empty quick info found (based on provider order)
            foreach (var provider in GetProviders().OfType <CommonQuickInfoProvider>())
            {
                try
                {
                    if (!extensionManager.IsDisabled(provider))
                    {
                        var context = new CommonQuickInfoContext(_services.WorkspaceServices.SolutionServices, semanticModel, position, options, 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);
        }
        private async Task <QuickInfoItem?> GetQuickInfoAsync(
            CommonQuickInfoContext context,
            SyntaxToken token)
        {
            if (token != default &&
                token.Span.IntersectsWith(context.Position))
            {
                return(await BuildQuickInfoAsync(context, token).ConfigureAwait(false));
            }

            return(null);
        }
示例#3
0
        protected override async Task <QuickInfoItem?> BuildQuickInfoAsync(
            CommonQuickInfoContext context, SyntaxToken token)
        {
            var tokenInformation = BindToken(context.Workspace, context.SemanticModel, token, context.CancellationToken);

            if (tokenInformation.Symbols.IsDefaultOrEmpty)
            {
                return(null);
            }

            return(await CreateContentAsync(
                       context.Workspace, context.SemanticModel, token, tokenInformation, supportedPlatforms : null, context.CancellationToken).ConfigureAwait(false));
        }
        public async Task <QuickInfoItem?> GetQuickInfoAsync(CommonQuickInfoContext context)
        {
            var tokens = await GetTokensAsync(context.SemanticModel.SyntaxTree, context.Position, context.CancellationToken).ConfigureAwait(false);

            foreach (var token in tokens)
            {
                var info = await GetQuickInfoAsync(context, token).ConfigureAwait(false);

                if (info != null)
                {
                    return(info);
                }
            }

            return(null);
        }
 protected abstract Task <QuickInfoItem?> BuildQuickInfoAsync(CommonQuickInfoContext context, SyntaxToken token);