It is nested under the the dict under beginCaptures. What that tells the syntax highlighter is that once you find the begin rule highlight the following groups with these scopes.
So, here I am saying that in the begin rule, highlight group 1 with the API scope:
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>meta.function-call.st2-api.python</string>
</dict>
</dict>
So basically group 1 is the work before the bracket.
So if I wanted to only highlight the word only as meta.function.call, you will notice that we have a beginCaptures and endCaptures followed by one more key that gives the entire begin and end a meta.function-call.python scope. I have marked it below with ** <==Remove Me**. This was how Python did it before I modified it. I just added an extra rule in begin capture to give an additional API scope to the word only. By removing those three lines, I believe it should still highlight the word with the function-call and the API scope because of the beginCapture rule, and it will only be applied to the word.
<key>begin</key>
<string>(?:\.)?(size|substr|begin_edit|end_edit|insert|erase|replace|sel|line|full_line|lines|split_by_newlines|word|find|find_all|rowcol|text_point)\s*(?=\()</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>meta.function-call.st2-api.python</string>
</dict>
</dict>
<key>end</key>
<string>(\))</string>
<key>endCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>punctuation.definition.arguments.end.python</string>
</dict>
</dict>
<key>name</key> <==Remove Me
<string>meta.function-call.python</string> <==Remove Me
<key>patterns</key> <==Remove Me
The generic_object_names as you can see is meant to capture dot members of an object but assign no scope to them.
<key>generic_object_names</key>
<dict>
<key>match</key>
<string>(\.\b([A-Za-z_][A-Za-z0-9_]*)\b(?!\(|\)|\b([A-Za-z_][A-Za-z0-9_]*)\b\.)</string>
</dict>
They automatically get python.source applied, but no additional scoping.
I define it in the repository (order does not matter because it is just a place to define rules that can be included in the main dict), and then I include it in key locations to capture them so they don’t get scoped along with things like function calls, or mistaken as a system name etc. because print is not the same thing as obj.print etc.
I hope that makes some sense. I don’t really have more time right now to explain further or to test anything out, but hopefully I have helped.