From 2ce105d4a4a42f0282b89ae03e6b457a45e18d8f Mon Sep 17 00:00:00 2001 From: Pokey Rule <755842+pokey@users.noreply.github.com> Date: Fri, 17 May 2024 19:44:39 +0100 Subject: [PATCH] Some tweaks --- .../recorded/languages/cpp/clearName.yml | 19 --------- .../recorded/languages/cpp/takeFunkName.yml | 25 ------------ .../recorded/languages/cpp/takeFunkName2.yml | 25 ------------ .../recorded/languages/cpp/takeFunkName3.yml | 19 --------- .../recorded/languages/cpp/takeName.yml | 25 ------------ .../recorded/languages/cpp/takeName2.yml | 25 ------------ .../recorded/languages/cpp/takeName3.yml | 25 ------------ data/fixtures/scopes/c/functionName.scope | 13 ++++++ data/fixtures/scopes/c/functionName2.scope | 13 ++++++ data/fixtures/scopes/c/functionName3.scope | 17 ++++++++ data/fixtures/scopes/c/functionName4.scope | 17 ++++++++ .../c/name.argument.formal.iteration.scope | 3 ++ .../c/name.argument.formal.iteration2.scope | 3 ++ .../scopes/c/name.argument.formal.scope | 36 +++++++++++++++++ .../scopes/c/name.argument.formal2.scope | 40 +++++++++++++++++++ data/fixtures/scopes/c/name.assignment.scope | 20 ++++++++++ data/fixtures/scopes/c/name.assignment2.scope | 20 ++++++++++ data/fixtures/scopes/c/name.function.scope | 13 ++++++ data/fixtures/scopes/c/name.function2.scope | 13 ++++++ data/fixtures/scopes/c/name.function3.scope | 17 ++++++++ data/fixtures/scopes/c/name.function4.scope | 17 ++++++++ data/fixtures/scopes/c/name.variable.scope | 24 +++++++++++ .../c/value.argument.formal.iteration2.scope | 3 ++ .../scopes/c/value.argument.formal2.scope | 20 ++++++++++ data/fixtures/scopes/c/value.assignment.scope | 20 ++++++++++ .../fixtures/scopes/c/value.assignment2.scope | 20 ++++++++++ data/fixtures/scopes/c/value.variable.scope | 39 ++++++++++++++++++ packages/common/src/scopeSupportFacets/c.ts | 10 +++++ .../scopeSupportFacetInfos.ts | 21 +++++++++- .../scopeSupportFacets.types.ts | 4 ++ queries/c.scm | 30 ++++++++++---- 31 files changed, 425 insertions(+), 171 deletions(-) delete mode 100644 data/fixtures/recorded/languages/cpp/clearName.yml delete mode 100644 data/fixtures/recorded/languages/cpp/takeFunkName.yml delete mode 100644 data/fixtures/recorded/languages/cpp/takeFunkName2.yml delete mode 100644 data/fixtures/recorded/languages/cpp/takeFunkName3.yml delete mode 100644 data/fixtures/recorded/languages/cpp/takeName.yml delete mode 100644 data/fixtures/recorded/languages/cpp/takeName2.yml delete mode 100644 data/fixtures/recorded/languages/cpp/takeName3.yml create mode 100644 data/fixtures/scopes/c/functionName.scope create mode 100644 data/fixtures/scopes/c/functionName2.scope create mode 100644 data/fixtures/scopes/c/functionName3.scope create mode 100644 data/fixtures/scopes/c/functionName4.scope create mode 100644 data/fixtures/scopes/c/name.argument.formal.iteration.scope create mode 100644 data/fixtures/scopes/c/name.argument.formal.iteration2.scope create mode 100644 data/fixtures/scopes/c/name.argument.formal.scope create mode 100644 data/fixtures/scopes/c/name.argument.formal2.scope create mode 100644 data/fixtures/scopes/c/name.assignment.scope create mode 100644 data/fixtures/scopes/c/name.assignment2.scope create mode 100644 data/fixtures/scopes/c/name.function.scope create mode 100644 data/fixtures/scopes/c/name.function2.scope create mode 100644 data/fixtures/scopes/c/name.function3.scope create mode 100644 data/fixtures/scopes/c/name.function4.scope create mode 100644 data/fixtures/scopes/c/name.variable.scope create mode 100644 data/fixtures/scopes/c/value.argument.formal.iteration2.scope create mode 100644 data/fixtures/scopes/c/value.argument.formal2.scope create mode 100644 data/fixtures/scopes/c/value.assignment.scope create mode 100644 data/fixtures/scopes/c/value.assignment2.scope create mode 100644 data/fixtures/scopes/c/value.variable.scope diff --git a/data/fixtures/recorded/languages/cpp/clearName.yml b/data/fixtures/recorded/languages/cpp/clearName.yml deleted file mode 100644 index 888176a4d2..0000000000 --- a/data/fixtures/recorded/languages/cpp/clearName.yml +++ /dev/null @@ -1,19 +0,0 @@ -languageId: cpp -command: - version: 1 - spokenForm: change name - action: clearAndSetSelection - targets: - - type: primitive - modifier: {type: containingScope, scopeType: name, includeSiblings: false} -initialState: - documentContents: a += "world" - selections: - - anchor: {line: 0, character: 6} - active: {line: 0, character: 6} - marks: {} -finalState: - documentContents: " += \"world\"" - selections: - - anchor: {line: 0, character: 0} - active: {line: 0, character: 0} diff --git a/data/fixtures/recorded/languages/cpp/takeFunkName.yml b/data/fixtures/recorded/languages/cpp/takeFunkName.yml deleted file mode 100644 index 9d07df2710..0000000000 --- a/data/fixtures/recorded/languages/cpp/takeFunkName.yml +++ /dev/null @@ -1,25 +0,0 @@ -languageId: cpp -command: - version: 1 - spokenForm: take funk name - action: setSelection - targets: - - type: primitive - modifier: {type: containingScope, scopeType: functionName} -initialState: - documentContents: |- - int f(int a, int b) { - - } - selections: - - anchor: {line: 1, character: 4} - active: {line: 1, character: 4} - marks: {} -finalState: - documentContents: |- - int f(int a, int b) { - - } - selections: - - anchor: {line: 0, character: 4} - active: {line: 0, character: 5} diff --git a/data/fixtures/recorded/languages/cpp/takeFunkName2.yml b/data/fixtures/recorded/languages/cpp/takeFunkName2.yml deleted file mode 100644 index 36a5a4930c..0000000000 --- a/data/fixtures/recorded/languages/cpp/takeFunkName2.yml +++ /dev/null @@ -1,25 +0,0 @@ -languageId: cpp -command: - version: 1 - spokenForm: take funk name - action: setSelection - targets: - - type: primitive - modifier: {type: containingScope, scopeType: functionName} -initialState: - documentContents: |- - int C::f(int a, int b) { - - } - selections: - - anchor: {line: 1, character: 4} - active: {line: 1, character: 4} - marks: {} -finalState: - documentContents: |- - int C::f(int a, int b) { - - } - selections: - - anchor: {line: 0, character: 7} - active: {line: 0, character: 8} diff --git a/data/fixtures/recorded/languages/cpp/takeFunkName3.yml b/data/fixtures/recorded/languages/cpp/takeFunkName3.yml deleted file mode 100644 index 55c3ce9c93..0000000000 --- a/data/fixtures/recorded/languages/cpp/takeFunkName3.yml +++ /dev/null @@ -1,19 +0,0 @@ -languageId: cpp -command: - version: 1 - spokenForm: take funk name - action: setSelection - targets: - - type: primitive - modifier: {type: containingScope, scopeType: functionName} -initialState: - documentContents: int f(int a, int b); - selections: - - anchor: {line: 0, character: 1} - active: {line: 0, character: 1} - marks: {} -finalState: - documentContents: int f(int a, int b); - selections: - - anchor: {line: 0, character: 4} - active: {line: 0, character: 5} diff --git a/data/fixtures/recorded/languages/cpp/takeName.yml b/data/fixtures/recorded/languages/cpp/takeName.yml deleted file mode 100644 index 700328232a..0000000000 --- a/data/fixtures/recorded/languages/cpp/takeName.yml +++ /dev/null @@ -1,25 +0,0 @@ -languageId: cpp -command: - version: 1 - spokenForm: take name - action: setSelection - targets: - - type: primitive - modifier: {type: containingScope, scopeType: name} -initialState: - documentContents: |- - void f() { - int i = 1; - } - selections: - - anchor: {line: 1, character: 13} - active: {line: 1, character: 13} - marks: {} -finalState: - documentContents: |- - void f() { - int i = 1; - } - selections: - - anchor: {line: 1, character: 8} - active: {line: 1, character: 9} diff --git a/data/fixtures/recorded/languages/cpp/takeName2.yml b/data/fixtures/recorded/languages/cpp/takeName2.yml deleted file mode 100644 index ab256c490b..0000000000 --- a/data/fixtures/recorded/languages/cpp/takeName2.yml +++ /dev/null @@ -1,25 +0,0 @@ -languageId: cpp -command: - version: 1 - spokenForm: take name - action: setSelection - targets: - - type: primitive - modifier: {type: containingScope, scopeType: name} -initialState: - documentContents: |- - void f(int i = 1) { - - } - selections: - - anchor: {line: 0, character: 15} - active: {line: 0, character: 15} - marks: {} -finalState: - documentContents: |- - void f(int i = 1) { - - } - selections: - - anchor: {line: 0, character: 11} - active: {line: 0, character: 12} diff --git a/data/fixtures/recorded/languages/cpp/takeName3.yml b/data/fixtures/recorded/languages/cpp/takeName3.yml deleted file mode 100644 index e9c949e65b..0000000000 --- a/data/fixtures/recorded/languages/cpp/takeName3.yml +++ /dev/null @@ -1,25 +0,0 @@ -languageId: cpp -command: - version: 1 - spokenForm: take name - action: setSelection - targets: - - type: primitive - modifier: {type: containingScope, scopeType: name} -initialState: - documentContents: |- - void f(int i = 1) { - - } - selections: - - anchor: {line: 1, character: 4} - active: {line: 1, character: 4} - marks: {} -finalState: - documentContents: |- - void f(int i = 1) { - - } - selections: - - anchor: {line: 0, character: 5} - active: {line: 0, character: 6} diff --git a/data/fixtures/scopes/c/functionName.scope b/data/fixtures/scopes/c/functionName.scope new file mode 100644 index 0000000000..502edc21b0 --- /dev/null +++ b/data/fixtures/scopes/c/functionName.scope @@ -0,0 +1,13 @@ +void C::funcName() {} +--- + +[Content] = +[Removal] = 0:8-0:16 + >--------< +0| void C::funcName() {} + +[Domain] = 0:0-0:21 + >---------------------< +0| void C::funcName() {} + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/c/functionName2.scope b/data/fixtures/scopes/c/functionName2.scope new file mode 100644 index 0000000000..9e40ba4f95 --- /dev/null +++ b/data/fixtures/scopes/c/functionName2.scope @@ -0,0 +1,13 @@ +void C::funcName(); +--- + +[Content] = +[Removal] = 0:8-0:16 + >--------< +0| void C::funcName(); + +[Domain] = 0:0-0:19 + >-------------------< +0| void C::funcName(); + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/c/functionName3.scope b/data/fixtures/scopes/c/functionName3.scope new file mode 100644 index 0000000000..d4efab616e --- /dev/null +++ b/data/fixtures/scopes/c/functionName3.scope @@ -0,0 +1,17 @@ +void aaa() {} +--- + +[Content] = +[Removal] = 0:5-0:8 + >---< +0| void aaa() {} + +[Leading delimiter] = 0:4-0:5 + >-< +0| void aaa() {} + +[Domain] = 0:0-0:13 + >-------------< +0| void aaa() {} + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/c/functionName4.scope b/data/fixtures/scopes/c/functionName4.scope new file mode 100644 index 0000000000..09d348b493 --- /dev/null +++ b/data/fixtures/scopes/c/functionName4.scope @@ -0,0 +1,17 @@ +void aaa(); +--- + +[Content] = +[Removal] = 0:5-0:8 + >---< +0| void aaa(); + +[Leading delimiter] = 0:4-0:5 + >-< +0| void aaa(); + +[Domain] = 0:0-0:11 + >-----------< +0| void aaa(); + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/c/name.argument.formal.iteration.scope b/data/fixtures/scopes/c/name.argument.formal.iteration.scope new file mode 100644 index 0000000000..d49b76ee45 --- /dev/null +++ b/data/fixtures/scopes/c/name.argument.formal.iteration.scope @@ -0,0 +1,3 @@ +void aaa(int bbb, int ccc); +--- + diff --git a/data/fixtures/scopes/c/name.argument.formal.iteration2.scope b/data/fixtures/scopes/c/name.argument.formal.iteration2.scope new file mode 100644 index 0000000000..e28c5c6e1c --- /dev/null +++ b/data/fixtures/scopes/c/name.argument.formal.iteration2.scope @@ -0,0 +1,3 @@ +void aaa(int bbb = 0, int ccc = 0) {} +--- + diff --git a/data/fixtures/scopes/c/name.argument.formal.scope b/data/fixtures/scopes/c/name.argument.formal.scope new file mode 100644 index 0000000000..2e34222a5b --- /dev/null +++ b/data/fixtures/scopes/c/name.argument.formal.scope @@ -0,0 +1,36 @@ +void aaa(int bbb); +--- + +[#1 Content] = +[#1 Removal] = 0:5-0:8 + >---< +0| void aaa(int bbb); + +[#1 Leading delimiter] = 0:4-0:5 + >-< +0| void aaa(int bbb); + +[#1 Domain] = 0:0-0:18 + >------------------< +0| void aaa(int bbb); + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 0:13-0:16 + >---< +0| void aaa(int bbb); + +[#2 Removal] = 0:12-0:16 + >----< +0| void aaa(int bbb); + +[#2 Leading delimiter] = 0:12-0:13 + >-< +0| void aaa(int bbb); + +[#2 Domain] = 0:8-0:17 + >---------< +0| void aaa(int bbb); + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/c/name.argument.formal2.scope b/data/fixtures/scopes/c/name.argument.formal2.scope new file mode 100644 index 0000000000..8dd69a34c2 --- /dev/null +++ b/data/fixtures/scopes/c/name.argument.formal2.scope @@ -0,0 +1,40 @@ +void aaa(int bbb = 0) {} +--- + +[#1 Content] = +[#1 Removal] = 0:5-0:8 + >---< +0| void aaa(int bbb = 0) {} + +[#1 Leading delimiter] = 0:4-0:5 + >-< +0| void aaa(int bbb = 0) {} + +[#1 Domain] = 0:0-0:24 + >------------------------< +0| void aaa(int bbb = 0) {} + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 0:13-0:16 + >---< +0| void aaa(int bbb = 0) {} + +[#2 Removal] = 0:13-0:17 + >----< +0| void aaa(int bbb = 0) {} + +[#2 Leading delimiter] = 0:12-0:13 + >-< +0| void aaa(int bbb = 0) {} + +[#2 Trailing delimiter] = 0:16-0:17 + >-< +0| void aaa(int bbb = 0) {} + +[#2 Domain] = 0:8-0:21 + >-------------< +0| void aaa(int bbb = 0) {} + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/c/name.assignment.scope b/data/fixtures/scopes/c/name.assignment.scope new file mode 100644 index 0000000000..0bdb285198 --- /dev/null +++ b/data/fixtures/scopes/c/name.assignment.scope @@ -0,0 +1,20 @@ +aaa = 0; +--- + +[Content] = 0:0-0:3 + >---< +0| aaa = 0; + +[Removal] = 0:0-0:6 + >------< +0| aaa = 0; + +[Trailing delimiter] = 0:3-0:6 + >---< +0| aaa = 0; + +[Domain] = 0:0-0:7 + >-------< +0| aaa = 0; + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/c/name.assignment2.scope b/data/fixtures/scopes/c/name.assignment2.scope new file mode 100644 index 0000000000..40f9af1ea5 --- /dev/null +++ b/data/fixtures/scopes/c/name.assignment2.scope @@ -0,0 +1,20 @@ +aaa += 0; +--- + +[Content] = 0:0-0:3 + >---< +0| aaa += 0; + +[Removal] = 0:0-0:7 + >-------< +0| aaa += 0; + +[Trailing delimiter] = 0:3-0:7 + >----< +0| aaa += 0; + +[Domain] = 0:0-0:8 + >--------< +0| aaa += 0; + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/c/name.function.scope b/data/fixtures/scopes/c/name.function.scope new file mode 100644 index 0000000000..502edc21b0 --- /dev/null +++ b/data/fixtures/scopes/c/name.function.scope @@ -0,0 +1,13 @@ +void C::funcName() {} +--- + +[Content] = +[Removal] = 0:8-0:16 + >--------< +0| void C::funcName() {} + +[Domain] = 0:0-0:21 + >---------------------< +0| void C::funcName() {} + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/c/name.function2.scope b/data/fixtures/scopes/c/name.function2.scope new file mode 100644 index 0000000000..9e40ba4f95 --- /dev/null +++ b/data/fixtures/scopes/c/name.function2.scope @@ -0,0 +1,13 @@ +void C::funcName(); +--- + +[Content] = +[Removal] = 0:8-0:16 + >--------< +0| void C::funcName(); + +[Domain] = 0:0-0:19 + >-------------------< +0| void C::funcName(); + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/c/name.function3.scope b/data/fixtures/scopes/c/name.function3.scope new file mode 100644 index 0000000000..d4efab616e --- /dev/null +++ b/data/fixtures/scopes/c/name.function3.scope @@ -0,0 +1,17 @@ +void aaa() {} +--- + +[Content] = +[Removal] = 0:5-0:8 + >---< +0| void aaa() {} + +[Leading delimiter] = 0:4-0:5 + >-< +0| void aaa() {} + +[Domain] = 0:0-0:13 + >-------------< +0| void aaa() {} + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/c/name.function4.scope b/data/fixtures/scopes/c/name.function4.scope new file mode 100644 index 0000000000..09d348b493 --- /dev/null +++ b/data/fixtures/scopes/c/name.function4.scope @@ -0,0 +1,17 @@ +void aaa(); +--- + +[Content] = +[Removal] = 0:5-0:8 + >---< +0| void aaa(); + +[Leading delimiter] = 0:4-0:5 + >-< +0| void aaa(); + +[Domain] = 0:0-0:11 + >-----------< +0| void aaa(); + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/c/name.variable.scope b/data/fixtures/scopes/c/name.variable.scope new file mode 100644 index 0000000000..f07546c69d --- /dev/null +++ b/data/fixtures/scopes/c/name.variable.scope @@ -0,0 +1,24 @@ +int aaa = 0; +--- + +[Content] = 0:4-0:7 + >---< +0| int aaa = 0; + +[Removal] = 0:4-0:8 + >----< +0| int aaa = 0; + +[Leading delimiter] = 0:3-0:4 + >-< +0| int aaa = 0; + +[Trailing delimiter] = 0:7-0:8 + >-< +0| int aaa = 0; + +[Domain] = 0:0-0:12 + >------------< +0| int aaa = 0; + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/c/value.argument.formal.iteration2.scope b/data/fixtures/scopes/c/value.argument.formal.iteration2.scope new file mode 100644 index 0000000000..e28c5c6e1c --- /dev/null +++ b/data/fixtures/scopes/c/value.argument.formal.iteration2.scope @@ -0,0 +1,3 @@ +void aaa(int bbb = 0, int ccc = 0) {} +--- + diff --git a/data/fixtures/scopes/c/value.argument.formal2.scope b/data/fixtures/scopes/c/value.argument.formal2.scope new file mode 100644 index 0000000000..977b50cd2e --- /dev/null +++ b/data/fixtures/scopes/c/value.argument.formal2.scope @@ -0,0 +1,20 @@ +void aaa(int bbb = 0) {} +--- + +[Content] = 0:19-0:20 + >-< +0| void aaa(int bbb = 0) {} + +[Removal] = 0:18-0:20 + >--< +0| void aaa(int bbb = 0) {} + +[Leading delimiter] = 0:18-0:19 + >-< +0| void aaa(int bbb = 0) {} + +[Domain] = 0:9-0:20 + >-----------< +0| void aaa(int bbb = 0) {} + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/c/value.assignment.scope b/data/fixtures/scopes/c/value.assignment.scope new file mode 100644 index 0000000000..a563272d9a --- /dev/null +++ b/data/fixtures/scopes/c/value.assignment.scope @@ -0,0 +1,20 @@ +aaa = 0; +--- + +[Content] = 0:6-0:7 + >-< +0| aaa = 0; + +[Removal] = 0:3-0:7 + >----< +0| aaa = 0; + +[Leading delimiter] = 0:3-0:6 + >---< +0| aaa = 0; + +[Domain] = 0:0-0:7 + >-------< +0| aaa = 0; + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/c/value.assignment2.scope b/data/fixtures/scopes/c/value.assignment2.scope new file mode 100644 index 0000000000..15a729096a --- /dev/null +++ b/data/fixtures/scopes/c/value.assignment2.scope @@ -0,0 +1,20 @@ +aaa += 0; +--- + +[Content] = 0:7-0:8 + >-< +0| aaa += 0; + +[Removal] = 0:3-0:8 + >-----< +0| aaa += 0; + +[Leading delimiter] = 0:3-0:7 + >----< +0| aaa += 0; + +[Domain] = 0:0-0:8 + >--------< +0| aaa += 0; + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/c/value.variable.scope b/data/fixtures/scopes/c/value.variable.scope new file mode 100644 index 0000000000..391ca48e74 --- /dev/null +++ b/data/fixtures/scopes/c/value.variable.scope @@ -0,0 +1,39 @@ +int aaa = 0; +--- + +[#1 Content] = 0:10-0:11 + >-< +0| int aaa = 0; + +[#1 Removal] = 0:9-0:11 + >--< +0| int aaa = 0; + +[#1 Leading delimiter] = 0:9-0:10 + >-< +0| int aaa = 0; + +[#1 Domain] = 0:0-0:12 + >------------< +0| int aaa = 0; + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 0:10-0:11 + >-< +0| int aaa = 0; + +[#2 Removal] = 0:9-0:11 + >--< +0| int aaa = 0; + +[#2 Leading delimiter] = 0:9-0:10 + >-< +0| int aaa = 0; + +[#2 Domain] = 0:4-0:11 + >-------< +0| int aaa = 0; + +[#2 Insertion delimiter] = " " diff --git a/packages/common/src/scopeSupportFacets/c.ts b/packages/common/src/scopeSupportFacets/c.ts index 9b6990b4b6..39465c535a 100644 --- a/packages/common/src/scopeSupportFacets/c.ts +++ b/packages/common/src/scopeSupportFacets/c.ts @@ -12,4 +12,14 @@ export const cScopeSupport: LanguageScopeSupportFacetMap = { ifStatement: supported, "comment.line": supported, "string.singleLine": supported, + "name.function": supported, + functionName: supported, + "name.argument.formal": supported, + "value.argument.formal": supported, + "name.argument.formal.iteration": supported, + "value.argument.formal.iteration": supported, + "name.variable": supported, + "value.variable": supported, + "name.assignment": supported, + "value.assignment": supported, }; diff --git a/packages/common/src/scopeSupportFacets/scopeSupportFacetInfos.ts b/packages/common/src/scopeSupportFacets/scopeSupportFacetInfos.ts index 0a2b2484af..a9c36ccf04 100644 --- a/packages/common/src/scopeSupportFacets/scopeSupportFacetInfos.ts +++ b/packages/common/src/scopeSupportFacets/scopeSupportFacetInfos.ts @@ -258,7 +258,16 @@ export const scopeSupportFacetInfos: Record< scopeType: "name", isIteration: true, }, - + "name.argument.formal": { + description: "The name of a parameter in a function declaration", + scopeType: "name", + }, + "name.argument.formal.iteration": { + description: + "Iteration scope of the names of the formal parameters of a function declaration; should be the whole parameter list", + scopeType: "name", + isIteration: true, + }, "key.attribute": { description: "Key (LHS) of an attribute eg in an xml element", scopeType: "collectionKey", @@ -326,6 +335,16 @@ export const scopeSupportFacetInfos: Record< scopeType: "value", isIteration: true, }, + "value.argument.formal": { + description: "The value of a parameter in a function declaration", + scopeType: "value", + }, + "value.argument.formal.iteration": { + description: + "Iteration scope of the names of the formal parameters of a function declaration; should be the whole parameter list", + scopeType: "value", + isIteration: true, + }, "type.variable": { description: "Type of variable in a variable declaration", diff --git a/packages/common/src/scopeSupportFacets/scopeSupportFacets.types.ts b/packages/common/src/scopeSupportFacets/scopeSupportFacets.types.ts index 7d4cc51c76..fe0ae6eca9 100644 --- a/packages/common/src/scopeSupportFacets/scopeSupportFacets.types.ts +++ b/packages/common/src/scopeSupportFacets/scopeSupportFacets.types.ts @@ -67,6 +67,8 @@ const scopeSupportFacets = [ "name.field", "name.resource", "name.resource.iteration", + "name.argument.formal", + "name.argument.formal.iteration", "key.attribute", "key.mapPair", @@ -84,6 +86,8 @@ const scopeSupportFacets = [ "value.yield", "value.resource", "value.resource.iteration", + "value.argument.formal", + "value.argument.formal.iteration", "type.variable", "type.formalParameter", diff --git a/queries/c.scm b/queries/c.scm index 2d47183a7a..fba9d9f486 100644 --- a/queries/c.scm +++ b/queries/c.scm @@ -64,11 +64,21 @@ ;;!! void funcName(); (declaration (function_declarator - declarator: (_) @functionName + declarator: (_ + !name + ) @functionName ) ) @namedFunction @functionName.domain ;;!! void C::funcName() {} +(declaration + (function_declarator + declarator: (_ + name: (_) @functionName + ) + ) +) @namedFunction @functionName.domain + (function_definition declarator: (_ declarator: (_ @@ -117,10 +127,13 @@ ) @_.domain (_ - declarator: (_ - name: (_) @name - ) -) @_.domain + (_ + declarator: (_ + name: (_) @name + ) + ) @_.domain + !declarator +) (_ declarator: (_ @@ -142,8 +155,11 @@ ) @_.domain (_ - name: (_) @name -) @_.domain + (_ + name: (_) @name + ) @_.domain + !declarator +) ;; > curl https://raw.githubusercontent.com/tree-sitter/tree-sitter-cpp/master/src/node-types.json | jq '[.[] | select(.type == "_type_specifier") | .subtypes[].type]' [