Skip to content

Commit 95394a4

Browse files
Added interior scopes to python
1 parent ff31585 commit 95394a4

File tree

12 files changed

+276
-29
lines changed

12 files changed

+276
-29
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
if True:
2+
a
3+
elif False:
4+
b
5+
else:
6+
c
7+
---
8+
9+
[#1 Content] =
10+
[#1 Removal] = 1:4-1:5
11+
>-<
12+
1| a
13+
14+
[#1 Domain] = 0:0-1:5
15+
>--------
16+
0| if True:
17+
1| a
18+
-----<
19+
20+
[#1 Insertion delimiter] = " "
21+
22+
23+
[#2 Content] =
24+
[#2 Removal] = 3:4-3:5
25+
>-<
26+
3| b
27+
28+
[#2 Domain] = 2:0-3:5
29+
>-----------
30+
2| elif False:
31+
3| b
32+
-----<
33+
34+
[#2 Insertion delimiter] = " "
35+
36+
37+
[#3 Content] =
38+
[#3 Removal] = 5:4-5:5
39+
>-<
40+
5| c
41+
42+
[#3 Domain] = 4:0-5:5
43+
>-----
44+
4| else:
45+
5| c
46+
-----<
47+
48+
[#3 Insertion delimiter] = " "
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
for v in values:
2+
pass
3+
---
4+
5+
[Content] =
6+
[Removal] = 1:4-1:8
7+
>----<
8+
1| pass
9+
10+
[Domain] = 0:0-1:8
11+
>----------------
12+
0| for v in values:
13+
1| pass
14+
--------<
15+
16+
[Insertion delimiter] = " "
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
match value:
2+
case 1:
3+
a
4+
case _:
5+
b
6+
---
7+
8+
[#1 Content] =
9+
[#1 Removal] = 2:8-2:9
10+
>-<
11+
2| a
12+
13+
[#1 Domain] = 1:4-2:9
14+
>-------
15+
1| case 1:
16+
2| a
17+
---------<
18+
19+
[#1 Insertion delimiter] = " "
20+
21+
22+
[#2 Content] =
23+
[#2 Removal] = 4:8-4:9
24+
>-<
25+
4| b
26+
27+
[#2 Domain] = 3:4-4:9
28+
>-------
29+
3| case _:
30+
4| b
31+
---------<
32+
33+
[#2 Insertion delimiter] = " "
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
1 if True else 0
2+
---
3+
4+
[#1 Content] =
5+
[#1 Removal] =
6+
[#1 Domain] = 0:0-0:1
7+
>-<
8+
0| 1 if True else 0
9+
10+
[#1 Insertion delimiter] = " "
11+
12+
13+
[#2 Content] =
14+
[#2 Removal] = 0:5-0:9
15+
>----<
16+
0| 1 if True else 0
17+
18+
[#2 Domain] = 0:2-0:9
19+
>-------<
20+
0| 1 if True else 0
21+
22+
[#2 Insertion delimiter] = " "
23+
24+
25+
[#3 Content] =
26+
[#3 Removal] = 0:15-0:16
27+
>-<
28+
0| 1 if True else 0
29+
30+
[#3 Domain] = 0:10-0:16
31+
>------<
32+
0| 1 if True else 0
33+
34+
[#3 Insertion delimiter] = " "
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
try:
2+
a
3+
except:
4+
b
5+
finally:
6+
c
7+
---
8+
9+
[#1 Content] =
10+
[#1 Removal] = 1:4-1:5
11+
>-<
12+
1| a
13+
14+
[#1 Domain] = 0:0-1:5
15+
>----
16+
0| try:
17+
1| a
18+
-----<
19+
20+
[#1 Insertion delimiter] = " "
21+
22+
23+
[#2 Content] =
24+
[#2 Removal] = 3:4-3:5
25+
>-<
26+
3| b
27+
28+
[#2 Domain] = 2:0-3:5
29+
>-------
30+
2| except:
31+
3| b
32+
-----<
33+
34+
[#2 Insertion delimiter] = " "
35+
36+
37+
[#3 Content] =
38+
[#3 Removal] = 5:4-5:5
39+
>-<
40+
5| c
41+
42+
[#3 Domain] = 4:0-5:5
43+
>--------
44+
4| finally:
45+
5| c
46+
-----<
47+
48+
[#3 Insertion delimiter] = " "
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
try:
2+
a
3+
except*:
4+
b
5+
---
6+
7+
[#1 Content] =
8+
[#1 Removal] = 1:4-1:5
9+
>-<
10+
1| a
11+
12+
[#1 Domain] = 0:0-1:5
13+
>----
14+
0| try:
15+
1| a
16+
-----<
17+
18+
[#1 Insertion delimiter] = " "
19+
20+
21+
[#2 Content] =
22+
[#2 Removal] = 3:4-3:5
23+
>-<
24+
3| b
25+
26+
[#2 Domain] = 2:0-3:5
27+
>--------
28+
2| except*:
29+
3| b
30+
-----<
31+
32+
[#2 Insertion delimiter] = " "

packages/common/src/scopeSupportFacets/lua.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ export const luaScopeSupport: LanguageScopeSupportFacetMap = {
1616
namedFunction: supported,
1717
disqualifyDelimiter: supported,
1818
"interior.function": supported,
19-
"interior.branch": supported,
19+
"interior.if": supported,
2020
};

packages/common/src/scopeSupportFacets/python.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ export const pythonScopeSupport: LanguageScopeSupportFacetMap = {
4343
"interior.class": supported,
4444
"interior.function": supported,
4545
"interior.lambda": supported,
46+
"interior.if": supported,
47+
"interior.try": supported,
48+
"interior.switchCase": supported,
49+
"interior.ternary": supported,
50+
"interior.loop": supported,
4651

4752
element: notApplicable,
4853
tags: notApplicable,

packages/common/src/scopeSupportFacets/scopeSupportFacetInfos.ts

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -705,6 +705,18 @@ export const scopeSupportFacetInfos: Record<
705705
isIteration: true,
706706
},
707707

708+
"interior.element": {
709+
description: "The interior/children of an XML element",
710+
scopeType: { type: "interior" },
711+
},
712+
"interior.command": {
713+
description: "The body of a Talon command",
714+
scopeType: { type: "interior" },
715+
},
716+
"interior.cell": {
717+
description: "The body of a code cell in markdown",
718+
scopeType: { type: "interior" },
719+
},
708720
"interior.class": {
709721
description: "The body of a class",
710722
scopeType: { type: "interior" },
@@ -717,23 +729,26 @@ export const scopeSupportFacetInfos: Record<
717729
description: "The body of a lambda/anonymous function",
718730
scopeType: { type: "interior" },
719731
},
720-
"interior.branch": {
732+
"interior.if": {
721733
description: "The body of an if/elif/else branch",
722734
scopeType: { type: "interior" },
723735
},
724-
"interior.element": {
725-
description: "The interior/children of an XML element",
736+
"interior.try": {
737+
description: "The body of an try/catch/finally branch",
726738
scopeType: { type: "interior" },
727739
},
728-
"interior.command": {
729-
description: "The body of a Talon command",
740+
"interior.switchCase": {
741+
description: "The body of an switch case branch",
730742
scopeType: { type: "interior" },
731743
},
732-
"interior.cell": {
733-
description: "The body of a code cell in markdown",
744+
"interior.ternary": {
745+
description: "The body of an ternary condition/branch",
746+
scopeType: { type: "interior" },
747+
},
748+
"interior.loop": {
749+
description: "The body of an for/while loop",
734750
scopeType: { type: "interior" },
735751
},
736-
737752
notebookCell: {
738753
description: "A cell in a notebook or a markdown code block",
739754
scopeType: "notebookCell",

0 commit comments

Comments
 (0)