internal static bool TryGetSyntax(
                SyntaxNode root,
                int position,
                ISyntaxFactsService syntaxFacts,
                SignatureHelpTriggerReason triggerReason,
                CancellationToken cancellationToken,
                [NotNullWhen(true)] out ExpressionSyntax?identifier,
                out SyntaxToken openBrace
                )
            {
                if (
                    CommonSignatureHelpUtilities.TryGetSyntax(
                        root,
                        position,
                        syntaxFacts,
                        triggerReason,
                        IsTriggerToken,
                        IsArgumentListToken,
                        cancellationToken,
                        out ArrayTypeSyntax arrayTypeSyntax
                        )
                    )
                {
                    identifier = arrayTypeSyntax.ElementType;
                    openBrace  = arrayTypeSyntax.RankSpecifiers.First().OpenBracketToken;
                    return(true);
                }

                identifier = null;
                openBrace  = default;
                return(false);
            }
        private bool TryGetConstructorInitializer(
            SyntaxNode root,
            int position,
            ISyntaxFactsService syntaxFacts,
            SignatureHelpTriggerReason triggerReason,
            CancellationToken cancellationToken,
            out ConstructorInitializerSyntax expression
            )
        {
            if (
                !CommonSignatureHelpUtilities.TryGetSyntax(
                    root,
                    position,
                    syntaxFacts,
                    triggerReason,
                    IsTriggerToken,
                    IsArgumentListToken,
                    cancellationToken,
                    out expression
                    )
                )
            {
                return(false);
            }

            return(expression.ArgumentList != null);
        }
            internal static bool TryGetSyntax(
                SyntaxNode root,
                int position,
                ISyntaxFactsService syntaxFacts,
                SignatureHelpTriggerReason triggerReason,
                CancellationToken cancellationToken,
                [NotNullWhen(true)] out ExpressionSyntax?identifier,
                out SyntaxToken openBrace
                )
            {
                if (
                    CommonSignatureHelpUtilities.TryGetSyntax(
                        root,
                        position,
                        syntaxFacts,
                        triggerReason,
                        IsTriggerToken,
                        IsArgumentListToken,
                        cancellationToken,
                        out ElementAccessExpressionSyntax elementAccessExpression
                        )
                    )
                {
                    identifier = elementAccessExpression.Expression;
                    openBrace  = elementAccessExpression.ArgumentList.OpenBracketToken;
                    return(true);
                }

                identifier = null;
                openBrace  = default;
                return(false);
            }
Ejemplo n.º 4
0
        private bool TryGetAttributeExpression(
            SyntaxNode root,
            int position,
            ISyntaxFactsService syntaxFacts,
            SignatureHelpTriggerReason triggerReason,
            CancellationToken cancellationToken,
            out AttributeSyntax attribute
            )
        {
            if (
                !CommonSignatureHelpUtilities.TryGetSyntax(
                    root,
                    position,
                    syntaxFacts,
                    triggerReason,
                    IsTriggerToken,
                    IsArgumentListToken,
                    cancellationToken,
                    out attribute
                    )
                )
            {
                return(false);
            }

            return(attribute.ArgumentList != null);
        }
Ejemplo n.º 5
0
        protected virtual bool TryGetGenericIdentifier(
            SyntaxNode root,
            int position,
            ISyntaxFactsService syntaxFacts,
            SignatureHelpTriggerReason triggerReason,
            CancellationToken cancellationToken,
            out SyntaxToken genericIdentifier,
            out SyntaxToken lessThanToken
            )
        {
            if (
                CommonSignatureHelpUtilities.TryGetSyntax(
                    root,
                    position,
                    syntaxFacts,
                    triggerReason,
                    IsTriggerToken,
                    IsArgumentListToken,
                    cancellationToken,
                    out GenericNameSyntax name
                    )
                )
            {
                genericIdentifier = name.Identifier;
                lessThanToken     = name.TypeArgumentList.LessThanToken;
                return(true);
            }

            genericIdentifier = default;
            lessThanToken     = default;
            return(false);
        }
