@@ -8,6 +8,15 @@ scopeName: source.tsx
8
8
fileTypes : [tsx]
9
9
uuid : 805375ec-d614-41f5-8993-5843fe63ea82
10
10
11
+ variables :
12
+ jsxTagOrAtrributeIdentifier : ' [_$a-zA-Z][-$\w.]'
13
+ jsxTagNamespace : (?:({{jsxTagOrAtrributeIdentifier}}*)(?<!\.|-)(:))?
14
+ jsxTagName : \s*{{jsxTagNamespace}}((?:[a-z][a-z0-9]*|({{jsxTagOrAtrributeIdentifier}}*))(?<!\.|-))
15
+ jsxOpeningTagWithoutAttributes : (<){{jsxTagName}}?\s*(>)
16
+ jsxClosingTag : (</){{jsxTagName}}?\s*(>)
17
+ jsxTagStart : (<){{jsxTagName}}(?=\s+(?!\?)|\/?>)
18
+ jsxTagStartLookahead : (?={{jsxTagStart}})
19
+
11
20
repository :
12
21
# Additions:
13
22
# expression repository need to include jsx first followed by whaterver ts grammar says
@@ -34,15 +43,15 @@ repository:
34
43
begin : |-
35
44
(?x)
36
45
(?<=[({\[,?=>:*]|&&|\|\||\?|{{lookBehindReturn}}|{{lookBehindDefault}}|^)\s*
37
- (?=(<)\s*(?:([_$a-zA-Z][-$\w.]*)(?<!\.|-)(:))?((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\w.]*))(?<!\.|-))?\s*(>) )
38
- end : (?!\s*(<)\s*(?:([_$a-zA-Z][-$\w.]*)(?<!\.|-)(:))?((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\w.]*))(?<!\.|-))?\s*(>) )
46
+ (?={{jsxOpeningTagWithoutAttributes}} )
47
+ end : (?!\s*{{jsxOpeningTagWithoutAttributes}} )
39
48
patterns :
40
49
- include : ' #jsx-tag-without-attributes'
41
50
42
51
jsx-tag-without-attributes :
43
52
name : meta.tag.without-attributes.tsx
44
- begin : (<)\s*(?:([_$a-zA-Z][-$\w.]*)(?<!\.|-)(:))?((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\w.]*))(?<!\.|-))?\s*(>)
45
- end : (</)\s*(?:([_$a-zA-Z][-$\w.]*)(?<!\.|-)(:))?((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\w.]*))(?<!\.|-))?\s*(>)
53
+ begin : ' {{jsxOpeningTagWithoutAttributes}} '
54
+ end : ' {{jsxClosingTag}} '
46
55
beginCaptures :
47
56
' 1 ' : {name: punctuation.definition.tag.begin.tsx}
48
57
' 2 ' : {name: entity.name.tag.namespace.tsx}
@@ -67,11 +76,8 @@ repository:
67
76
(?x)
68
77
(?<=[({\[,?=>:*]|&&|\|\||\?|{{lookBehindReturn}}|{{lookBehindDefault}}|^)\s*
69
78
(?!<\s*[_$[:alpha:]][_$[:alnum:]]*((\s+extends\s+[^=>])|,)) # look ahead is not type parameter of arrow
70
- (?=(<)\s*
71
- ([_$a-zA-Z][-$\w.]*(?<!\.|-):)?
72
- ([_$a-zA-Z][-$\w.]*(?<!\.|-))
73
- (?=\s+(?!\?)|/?>))
74
- end : (/>)|(?:(</)\s*(?:([_$a-zA-Z][-$\w.]*)(?<!\.|-)(:))?((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\w.]*))(?<!\.|-))\s*(>))
79
+ {{jsxTagStartLookahead}}
80
+ end : (/>)|(?:{{jsxClosingTag}})
75
81
endCaptures :
76
82
' 0 ' : { name: meta.tag.tsx }
77
83
' 1 ' : { name: punctuation.definition.tag.end.tsx }
@@ -86,13 +92,8 @@ repository:
86
92
87
93
jsx-child-tag :
88
94
# Because this would be included from the jsx-children, this doesnt need to inspect surrounding context
89
- begin : |-
90
- (?x)
91
- (?=(<)\s*
92
- ([_$a-zA-Z][-$\w.]*(?<!\.|-):)?
93
- ([_$a-zA-Z][-$\w.]*(?<!\.|-))
94
- (?=\s+(?!\?)|/?>))
95
- end : (/>)|(?:(</)\s*(?:([_$a-zA-Z][-$\w.]*)(?<!\.|-)(:))?((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\w.]*))(?<!\.|-))\s*(>))
95
+ begin : ' {{jsxTagStartLookahead}}'
96
+ end : (/>)|(?:{{jsxClosingTag}})
96
97
endCaptures :
97
98
' 0 ' : { name: meta.tag.tsx }
98
99
' 1 ' : { name: punctuation.definition.tag.end.tsx }
@@ -107,20 +108,10 @@ repository:
107
108
108
109
jsx-tag :
109
110
name : meta.tag.tsx
110
- begin : |-
111
- (?x)
112
- (?=(<)\s*
113
- (?:([_$a-zA-Z][-$\w.]*)(?<!\.|-)(:))?
114
- ([_$a-zA-Z][-$\w.]*(?<!\.|-))
115
- (?=\s+(?!\?)|/?>))
116
- end : (?=(/>)|(?:(</)\s*(?:([_$a-zA-Z][-$\w.]*)(?<!\.|-)(:))?([_$a-zA-Z][-$\w.]*(?<!\.|-))\s*(>)))
111
+ begin : ' {{jsxTagStartLookahead}}'
112
+ end : (?=(/>)|(?:{{jsxClosingTag}}))
117
113
patterns :
118
- - begin : |-
119
- (?x)
120
- (<)\s*
121
- (?:([_$a-zA-Z][-$\w.]*)(?<!\.|-)(:))?
122
- ((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\w.]*))(?<!\.|-))
123
- (?=\s+(?!\?)|/?>)
114
+ - begin : ' {{jsxTagStart}}'
124
115
beginCaptures :
125
116
' 1 ' : { name: punctuation.definition.tag.begin.tsx }
126
117
' 2 ' : { name: entity.name.tag.namespace.tsx }
@@ -184,7 +175,7 @@ repository:
184
175
match : |-
185
176
(?x)
186
177
\s*
187
- (?:([_$a-zA-Z][-$\w.] *)(:))?
178
+ (?:({{jsxTagOrAtrributeIdentifier}} *)(:))?
188
179
([_$a-zA-Z][-$\w]*)
189
180
(?=\s|=|/?>|/\*|//)
190
181
captures :
0 commit comments