From fdcacb384917a4f2306db65b3a7510d8eff2959d Mon Sep 17 00:00:00 2001 From: Sheik Althaf Date: Tue, 18 Mar 2025 14:57:48 +0530 Subject: [PATCH] typescript: Add highlighting for Angular inline components (#26553) Closes #ISSUE Release Notes: - N/A *or* Added/Fixed/Improved ... Before image After Image --- .../languages/src/typescript/injections.scm | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/crates/languages/src/typescript/injections.scm b/crates/languages/src/typescript/injections.scm index c8bb72bdc5..7affdc5b75 100644 --- a/crates/languages/src/typescript/injections.scm +++ b/crates/languages/src/typescript/injections.scm @@ -62,3 +62,40 @@ arguments: (arguments (template_string (string_fragment) @injection.content (#set! injection.language "graphql"))) ) + +;; Angular Component template injection +(call_expression + function: [ + (identifier) @_decorator (#eq? @_decorator "Component") + (member_expression property: (property_identifier) @_decorator (#eq? @_decorator "Component")) + ] + arguments: (arguments (object + (pair + key: (property_identifier) @_prop (#eq? @_prop "template") + value: [ + (string) @injection.content + (template_string) @injection.content + (template_string (string_fragment) @injection.content) + ] + ))) + (#set! injection.language "angular")) + +;; Angular Component styles injection +(call_expression + function: [ + (identifier) @_decorator (#eq? @_decorator "Component") + (member_expression property: (property_identifier) @_decorator (#eq? @_decorator "Component")) + ] + arguments: (arguments (object + (pair + key: (property_identifier) @_prop (#eq? @_prop "styles") + value: [ + (string) @injection.content + (template_string) @injection.content + (template_string (string_fragment) @injection.content) + (array (string) @injection.content) + (array (template_string) @injection.content) + (array (template_string (string_fragment)) @injection.content) + ] + ))) + (#set! injection.language "css"))