Exemple #1
0
        protected override async Task <SignatureHelpItems> GetItemsWorkerAsync(Document document, int position, SignatureHelpTriggerInfo triggerInfo, CancellationToken cancellationToken)
        {
            var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);

            if (!TryGetInitializerExpression(root, position, document.GetLanguageService <ISyntaxFactsService>(), triggerInfo.TriggerReason, cancellationToken, out var initializerExpression))
            {
                return(null);
            }

            var addMethods = await CommonSignatureHelpUtilities.GetCollectionInitializerAddMethodsAsync(
                document, initializerExpression, cancellationToken).ConfigureAwait(false);

            if (addMethods.IsDefaultOrEmpty)
            {
                return(null);
            }

            var textSpan    = SignatureHelpUtilities.GetSignatureHelpSpan(initializerExpression);
            var syntaxFacts = document.GetLanguageService <ISyntaxFactsService>();

            var semanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);

            return(CreateCollectionInitializerSignatureHelpItems(addMethods.Select(s =>
                                                                                   ConvertMethodGroupMethod(document, s, initializerExpression.OpenBraceToken.SpanStart, semanticModel)).ToList(),
                                                                 textSpan, GetCurrentArgumentState(root, position, syntaxFacts, textSpan, cancellationToken)));
        }