From 0e77a7dfbf2e636c24a61aeba6b60b35d76d2bd9 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Thu, 3 Jul 2025 10:41:56 +0200 Subject: [PATCH] Added argument.catch facet --- .../scopes/csharp/argument.catch.scope | 21 +++++ .../scopes/csharp/name.argument.catch.scope | 41 ++++++++++ .../scopes/csharp/type.argument.catch.scope | 41 ++++++++++ .../fixtures/scopes/java/argument.catch.scope | 21 +++++ .../scopes/java/name.argument.catch.scope | 41 ++++++++++ .../scopes/java/type.argument.catch.scope | 49 ++++++++++++ .../javascript.core/argument.catch.scope | 11 +++ .../branch.try.iteration.scope | 30 +++----- .../scopes/javascript.core/branch.try.scope | 77 +++++++------------ .../javascript.core/name.argument.catch.scope | 11 +++ .../scopes/python/argument.catch.scope | 38 +++++++++ .../scopes/python/name.argument.catch.scope | 44 +++++++++++ .../scopes/python/type.argument.catch.scope | 52 +++++++++++++ .../typescript.core/argument.catch.scope | 11 +++ .../typescript.core/type.argument.catch.scope | 21 +++++ packages/common/src/scopeSupportFacets/c.ts | 3 + .../common/src/scopeSupportFacets/csharp.ts | 3 + packages/common/src/scopeSupportFacets/css.ts | 11 ++- .../common/src/scopeSupportFacets/html.ts | 11 ++- .../common/src/scopeSupportFacets/java.ts | 3 + .../src/scopeSupportFacets/javascript.ts | 3 + .../common/src/scopeSupportFacets/json.ts | 11 ++- .../common/src/scopeSupportFacets/markdown.ts | 11 ++- .../common/src/scopeSupportFacets/python.ts | 3 + packages/common/src/scopeSupportFacets/scm.ts | 11 ++- .../scopeSupportFacetInfos.ts | 20 ++++- .../scopeSupportFacets.types.ts | 3 + .../common/src/scopeSupportFacets/talon.ts | 11 ++- .../src/scopeSupportFacets/typescript.ts | 1 + packages/common/src/scopeSupportFacets/xml.ts | 11 ++- .../common/src/scopeSupportFacets/yaml.ts | 11 ++- queries/csharp.scm | 12 ++- queries/java.scm | 9 +++ queries/javascript.scm | 6 ++ queries/python.scm | 11 +++ queries/typescript.core.scm | 19 +++++ 36 files changed, 595 insertions(+), 98 deletions(-) create mode 100644 data/fixtures/scopes/csharp/argument.catch.scope create mode 100644 data/fixtures/scopes/csharp/name.argument.catch.scope create mode 100644 data/fixtures/scopes/csharp/type.argument.catch.scope create mode 100644 data/fixtures/scopes/java/argument.catch.scope create mode 100644 data/fixtures/scopes/java/name.argument.catch.scope create mode 100644 data/fixtures/scopes/java/type.argument.catch.scope create mode 100644 data/fixtures/scopes/javascript.core/argument.catch.scope create mode 100644 data/fixtures/scopes/javascript.core/name.argument.catch.scope create mode 100644 data/fixtures/scopes/python/argument.catch.scope create mode 100644 data/fixtures/scopes/python/name.argument.catch.scope create mode 100644 data/fixtures/scopes/python/type.argument.catch.scope create mode 100644 data/fixtures/scopes/typescript.core/argument.catch.scope create mode 100644 data/fixtures/scopes/typescript.core/type.argument.catch.scope diff --git a/data/fixtures/scopes/csharp/argument.catch.scope b/data/fixtures/scopes/csharp/argument.catch.scope new file mode 100644 index 0000000000..a0a0c60d26 --- /dev/null +++ b/data/fixtures/scopes/csharp/argument.catch.scope @@ -0,0 +1,21 @@ +try {} +catch(MyException ex) {} +catch(Exception ex) {} +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 1:6-1:20 + >--------------< +1| catch(MyException ex) {} + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = +[#2 Domain] = 2:6-2:18 + >------------< +2| catch(Exception ex) {} + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/csharp/name.argument.catch.scope b/data/fixtures/scopes/csharp/name.argument.catch.scope new file mode 100644 index 0000000000..08df3f843f --- /dev/null +++ b/data/fixtures/scopes/csharp/name.argument.catch.scope @@ -0,0 +1,41 @@ +try {} +catch(MyException ex) {} +catch(Exception ex) {} +--- + +[#1 Content] = 1:18-1:20 + >--< +1| catch(MyException ex) {} + +[#1 Removal] = 1:17-1:20 + >---< +1| catch(MyException ex) {} + +[#1 Leading delimiter] = 1:17-1:18 + >-< +1| catch(MyException ex) {} + +[#1 Domain] = 1:6-1:20 + >--------------< +1| catch(MyException ex) {} + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 2:16-2:18 + >--< +2| catch(Exception ex) {} + +[#2 Removal] = 2:15-2:18 + >---< +2| catch(Exception ex) {} + +[#2 Leading delimiter] = 2:15-2:16 + >-< +2| catch(Exception ex) {} + +[#2 Domain] = 2:6-2:18 + >------------< +2| catch(Exception ex) {} + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/csharp/type.argument.catch.scope b/data/fixtures/scopes/csharp/type.argument.catch.scope new file mode 100644 index 0000000000..5dc6b51f56 --- /dev/null +++ b/data/fixtures/scopes/csharp/type.argument.catch.scope @@ -0,0 +1,41 @@ +try {} +catch(MyException ex) {} +catch(Exception ex) {} +--- + +[#1 Content] = 1:6-1:17 + >-----------< +1| catch(MyException ex) {} + +[#1 Removal] = 1:6-1:18 + >------------< +1| catch(MyException ex) {} + +[#1 Trailing delimiter] = 1:17-1:18 + >-< +1| catch(MyException ex) {} + +[#1 Domain] = 1:6-1:20 + >--------------< +1| catch(MyException ex) {} + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 2:6-2:15 + >---------< +2| catch(Exception ex) {} + +[#2 Removal] = 2:6-2:16 + >----------< +2| catch(Exception ex) {} + +[#2 Trailing delimiter] = 2:15-2:16 + >-< +2| catch(Exception ex) {} + +[#2 Domain] = 2:6-2:18 + >------------< +2| catch(Exception ex) {} + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/java/argument.catch.scope b/data/fixtures/scopes/java/argument.catch.scope new file mode 100644 index 0000000000..e0026ab550 --- /dev/null +++ b/data/fixtures/scopes/java/argument.catch.scope @@ -0,0 +1,21 @@ +try {} +catch(final MyException ex) {} +catch(final Exception ex) {} +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 1:6-1:26 + >--------------------< +1| catch(final MyException ex) {} + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = +[#2 Domain] = 2:6-2:24 + >------------------< +2| catch(final Exception ex) {} + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/java/name.argument.catch.scope b/data/fixtures/scopes/java/name.argument.catch.scope new file mode 100644 index 0000000000..aeaeac26ef --- /dev/null +++ b/data/fixtures/scopes/java/name.argument.catch.scope @@ -0,0 +1,41 @@ +try {} +catch(final MyException ex) {} +catch(final Exception ex) {} +--- + +[#1 Content] = 1:24-1:26 + >--< +1| catch(final MyException ex) {} + +[#1 Removal] = 1:23-1:26 + >---< +1| catch(final MyException ex) {} + +[#1 Leading delimiter] = 1:23-1:24 + >-< +1| catch(final MyException ex) {} + +[#1 Domain] = 1:6-1:26 + >--------------------< +1| catch(final MyException ex) {} + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 2:22-2:24 + >--< +2| catch(final Exception ex) {} + +[#2 Removal] = 2:21-2:24 + >---< +2| catch(final Exception ex) {} + +[#2 Leading delimiter] = 2:21-2:22 + >-< +2| catch(final Exception ex) {} + +[#2 Domain] = 2:6-2:24 + >------------------< +2| catch(final Exception ex) {} + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/java/type.argument.catch.scope b/data/fixtures/scopes/java/type.argument.catch.scope new file mode 100644 index 0000000000..14d276134e --- /dev/null +++ b/data/fixtures/scopes/java/type.argument.catch.scope @@ -0,0 +1,49 @@ +try {} +catch(final MyException ex) {} +catch(final Exception ex) {} +--- + +[#1 Content] = 1:12-1:23 + >-----------< +1| catch(final MyException ex) {} + +[#1 Removal] = 1:12-1:24 + >------------< +1| catch(final MyException ex) {} + +[#1 Leading delimiter] = 1:11-1:12 + >-< +1| catch(final MyException ex) {} + +[#1 Trailing delimiter] = 1:23-1:24 + >-< +1| catch(final MyException ex) {} + +[#1 Domain] = 1:6-1:26 + >--------------------< +1| catch(final MyException ex) {} + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 2:12-2:21 + >---------< +2| catch(final Exception ex) {} + +[#2 Removal] = 2:12-2:22 + >----------< +2| catch(final Exception ex) {} + +[#2 Leading delimiter] = 2:11-2:12 + >-< +2| catch(final Exception ex) {} + +[#2 Trailing delimiter] = 2:21-2:22 + >-< +2| catch(final Exception ex) {} + +[#2 Domain] = 2:6-2:24 + >------------------< +2| catch(final Exception ex) {} + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/javascript.core/argument.catch.scope b/data/fixtures/scopes/javascript.core/argument.catch.scope new file mode 100644 index 0000000000..16f9ccf70f --- /dev/null +++ b/data/fixtures/scopes/javascript.core/argument.catch.scope @@ -0,0 +1,11 @@ +try {} +catch(error) {} +--- + +[Content] = +[Removal] = +[Domain] = 1:6-1:11 + >-----< +1| catch(error) {} + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/javascript.core/branch.try.iteration.scope b/data/fixtures/scopes/javascript.core/branch.try.iteration.scope index 639da14aee..016ff51260 100644 --- a/data/fixtures/scopes/javascript.core/branch.try.iteration.scope +++ b/data/fixtures/scopes/javascript.core/branch.try.iteration.scope @@ -1,24 +1,12 @@ -try { - a -} -catch (e) { - b -} -finally { - c -} +try {} +catch(error) {} +finally {} --- [Range] = -[Domain] = 0:0-8:1 - >----- -0| try { -1| a -2| } -3| catch (e) { -4| b -5| } -6| finally { -7| c -8| } - -< +[Domain] = 0:0-2:10 + >------ +0| try {} +1| catch(error) {} +2| finally {} + ----------< diff --git a/data/fixtures/scopes/javascript.core/branch.try.scope b/data/fixtures/scopes/javascript.core/branch.try.scope index ea74af16e4..f80e3211ce 100644 --- a/data/fixtures/scopes/javascript.core/branch.try.scope +++ b/data/fixtures/scopes/javascript.core/branch.try.scope @@ -1,66 +1,45 @@ -try { - -} -catch(error) { - -} -finally { - -} +try {} +catch(error) {} +finally {} --- [#1 Content] = -[#1 Domain] = 0:0-2:1 - >----- -0| try { -1| -2| } - -< - -[#1 Removal] = 0:0-3:0 - >----- -0| try { -1| -2| } -3| catch(error) { +[#1 Domain] = 0:0-0:6 + >------< +0| try {} + +[#1 Removal] = 0:0-1:0 + >------ +0| try {} +1| catch(error) {} < [#1 Insertion delimiter] = "\n" [#2 Content] = -[#2 Domain] = 3:0-5:1 - >-------------- -3| catch(error) { -4| -5| } - -< - -[#2 Removal] = 3:0-6:0 - >-------------- -3| catch(error) { -4| -5| } -6| finally { +[#2 Domain] = 1:0-1:15 + >---------------< +1| catch(error) {} + +[#2 Removal] = 1:0-2:0 + >--------------- +1| catch(error) {} +2| finally {} < [#2 Insertion delimiter] = "\n" [#3 Content] = -[#3 Domain] = 6:0-8:1 - >--------- -6| finally { -7| -8| } - -< - -[#3 Removal] = 5:1-8:1 - > -5| } -6| finally { -7| -8| } - -< +[#3 Domain] = 2:0-2:10 + >----------< +2| finally {} + +[#3 Removal] = 1:15-2:10 + > +1| catch(error) {} +2| finally {} + ----------< [#3 Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/javascript.core/name.argument.catch.scope b/data/fixtures/scopes/javascript.core/name.argument.catch.scope new file mode 100644 index 0000000000..16f9ccf70f --- /dev/null +++ b/data/fixtures/scopes/javascript.core/name.argument.catch.scope @@ -0,0 +1,11 @@ +try {} +catch(error) {} +--- + +[Content] = +[Removal] = +[Domain] = 1:6-1:11 + >-----< +1| catch(error) {} + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/python/argument.catch.scope b/data/fixtures/scopes/python/argument.catch.scope new file mode 100644 index 0000000000..153e58326d --- /dev/null +++ b/data/fixtures/scopes/python/argument.catch.scope @@ -0,0 +1,38 @@ +try: + pass +except MyException as ex: + pass +except Exception as ex: + pass +--- + +[#1 Content] = +[#1 Domain] = 2:7-2:24 + >-----------------< +2| except MyException as ex: + +[#1 Removal] = 2:6-2:24 + >------------------< +2| except MyException as ex: + +[#1 Leading delimiter] = 2:6-2:7 + >-< +2| except MyException as ex: + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Domain] = 4:7-4:22 + >---------------< +4| except Exception as ex: + +[#2 Removal] = 4:6-4:22 + >----------------< +4| except Exception as ex: + +[#2 Leading delimiter] = 4:6-4:7 + >-< +4| except Exception as ex: + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/python/name.argument.catch.scope b/data/fixtures/scopes/python/name.argument.catch.scope new file mode 100644 index 0000000000..966a24e0bb --- /dev/null +++ b/data/fixtures/scopes/python/name.argument.catch.scope @@ -0,0 +1,44 @@ +try: + pass +except MyException as ex: + pass +except Exception as ex: + pass +--- + +[#1 Content] = 2:22-2:24 + >--< +2| except MyException as ex: + +[#1 Removal] = 2:21-2:24 + >---< +2| except MyException as ex: + +[#1 Leading delimiter] = 2:21-2:22 + >-< +2| except MyException as ex: + +[#1 Domain] = 2:7-2:24 + >-----------------< +2| except MyException as ex: + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 4:20-4:22 + >--< +4| except Exception as ex: + +[#2 Removal] = 4:19-4:22 + >---< +4| except Exception as ex: + +[#2 Leading delimiter] = 4:19-4:20 + >-< +4| except Exception as ex: + +[#2 Domain] = 4:7-4:22 + >---------------< +4| except Exception as ex: + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/python/type.argument.catch.scope b/data/fixtures/scopes/python/type.argument.catch.scope new file mode 100644 index 0000000000..a7cd6b539a --- /dev/null +++ b/data/fixtures/scopes/python/type.argument.catch.scope @@ -0,0 +1,52 @@ +try: + pass +except MyException as ex: + pass +except Exception as ex: + pass +--- + +[#1 Content] = 2:7-2:18 + >-----------< +2| except MyException as ex: + +[#1 Removal] = 2:7-2:19 + >------------< +2| except MyException as ex: + +[#1 Leading delimiter] = 2:6-2:7 + >-< +2| except MyException as ex: + +[#1 Trailing delimiter] = 2:18-2:19 + >-< +2| except MyException as ex: + +[#1 Domain] = 2:7-2:24 + >-----------------< +2| except MyException as ex: + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 4:7-4:16 + >---------< +4| except Exception as ex: + +[#2 Removal] = 4:7-4:17 + >----------< +4| except Exception as ex: + +[#2 Leading delimiter] = 4:6-4:7 + >-< +4| except Exception as ex: + +[#2 Trailing delimiter] = 4:16-4:17 + >-< +4| except Exception as ex: + +[#2 Domain] = 4:7-4:22 + >---------------< +4| except Exception as ex: + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/typescript.core/argument.catch.scope b/data/fixtures/scopes/typescript.core/argument.catch.scope new file mode 100644 index 0000000000..73aa502737 --- /dev/null +++ b/data/fixtures/scopes/typescript.core/argument.catch.scope @@ -0,0 +1,11 @@ +try {} +catch(error: unknown) {} +--- + +[Content] = +[Removal] = +[Domain] = 1:6-1:20 + >--------------< +1| catch(error: unknown) {} + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/typescript.core/type.argument.catch.scope b/data/fixtures/scopes/typescript.core/type.argument.catch.scope new file mode 100644 index 0000000000..319579bbab --- /dev/null +++ b/data/fixtures/scopes/typescript.core/type.argument.catch.scope @@ -0,0 +1,21 @@ +try {} +catch(error: unknown) {} +--- + +[Content] = 1:13-1:20 + >-------< +1| catch(error: unknown) {} + +[Removal] = 1:11-1:20 + >---------< +1| catch(error: unknown) {} + +[Leading delimiter] = 1:11-1:13 + >--< +1| catch(error: unknown) {} + +[Domain] = 1:6-1:20 + >--------------< +1| catch(error: unknown) {} + +[Insertion delimiter] = " " diff --git a/packages/common/src/scopeSupportFacets/c.ts b/packages/common/src/scopeSupportFacets/c.ts index caf4d447b1..a84356ae4c 100644 --- a/packages/common/src/scopeSupportFacets/c.ts +++ b/packages/common/src/scopeSupportFacets/c.ts @@ -192,6 +192,9 @@ export const cCoreScopeSupport: LanguageScopeSupportFacetMap = { "branch.try": notApplicable, "branch.try.iteration": notApplicable, "interior.try": notApplicable, + "argument.catch": notApplicable, + "name.argument.catch": notApplicable, + "type.argument.catch": notApplicable, // Interface "statement.interface": notApplicable, diff --git a/packages/common/src/scopeSupportFacets/csharp.ts b/packages/common/src/scopeSupportFacets/csharp.ts index 08db92dfab..6aa13c810f 100644 --- a/packages/common/src/scopeSupportFacets/csharp.ts +++ b/packages/common/src/scopeSupportFacets/csharp.ts @@ -64,6 +64,7 @@ export const csharpScopeSupport: LanguageScopeSupportFacetMap = { "name.argument.formal.method": supported, "name.argument.formal.method.iteration": supported, "name.argument.formal": supported, + "name.argument.catch": supported, "name.assignment": supported, "name.class": supported, "name.interface": supported, @@ -104,6 +105,7 @@ export const csharpScopeSupport: LanguageScopeSupportFacetMap = { "type.argument.formal.method.iteration": supported, "type.argument.formal.constructor": supported, "type.argument.formal.constructor.iteration": supported, + "type.argument.catch": supported, "type.cast": supported, "type.class": supported, "type.interface": supported, @@ -167,6 +169,7 @@ export const csharpScopeSupport: LanguageScopeSupportFacetMap = { "argument.formal.method.singleLine": supported, "argument.formal.method.multiLine": supported, "argument.formal.method.iteration": supported, + "argument.catch": supported, ifStatement: supported, statement: supported, diff --git a/packages/common/src/scopeSupportFacets/css.ts b/packages/common/src/scopeSupportFacets/css.ts index dd7b7c09ba..6f4982c402 100644 --- a/packages/common/src/scopeSupportFacets/css.ts +++ b/packages/common/src/scopeSupportFacets/css.ts @@ -82,6 +82,14 @@ export const cssScopeSupport: LanguageScopeSupportFacetMap = { "value.command": notApplicable, "interior.command": notApplicable, + // Try catch + "branch.try": notApplicable, + "branch.try.iteration": notApplicable, + "interior.try": notApplicable, + "argument.catch": notApplicable, + "name.argument.catch": notApplicable, + "type.argument.catch": notApplicable, + anonymousFunction: notApplicable, "argument.actual.multiLine": notApplicable, "argument.actual.constructor.iteration": notApplicable, @@ -131,8 +139,6 @@ export const cssScopeSupport: LanguageScopeSupportFacetMap = { "branch.switchCase": notApplicable, "branch.ternary": notApplicable, "branch.ternary.iteration": notApplicable, - "branch.try.iteration": notApplicable, - "branch.try": notApplicable, "comment.line": notApplicable, "condition.doWhile": notApplicable, "condition.for": notApplicable, @@ -169,7 +175,6 @@ export const cssScopeSupport: LanguageScopeSupportFacetMap = { "interior.switch": notApplicable, "interior.switchCase": notApplicable, "interior.ternary": notApplicable, - "interior.try": notApplicable, "interior.namespace": notApplicable, "interior.static": notApplicable, "key.attribute": notApplicable, diff --git a/packages/common/src/scopeSupportFacets/html.ts b/packages/common/src/scopeSupportFacets/html.ts index d35d76d17a..15bb5887b3 100644 --- a/packages/common/src/scopeSupportFacets/html.ts +++ b/packages/common/src/scopeSupportFacets/html.ts @@ -60,6 +60,14 @@ export const htmlScopeSupport: LanguageScopeSupportFacetMap = { "value.command": notApplicable, "interior.command": notApplicable, + // Try catch + "branch.try": notApplicable, + "branch.try.iteration": notApplicable, + "interior.try": notApplicable, + "argument.catch": notApplicable, + "name.argument.catch": notApplicable, + "type.argument.catch": notApplicable, + "argument.actual.constructor.iteration": notApplicable, "argument.actual.constructor.singleLine": notApplicable, "argument.actual.constructor.multiLine": notApplicable, @@ -112,8 +120,6 @@ export const htmlScopeSupport: LanguageScopeSupportFacetMap = { "branch.switchCase": notApplicable, "branch.ternary": notApplicable, "branch.ternary.iteration": notApplicable, - "branch.try.iteration": notApplicable, - "branch.try": notApplicable, "collectionItem.unenclosed.iteration": notApplicable, "collectionItem.unenclosed": notApplicable, "comment.line": notApplicable, @@ -145,7 +151,6 @@ export const htmlScopeSupport: LanguageScopeSupportFacetMap = { "interior.switch": notApplicable, "interior.switchCase": notApplicable, "interior.ternary": notApplicable, - "interior.try": notApplicable, "interior.namespace": notApplicable, "interior.static": notApplicable, "key.mapPair.iteration": notApplicable, diff --git a/packages/common/src/scopeSupportFacets/java.ts b/packages/common/src/scopeSupportFacets/java.ts index 97011eab80..d17de03b76 100644 --- a/packages/common/src/scopeSupportFacets/java.ts +++ b/packages/common/src/scopeSupportFacets/java.ts @@ -27,6 +27,7 @@ export const javaScopeSupport: LanguageScopeSupportFacetMap = { "argument.formal.lambda.singleLine": supported, "argument.formal.lambda.multiLine": supported, "argument.formal.lambda.iteration": supported, + "argument.catch": supported, "argumentList.actual.empty": supported, "argumentList.actual.singleLine": supported, @@ -116,6 +117,7 @@ export const javaScopeSupport: LanguageScopeSupportFacetMap = { "name.argument.formal.constructor.iteration": supported, "name.argument.formal.method": supported, "name.argument.formal.method.iteration": supported, + "name.argument.catch": supported, "name.assignment": supported, "name.class": supported, "name.interface": supported, @@ -146,6 +148,7 @@ export const javaScopeSupport: LanguageScopeSupportFacetMap = { "type.argument.formal.method": supported, "type.argument.formal.constructor.iteration": supported, "type.argument.formal.method.iteration": supported, + "type.argument.catch": supported, "type.foreach": supported, "type.field.class": supported, "type.field.interface": supported, diff --git a/packages/common/src/scopeSupportFacets/javascript.ts b/packages/common/src/scopeSupportFacets/javascript.ts index be1c0f176d..874663c5ef 100644 --- a/packages/common/src/scopeSupportFacets/javascript.ts +++ b/packages/common/src/scopeSupportFacets/javascript.ts @@ -75,6 +75,7 @@ export const javascriptCoreScopeSupport: LanguageScopeSupportFacetMap = { "argument.formal.lambda.singleLine": supported, "argument.formal.lambda.multiLine": supported, "argument.formal.lambda.iteration": supported, + "argument.catch": supported, "argumentList.actual.empty": supported, "argumentList.actual.singleLine": supported, @@ -129,6 +130,7 @@ export const javascriptCoreScopeSupport: LanguageScopeSupportFacetMap = { "name.argument.formal.method.iteration": supported, "name.argument.formal.constructor": supported, "name.argument.formal.constructor.iteration": supported, + "name.argument.catch": supported, "name.foreach": supported, "name.assignment": supported, "name.assignment.pattern": supported, @@ -267,6 +269,7 @@ export const javascriptScopeSupport: LanguageScopeSupportFacetMap = { "type.argument.formal.method.iteration": notApplicable, "type.argument.formal.constructor": notApplicable, "type.argument.formal.constructor.iteration": notApplicable, + "type.argument.catch": notApplicable, "type.alias": notApplicable, "type.cast": notApplicable, "type.field.class": notApplicable, diff --git a/packages/common/src/scopeSupportFacets/json.ts b/packages/common/src/scopeSupportFacets/json.ts index 59b30bb1a5..e4f54cb6c1 100644 --- a/packages/common/src/scopeSupportFacets/json.ts +++ b/packages/common/src/scopeSupportFacets/json.ts @@ -63,6 +63,14 @@ export const jsonScopeSupport: LanguageScopeSupportFacetMap = { "value.command": notApplicable, "interior.command": notApplicable, + // Try catch + "branch.try": notApplicable, + "branch.try.iteration": notApplicable, + "interior.try": notApplicable, + "argument.catch": notApplicable, + "name.argument.catch": notApplicable, + "type.argument.catch": notApplicable, + anonymousFunction: notApplicable, "argument.actual.singleLine": notApplicable, "argument.actual.multiLine": notApplicable, @@ -117,8 +125,6 @@ export const jsonScopeSupport: LanguageScopeSupportFacetMap = { "branch.switchCase.iteration": notApplicable, "branch.ternary": notApplicable, "branch.ternary.iteration": notApplicable, - "branch.try": notApplicable, - "branch.try.iteration": notApplicable, "collectionItem.unenclosed": notApplicable, "collectionItem.unenclosed.iteration": notApplicable, "condition.doWhile": notApplicable, @@ -159,7 +165,6 @@ export const jsonScopeSupport: LanguageScopeSupportFacetMap = { "interior.switch": notApplicable, "interior.switchCase": notApplicable, "interior.ternary": notApplicable, - "interior.try": notApplicable, "interior.static": notApplicable, "interior.namespace": notApplicable, "key.attribute": notApplicable, diff --git a/packages/common/src/scopeSupportFacets/markdown.ts b/packages/common/src/scopeSupportFacets/markdown.ts index 0858783269..7c59b2f481 100644 --- a/packages/common/src/scopeSupportFacets/markdown.ts +++ b/packages/common/src/scopeSupportFacets/markdown.ts @@ -59,6 +59,14 @@ export const markdownScopeSupport: LanguageScopeSupportFacetMap = { "value.command": notApplicable, "interior.command": notApplicable, + // Try catch + "branch.try": notApplicable, + "branch.try.iteration": notApplicable, + "interior.try": notApplicable, + "argument.catch": notApplicable, + "name.argument.catch": notApplicable, + "type.argument.catch": notApplicable, + anonymousFunction: notApplicable, "argument.actual.singleLine": notApplicable, "argument.actual.multiLine": notApplicable, @@ -113,8 +121,6 @@ export const markdownScopeSupport: LanguageScopeSupportFacetMap = { "branch.switchCase.iteration": notApplicable, "branch.ternary": notApplicable, "branch.ternary.iteration": notApplicable, - "branch.try": notApplicable, - "branch.try.iteration": notApplicable, "collectionItem.unenclosed.iteration": notApplicable, "comment.line": notApplicable, "condition.doWhile": notApplicable, @@ -154,7 +160,6 @@ export const markdownScopeSupport: LanguageScopeSupportFacetMap = { "interior.switch": notApplicable, "interior.switchCase": notApplicable, "interior.ternary": notApplicable, - "interior.try": notApplicable, "interior.namespace": notApplicable, "interior.static": notApplicable, "key.attribute": notApplicable, diff --git a/packages/common/src/scopeSupportFacets/python.ts b/packages/common/src/scopeSupportFacets/python.ts index 1b5758fc32..c8aa06d40a 100644 --- a/packages/common/src/scopeSupportFacets/python.ts +++ b/packages/common/src/scopeSupportFacets/python.ts @@ -15,6 +15,7 @@ export const pythonScopeSupport: LanguageScopeSupportFacetMap = { "name.argument.formal.iteration": supported, "name.argument.formal.method": supported, "name.argument.formal.method.iteration": supported, + "name.argument.catch": supported, "name.assignment": supported, "name.assignment.pattern": supported, "name.class": supported, @@ -58,6 +59,7 @@ export const pythonScopeSupport: LanguageScopeSupportFacetMap = { "type.argument.formal.method": supported, "type.argument.formal.method.iteration": supported, "type.argument.formal": supported, + "type.argument.catch": supported, "type.class": supported, "type.field.class": supported, "type.return": supported, @@ -101,6 +103,7 @@ export const pythonScopeSupport: LanguageScopeSupportFacetMap = { "argument.formal.method.iteration": supported, "argument.formal.lambda.singleLine": supported, "argument.formal.lambda.iteration": supported, + "argument.catch": supported, "argumentList.actual.empty": supported, "argumentList.actual.singleLine": supported, diff --git a/packages/common/src/scopeSupportFacets/scm.ts b/packages/common/src/scopeSupportFacets/scm.ts index 98981538b3..60c0930a14 100644 --- a/packages/common/src/scopeSupportFacets/scm.ts +++ b/packages/common/src/scopeSupportFacets/scm.ts @@ -65,6 +65,14 @@ export const scmScopeSupport: LanguageScopeSupportFacetMap = { "value.command": notApplicable, "interior.command": notApplicable, + // Try catch + "branch.try": notApplicable, + "branch.try.iteration": notApplicable, + "interior.try": notApplicable, + "argument.catch": notApplicable, + "name.argument.catch": notApplicable, + "type.argument.catch": notApplicable, + anonymousFunction: notApplicable, "argument.actual.constructor.singleLine": notApplicable, "argument.actual.constructor.multiLine": notApplicable, @@ -113,8 +121,6 @@ export const scmScopeSupport: LanguageScopeSupportFacetMap = { "branch.switchCase.iteration": notApplicable, "branch.ternary": notApplicable, "branch.ternary.iteration": notApplicable, - "branch.try": notApplicable, - "branch.try.iteration": notApplicable, "comment.block": notApplicable, "condition.doWhile": notApplicable, "condition.for": notApplicable, @@ -154,7 +160,6 @@ export const scmScopeSupport: LanguageScopeSupportFacetMap = { "interior.switch": notApplicable, "interior.switchCase": notApplicable, "interior.ternary": notApplicable, - "interior.try": notApplicable, "interior.namespace": notApplicable, "interior.static": notApplicable, "key.attribute": notApplicable, diff --git a/packages/common/src/scopeSupportFacets/scopeSupportFacetInfos.ts b/packages/common/src/scopeSupportFacets/scopeSupportFacetInfos.ts index e2327e0108..23ed91a07c 100644 --- a/packages/common/src/scopeSupportFacets/scopeSupportFacetInfos.ts +++ b/packages/common/src/scopeSupportFacets/scopeSupportFacetInfos.ts @@ -346,6 +346,11 @@ export const scopeSupportFacetInfos: Record< scopeType: "argumentOrParameter", isIteration: true, }, + "argument.catch": { + description: "A parameter in a catch clause", + scopeType: "argumentOrParameter", + insertionDelimiterHint: '", "', + }, "argumentList.actual.empty": { description: "An empty list of arguments in a function call", @@ -699,7 +704,7 @@ export const scopeSupportFacetInfos: Record< isIteration: true, }, "name.argument.actual": { - description: "The name of a (keyword) argument in a function call", + description: "Name of a (keyword) argument in a function call", scopeType: "name", }, "name.argument.actual.iteration": { @@ -709,7 +714,7 @@ export const scopeSupportFacetInfos: Record< isIteration: true, }, "name.argument.formal": { - description: "The name of a parameter in a function declaration", + description: "Name of a parameter in a function declaration", scopeType: "name", }, "name.argument.formal.iteration": { @@ -719,7 +724,7 @@ export const scopeSupportFacetInfos: Record< isIteration: true, }, "name.argument.formal.method": { - description: "The name of a parameter in a class method declaration", + description: "Name of a parameter in a class method declaration", scopeType: "name", }, "name.argument.formal.method.iteration": { @@ -738,6 +743,10 @@ export const scopeSupportFacetInfos: Record< scopeType: "name", isIteration: true, }, + "name.argument.catch": { + description: "Name of a parameter in a catch clause", + scopeType: "name", + }, "key.attribute": { description: "Key (LHS) of an attribute eg in a xml element", @@ -910,6 +919,11 @@ export const scopeSupportFacetInfos: Record< scopeType: "type", isIteration: true, }, + "type.argument.catch": { + description: "Type of parameter in a catch clause", + scopeType: "type", + }, + "type.return": { description: "Type of return value in a function declaration", scopeType: "type", diff --git a/packages/common/src/scopeSupportFacets/scopeSupportFacets.types.ts b/packages/common/src/scopeSupportFacets/scopeSupportFacets.types.ts index 6c8b3237e6..044710bcef 100644 --- a/packages/common/src/scopeSupportFacets/scopeSupportFacets.types.ts +++ b/packages/common/src/scopeSupportFacets/scopeSupportFacets.types.ts @@ -88,6 +88,7 @@ export const scopeSupportFacets = [ "argument.formal.lambda.singleLine", "argument.formal.lambda.multiLine", "argument.formal.lambda.iteration", + "argument.catch", "argumentList.actual.empty", "argumentList.actual.singleLine", @@ -175,6 +176,7 @@ export const scopeSupportFacets = [ "name.argument.formal.method.iteration", "name.argument.formal.constructor", "name.argument.formal.constructor.iteration", + "name.argument.catch", "name.iteration.block", "name.iteration.class", "name.iteration.interface", @@ -231,6 +233,7 @@ export const scopeSupportFacets = [ "type.argument.formal.method.iteration", "type.argument.formal.constructor", "type.argument.formal.constructor.iteration", + "type.argument.catch", "type.iteration.block", "type.iteration.class", "type.iteration.interface", diff --git a/packages/common/src/scopeSupportFacets/talon.ts b/packages/common/src/scopeSupportFacets/talon.ts index d2f94d6216..9520bebc23 100644 --- a/packages/common/src/scopeSupportFacets/talon.ts +++ b/packages/common/src/scopeSupportFacets/talon.ts @@ -84,6 +84,14 @@ export const talonScopeSupport: LanguageScopeSupportFacetMap = { "type.field.interface": notApplicable, "type.iteration.interface": notApplicable, + // Try catch + "branch.try": notApplicable, + "branch.try.iteration": notApplicable, + "interior.try": notApplicable, + "argument.catch": notApplicable, + "name.argument.catch": notApplicable, + "type.argument.catch": notApplicable, + anonymousFunction: notApplicable, "argument.actual.multiLine": notApplicable, "argument.actual.constructor.singleLine": notApplicable, @@ -132,8 +140,6 @@ export const talonScopeSupport: LanguageScopeSupportFacetMap = { "branch.switchCase.iteration": notApplicable, "branch.ternary": notApplicable, "branch.ternary.iteration": notApplicable, - "branch.try": notApplicable, - "branch.try.iteration": notApplicable, "collectionItem.unenclosed": notApplicable, "collectionItem.unenclosed.iteration": notApplicable, "comment.block": notApplicable, @@ -174,7 +180,6 @@ export const talonScopeSupport: LanguageScopeSupportFacetMap = { "interior.switch": notApplicable, "interior.switchCase": notApplicable, "interior.ternary": notApplicable, - "interior.try": notApplicable, "interior.namespace": notApplicable, "interior.static": notApplicable, "key.attribute": notApplicable, diff --git a/packages/common/src/scopeSupportFacets/typescript.ts b/packages/common/src/scopeSupportFacets/typescript.ts index 0d7ad37ed7..0324051934 100644 --- a/packages/common/src/scopeSupportFacets/typescript.ts +++ b/packages/common/src/scopeSupportFacets/typescript.ts @@ -13,6 +13,7 @@ export const typescriptScopeSupport: LanguageScopeSupportFacetMap = { "type.argument.formal.method.iteration": supported, "type.argument.formal.constructor": supported, "type.argument.formal.constructor.iteration": supported, + "type.argument.catch": supported, "type.alias": supported, "type.cast": supported, "type.field.class": supported, diff --git a/packages/common/src/scopeSupportFacets/xml.ts b/packages/common/src/scopeSupportFacets/xml.ts index 77ec8fe322..738ad62668 100644 --- a/packages/common/src/scopeSupportFacets/xml.ts +++ b/packages/common/src/scopeSupportFacets/xml.ts @@ -60,6 +60,14 @@ export const xmlScopeSupport: LanguageScopeSupportFacetMap = { "value.command": notApplicable, "interior.command": notApplicable, + // Try catch + "branch.try": notApplicable, + "branch.try.iteration": notApplicable, + "interior.try": notApplicable, + "argument.catch": notApplicable, + "name.argument.catch": notApplicable, + "type.argument.catch": notApplicable, + anonymousFunction: notApplicable, "argument.actual.singleLine": notApplicable, "argument.actual.multiLine": notApplicable, @@ -113,8 +121,6 @@ export const xmlScopeSupport: LanguageScopeSupportFacetMap = { "branch.switchCase.iteration": notApplicable, "branch.ternary": notApplicable, "branch.ternary.iteration": notApplicable, - "branch.try": notApplicable, - "branch.try.iteration": notApplicable, "collectionItem.unenclosed": notApplicable, "collectionItem.unenclosed.iteration": notApplicable, "comment.line": notApplicable, @@ -153,7 +159,6 @@ export const xmlScopeSupport: LanguageScopeSupportFacetMap = { "interior.switch": notApplicable, "interior.switchCase": notApplicable, "interior.ternary": notApplicable, - "interior.try": notApplicable, "interior.namespace": notApplicable, "interior.static": notApplicable, "key.mapPair": notApplicable, diff --git a/packages/common/src/scopeSupportFacets/yaml.ts b/packages/common/src/scopeSupportFacets/yaml.ts index 5d7d715d13..c0cb03f010 100644 --- a/packages/common/src/scopeSupportFacets/yaml.ts +++ b/packages/common/src/scopeSupportFacets/yaml.ts @@ -69,6 +69,14 @@ export const yamlScopeSupport: LanguageScopeSupportFacetMap = { "value.command": notApplicable, "interior.command": notApplicable, + // Try catch + "branch.try": notApplicable, + "branch.try.iteration": notApplicable, + "interior.try": notApplicable, + "argument.catch": notApplicable, + "name.argument.catch": notApplicable, + "type.argument.catch": notApplicable, + anonymousFunction: notApplicable, "argument.actual.singleLine": notApplicable, "argument.actual.multiLine": notApplicable, @@ -123,8 +131,6 @@ export const yamlScopeSupport: LanguageScopeSupportFacetMap = { "branch.switchCase.iteration": notApplicable, "branch.ternary": notApplicable, "branch.ternary.iteration": notApplicable, - "branch.try": notApplicable, - "branch.try.iteration": notApplicable, "comment.block": notApplicable, "condition.doWhile": notApplicable, "condition.for": notApplicable, @@ -163,7 +169,6 @@ export const yamlScopeSupport: LanguageScopeSupportFacetMap = { "interior.switch": notApplicable, "interior.switchCase": notApplicable, "interior.ternary": notApplicable, - "interior.try": notApplicable, "interior.namespace": notApplicable, "interior.static": notApplicable, "key.attribute": notApplicable, diff --git a/queries/csharp.scm b/queries/csharp.scm index fd692f2dd3..702e446296 100644 --- a/queries/csharp.scm +++ b/queries/csharp.scm @@ -473,13 +473,14 @@ (_ name: (_) @name + (#not-parent-type? @name catch_declaration) ) @_.domain ( (_ type: (_) @type ) @_.domain - (#not-type? @_.domain cast_expression) + (#not-type? @_.domain catch_declaration cast_expression) ) ;;!! (int)5.5; @@ -573,6 +574,15 @@ ")" @name.iteration.end.startOf @value.iteration.end.startOf @type.iteration.end.startOf ) +;;!! catch(Exception ex) {} +;;! ^^^^^^^^^^^^ +;;! ^^^^^^^^^ +;;! ^^ +(catch_declaration + type: (_) @argumentOrParameter.start @type @_.domain.start + name: (_) @argumentOrParameter.end @name @_.domain.end +) + operator: [ "->" "<" diff --git a/queries/java.scm b/queries/java.scm index 28a4ea3fc6..e53eb00724 100644 --- a/queries/java.scm +++ b/queries/java.scm @@ -591,6 +591,15 @@ (#empty-single-multi-delimiter! @argumentList @argumentList "" ", " ",\n") ) @argumentList.domain @argumentOrParameter.iteration.domain +;;!! catch(Exception ex) {} +;;! ^^^^^^^^^^^^ +;;! ^^^^^^^^^ +;;! ^^ +(catch_formal_parameter + (catch_type) @type + name: (_) @name +) @argumentOrParameter @_.domain + ;;!! try (PrintWriter writer = create()) { } ;;! ^^^^^^^^^^^ ^^^^^ ^^^^^^^^ (try_with_resources_statement diff --git a/queries/javascript.scm b/queries/javascript.scm index 979093a68c..1ec03b8a75 100644 --- a/queries/javascript.scm +++ b/queries/javascript.scm @@ -56,3 +56,9 @@ right: (_) @value ) @_.domain ) + +;;!! catch(error) {} +;;! ^^^^^ +(catch_clause + parameter: (_) @argumentOrParameter @name +) diff --git a/queries/python.scm b/queries/python.scm index 3873da8c35..ce0e297ac9 100644 --- a/queries/python.scm +++ b/queries/python.scm @@ -565,6 +565,17 @@ (block) @interior ) @branch @interior.domain +;;!! except Exception as ex: +;;! ^^^^^^^^^^^^^^^ +;;! ^^^^^^^^^ +;;! ^^ +(except_clause + (as_pattern + (_) @type + alias: (_) @name + ) @argumentOrParameter @_.domain +) + ;;!! finally: pass ;;! ^^^^^^^^^^^^^ (finally_clause diff --git a/queries/typescript.core.scm b/queries/typescript.core.scm index 5e0afe182a..e7aa1fe37b 100644 --- a/queries/typescript.core.scm +++ b/queries/typescript.core.scm @@ -299,6 +299,25 @@ (_) @type ) +;;!! catch(error: unknown) {} +;;! ^^^^^^^^^^^^^^ +(catch_clause + parameter: (_) @argumentOrParameter.start + type: (_ + (_) @argumentOrParameter.end + )? +) + +;;!! catch(error: unknown) {} +;;! ^^^^^ +;;! ^^^^^^^ +(catch_clause + parameter: (_) @name @type.leading.endOf @_.domain.start + type: (_ + (_) @type @_.domain.end + )? +) + ;;!! interface Aaa {} ;;!! type Aaa = Bbb; (