[language-(java|type)script] Prevent the FOO in <FOO.Bar>

…from getting a `constant.other` scope applied.

Also ensure correct scoping of JSX tags even when the tag name is a member expression like `Foo.Bar`.
This commit is contained in:
Andrew Dupont 2024-05-18 15:44:04 -07:00
parent 5024f052e0
commit 55e869c786
3 changed files with 48 additions and 5 deletions

View File

@ -1,3 +1,25 @@
; MISC
; ====
; In the JSX construct `<FOO.Bar>`, `FOO` should not be marked as
; `constant.other.js`. Block off identifiers within complex JSX tag names early
; to prevent this.
(jsx_opening_element
(member_expression
(identifier) @_IGNORE_
(#set! capture.final)))
(jsx_closing_element
(member_expression
(identifier) @_IGNORE_
(#set! capture.final)))
(jsx_self_closing_element
(member_expression
(identifier) @_IGNORE_
(#set! capture.final)))
; STRINGS
; =======
@ -775,16 +797,16 @@
; The "Foo" in `<Foo />`.
(jsx_self_closing_element
name: (identifier) @entity.name.tag.js
name: (_) @entity.name.tag.js
) @meta.tag.jsx.js
; The "Foo" in `<Foo>`.
(jsx_opening_element
name: (identifier) @entity.name.tag.js)
name: (_) @entity.name.tag.js)
; The "Foo" in `</Foo>`.
(jsx_closing_element
name: (identifier) @entity.name.tag.js)
name: (_) @entity.name.tag.js)
; The "bar" in `<Foo bar={true} />`.
(jsx_attribute

View File

@ -14,8 +14,8 @@ treeSitter:
languageSegment: 'ts.tsx'
grammar: 'tree-sitter-tsx/tree-sitter-tsx.wasm'
highlightsQuery: [
'common/highlights.scm'
'tree-sitter-tsx/highlights.scm'
'common/highlights.scm'
]
indentsQuery: [
'common/indents.scm'

View File

@ -1,10 +1,31 @@
; MISC
; ====
; In the JSX construct `<FOO.Bar>`, `FOO` should not be marked as
; `constant.other.ts.tsx`. Block off identifiers within complex JSX tag names
; early to prevent this.
(jsx_opening_element
(nested_identifier
(identifier) @_IGNORE_
(#set! capture.final)))
(jsx_closing_element
(nested_identifier
(identifier) @_IGNORE_
(#set! capture.final)))
(jsx_self_closing_element
(nested_identifier
(identifier) @_IGNORE_
(#set! capture.final)))
; JSX
; ===
; The "Foo" in `<Foo />`.
(jsx_self_closing_element
name: (identifier) @entity.name.tag.ts.tsx
name: (_) @entity.name.tag.ts.tsx
) @meta.tag.ts.tsx
; The "Foo" in `<Foo>`.