File tree Expand file tree Collapse file tree 8 files changed +86
-52
lines changed Expand file tree Collapse file tree 8 files changed +86
-52
lines changed Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ repository:
27
27
statement :
28
28
patterns : [
29
29
{
30
- include : " #from- import"
30
+ include : " #import"
31
31
}
32
32
{
33
33
include : " #class-declaration"
@@ -259,7 +259,7 @@ repository:
259
259
(?x)
260
260
\\ b(?<!\\ .)(
261
261
as | async | continue | del | assert | break | finally | for
262
- | from | elif | else | if | import | except | pass | raise
262
+ | from | elif | else | if | except | pass | raise
263
263
| return | try | while | with
264
264
)\\ b
265
265
@@ -926,20 +926,29 @@ repository:
926
926
]
927
927
}
928
928
]
929
- " from- import" :
929
+ import :
930
930
comment : '''
931
- The main purpose of this rule is to consume '...', so that
932
- it's not tokenized as ellipsis.
931
+ Import statements
933
932
934
933
'''
935
- match : '''
936
- (?x)
937
- \\ s* \\ b(from)\\ b (\\ s*\\ .+\\ s*)
938
-
939
- '''
940
- captures :
941
- " 1" :
942
- name : " keyword.control.flow.python"
934
+ patterns : [
935
+ {
936
+ match : '''
937
+ (?x)
938
+ \\ s* \\ b(from)\\ b (\\ s*\\ .+\\ s*) (import)?
939
+
940
+ '''
941
+ captures :
942
+ " 1" :
943
+ name : " keyword.control.import.python"
944
+ " 3" :
945
+ name : " keyword.control.import.python"
946
+ }
947
+ {
948
+ name : " keyword.control.import.python"
949
+ match : " \\ b(?<!\\ .)import\\ b"
950
+ }
951
+ ]
943
952
" class-declaration" :
944
953
patterns : [
945
954
{
Original file line number Diff line number Diff line change 44
44
<array >
45
45
<dict >
46
46
<key >include </key >
47
- <string >#from- import </string >
47
+ <string >#import </string >
48
48
</dict >
49
49
<dict >
50
50
<key >include </key >
420
420
<string >(?x)
421
421
\b(?< !\.)(
422
422
as | async | continue | del | assert | break | finally | for
423
- | from | elif | else | if | import | except | pass | raise
423
+ | from | elif | else | if | except | pass | raise
424
424
| return | try | while | with
425
425
)\b
426
426
</string >
1480
1480
</dict >
1481
1481
</array >
1482
1482
</dict >
1483
- <key >from- import </key >
1483
+ <key >import </key >
1484
1484
<dict >
1485
1485
<key >comment </key >
1486
- <string >The main purpose of this rule is to consume '...', so that
1487
- it's not tokenized as ellipsis.
1486
+ <string >Import statements
1488
1487
</string >
1489
- <key >match </key >
1490
- <string >(?x)
1491
- \s* \b(from)\b (\s*\.+\s*)
1488
+ <key >patterns </key >
1489
+ <array >
1490
+ <dict >
1491
+ <key >match </key >
1492
+ <string >(?x)
1493
+ \s* \b(from)\b (\s*\.+\s*) (import)?
1492
1494
</string >
1493
- <key >captures </key >
1494
- <dict >
1495
- <key >1 </key >
1495
+ <key >captures </key >
1496
+ <dict >
1497
+ <key >1 </key >
1498
+ <dict >
1499
+ <key >name </key >
1500
+ <string >keyword.control.import.python </string >
1501
+ </dict >
1502
+ <key >3 </key >
1503
+ <dict >
1504
+ <key >name </key >
1505
+ <string >keyword.control.import.python </string >
1506
+ </dict >
1507
+ </dict >
1508
+ </dict >
1496
1509
<dict >
1497
1510
<key >name </key >
1498
- <string >keyword.control.flow.python </string >
1511
+ <string >keyword.control.import.python </string >
1512
+ <key >match </key >
1513
+ <string >\b(?< !\.)import\b </string >
1499
1514
</dict >
1500
- </dict >
1515
+ </array >
1501
1516
</dict >
1502
1517
<key >class-declaration </key >
1503
1518
<dict >
Original file line number Diff line number Diff line change @@ -72,7 +72,7 @@ repository:
72
72
73
73
statement :
74
74
patterns :
75
- - include : ' #from- import'
75
+ - include : ' #import'
76
76
- include : ' #class-declaration'
77
77
- include : ' #function-declaration'
78
78
- include : ' #statement-keyword'
@@ -219,7 +219,7 @@ repository:
219
219
(?x)
220
220
\b(?<!\.)(
221
221
as | async | continue | del | assert | break | finally | for
222
- | from | elif | else | if | import | except | pass | raise
222
+ | from | elif | else | if | except | pass | raise
223
223
| return | try | while | with
224
224
)\b
225
225
- name : storage.modifier.declaration.python
@@ -650,15 +650,18 @@ repository:
650
650
- match : |
651
651
(?x) \{ [^'"}\n]*? \} (?=.*?\})
652
652
653
- from- import :
653
+ import :
654
654
comment : |
655
- The main purpose of this rule is to consume '...', so that
656
- it's not tokenized as ellipsis.
657
- match : |
658
- (?x)
659
- \s* \b(from)\b (\s*\.+\s*)
660
- captures :
661
- ' 1 ' : {name: keyword.control.flow.python}
655
+ Import statements
656
+ patterns :
657
+ - match : |
658
+ (?x)
659
+ \s* \b(from)\b (\s*\.+\s*) (import)?
660
+ captures:
661
+ '1': {name: keyword.control.import.python}
662
+ '3': {name: keyword.control.import.python}
663
+ - name : keyword.control.import.python
664
+ match : \b(?<!\.)import\b
662
665
663
666
class-declaration :
664
667
patterns :
Original file line number Diff line number Diff line change @@ -40,6 +40,7 @@ invalid.illegal.operator.python
40
40
invalid.illegal.prefix.python
41
41
keyword.codetag.notation.python
42
42
keyword.control.flow.python
43
+ keyword.control.import.python
43
44
keyword.illegal.name.python
44
45
keyword.operator.arithmetic.python
45
46
keyword.operator.assignment.python
Original file line number Diff line number Diff line change 31
31
: source .python
32
32
if : keyword .control .flow .python , source .python
33
33
: source .python
34
- import : keyword .control .flow .python , source .python
34
+ import : keyword .control .import .python , source .python
35
35
: source .python
36
36
except : keyword .control .flow .python , source .python
37
37
: source .python
Original file line number Diff line number Diff line change 3
3
4
4
5
5
6
- from : keyword .control .flow .python , source .python
6
+ from : keyword .control .import .python , source .python
7
7
... : source .python
8
8
foo : source .python
9
9
: source .python
10
- import : keyword .control .flow .python , source .python
10
+ import : keyword .control .import .python , source .python
11
11
: source .python
12
12
bar : source .python
13
13
: source .python
16
16
spam : source .python
17
17
, : source .python
18
18
baz : source .python
19
- import : keyword .control .flow .python , source .python
19
+ import : keyword .control .import .python , source .python
20
20
: source .python
21
21
time : source .python
22
22
: source .python
Original file line number Diff line number Diff line change 4
4
5
5
6
6
7
- from : keyword .control .flow .python , source .python
7
+ from : keyword .control .import .python , source .python
8
8
.... : source .python
9
- import : keyword .control .flow .python , source .python
9
+ import : keyword .control .import .python , source .python
10
10
: source .python
11
11
a : source .python
12
- from : keyword .control .flow .python , source .python
12
+ from : keyword .control .import .python , source .python
13
13
... : source .python
14
- import : keyword .control .flow .python , source .python
14
+ import : keyword .control .import .python , source .python
15
15
: source .python
16
16
b : source .python
17
- from : keyword .control .flow .python , source .python
17
+ from : keyword .control .import .python , source .python
18
18
.. : source .python
19
- import : keyword .control .flow .python , source .python
19
+ import : keyword .control .import .python , source .python
20
20
: source .python
21
21
c : source .python
Original file line number Diff line number Diff line change 1
1
from ....import a
2
2
from ...import b
3
3
from ..import c
4
+ from .import d
4
5
5
6
6
7
7
- from : keyword .control .flow .python , source .python
8
+ from : keyword .control .import .python , source .python
8
9
.... : source .python
9
- import : keyword .control .flow .python , source .python
10
+ import : keyword .control .import .python , source .python
10
11
: source .python
11
12
a : source .python
12
- from : keyword .control .flow .python , source .python
13
+ from : keyword .control .import .python , source .python
13
14
... : source .python
14
- import : keyword .control .flow .python , source .python
15
+ import : keyword .control .import .python , source .python
15
16
: source .python
16
17
b : source .python
17
- from : keyword .control .flow .python , source .python
18
+ from : keyword .control .import .python , source .python
18
19
.. : source .python
19
- import : keyword .control .flow .python , source .python
20
+ import : keyword .control .import .python , source .python
20
21
: source .python
21
22
c : source .python
23
+ from : keyword .control .import .python , source .python
24
+ . : source .python
25
+ import : keyword .control .import .python , source .python
26
+ : source .python
27
+ d : source .python
You can’t perform that action at this time.
0 commit comments