File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -693,31 +693,25 @@ private static bool IsSubPartOfConditionalAccess(VBasic.Syntax.MemberAccessExpre
693693
694694 while ( parent != null )
695695 {
696+ // On right hand side of a ?. conditional access
697+ if ( parent is VBSyntax . ConditionalAccessExpressionSyntax cae && cae . WhenNotNull == child )
698+ {
699+ return true ;
700+ }
701+
702+ // Recurse outwards through chained accesses
696703 if ( parent . IsKind ( VBasic . SyntaxKind . InvocationExpression ,
697704 VBasic . SyntaxKind . SimpleMemberAccessExpression ,
698- VBasic . SyntaxKind . ParenthesizedExpression ) )
705+ VBasic . SyntaxKind . ParenthesizedExpression ,
706+ VBasic . SyntaxKind . ConditionalAccessExpression ) )
699707 {
700708 child = parent ;
701709 parent = parent . Parent ;
702- continue ;
703710 }
704-
705- if ( parent is VBSyntax . ConditionalAccessExpressionSyntax cae )
711+ else
706712 {
707- if ( cae . WhenNotNull == child )
708- {
709- return true ;
710- }
711-
712- if ( cae . Expression == child )
713- {
714- child = parent ;
715- parent = parent . Parent ;
716- continue ;
717- }
713+ break ;
718714 }
719-
720- break ;
721715 }
722716
723717 return false ;
You can’t perform that action at this time.
0 commit comments