@@ -130,6 +130,9 @@ private static Location GetSignificantLocation(SyntaxNode expression)
130130 if ( expression is InvocationExpressionSyntax )
131131 return GetSignificantInvocationLocation ( expression ) ;
132132
133+ if ( expression is ElementAccessExpressionSyntax )
134+ return GetSignificantInvocationLocation ( expression ) ;
135+
133136 var node = GetSignificantNodeCore ( expression ) ;
134137 return node . GetLocation ( ) ;
135138 }
@@ -141,6 +144,11 @@ private static SyntaxNode GetSignificantNodeCore(SyntaxNode expression)
141144 return GetSignificantNodeCore ( ie . Expression ) ;
142145 }
143146
147+ if ( expression is ElementAccessExpressionSyntax ea )
148+ {
149+ return GetSignificantNodeCore ( ea . Expression ) ;
150+ }
151+
144152 if ( expression is MemberAccessExpressionSyntax mae )
145153 {
146154 return mae . Name ;
@@ -163,6 +171,18 @@ private static Location GetSignificantInvocationLocation(SyntaxNode expression)
163171 var span = TextSpan . FromBounds ( start , end ) ;
164172 return Location . Create ( invocation . SyntaxTree , span ) ;
165173 }
174+ else if ( expression is ElementAccessExpressionSyntax elementAccess )
175+ {
176+ // Get the name part (e.g., bar in foo.bar[2])
177+ var nameNode = GetSignificantNodeCore ( elementAccess . Expression ) ;
178+
179+ // Compute the span from name start to the full invocation end
180+ var start = nameNode . SpanStart ;
181+ var end = elementAccess . Span . End ;
182+
183+ var span = TextSpan . FromBounds ( start , end ) ;
184+ return Location . Create ( elementAccess . SyntaxTree , span ) ;
185+ }
166186
167187 return expression . GetLocation ( ) ;
168188 }
0 commit comments