Skip to content

Commit b75a3bb

Browse files
committed
Tokenize identifiers to help linters
1 parent 010175e commit b75a3bb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+462
-108
lines changed

grammars/MagicPython.cson

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,10 @@ repository:
359359
{
360360
include: "#member-access"
361361
}
362+
{
363+
comment: "Tokenize identifiers to help linters"
364+
match: "(?x) \\b ([[:alpha:]_]\\w*) \\b"
365+
}
362366
]
363367
"member-access":
364368
begin: "\\.\\s*(?!\\.)"

grammars/MagicPython.tmLanguage

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,12 @@
550550
<key>include</key>
551551
<string>#member-access</string>
552552
</dict>
553+
<dict>
554+
<key>comment</key>
555+
<string>Tokenize identifiers to help linters</string>
556+
<key>match</key>
557+
<string>(?x) \b ([[:alpha:]_]\w*) \b</string>
558+
</dict>
553559
</array>
554560
</dict>
555561
<key>member-access</key>

grammars/src/MagicPython.syntax.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,8 @@ repository:
262262
patterns:
263263
- include: '#expression-base'
264264
- include: '#member-access'
265+
- comment: Tokenize identifiers to help linters
266+
match: (?x) \b ([[:alpha:]_]\w*) \b
265267

266268
member-access:
267269
begin: \.\s*(?!\.)

