@@ -134,9 +134,25 @@ API::Node getExtraSuccessorFromNode(API::Node node, AccessPathTokenBase token) {
134134 token .getAnArgument ( ) = "any-named" and
135135 result = node .getKeywordParameter ( _)
136136 )
137+ or
138+ // content based steps
139+ //
140+ // note: if we want to migrate to use `FlowSummaryImpl::Input::encodeContent` like
141+ // they do in Ruby, be aware that we currently don't make
142+ // `DataFlow::DictionaryElementContent` just from seeing a subscript read, so we would
143+ // need to add that. (also need to handle things like `DictionaryElementAny` which
144+ // doesn't have any value for .getAnArgument())
145+ (
146+ token .getName ( ) = "DictionaryElement" and
147+ result = node .getSubscript ( token .getAnArgument ( ) )
148+ or
149+ token .getName ( ) = "DictionaryElementAny" and
150+ result = node .getASubscript ( ) and
151+ not exists ( token .getAnArgument ( ) )
152+ // TODO: ListElement/SetElement/TupleElement
153+ )
137154 // Some features don't have MaD tokens yet, they would need to be added to API-graphs first.
138155 // - decorators ("DecoratedClass", "DecoratedMember", "DecoratedParameter")
139- // - Array/Map elements ("ArrayElement", "Element", "MapKey", "MapValue")
140156}
141157
142158/**
@@ -242,15 +258,19 @@ InvokeNode getAnInvocationOf(API::Node node) { result = node.getACall() }
242258 */
243259bindingset [ name]
244260predicate isExtraValidTokenNameInIdentifyingAccessPath ( string name ) {
245- name = [ "Member" , "Instance" , "Awaited" , "Call" , "Method" , "Subclass" ]
261+ name =
262+ [
263+ "Member" , "Instance" , "Awaited" , "Call" , "Method" , "Subclass" , "DictionaryElement" ,
264+ "DictionaryElementAny"
265+ ]
246266}
247267
248268/**
249269 * Holds if `name` is a valid name for an access path token with no arguments, occurring
250270 * in an identifying access path.
251271 */
252272predicate isExtraValidNoArgumentTokenInIdentifyingAccessPath ( string name ) {
253- name = [ "Instance" , "Awaited" , "Call" , "Subclass" ]
273+ name = [ "Instance" , "Awaited" , "Call" , "Subclass" , "DictionaryElementAny" ]
254274}
255275
256276/**
@@ -259,7 +279,7 @@ predicate isExtraValidNoArgumentTokenInIdentifyingAccessPath(string name) {
259279 */
260280bindingset [ name, argument]
261281predicate isExtraValidTokenArgumentInIdentifyingAccessPath ( string name , string argument ) {
262- name = [ "Member" , "Method" ] and
282+ name = [ "Member" , "Method" , "DictionaryElement" ] and
263283 exists ( argument )
264284 or
265285 name = [ "Argument" , "Parameter" ] and
0 commit comments