From 59bf1669ece4e614cc4a351f400124021191bb51 Mon Sep 17 00:00:00 2001 From: ChrHorn Date: Mon, 1 Aug 2022 22:15:17 +0200 Subject: [PATCH] javascript queries: fix parameters (#3280) --- .../queries/javascript/highlights-params.scm | 12 ------ runtime/queries/javascript/highlights.scm | 37 +++++++++++++++++++ runtime/queries/javascript/locals.scm | 8 +++- 3 files changed, 44 insertions(+), 13 deletions(-) delete mode 100644 runtime/queries/javascript/highlights-params.scm diff --git a/runtime/queries/javascript/highlights-params.scm b/runtime/queries/javascript/highlights-params.scm deleted file mode 100644 index 95ffc7248..000000000 --- a/runtime/queries/javascript/highlights-params.scm +++ /dev/null @@ -1,12 +0,0 @@ -(formal_parameters - [ - (identifier) @variable.parameter - (array_pattern - (identifier) @variable.parameter) - (object_pattern - [ - (pair_pattern value: (identifier) @variable.parameter) - (shorthand_property_identifier_pattern) @variable.parameter - ]) - ] -) diff --git a/runtime/queries/javascript/highlights.scm b/runtime/queries/javascript/highlights.scm index 60336c3b4..9e30d0e78 100644 --- a/runtime/queries/javascript/highlights.scm +++ b/runtime/queries/javascript/highlights.scm @@ -46,6 +46,43 @@ (assignment_expression left: (identifier) @function right: [(function) (arrow_function)]) + +; Function and method parameters +;------------------------------- + +; (p) => ... +(formal_parameters + (identifier) @variable.parameter) + +; (...p) => ... +(formal_parameters + (rest_pattern + (identifier) @variable.parameter)) + +; ({ p }) => ... +(formal_parameters + (object_pattern + (shorthand_property_identifier_pattern) @variable.parameter)) + +; ({ a: p }) => ... +(formal_parameters + (object_pattern + (pair_pattern + value: (identifier) @variable.parameter))) + +; ([ p ]) => ... +(formal_parameters + (array_pattern + (identifier) @variable.parameter)) + +; (p = 1) => ... +(formal_parameters + (assignment_pattern + left: (identifier) @variable.parameter)) + +; p => ... +(arrow_function + parameter: (identifier) @variable.parameter) ; Function and method calls ;-------------------------- diff --git a/runtime/queries/javascript/locals.scm b/runtime/queries/javascript/locals.scm index 5d680acf3..cc5f2e14f 100644 --- a/runtime/queries/javascript/locals.scm +++ b/runtime/queries/javascript/locals.scm @@ -12,7 +12,13 @@ ; Definitions ;------------ -(pattern/identifier)@local.definition +(pattern/identifier) @local.definition + +(pattern/rest_pattern + (identifier) @local.definition) + +(arrow_function + parameter: (identifier) @local.definition) (variable_declarator name: (identifier) @local.definition)