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

Fixed ECMAScript private member highlighting #10554

Merged
merged 1 commit into from
Apr 27, 2024
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
2 changes: 2 additions & 0 deletions book/src/themes.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ We use a similar set of scopes as
- `parameter` - Function parameters
- `other`
- `member` - Fields of composite data types (e.g. structs, unions)
- `private` - Private fields that use a unique syntax (currently just ECMAScript-based languages)

- `label`

Expand Down Expand Up @@ -206,6 +207,7 @@ We use a similar set of scopes as
- `function`
- `builtin`
- `method`
- `private` - Private methods that use a unique syntax (currently just ECMAScript-based languages)
- `macro`
- `special` (preprocessor in C)

Expand Down
13 changes: 13 additions & 0 deletions runtime/queries/ecma/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,24 @@
name: (identifier) @function)
(method_definition
name: (property_identifier) @function.method)
(method_definition
name: (private_property_identifier) @function.method.private)

(pair
key: (property_identifier) @function.method
value: [(function) (arrow_function)])
(pair
key: (private_property_identifier) @function.method.private
value: [(function) (arrow_function)])

(assignment_expression
left: (member_expression
property: (property_identifier) @function.method)
right: [(function) (arrow_function)])
(assignment_expression
left: (member_expression
property: (private_property_identifier) @function.method.private)
right: [(function) (arrow_function)])

(variable_declarator
name: (identifier) @function
Expand All @@ -64,6 +73,9 @@
(call_expression
function: (member_expression
property: (property_identifier) @function.method))
(call_expression
function: (member_expression
property: (private_property_identifier) @function.method.private))

; Variables
;----------
Expand All @@ -74,6 +86,7 @@
;-----------

(property_identifier) @variable.other.member
(private_property_identifier) @variable.other.member.private
(shorthand_property_identifier) @variable.other.member
(shorthand_property_identifier_pattern) @variable.other.member

Expand Down
Loading