src/EditorFeatures/CSharp/CompleteStatement/CompleteStatementCommandHandler.cs
/// <summary>
/// Examines the enclosing statement-like syntax for an expression which is eligible for statement completion.
/// </summary>
/// <remarks>
/// <para>This method tries to identify <paramref name="currentNode"/> as a node located within an argument
/// list, where the immediately-containing statement resembles an "expression statement". This method returns
/// <see langword="true"/> if the node matches a recognizable pattern of this form.</para>
/// </remarks>
Examines the enclosing statement-like syntax for an expression which is eligible for statement completion.
Examines the enclosing statement - like syntax for an expression which is eligible for statement completion .
private static bool LooksLikeNodeInArgumentList(SyntaxNode currentNode,
            SnapshotPoint caret, ISyntaxFactsService syntaxFacts)
        {
            var nodeFound = false;
            while (!IsStatementOrFieldDeclaration(currentNode, syntaxFacts))
            {
                if (currentNode.IsKind(SyntaxKind.ArgumentList, SyntaxKind.ArrayRankSpecifier, SyntaxKind.BracketedArgumentList, SyntaxKind.ParenthesizedExpression))
                {
                    nodeFound = true;
                }
                if (IsInAString(currentNode, caret))
                {
                    return false;
                }
                if (currentNode.Parent == null)
                {
                    return false;
                }
                currentNode = currentNode.Parent;
            }
            if (currentNode == null || !nodeFound || !StatementIsACandidate(currentNode, caret.Position))
            {
                return false;
            }
            return true;
        }
private static bool LooksLikeNodeInArgumentList ( SyntaxNode currentNode , SnapshotPoint caret , ISyntaxFactsService syntaxFacts ) { var nodeFound = false ; while ( ! IsStatementOrFieldDeclaration ( currentNode , syntaxFacts ) ) { if ( currentNode . IsKind ( SyntaxKind . ArgumentList , SyntaxKind . ArrayRankSpecifier , SyntaxKind . BracketedArgumentList , SyntaxKind . ParenthesizedExpression ) ) { nodeFound = true ; } if ( IsInAString ( currentNode , caret ) ) { return false ; } if ( currentNode . Parent == null ) { return false ; } currentNode = currentNode . Parent ; } if ( currentNode == null || ! nodeFound || ! StatementIsACandidate ( currentNode , caret . Position ) ) { return false ; } return true ; }
Examines the enclosing statement-like syntax for an expression which is eligible for statement completion.
Examines the enclosing statement - like syntax for an expression which is eligible for statement completion .
// work our way up the tree, looking for a node of interest within the current statement // This feature operates inside the following types of nodes,  // and can be expanded if more cases are implemented: // ArgumentList: covers method invocations like object.Method(arg) // ArrayRankSpecifier: covers new Type[dim] // ElementAccessExpression: covers indexer invocations like array[index] // ParenthesizedExpression: covers (3*(x+y)) // No special action is performed at this time if `;` is typed inside a string, including // interpolated strings.   // We reached the root without finding a statement // if we never found a statement, or a node of interest, or the statement kind is not a candidate for completion, return
currentNode
SyntaxNode
caret
SnapshotPoint
syntaxFacts
ISyntaxFactsService
remarks
This method tries to identify  as a node located within an argument
list, where the immediately-containing statement resembles an "expression statement". This method returns
if the node matches a recognizable pattern of this form.
This method tries to identify as a node located within an argument list where the immediately - containing statement resembles an " expression statement " . This method returns if the node matches a recognizable pattern of this form .