feat(angular)!: switch to parser supporting v17 (#5779)

This commit is contained in:
Dennis van den Berg 2024-01-27 12:17:25 +01:00 committed by GitHub
parent 589fa77c23
commit 2fb2100fed
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 159 additions and 52 deletions

View file

@ -0,0 +1 @@
; inherits: html

View file

@ -1,7 +1,7 @@
; inherits: html_tags
(identifier) @variable
(pipe_sequence
"|" @operator)
(pipe_operator) @operator
(string) @string
@ -15,6 +15,27 @@
(pipe_arguments
(identifier) @variable.parameter))
(structural_directive
"*" @keyword
(identifier) @keyword)
(attribute
(attribute_name) @variable.member
(#lua-match? @variable.member "#.*"))
(binding_name
(identifier) @keyword)
(event_binding
(binding_name
(identifier) @keyword))
(event_binding
"\"" @punctuation.delimiter)
(property_binding
"\"" @punctuation.delimiter)
(structural_assignment
operator: (identifier) @keyword)
@ -29,10 +50,38 @@
((identifier) @function.builtin
(#eq? @function.builtin "$any")))
(pair
key:
((identifier) @variable.builtin
(#eq? @variable.builtin "$implicit")))
((control_keyword) @keyword.repeat
(#any-of? @keyword.repeat "for" "empty"))
((control_keyword) @keyword.conditional
(#any-of? @keyword.conditional "if" "else" "switch" "case" "default"))
((control_keyword) @keyword.coroutine
(#any-of? @keyword.coroutine "defer" "placeholder" "loading"))
((control_keyword) @keyword.exception
(#eq? @keyword.exception "error"))
(special_keyword) @keyword
((identifier) @boolean
(#any-of? @boolean "true" "false"))
((identifier) @variable.builtin
(#any-of? @variable.builtin "this" "$event"))
((identifier) @constant.builtin
(#eq? @constant.builtin "null"))
[
"let"
"as"
] @keyword
(ternary_operator)
(conditional_operator)
] @keyword.conditional.ternary
[
"("
@ -41,8 +90,21 @@
"]"
"{"
"}"
"@"
"} @"
(if_end_expression)
(for_end_expression)
(switch_end_expression)
(case_end_expression)
(default_end_expression)
(defer_end_expression)
] @punctuation.bracket
[
"{{"
"}}"
] @punctuation.special
[
";"
"."
@ -50,27 +112,25 @@
"?."
] @punctuation.delimiter
((identifier) @boolean
(#any-of? @boolean "true" "false"))
(concatination_expression
"+" @operator)
((identifier) @variable.builtin
(#any-of? @variable.builtin "this" "\$event" "null"))
[
"-"
"&&"
"+"
"<"
"<="
"="
"=="
"==="
"!="
"!=="
">"
">="
"*"
"/"
"||"
"%"
] @operator
(binary_expression
[
"-"
"&&"
"+"
"<"
"<="
"="
"=="
"==="
"!="
"!=="
">"
">="
"*"
"/"
"||"
"%"
] @operator)

View file

@ -0,0 +1 @@
; inherits: html_tags

View file

@ -0,0 +1 @@
; inherits: html_tags

View file

@ -0,0 +1 @@
; inherits: html

View file

@ -137,3 +137,65 @@
(string
(string_fragment) @injection.content)
(#set! injection.language "html"))
;---- Angular injections -----
; @Component({
; template: `<html>`
; })
(decorator
(call_expression
function:
((identifier) @_name
(#eq? @_name "Component"))
arguments:
(arguments
(object
(pair
key:
((property_identifier) @_prop
(#eq? @_prop "template"))
value:
((template_string) @injection.content
(#offset! @injection.content 0 1 0 -1)
(#set! injection.language "angular")))))))
; @Component({
; styles: [`<css>`]
; })
(decorator
(call_expression
function:
((identifier) @_name
(#eq? @_name "Component"))
arguments:
(arguments
(object
(pair
key:
((property_identifier) @_prop
(#eq? @_prop "styles"))
value:
(array
((template_string) @injection.content
(#offset! @injection.content 0 1 0 -1)
(#set! injection.language "css"))))))))
; @Component({
; styles: `<css>`
; })
(decorator
(call_expression
function:
((identifier) @_name
(#eq? @_name "Component"))
arguments:
(arguments
(object
(pair
key:
((property_identifier) @_prop
(#eq? @_prop "styles"))
value:
((template_string) @injection.content
(#offset! @injection.content 0 1 0 -1)
(#set! injection.language "css")))))))

View file

@ -89,23 +89,3 @@
(quoted_attribute_value
(attribute_value) @injection.content)
(#set! injection.language "javascript"))
(attribute
((attribute_name) @_name
(#lua-match? @_name "[%[%(].*[%)%]]"))
(quoted_attribute_value
(attribute_value) @injection.content)
(#set! injection.language "angular"))
(attribute
((attribute_name) @_name
(#lua-match? @_name "^%*"))
(quoted_attribute_value
(attribute_value) @injection.content)
(#set! injection.language "angular"))
(element
((text) @injection.content
(#lua-match? @injection.content "%{%{.*%}%}")
(#offset! @injection.content 0 2 0 -2))
(#set! injection.language "angular"))