Ejemplo n.º 6
0
        private bool TryGetInvocationExpression(SyntaxNode root, int position, ISyntaxFactsService syntaxFacts, SignatureHelpTriggerReason triggerReason, CancellationToken cancellationToken, out InvocationExpressionSyntax expression)
        {
            if (!CommonSignatureHelpUtilities.TryGetSyntax(root, position, syntaxFacts, triggerReason, IsTriggerToken, IsArgumentListToken, cancellationToken, out expression))
            {
                return false;
            }

            return expression.ArgumentList != null;
        }
Ejemplo n.º 7
0
            internal static bool TryGetSyntax(SyntaxNode root, int position, ISyntaxFactsService syntaxFacts, SignatureHelpTriggerReason triggerReason, CancellationToken cancellationToken, out ExpressionSyntax identifier, out SyntaxToken openBrace)
            {
                ElementBindingExpressionSyntax elementBindingExpression;

                if (CommonSignatureHelpUtilities.TryGetSyntax(root, position, syntaxFacts, triggerReason, IsTriggerToken, IsArgumentListToken, cancellationToken, out elementBindingExpression))
                {
                    identifier = ((ConditionalAccessExpressionSyntax)elementBindingExpression.Parent).Expression;
                    openBrace  = elementBindingExpression.ArgumentList.OpenBracketToken;

                    return(true);
                }

                identifier = null;
                openBrace  = default(SyntaxToken);
                return(false);
            }
Ejemplo n.º 8
0
            internal static bool TryGetSyntax(SyntaxNode root, int position, ISyntaxFactsService syntaxFacts, SignatureHelpTriggerReason triggerReason, CancellationToken cancellationToken, out ExpressionSyntax identifier, out SyntaxToken openBrace)
            {
                if (CommonSignatureHelpUtilities.TryGetSyntax(root, position, syntaxFacts, triggerReason, IsTriggerToken, IsArgumentListToken, cancellationToken, out ElementBindingExpressionSyntax elementBindingExpression))
                {
                    // Find the first conditional access expression that starts left of our open bracket
                    var conditionalAccess = elementBindingExpression.FirstAncestorOrSelf <ConditionalAccessExpressionSyntax>(
                        c => c.SpanStart < elementBindingExpression.SpanStart);

                    identifier = conditionalAccess.Expression;
                    openBrace  = elementBindingExpression.ArgumentList.OpenBracketToken;

                    return(true);
                }

                identifier = null;
                openBrace  = default(SyntaxToken);
                return(false);
            }
Ejemplo n.º 9
0
 private bool TryGetInitializerExpression(
     SyntaxNode root,
     int position,
     ISyntaxFactsService syntaxFacts,
     SignatureHelpTriggerReason triggerReason,
     CancellationToken cancellationToken,
     out InitializerExpressionSyntax expression
     ) =>
 CommonSignatureHelpUtilities.TryGetSyntax(
     root,
     position,
     syntaxFacts,
     triggerReason,
     IsTriggerToken,
     IsInitializerExpressionToken,
     cancellationToken,
     out expression
     ) &&
 expression != null;
Ejemplo n.º 10
0
 private bool TryGetParenthesizedExpression(
     SignatureHelpTriggerReason triggerReason,
     SyntaxNode root,
     int position,
     ISyntaxFactsService syntaxFacts,
     CancellationToken cancellationToken,
     [NotNullWhen(true)] out ParenthesizedExpressionSyntax?parenthesizedExpression
     )
 {
     return(CommonSignatureHelpUtilities.TryGetSyntax(
                root,
                position,
                syntaxFacts,
                triggerReason,
                IsParenthesizedExpressionTriggerToken,
                IsParenthesizedExpressionToken,
                cancellationToken,
                out parenthesizedExpression
                ));
 }
Ejemplo n.º 11
0
 private bool TryGetTupleExpression(
     SignatureHelpTriggerReason triggerReason,
     SyntaxNode root,
     int position,
     ISyntaxFactsService syntaxFacts,
     CancellationToken cancellationToken,
     [NotNullWhen(true)] out TupleExpressionSyntax?tupleExpression
     )
 {
     return(CommonSignatureHelpUtilities.TryGetSyntax(
                root,
                position,
                syntaxFacts,
                triggerReason,
                IsTupleExpressionTriggerToken,
                IsTupleArgumentListToken,
                cancellationToken,
                out tupleExpression
                ));
 }