From 9c92d3ee73c33b246cd74e55e028909abe074e10 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Sat, 25 Jan 2025 07:05:41 +0100 Subject: [PATCH] Added iteration scope for python arguments --- .../name.argument.actual.iteration.scope | 16 ++++++++ .../scopes/python/name.argument.actual.scope | 29 ++++++++++++++ .../value.argument.actual.iteration.scope | 16 ++++++++ .../scopes/python/value.argument.actual.scope | 39 +++++++++++++++++++ .../common/src/scopeSupportFacets/python.ts | 6 +++ .../scopeSupportFacetInfos.ts | 22 ++++++++++- .../scopeSupportFacets.types.ts | 4 ++ queries/python.scm | 6 +-- 8 files changed, 134 insertions(+), 4 deletions(-) create mode 100644 data/fixtures/scopes/python/name.argument.actual.iteration.scope create mode 100644 data/fixtures/scopes/python/name.argument.actual.scope create mode 100644 data/fixtures/scopes/python/value.argument.actual.iteration.scope create mode 100644 data/fixtures/scopes/python/value.argument.actual.scope diff --git a/data/fixtures/scopes/python/name.argument.actual.iteration.scope b/data/fixtures/scopes/python/name.argument.actual.iteration.scope new file mode 100644 index 0000000000..f944e40b4b --- /dev/null +++ b/data/fixtures/scopes/python/name.argument.actual.iteration.scope @@ -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) diff --git a/data/fixtures/scopes/python/name.argument.actual.scope b/data/fixtures/scopes/python/name.argument.actual.scope new file mode 100644 index 0000000000..12a9e7017a --- /dev/null +++ b/data/fixtures/scopes/python/name.argument.actual.scope @@ -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] = " " diff --git a/data/fixtures/scopes/python/value.argument.actual.iteration.scope b/data/fixtures/scopes/python/value.argument.actual.iteration.scope new file mode 100644 index 0000000000..f944e40b4b --- /dev/null +++ b/data/fixtures/scopes/python/value.argument.actual.iteration.scope @@ -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) diff --git a/data/fixtures/scopes/python/value.argument.actual.scope b/data/fixtures/scopes/python/value.argument.actual.scope new file mode 100644 index 0000000000..01ee1717d2 --- /dev/null +++ b/data/fixtures/scopes/python/value.argument.actual.scope @@ -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] = " " diff --git a/packages/common/src/scopeSupportFacets/python.ts b/packages/common/src/scopeSupportFacets/python.ts index 05f5bd400b..7df0aa9c71 100644 --- a/packages/common/src/scopeSupportFacets/python.ts +++ b/packages/common/src/scopeSupportFacets/python.ts @@ -7,10 +7,16 @@ export const pythonScopeSupport: LanguageScopeSupportFacetMap = { "name.foreach": supported, "name.resource": supported, "name.resource.iteration": supported, + "name.argument.actual": supported, + "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, diff --git a/packages/common/src/scopeSupportFacets/scopeSupportFacetInfos.ts b/packages/common/src/scopeSupportFacets/scopeSupportFacetInfos.ts index 12b1b412e1..8c3341452b 100644 --- a/packages/common/src/scopeSupportFacets/scopeSupportFacetInfos.ts +++ b/packages/common/src/scopeSupportFacets/scopeSupportFacetInfos.ts @@ -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", @@ -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": { @@ -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", diff --git a/packages/common/src/scopeSupportFacets/scopeSupportFacets.types.ts b/packages/common/src/scopeSupportFacets/scopeSupportFacets.types.ts index 671d1efefe..11d1d4bd5e 100644 --- a/packages/common/src/scopeSupportFacets/scopeSupportFacets.types.ts +++ b/packages/common/src/scopeSupportFacets/scopeSupportFacets.types.ts @@ -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", @@ -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", diff --git a/queries/python.scm b/queries/python.scm index f5e61291d0..6a98b0dbcd 100644 --- a/queries/python.scm +++ b/queries/python.scm @@ -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 + ")" @argumentOrParameter.iteration.end.startOf @name.iteration.end.startOf @value.iteration.end.startOf +) @argumentOrParameter.iteration.domain @name.iteration.domain @value.iteration.domain (call (generator_expression