chore(ecma,jsx): update parser and queries

This commit is contained in:
Amaan Qureshi 2024-01-31 10:55:10 -05:00
parent 364b86ec8e
commit 6da205148f
6 changed files with 27 additions and 9 deletions

View file

@ -297,7 +297,7 @@
"revision": "2b57cd9541f9fd3a89207d054ce8fbe72657c444" "revision": "2b57cd9541f9fd3a89207d054ce8fbe72657c444"
}, },
"javascript": { "javascript": {
"revision": "f1e5a09b8d02f8209a68249c93f0ad647b228e6e" "revision": "6d84193ae2395e54b699d9b7358bcf66cbcc19f5"
}, },
"jq": { "jq": {
"revision": "13990f530e8e6709b7978503da9bc8701d366791" "revision": "13990f530e8e6709b7978503da9bc8701d366791"

View file

@ -3,7 +3,7 @@
(for_statement) (for_statement)
(while_statement) (while_statement)
(arrow_function) (arrow_function)
(function) (function_expression)
(function_declaration) (function_declaration)
(class_declaration) (class_declaration)
(method_definition) (method_definition)

View file

@ -36,7 +36,7 @@
; Function and method definitions ; Function and method definitions
;-------------------------------- ;--------------------------------
(function (function_expression
name: (identifier) @function) name: (identifier) @function)
(function_declaration (function_declaration
@ -61,7 +61,7 @@
(pair (pair
key: (property_identifier) @function.method key: (property_identifier) @function.method
value: (function)) value: (function_expression))
(pair (pair
key: (property_identifier) @function.method key: (property_identifier) @function.method
@ -77,7 +77,7 @@
left: left:
(member_expression (member_expression
property: (property_identifier) @function.method) property: (property_identifier) @function.method)
right: (function)) right: (function_expression))
(variable_declarator (variable_declarator
name: (identifier) @function name: (identifier) @function
@ -85,7 +85,7 @@
(variable_declarator (variable_declarator
name: (identifier) @function name: (identifier) @function
value: (function)) value: (function_expression))
(assignment_expression (assignment_expression
left: (identifier) @function left: (identifier) @function
@ -93,7 +93,7 @@
(assignment_expression (assignment_expression
left: (identifier) @function left: (identifier) @function
right: (function)) right: (function_expression))
; Function and method calls ; Function and method calls
;-------------------------- ;--------------------------
@ -158,7 +158,10 @@
(undefined) (undefined)
] @constant.builtin ] @constant.builtin
(comment) @comment @spell [
(comment)
(html_comment)
] @comment @spell
((comment) @comment.documentation ((comment) @comment.documentation
(#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$")) (#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$"))

View file

@ -16,6 +16,7 @@
] ]
(#lua-match? @injection.language "^[a-zA-Z][a-zA-Z0-9]*$") (#lua-match? @injection.language "^[a-zA-Z][a-zA-Z0-9]*$")
(#offset! @injection.content 0 1 0 -1) (#offset! @injection.content 0 1 0 -1)
(#set! injection.include-children)
(#not-eq? @injection.language "svg")) (#not-eq? @injection.language "svg"))
; svg`...` or svg(`...`), which uses the html parser, so is not included in the previous query ; svg`...` or svg(`...`), which uses the html parser, so is not included in the previous query
@ -30,6 +31,7 @@
(template_string) @injection.content (template_string) @injection.content
] ]
(#offset! @injection.content 0 1 0 -1) (#offset! @injection.content 0 1 0 -1)
(#set! injection.include-children)
(#set! injection.language "html")) (#set! injection.language "html"))
(call_expression (call_expression
@ -39,6 +41,7 @@
arguments: arguments:
((template_string) @injection.content ((template_string) @injection.content
(#offset! @injection.content 0 1 0 -1) (#offset! @injection.content 0 1 0 -1)
(#set! injection.include-children)
(#set! injection.language "graphql"))) (#set! injection.language "graphql")))
(call_expression (call_expression
@ -48,6 +51,7 @@
arguments: arguments:
((template_string) @injection.content ((template_string) @injection.content
(#offset! @injection.content 0 1 0 -1) (#offset! @injection.content 0 1 0 -1)
(#set! injection.include-children)
(#set! injection.language "glimmer"))) (#set! injection.language "glimmer")))
((glimmer_template) @injection.content ((glimmer_template) @injection.content
@ -62,6 +66,7 @@
arguments: arguments:
((template_string) @injection.content ((template_string) @injection.content
(#offset! @injection.content 0 1 0 -1) (#offset! @injection.content 0 1 0 -1)
(#set! injection.include-children)
(#set! injection.language "styled"))) (#set! injection.language "styled")))
; styled(Component)`<css>` ; styled(Component)`<css>`
@ -73,6 +78,7 @@
arguments: arguments:
((template_string) @injection.content ((template_string) @injection.content
(#offset! @injection.content 0 1 0 -1) (#offset! @injection.content 0 1 0 -1)
(#set! injection.include-children)
(#set! injection.language "styled"))) (#set! injection.language "styled")))
; styled.div.attrs({ prop: "foo" })`<css>` ; styled.div.attrs({ prop: "foo" })`<css>`
@ -88,6 +94,7 @@
arguments: arguments:
((template_string) @injection.content ((template_string) @injection.content
(#offset! @injection.content 0 1 0 -1) (#offset! @injection.content 0 1 0 -1)
(#set! injection.include-children)
(#set! injection.language "styled"))) (#set! injection.language "styled")))
; styled(Component).attrs({ prop: "foo" })`<css>` ; styled(Component).attrs({ prop: "foo" })`<css>`
@ -103,6 +110,7 @@
arguments: arguments:
((template_string) @injection.content ((template_string) @injection.content
(#offset! @injection.content 0 1 0 -1) (#offset! @injection.content 0 1 0 -1)
(#set! injection.include-children)
(#set! injection.language "styled"))) (#set! injection.language "styled")))
((regex_pattern) @injection.content ((regex_pattern) @injection.content
@ -115,6 +123,7 @@
((template_string) @injection.content ((template_string) @injection.content
(#lua-match? @injection.content "^`#graphql") (#lua-match? @injection.content "^`#graphql")
(#offset! @injection.content 0 1 0 -1) (#offset! @injection.content 0 1 0 -1)
(#set! injection.include-children)
(#set! injection.language "graphql")) (#set! injection.language "graphql"))
; el.innerHTML = `<html>` ; el.innerHTML = `<html>`
@ -125,6 +134,7 @@
(#any-of? @_prop "outerHTML" "innerHTML")) (#any-of? @_prop "outerHTML" "innerHTML"))
right: (template_string) @injection.content right: (template_string) @injection.content
(#offset! @injection.content 0 1 0 -1) (#offset! @injection.content 0 1 0 -1)
(#set! injection.include-children)
(#set! injection.language "html")) (#set! injection.language "html"))
; el.innerHTML = '<html>' ; el.innerHTML = '<html>'
@ -157,6 +167,7 @@
value: value:
((template_string) @injection.content ((template_string) @injection.content
(#offset! @injection.content 0 1 0 -1) (#offset! @injection.content 0 1 0 -1)
(#set! injection.include-children)
(#set! injection.language "angular"))))))) (#set! injection.language "angular")))))))
; @Component({ ; @Component({
@ -178,6 +189,7 @@
(array (array
((template_string) @injection.content ((template_string) @injection.content
(#offset! @injection.content 0 1 0 -1) (#offset! @injection.content 0 1 0 -1)
(#set! injection.include-children)
(#set! injection.language "css")))))))) (#set! injection.language "css"))))))))
; @Component({ ; @Component({
@ -197,5 +209,6 @@
(#eq? @_prop "styles")) (#eq? @_prop "styles"))
value: value:
((template_string) @injection.content ((template_string) @injection.content
(#set! injection.include-children)
(#offset! @injection.content 0 1 0 -1) (#offset! @injection.content 0 1 0 -1)
(#set! injection.language "css"))))))) (#set! injection.language "css")))))))

View file

@ -2,7 +2,7 @@
;------- ;-------
(statement_block) @local.scope (statement_block) @local.scope
(function) @local.scope (function_expression) @local.scope
(arrow_function) @local.scope (arrow_function) @local.scope

View file

@ -62,4 +62,6 @@
(identifier) @tag.builtin (identifier) @tag.builtin
(property_identifier) @tag)) (property_identifier) @tag))
(html_character_reference) @tag
(jsx_text) @none (jsx_text) @none