misc/example.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ async def coroutine(db:aio_db.DatabaseConnection) -> List[str]:
3838
\Z""",
3939
re.VERBOSE | re.DOTALL)
4040

41-
# NOTE Numbers with leading zeroes are invalid in Python3,
41+
# NOTE Numbers with leading zeros are invalid in Python 3,
4242
# use 0o...
4343
answer = func(0xdeadbeef + 0b0010001 + 0123 + 0o123 +
4444
# complex numbers

test/calls/call1.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
( : meta.function-call.python, punctuation.definition.arguments.begin.python, source.python
77
A : constant.other.caps.python, meta.function-call.arguments.python, meta.function-call.python, source.python
88
, : meta.function-call.arguments.python, meta.function-call.python, punctuation.separator.arguments.python, source.python
9-
b : meta.function-call.arguments.python, meta.function-call.python, source.python
9+
: meta.function-call.arguments.python, meta.function-call.python, source.python
10+
b : meta.function-call.arguments.python, meta.function-call.python, source.python
1011
, : meta.function-call.arguments.python, meta.function-call.python, punctuation.separator.arguments.python, source.python
1112
: meta.function-call.arguments.python, meta.function-call.python, source.python
1213
c : meta.function-call.arguments.python, meta.function-call.python, meta.item-access.python, source.python

test/calls/call4.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
None : keyword.illegal.name.python, source.python
2424
: source.python
2525
and : keyword.operator.logical.python, source.python
26-
foo : source.python
26+
: source.python
27+
foo : source.python
2728
. : source.python
2829
None : keyword.illegal.name.python, source.python
2930
. : source.python

test/calls/call6.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
: meta.function-call.python, source.python
99
* : keyword.operator.unpacking.arguments.python, meta.function-call.python, source.python
1010
a : meta.function-call.arguments.python, meta.function-call.python, source.python
11+
: meta.function-call.arguments.python, meta.function-call.python, source.python
1112
, : meta.function-call.arguments.python, meta.function-call.python, punctuation.separator.arguments.python, source.python
1213
: meta.function-call.arguments.python, meta.function-call.python, source.python
1314
* : keyword.operator.unpacking.arguments.python, meta.function-call.arguments.python, meta.function-call.python, source.python
@@ -19,6 +20,7 @@
1920
: meta.function-call.python, source.python
2021
** : keyword.operator.unpacking.arguments.python, meta.function-call.python, source.python
2122
a : meta.function-call.arguments.python, meta.function-call.python, source.python
23+
: meta.function-call.arguments.python, meta.function-call.python, source.python
2224
, : meta.function-call.arguments.python, meta.function-call.python, punctuation.separator.arguments.python, source.python
2325
: meta.function-call.arguments.python, meta.function-call.python, source.python
2426
** : keyword.operator.unpacking.arguments.python, meta.function-call.arguments.python, meta.function-call.python, source.python

test/calls/print1.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@
3232
2 : constant.numeric.dec.python, meta.function-call.arguments.python, meta.function-call.python, source.python
3333
) : meta.function-call.python, punctuation.definition.arguments.end.python, source.python
3434
print : source.python, support.function.builtin.python
35-
x, : source.python
35+
: source.python
36+
x : source.python
37+
, : source.python
3638
print : meta.function-call.python, source.python, support.function.builtin.python
3739
( : meta.function-call.python, punctuation.definition.arguments.begin.python, source.python
3840
x : meta.function-call.arguments.python, meta.function-call.python, source.python
@@ -76,11 +78,14 @@
7678
( : meta.function-call.python, punctuation.definition.arguments.begin.python, source.python
7779
x : meta.function-call.arguments.python, meta.function-call.python, source.python
7880
, : meta.function-call.arguments.python, meta.function-call.python, punctuation.separator.arguments.python, source.python
79-
y : meta.function-call.arguments.python, meta.function-call.python, source.python
81+
: meta.function-call.arguments.python, meta.function-call.python, source.python
82+
y : meta.function-call.arguments.python, meta.function-call.python, source.python
8083
) : meta.function-call.python, punctuation.definition.arguments.end.python, source.python
8184
print : meta.function-call.python, source.python, support.function.builtin.python
8285
( : meta.function-call.python, punctuation.definition.arguments.begin.python, source.python
8386
( : meta.function-call.arguments.python, meta.function-call.python, punctuation.parenthesis.begin.python, source.python
84-
x, y : meta.function-call.arguments.python, meta.function-call.python, source.python
87+
x : meta.function-call.arguments.python, meta.function-call.python, source.python
88+
, : meta.function-call.arguments.python, meta.function-call.python, source.python
89+
y : meta.function-call.arguments.python, meta.function-call.python, source.python
8590
) : meta.function-call.arguments.python, meta.function-call.python, punctuation.parenthesis.end.python, source.python
8691
) : meta.function-call.python, punctuation.definition.arguments.end.python, source.python

test/classes/class1.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ class Foo -> None: pass
33

44

55
class : source.python, storage.type.class.python
6-
Foo : source.python
6+
: source.python
7+
Foo : source.python
8+
: source.python
79
-> : invalid.illegal.annotation.python, source.python
810
: source.python
911
None : constant.language.python, source.python

test/classes/class11.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,16 @@ def : meta.function.python, source.python, storage.type.function.pytho
3636
a : source.python
3737
: source.python
3838
= : keyword.operator.assignment.python, source.python
39-
a : source.python
39+
: source.python
40+
a : source.python
4041
: source.python
4142
self : source.python, variable.language.special.self.python
4243
. : source.python
4344
b : source.python
4445
: source.python
4546
= : keyword.operator.assignment.python, source.python
46-
b : source.python
47+
: source.python
48+
b : source.python
4749
: source.python
4850
print : meta.function-call.python, source.python, support.function.builtin.python
4951
( : meta.function-call.python, punctuation.definition.arguments.begin.python, source.python
@@ -53,14 +55,16 @@ def : meta.function.python, source.python, storage.type.function.pytho
5355
self : meta.function-call.python, source.python, variable.language.special.self.python
5456
( : meta.function-call.python, punctuation.definition.arguments.begin.python, source.python
5557
) : meta.function-call.python, punctuation.definition.arguments.end.python, source.python
56-
a : source.python
58+
: source.python
59+
a : source.python
5760
. : source.python
5861
self : source.python
5962
: source.python
6063
= : keyword.operator.assignment.python, source.python
6164
: source.python
6265
1 : constant.numeric.dec.python, source.python
63-
a : source.python
66+
: source.python
67+
a : source.python
6468
. : source.python
6569
self : source.python
6670
. : source.python

0 commit comments

Comments
 (0)