Skip to content

Commit

Permalink
Add support for yield statements for "value" in Python (#2215)
Browse files Browse the repository at this point in the history
  • Loading branch information
pokey authored Feb 1, 2024
1 parent be6ab53 commit aed028e
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/common/src/scopeSupportFacets/python.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const pythonScopeSupport: LanguageScopeSupportFacetMap = {
"name.resource": supported,
"name.resource.iteration": supported,
"value.foreach": supported,
"value.yield": supported,
"value.resource": supported,
"value.resource.iteration": supported,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,10 @@ export const scopeSupportFacetInfos: Record<
description: "Value (RHS) of a field in a class / interface",
scopeType: "value",
},
"value.yield": {
description: "Value of a yield statement",
scopeType: "value",
},
"value.resource": {
description: "Value of a 'with' / 'use' / 'using' statement",
scopeType: "value",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ const scopeSupportFacets = [
"value.return",
"value.return.lambda",
"value.field",
"value.yield",
"value.resource",
"value.resource.iteration",

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
def aaa():
yield bbb
---

[Content] = 1:10-1:13
1| yield bbb
>---<

[Removal] = 1:9-1:13
1| yield bbb
>----<

[Leading delimiter] = 1:9-1:10
1| yield bbb
>-<

[Domain] = 1:4-1:13
1| yield bbb
>---------<

[Insertion delimiter] = " "
12 changes: 12 additions & 0 deletions queries/python.scm
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,18 @@
(_) @value
) @_.domain

;;!! yield 1
;;! ^
;;! xx
;;! -------
;;
;; NOTE: in tree-sitter, both "yield" and the "1" are children of `yield` but
;; "yield" is anonymous whereas "1" is named node, so no need to exclude
;; explicitly
(yield
(_) @value
) @_.domain

;;!! with aaa:
;;! ^^^
;;! --------
Expand Down

0 comments on commit aed028e

Please sign in to comment.