From e00d737196f7f71bb8a5675577255b6f86743ca6 Mon Sep 17 00:00:00 2001 From: Devzeth <47153906+devzeth@users.noreply.github.com> Date: Sun, 2 Mar 2025 01:43:51 +0100 Subject: [PATCH] Add `constructor` highlighting for JS/TS/TSX (#25207) Closes #19267 Adds highlight field specifically for `constructor` in JS/TS/TSX so that it can be highlighted as a different color than regular methods Release Notes: - N/A --------- Co-authored-by: Ben Kunkle --- crates/languages/src/javascript/highlights.scm | 3 +++ crates/languages/src/tsx/highlights.scm | 6 +++--- crates/languages/src/typescript/highlights.scm | 3 +++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/crates/languages/src/javascript/highlights.scm b/crates/languages/src/javascript/highlights.scm index 9986390b4e4c717262f4c8f5729f0aafa82083cc..f46db408e7d73bb1aa714cf02176870f47d388de 100644 --- a/crates/languages/src/javascript/highlights.scm +++ b/crates/languages/src/javascript/highlights.scm @@ -25,6 +25,9 @@ name: (identifier) @function) (method_definition name: (property_identifier) @function.method) +(method_definition + name: (property_identifier) @constructor + (#eq? @constructor "constructor")) (pair key: (property_identifier) @function.method diff --git a/crates/languages/src/tsx/highlights.scm b/crates/languages/src/tsx/highlights.scm index d21f0c2147b33f4b291630e3a14f7660c2395b2d..5b83ec903c8d429eac872600247d75f58234598f 100644 --- a/crates/languages/src/tsx/highlights.scm +++ b/crates/languages/src/tsx/highlights.scm @@ -25,6 +25,9 @@ name: (identifier) @function) (method_definition name: (property_identifier) @function.method) +(method_definition + name: (property_identifier) @constructor + (#eq? @constructor "constructor")) (pair key: (property_identifier) @function.method @@ -45,9 +48,6 @@ ; Special identifiers -((identifier) @constructor - (#match? @constructor "^[A-Z]")) - ((identifier) @type (#match? @type "^[A-Z]")) (type_identifier) @type diff --git a/crates/languages/src/typescript/highlights.scm b/crates/languages/src/typescript/highlights.scm index bccb22fa9c743ec1a5269e6fb69bcc371b1c5cdc..502957c93bc565e3c7b06467996a374d513412a9 100644 --- a/crates/languages/src/typescript/highlights.scm +++ b/crates/languages/src/typescript/highlights.scm @@ -57,6 +57,9 @@ name: (identifier) @function) (method_definition name: (property_identifier) @function.method) +(method_definition + name: (property_identifier) @constructor + (#eq? @constructor "constructor")) (pair key: (property_identifier) @function.method