Skip to content

Commit 5408d3f

Browse files
committed
Fix scoping of item access (ex: brackets in foo[a])
1 parent 2f6e77f commit 5408d3f

File tree

9 files changed

+40
-24
lines changed

9 files changed

+40
-24
lines changed

grammars/MagicPython.cson

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,18 +1179,18 @@ repository:
11791179
name: "punctuation.definition.arguments.end.python"
11801180
patterns: [
11811181
{
1182-
include: "#dict-name"
1182+
include: "#item-name"
11831183
}
11841184
{
1185-
include: "#dict-index"
1185+
include: "#item-index"
11861186
}
11871187
{
11881188
include: "#expression"
11891189
}
11901190
]
11911191
}
11921192
]
1193-
"dict-name":
1193+
"item-name":
11941194
patterns: [
11951195
{
11961196
include: "#special-names"
@@ -1203,8 +1203,8 @@ repository:
12031203
'''
12041204
}
12051205
]
1206-
"dict-index":
1207-
name: "meta.function-call.arguments.python"
1206+
"item-index":
1207+
name: "meta.item-access.arguments.python"
12081208
begin: "(\\[)"
12091209
end: "(?=\\])"
12101210
beginCaptures:

grammars/MagicPython.syntax.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -800,19 +800,19 @@ repository:
800800
endCaptures:
801801
'1': {name: punctuation.definition.arguments.end.python}
802802
patterns:
803-
- include: '#dict-name'
804-
- include: '#dict-index'
803+
- include: '#item-name'
804+
- include: '#item-index'
805805
- include: '#expression'
806806

807-
dict-name:
807+
item-name:
808808
patterns:
809809
- include: '#special-names'
810810
- match: |
811811
(?x)
812812
\b ([[:alpha:]_]\w*) \b
813813
814-
dict-index:
815-
name: meta.function-call.arguments.python
814+
item-index:
815+
name: meta.item-access.arguments.python
816816
begin: (\[)
817817
end: (?=\])
818818
beginCaptures:

grammars/MagicPython.tmLanguage

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1928,11 +1928,11 @@ it's not tokenized as ellipsis.
19281928
<array>
19291929
<dict>
19301930
<key>include</key>
1931-
<string>#dict-name</string>
1931+
<string>#item-name</string>
19321932
</dict>
19331933
<dict>
19341934
<key>include</key>
1935-
<string>#dict-index</string>
1935+
<string>#item-index</string>
19361936
</dict>
19371937
<dict>
19381938
<key>include</key>
@@ -1942,7 +1942,7 @@ it&apos;s not tokenized as ellipsis.
19421942
</dict>
19431943
</array>
19441944
</dict>
1945-
<key>dict-name</key>
1945+
<key>item-name</key>
19461946
<dict>
19471947
<key>patterns</key>
19481948
<array>
@@ -1958,10 +1958,10 @@ it&apos;s not tokenized as ellipsis.
19581958
</dict>
19591959
</array>
19601960
</dict>
1961-
<key>dict-index</key>
1961+
<key>item-index</key>
19621962
<dict>
19631963
<key>name</key>
1964-
<string>meta.function-call.arguments.python</string>
1964+
<string>meta.item-access.arguments.python</string>
19651965
<key>begin</key>
19661966
<string>(\[)</string>
19671967
<key>end</key>

misc/scopes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ meta.function-call.python
5858
meta.function.decorator.python
5959
meta.function.parameters.python
6060
meta.function.python
61+
meta.item-access.arguments.python
6162
meta.item-access.python
6263
meta.lambda-function.python
6364
meta.named.regexp

test/calls/call1.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
, : meta.function-call.arguments.python, meta.function-call.python, punctuation.separator.arguments.python, source.python
1111
: meta.function-call.arguments.python, meta.function-call.python, source.python
1212
c : meta.function-call.arguments.python, meta.function-call.python, meta.item-access.python, source.python
13-
[ : meta.function-call.arguments.python, meta.function-call.python, meta.item-access.python, punctuation.definition.arguments.begin.python, source.python
13+
[ : meta.function-call.arguments.python, meta.function-call.python, meta.item-access.arguments.python, meta.item-access.python, punctuation.definition.arguments.begin.python, source.python
1414
1 : constant.numeric.dec.python, meta.function-call.arguments.python, meta.function-call.python, meta.item-access.arguments.python, meta.item-access.python, source.python
1515
] : meta.function-call.arguments.python, meta.function-call.python, meta.item-access.python, punctuation.definition.arguments.end.python, source.python
1616
, : meta.function-call.arguments.python, meta.function-call.python, punctuation.separator.arguments.python, source.python

test/expressions/expr11.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
a = self.some_list[1:2]
2+
3+
4+
5+
a : source.python
6+
= : keyword.operator.assignment.python, source.python
7+
: source.python
8+
self : source.python, variable.language.special.self.python
9+
. : source.python
10+
some_list : meta.item-access.python, source.python
11+
[ : meta.item-access.arguments.python, meta.item-access.python, punctuation.definition.arguments.begin.python, source.python
12+
1 : constant.numeric.dec.python, meta.item-access.arguments.python, meta.item-access.python, source.python
13+
: : meta.item-access.arguments.python, meta.item-access.python, source.python
14+
2 : constant.numeric.dec.python, meta.item-access.arguments.python, meta.item-access.python, source.python
15+
] : meta.item-access.python, punctuation.definition.arguments.end.python, source.python

test/functions/decl2.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ def : meta.function.python, source.python, storage.type.function.pytho
1515
-> : meta.function.python, punctuation.separator.annotation.result.python, source.python
1616
: meta.function.python, source.python
1717
qqq : meta.function.python, meta.item-access.python, source.python
18-
[ : meta.function-call.arguments.python, meta.function.python, meta.item-access.python, punctuation.definition.arguments.begin.python, source.python
19-
None : constant.language.python, meta.function-call.arguments.python, meta.function.python, meta.item-access.arguments.python, meta.item-access.python, source.python
18+
[ : meta.function.python, meta.item-access.arguments.python, meta.item-access.python, punctuation.definition.arguments.begin.python, source.python
19+
None : constant.language.python, meta.function.python, meta.item-access.arguments.python, meta.item-access.python, source.python
2020
] : meta.function.python, meta.item-access.python, punctuation.definition.arguments.end.python, source.python
2121
: : meta.function.python, punctuation.section.function.begin.python, source.python
2222
: source.python

test/functions/decorators6.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ def foo(): pass
3030
. \ : invalid.illegal.decorator.python, meta.function.decorator.python, source.python
3131
: source.python
3232
baz : meta.item-access.python, source.python
33-
[ : meta.function-call.arguments.python, meta.item-access.python, punctuation.definition.arguments.begin.python, source.python
34-
1 : constant.numeric.dec.python, meta.function-call.arguments.python, meta.item-access.arguments.python, meta.item-access.python, source.python
35-
: : meta.function-call.arguments.python, meta.item-access.arguments.python, meta.item-access.python, source.python
36-
2 : constant.numeric.dec.python, meta.function-call.arguments.python, meta.item-access.arguments.python, meta.item-access.python, source.python
33+
[ : meta.item-access.arguments.python, meta.item-access.python, punctuation.definition.arguments.begin.python, source.python
34+
1 : constant.numeric.dec.python, meta.item-access.arguments.python, meta.item-access.python, source.python
35+
: : meta.item-access.arguments.python, meta.item-access.python, source.python
36+
2 : constant.numeric.dec.python, meta.item-access.arguments.python, meta.item-access.python, source.python
3737
] : meta.item-access.python, punctuation.definition.arguments.end.python, source.python
3838
@ : entity.name.function.decorator.python, meta.function.decorator.python, source.python
3939
foo : entity.name.function.decorator.python, meta.function.decorator.python, source.python

test/strings/bytes2.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99

1010

1111
a : meta.item-access.python, source.python
12-
[ : meta.function-call.arguments.python, meta.item-access.python, punctuation.definition.arguments.begin.python, source.python
13-
1 : constant.numeric.dec.python, meta.function-call.arguments.python, meta.item-access.arguments.python, meta.item-access.python, source.python
12+
[ : meta.item-access.arguments.python, meta.item-access.python, punctuation.definition.arguments.begin.python, source.python
13+
1 : constant.numeric.dec.python, meta.item-access.arguments.python, meta.item-access.python, source.python
1414
] : meta.item-access.python, punctuation.definition.arguments.end.python, source.python
1515
: source.python
1616
= : keyword.operator.assignment.python, source.python

0 commit comments

Comments
 (0)