Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

javascript queries: fix parameters #3280

Merged
merged 1 commit into from
Aug 1, 2022
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
12 changes: 0 additions & 12 deletions runtime/queries/javascript/highlights-params.scm

This file was deleted.

37 changes: 37 additions & 0 deletions runtime/queries/javascript/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -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
;--------------------------
Expand Down
8 changes: 7 additions & 1 deletion runtime/queries/javascript/locals.scm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down