From bb668cffe89436d5084977f031a5f7d98b8c41c1 Mon Sep 17 00:00:00 2001 From: Elizabeth Date: Mon, 22 Apr 2024 17:51:49 +0100 Subject: [PATCH] Fixed ECMAScript private member highlighting --- book/src/themes.md | 2 ++ runtime/queries/ecma/highlights.scm | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/book/src/themes.md b/book/src/themes.md index d982dee9a7e2..e3b95c0a7af0 100644 --- a/book/src/themes.md +++ b/book/src/themes.md @@ -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` @@ -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) diff --git a/runtime/queries/ecma/highlights.scm b/runtime/queries/ecma/highlights.scm index 07f7dfeda330..dc8ce5e7309b 100644 --- a/runtime/queries/ecma/highlights.scm +++ b/runtime/queries/ecma/highlights.scm @@ -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 @@ -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 ;---------- @@ -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