Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added interior scopes to python #2814

Merged
merged 4 commits into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions data/fixtures/scopes/python/interior.if.scope
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
if True:
a
elif False:
b
else:
c
---

[#1 Content] =
[#1 Removal] = 1:4-1:5
>-<
1| a

[#1 Domain] = 0:0-1:5
>--------
0| if True:
1| a
-----<

[#1 Insertion delimiter] = " "


[#2 Content] =
[#2 Removal] = 3:4-3:5
>-<
3| b

[#2 Domain] = 2:0-3:5
>-----------
2| elif False:
3| b
-----<

[#2 Insertion delimiter] = " "


[#3 Content] =
[#3 Removal] = 5:4-5:5
>-<
5| c

[#3 Domain] = 4:0-5:5
>-----
4| else:
5| c
-----<

[#3 Insertion delimiter] = " "
16 changes: 16 additions & 0 deletions data/fixtures/scopes/python/interior.loop.scope
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
for v in values:
pass
---

[Content] =
[Removal] = 1:4-1:8
>----<
1| pass

[Domain] = 0:0-1:8
>----------------
0| for v in values:
1| pass
--------<

[Insertion delimiter] = " "
16 changes: 16 additions & 0 deletions data/fixtures/scopes/python/interior.loop2.scope
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
while True:
pass
---

[Content] =
[Removal] = 1:4-1:8
>----<
1| pass

[Domain] = 0:0-1:8
>-----------
0| while True:
1| pass
--------<

[Insertion delimiter] = " "
62 changes: 62 additions & 0 deletions data/fixtures/scopes/python/interior.switchCase.scope
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
match value:
case 1:
a
case _:
b
---

[#1 Content] = 1:4-4:9
>-------
1| case 1:
2| a
3| case _:
4| b
---------<

[#1 Removal] = 0:12-4:9
>
0| match value:
1| case 1:
2| a
3| case _:
4| b
---------<

[#1 Domain] = 0:0-4:9
>------------
0| match value:
1| case 1:
2| a
3| case _:
4| b
---------<

[#1 Insertion delimiter] = " "


[#2 Content] =
[#2 Removal] = 2:8-2:9
>-<
2| a

[#2 Domain] = 1:4-2:9
>-------
1| case 1:
2| a
---------<

[#2 Insertion delimiter] = " "


[#3 Content] =
[#3 Removal] = 4:8-4:9
>-<
4| b

[#3 Domain] = 3:4-4:9
>-------
3| case _:
4| b
---------<

[#3 Insertion delimiter] = " "
34 changes: 34 additions & 0 deletions data/fixtures/scopes/python/interior.ternary.scope
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
1 if True else 0
---

[#1 Content] =
[#1 Removal] =
[#1 Domain] = 0:0-0:1
>-<
0| 1 if True else 0

[#1 Insertion delimiter] = " "


[#2 Content] =
[#2 Removal] = 0:5-0:9
>----<
0| 1 if True else 0

[#2 Domain] = 0:2-0:9
>-------<
0| 1 if True else 0

[#2 Insertion delimiter] = " "


[#3 Content] =
[#3 Removal] = 0:15-0:16
>-<
0| 1 if True else 0

[#3 Domain] = 0:10-0:16
>------<
0| 1 if True else 0

[#3 Insertion delimiter] = " "
48 changes: 48 additions & 0 deletions data/fixtures/scopes/python/interior.try.scope
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
try:
a
except:
b
finally:
c
---

[#1 Content] =
[#1 Removal] = 1:4-1:5
>-<
1| a

[#1 Domain] = 0:0-1:5
>----
0| try:
1| a
-----<

[#1 Insertion delimiter] = " "


[#2 Content] =
[#2 Removal] = 3:4-3:5
>-<
3| b

[#2 Domain] = 2:0-3:5
>-------
2| except:
3| b
-----<

[#2 Insertion delimiter] = " "


[#3 Content] =
[#3 Removal] = 5:4-5:5
>-<
5| c

[#3 Domain] = 4:0-5:5
>--------
4| finally:
5| c
-----<

[#3 Insertion delimiter] = " "
32 changes: 32 additions & 0 deletions data/fixtures/scopes/python/interior.try2.scope
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
try:
a
except*:
b
---

[#1 Content] =
[#1 Removal] = 1:4-1:5
>-<
1| a

[#1 Domain] = 0:0-1:5
>----
0| try:
1| a
-----<

[#1 Insertion delimiter] = " "


[#2 Content] =
[#2 Removal] = 3:4-3:5
>-<
3| b

[#2 Domain] = 2:0-3:5
>--------
2| except*:
3| b
-----<

[#2 Insertion delimiter] = " "
16 changes: 16 additions & 0 deletions data/fixtures/scopes/python/interior.with.scope
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
with file:
pass
---

[Content] =
[Removal] = 1:4-1:8
>----<
1| pass

[Domain] = 0:0-1:8
>----------
0| with file:
1| pass
--------<

[Insertion delimiter] = " "
2 changes: 1 addition & 1 deletion packages/common/src/scopeSupportFacets/lua.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ export const luaScopeSupport: LanguageScopeSupportFacetMap = {
namedFunction: supported,
disqualifyDelimiter: supported,
"interior.function": supported,
"interior.branch": supported,
"interior.if": supported,
};
6 changes: 6 additions & 0 deletions packages/common/src/scopeSupportFacets/python.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ export const pythonScopeSupport: LanguageScopeSupportFacetMap = {
"interior.class": supported,
"interior.function": supported,
"interior.lambda": supported,
"interior.if": supported,
"interior.try": supported,
"interior.switchCase": supported,
"interior.ternary": supported,
"interior.loop": supported,
"interior.with": supported,

element: notApplicable,
tags: notApplicable,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,18 @@ export const scopeSupportFacetInfos: Record<
isIteration: true,
},

"interior.element": {
description: "The interior/children of an XML element",
scopeType: { type: "interior" },
},
"interior.command": {
description: "The body of a Talon command",
scopeType: { type: "interior" },
},
"interior.cell": {
description: "The body of a code cell in markdown",
scopeType: { type: "interior" },
},
"interior.class": {
description: "The body of a class",
scopeType: { type: "interior" },
Expand All @@ -717,20 +729,28 @@ export const scopeSupportFacetInfos: Record<
description: "The body of a lambda/anonymous function",
scopeType: { type: "interior" },
},
"interior.branch": {
"interior.if": {
description: "The body of an if/elif/else branch",
scopeType: { type: "interior" },
},
"interior.element": {
description: "The interior/children of an XML element",
"interior.try": {
description: "The body of an try/catch/finally branch",
scopeType: { type: "interior" },
},
"interior.command": {
description: "The body of a Talon command",
"interior.switchCase": {
description: "The body of an switch case branch",
scopeType: { type: "interior" },
},
"interior.cell": {
description: "The body of a code cell in markdown",
"interior.ternary": {
description: "The body of an ternary condition/branch",
scopeType: { type: "interior" },
},
"interior.loop": {
description: "The body of an for/while loop",
scopeType: { type: "interior" },
},
"interior.with": {
description: "The body of an with/use/using statement",
scopeType: { type: "interior" },
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,15 @@ export const scopeSupportFacets = [
"interior.class",
"interior.function",
"interior.lambda",
"interior.branch",
"interior.element",
"interior.command",
"interior.cell",
"interior.if",
"interior.try",
"interior.switchCase",
"interior.ternary",
"interior.loop",
"interior.with",

"notebookCell",

Expand Down
Loading
Loading