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

@ -6,7 +6,7 @@
"revision": "c21c3a0f996363ed17b8ac99d827fe5a4821f217" "revision": "c21c3a0f996363ed17b8ac99d827fe5a4821f217"
}, },
"angular": { "angular": {
"revision": "624ff108fe949727217cddb302f20e4f16997b1c" "revision": "28119b4dc813d3f8267d451c44548e99124fbf9a"
}, },
"apex": { "apex": {
"revision": "ca70b2347a79615cd749517f6c6c2352e50a7ce9" "revision": "ca70b2347a79615cd749517f6c6c2352e50a7ce9"

View file

@ -95,10 +95,11 @@ list.agda = {
list.angular = { list.angular = {
install_info = { install_info = {
url = "https://github.com/steelsojka/tree-sitter-angular", url = "https://github.com/dlvandenberg/tree-sitter-angular",
files = { "src/parser.c" }, files = { "src/parser.c", "src/scanner.c" },
requires_generate_from_grammar = true, generate_requires_npm = true,
}, },
maintainers = { "@dlvandenberg" },
experimental = true, experimental = true,
} }

View file

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

View file

@ -1,7 +1,7 @@
; inherits: html_tags
(identifier) @variable (identifier) @variable
(pipe_sequence (pipe_operator) @operator
"|" @operator)
(string) @string (string) @string
@ -15,6 +15,27 @@
(pipe_arguments (pipe_arguments
(identifier) @variable.parameter)) (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 (structural_assignment
operator: (identifier) @keyword) operator: (identifier) @keyword)
@ -29,10 +50,38 @@
((identifier) @function.builtin ((identifier) @function.builtin
(#eq? @function.builtin "$any"))) (#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" (ternary_operator)
"as" (conditional_operator)
] @keyword ] @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.bracket
[
"{{"
"}}"
] @punctuation.special
[ [
";" ";"
"." "."
@ -50,27 +112,25 @@
"?." "?."
] @punctuation.delimiter ] @punctuation.delimiter
((identifier) @boolean (concatination_expression
(#any-of? @boolean "true" "false")) "+" @operator)
((identifier) @variable.builtin (binary_expression
(#any-of? @variable.builtin "this" "\$event" "null")) [
"-"
[ "&&"
"-" "+"
"&&" "<"
"+" "<="
"<" "="
"<=" "=="
"=" "==="
"==" "!="
"===" "!=="
"!=" ">"
"!==" ">="
">" "*"
">=" "/"
"*" "||"
"/" "%"
"||" ] @operator)
"%"
] @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
(string_fragment) @injection.content) (string_fragment) @injection.content)
(#set! injection.language "html")) (#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 (quoted_attribute_value
(attribute_value) @injection.content) (attribute_value) @injection.content)
(#set! injection.language "javascript")) (#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"))