Skip to content

Commit

Permalink
Added function scope test to python (#2325)
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreasArvidsson authored May 12, 2024
1 parent 8b51d18 commit bccc6d8
Show file tree
Hide file tree
Showing 13 changed files with 69 additions and 186 deletions.
29 changes: 0 additions & 29 deletions data/fixtures/recorded/languages/python/clearCoreFunk.yml

This file was deleted.

27 changes: 0 additions & 27 deletions data/fixtures/recorded/languages/python/clearCoreFunk2.yml

This file was deleted.

25 changes: 0 additions & 25 deletions data/fixtures/recorded/languages/python/takeFunk.yml

This file was deleted.

27 changes: 0 additions & 27 deletions data/fixtures/recorded/languages/python/takeFunk2.yml

This file was deleted.

23 changes: 0 additions & 23 deletions data/fixtures/recorded/languages/python/takeLambda.yml

This file was deleted.

27 changes: 0 additions & 27 deletions data/fixtures/recorded/languages/python/takeLambdaMade.yml

This file was deleted.

27 changes: 0 additions & 27 deletions data/fixtures/recorded/languages/python/takeLambdaPit.yml

This file was deleted.

14 changes: 14 additions & 0 deletions data/fixtures/scopes/python/anonymousFunction.scope
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
lambda: pass
---

[Content] =
[Removal] =
[Domain] = 0:0-0:12
>------------<
0| lambda: pass

[Interior] = 0:8-0:12
>----<
0| lambda: pass

[Insertion delimiter] = "\n"
14 changes: 14 additions & 0 deletions data/fixtures/scopes/python/anonymousFunction2.scope
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
lambda x: x
---

[Content] =
[Removal] =
[Domain] = 0:0-0:11
>-----------<
0| lambda x: x

[Interior] = 0:10-0:11
>-<
0| lambda x: x

[Insertion delimiter] = "\n"
17 changes: 17 additions & 0 deletions data/fixtures/scopes/python/namedFunction.scope
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
def foo():
pass
---

[Content] =
[Removal] =
[Domain] = 0:0-1:8
>----------
0| def foo():
1| pass
--------<

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

[Insertion delimiter] = "\n\n"
19 changes: 19 additions & 0 deletions data/fixtures/scopes/python/namedFunction2.scope
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
@foo
def bar(value: string) -> str:
return value
---

[Content] =
[Removal] =
[Domain] = 0:0-2:16
>----
0| @foo
1| def bar(value: string) -> str:
2| return value
----------------<

[Interior] = 2:4-2:16
>------------<
2| return value

[Insertion delimiter] = "\n\n"
2 changes: 2 additions & 0 deletions packages/common/src/scopeSupportFacets/python.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ export const pythonScopeSupport: LanguageScopeSupportFacetMap = {
"value.yield": supported,
"value.resource": supported,
"value.resource.iteration": supported,
namedFunction: supported,
anonymousFunction: supported,

"argument.actual": supportedLegacy,
"argument.actual.iteration": supportedLegacy,
Expand Down
4 changes: 3 additions & 1 deletion queries/python.scm
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,9 @@

;;!! lambda _: pass
;;! ^^^^^^^^^^^^^^
(lambda) @anonymousFunction
(lambda
body: (_) @anonymousFunction.interior
) @anonymousFunction

;;!! match value:
;;! ^^^^^
Expand Down

0 comments on commit bccc6d8

Please sign in to comment.