Skip to content
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
aaa(bbb=0, ccc=1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Names come from compiler history -- an "actual" parameter is where it is passed, a formal parameter is where it is defined in the function definition (if there is one)

---

[#1 Range] =
[#1 Domain] = 0:0-0:17
>-----------------<
0| aaa(bbb=0, ccc=1)


[#2 Range] = 0:4-0:16
>------------<
0| aaa(bbb=0, ccc=1)

[#2 Domain] = 0:3-0:17
>--------------<
0| aaa(bbb=0, ccc=1)
29 changes: 29 additions & 0 deletions data/fixtures/scopes/python/name.argument.actual.scope
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
aaa(bbb=0, ccc=1)
---

[#1 Content] =
[#1 Removal] = 0:4-0:7
>---<
0| aaa(bbb=0, ccc=1)

[#1 Domain] = 0:4-0:9
>-----<
0| aaa(bbb=0, ccc=1)

[#1 Insertion delimiter] = " "


[#2 Content] =
[#2 Removal] = 0:11-0:14
>---<
0| aaa(bbb=0, ccc=1)

[#2 Leading delimiter] = 0:10-0:11
>-<
0| aaa(bbb=0, ccc=1)

[#2 Domain] = 0:11-0:16
>-----<
0| aaa(bbb=0, ccc=1)

[#2 Insertion delimiter] = " "
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
aaa(bbb=0, ccc=1)
---

[#1 Range] =
[#1 Domain] = 0:0-0:17
>-----------------<
0| aaa(bbb=0, ccc=1)


[#2 Range] = 0:4-0:16
>------------<
0| aaa(bbb=0, ccc=1)

[#2 Domain] = 0:3-0:17
>--------------<
0| aaa(bbb=0, ccc=1)
39 changes: 39 additions & 0 deletions data/fixtures/scopes/python/value.argument.actual.scope
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
aaa(bbb=0, ccc=1)
---

[#1 Content] = 0:8-0:9
>-<
0| aaa(bbb=0, ccc=1)

[#1 Removal] = 0:7-0:9
>--<
0| aaa(bbb=0, ccc=1)

[#1 Leading delimiter] = 0:7-0:8
>-<
0| aaa(bbb=0, ccc=1)

[#1 Domain] = 0:4-0:9
>-----<
0| aaa(bbb=0, ccc=1)

[#1 Insertion delimiter] = " "


[#2 Content] = 0:15-0:16
>-<
0| aaa(bbb=0, ccc=1)

[#2 Removal] = 0:14-0:16
>--<
0| aaa(bbb=0, ccc=1)

[#2 Leading delimiter] = 0:14-0:15
>-<
0| aaa(bbb=0, ccc=1)

[#2 Domain] = 0:11-0:16
>-----<
0| aaa(bbb=0, ccc=1)

[#2 Insertion delimiter] = " "
6 changes: 6 additions & 0 deletions packages/common/src/scopeSupportFacets/python.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,16 @@ export const pythonScopeSupport: LanguageScopeSupportFacetMap = {
"name.foreach": supported,
"name.resource": supported,
"name.resource.iteration": supported,
"name.argument.actual": supported,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NB: we could extend this to other languages that support keyword arguments like ruby, but we need to have familiarity with them. A quick check of

(hash) @map
shows that it doesn't even support argument yet

"name.argument.actual.iteration": supported,

"value.foreach": supported,
"value.yield": supported,
"value.resource": supported,
"value.resource.iteration": supported,
"value.argument.actual": supported,
"value.argument.actual.iteration": supported,

namedFunction: supported,
anonymousFunction: supported,
disqualifyDelimiter: supported,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,16 @@ export const scopeSupportFacetInfos: Record<
scopeType: "name",
isIteration: true,
},
"name.argument.actual": {
description: "The name of a (keyword) argument in a function call",
scopeType: "name",
},
"name.argument.actual.iteration": {
description:
"Iteration scope of the names of the actual parameters of a function call; should be the whole arguments list",
scopeType: "name",
isIteration: true,
},
"name.argument.formal": {
description: "The name of a parameter in a function declaration",
scopeType: "name",
Expand Down Expand Up @@ -556,7 +566,7 @@ export const scopeSupportFacetInfos: Record<
isIteration: true,
},
"value.argument.formal": {
description: "The value of a parameter in a function declaration",
description: "The value of a (keyword) argument in a function declaration",
scopeType: "value",
},
"value.argument.formal.iteration": {
Expand All @@ -565,6 +575,16 @@ export const scopeSupportFacetInfos: Record<
scopeType: "value",
isIteration: true,
},
"value.argument.actual": {
description: "The value of a argument in a function call",
scopeType: "value",
},
"value.argument.actual.iteration": {
description:
"Iteration scope of the values of the actual parameters of a function call; should be the whole arguments list",
scopeType: "value",
isIteration: true,
},
"value.argument.formal.method": {
description: "The value of a parameter in a class method declaration",
scopeType: "value",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ export const scopeSupportFacets = [
"name.field",
"name.resource",
"name.resource.iteration",
"name.argument.actual",
"name.argument.actual.iteration",
"name.argument.formal",
"name.argument.formal.iteration",
"name.argument.formal.method",
Expand All @@ -141,6 +143,8 @@ export const scopeSupportFacets = [
"value.yield",
"value.resource",
"value.resource.iteration",
"value.argument.actual",
"value.argument.actual.iteration",
"value.argument.formal",
"value.argument.formal.iteration",
"value.argument.formal.method",
Expand Down
6 changes: 3 additions & 3 deletions queries/python.scm
Original file line number Diff line number Diff line change
Expand Up @@ -626,9 +626,9 @@
) @argumentOrParameter.iteration.domain

(argument_list
"(" @argumentOrParameter.iteration.start.endOf
")" @argumentOrParameter.iteration.end.startOf
) @argumentOrParameter.iteration.domain
"(" @argumentOrParameter.iteration.start.endOf @name.iteration.start.endOf @value.iteration.start.endOf
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NB: Andreas says there's a limit of three captures on each node and more are silently discarded by tree-sitter, so beware.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally we should lint this - or adding to SCM tests

")" @argumentOrParameter.iteration.end.startOf @name.iteration.end.startOf @value.iteration.end.startOf
) @argumentOrParameter.iteration.domain @name.iteration.domain @value.iteration.domain

(call
(generator_expression
Expand Down
Loading