Skip to content

Commit ee94bd5

Browse files
committed
Merge branch 'master' into multiLineArrowParameters
2 parents bf14f62 + 874564b commit ee94bd5

8 files changed

+232
-232
lines changed

TypeScript.YAML-tmLanguage

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ variables:
3737
# Identifier start | matching braces | matching parenthesis | matching square brackets | matching strings
3838
typeArgumentsStart: ({{typeParamersStart}}|(\'[^\']*\')|(\"[^\"]*\")|(\`[^\`]*\`))
3939
typeArgumentsInnerExpressionPart: '[^<>\(]|{{matchingParenthesis}}|(?<==)\>'
40-
typeArguments: (<\s*{{typeArgumentsStart}}({{typeArgumentsInnerExpressionPart}}|\<\s*{{typeArgumentsStart}}({{typeArgumentsInnerExpressionPart}})*(?!=)\>)*(?!=)>\s*)
40+
typeArguments: '<\s*{{typeArgumentsStart}}({{typeArgumentsInnerExpressionPart}}|\<\s*{{typeArgumentsStart}}({{typeArgumentsInnerExpressionPart}})*(?!=)\>)*(?!=)>'
41+
functionCallLookup: \s*(\?\.\s*)?({{typeArguments}}\s*)?\(
4142
returnTypeOfArrow: \s*([^<>\(\)]|\<[^<>]+\>|\([^\(\)]+\))+
42-
functionCallLookup: \s*(\?\.\s*)?{{typeArguments}}?\(
4343
arrowLookup: |-
4444
# sure shot arrow functions even if => is on new line
4545
(
@@ -1121,16 +1121,7 @@ repository:
11211121
- include: '#comment'
11221122
- name: meta.function-call.ts punctuation.accessor.optional.ts
11231123
match: \?\.
1124-
- name: meta.type.parameters.ts
1125-
begin: \<
1126-
beginCaptures:
1127-
'0': { name: punctuation.definition.typeparameters.begin.ts }
1128-
end: \>
1129-
endCaptures:
1130-
'0': { name: punctuation.definition.typeparameters.end.ts }
1131-
patterns:
1132-
- include: '#type'
1133-
- include: '#punctuation-comma'
1124+
- include: '#type-arguments'
11341125
- include: '#paren-expression'
11351126

11361127
new-expr:
@@ -1290,7 +1281,7 @@ repository:
12901281
- name: keyword.operator.arithmetic.ts
12911282
match: '%|\*|/|-|\+'
12921283
# capture the arithmetic sign followed by variable or parenthesized expression so that it is not interpreted as regex
1293-
- match: (?<=[_$[:alnum:])])\s*(/)(?![/*])
1284+
- match: (?<=[_$[:alnum:])\]])\s*(/)(?![/*])
12941285
captures:
12951286
'1': { name: keyword.operator.arithmetic.ts }
12961287

@@ -1814,6 +1805,19 @@ repository:
18141805
- include: '#type'
18151806
- include: '#punctuation-comma'
18161807

1808+
#type arguments
1809+
type-arguments:
1810+
name: meta.type.parameters.ts
1811+
begin: \<
1812+
beginCaptures:
1813+
'0': { name: punctuation.definition.typeparameters.begin.ts }
1814+
end: \>
1815+
endCaptures:
1816+
'0': { name: punctuation.definition.typeparameters.end.ts }
1817+
patterns:
1818+
- include: '#type'
1819+
- include: '#punctuation-comma'
1820+
18171821
#different types
18181822
type:
18191823
patterns:
@@ -2092,7 +2096,7 @@ repository:
20922096
- include: '#regexp'
20932097
# Check if complete regexp syntax
20942098
- name: string.regexp.ts
2095-
begin: (?<![_$[:alnum:])])\/(?![\/*])(?=(?:[^\/\\\[]|\\.|\[([^\]\\]|\\.)+\])+\/(?![\/*])[gimuy]*(?!\s*[a-zA-Z0-9_$]))
2099+
begin: (?<![_$[:alnum:])\]])\/(?![\/*])(?=(?:[^\/\\\[]|\\.|\[([^\]\\]|\\.)+\])+\/(?![\/*])[gimuy]*(?!\s*[a-zA-Z0-9_$]))
20962100
beginCaptures:
20972101
'0': {name: punctuation.definition.string.begin.ts}
20982102
end: (/)([gimuy]*)

TypeScript.tmLanguage

Lines changed: 40 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3502,39 +3502,8 @@
35023502
<string>\?\.</string>
35033503
</dict>
35043504
<dict>
3505-
<key>name</key>
3506-
<string>meta.type.parameters.ts</string>
3507-
<key>begin</key>
3508-
<string>\&lt;</string>
3509-
<key>beginCaptures</key>
3510-
<dict>
3511-
<key>0</key>
3512-
<dict>
3513-
<key>name</key>
3514-
<string>punctuation.definition.typeparameters.begin.ts</string>
3515-
</dict>
3516-
</dict>
3517-
<key>end</key>
3518-
<string>\&gt;</string>
3519-
<key>endCaptures</key>
3520-
<dict>
3521-
<key>0</key>
3522-
<dict>
3523-
<key>name</key>
3524-
<string>punctuation.definition.typeparameters.end.ts</string>
3525-
</dict>
3526-
</dict>
3527-
<key>patterns</key>
3528-
<array>
3529-
<dict>
3530-
<key>include</key>
3531-
<string>#type</string>
3532-
</dict>
3533-
<dict>
3534-
<key>include</key>
3535-
<string>#punctuation-comma</string>
3536-
</dict>
3537-
</array>
3505+
<key>include</key>
3506+
<string>#type-arguments</string>
35383507
</dict>
35393508
<dict>
35403509
<key>include</key>
@@ -4001,7 +3970,7 @@
40013970
</dict>
40023971
<dict>
40033972
<key>match</key>
4004-
<string>(?&lt;=[_$[:alnum:])])\s*(/)(?![/*])</string>
3973+
<string>(?&lt;=[_$[:alnum:])\]])\s*(/)(?![/*])</string>
40053974
<key>captures</key>
40063975
<dict>
40073976
<key>1</key>
@@ -5153,6 +5122,42 @@
51535122
</dict>
51545123
</array>
51555124
</dict>
5125+
<key>type-arguments</key>
5126+
<dict>
5127+
<key>name</key>
5128+
<string>meta.type.parameters.ts</string>
5129+
<key>begin</key>
5130+
<string>\&lt;</string>
5131+
<key>beginCaptures</key>
5132+
<dict>
5133+
<key>0</key>
5134+
<dict>
5135+
<key>name</key>
5136+
<string>punctuation.definition.typeparameters.begin.ts</string>
5137+
</dict>
5138+
</dict>
5139+
<key>end</key>
5140+
<string>\&gt;</string>
5141+
<key>endCaptures</key>
5142+
<dict>
5143+
<key>0</key>
5144+
<dict>
5145+
<key>name</key>
5146+
<string>punctuation.definition.typeparameters.end.ts</string>
5147+
</dict>
5148+
</dict>
5149+
<key>patterns</key>
5150+
<array>
5151+
<dict>
5152+
<key>include</key>
5153+
<string>#type</string>
5154+
</dict>
5155+
<dict>
5156+
<key>include</key>
5157+
<string>#punctuation-comma</string>
5158+
</dict>
5159+
</array>
5160+
</dict>
51565161
<key>type</key>
51575162
<dict>
51585163
<key>patterns</key>
@@ -5906,7 +5911,7 @@
59065911
<key>name</key>
59075912
<string>string.regexp.ts</string>
59085913
<key>begin</key>
5909-
<string>(?&lt;![_$[:alnum:])])\/(?![\/*])(?=(?:[^\/\\\[]|\\.|\[([^\]\\]|\\.)+\])+\/(?![\/*])[gimuy]*(?!\s*[a-zA-Z0-9_$]))</string>
5914+
<string>(?&lt;![_$[:alnum:])\]])\/(?![\/*])(?=(?:[^\/\\\[]|\\.|\[([^\]\\]|\\.)+\])+\/(?![\/*])[gimuy]*(?!\s*[a-zA-Z0-9_$]))</string>
59105915
<key>beginCaptures</key>
59115916
<dict>
59125917
<key>0</key>

TypeScriptReact.YAML-tmLanguage

Lines changed: 28 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ uuid: 805375ec-d614-41f5-8993-5843fe63ea82
1010

1111
variables:
1212
possiblyMultilineArrow: ([\(]\s*$) # during lookup treat ( followed by line end as arrow
13+
jsxTagOrAtrributeIdentifier: '[_$a-zA-Z][-$\w.]'
14+
jsxTagNamespace: (?:({{jsxTagOrAtrributeIdentifier}}*)(?<!\.|-)(:))?
15+
jsxTagName: \s*{{jsxTagNamespace}}((?:[a-z][a-z0-9]*|({{jsxTagOrAtrributeIdentifier}}*))(?<!\.|-))
16+
jsxOpeningTagWithoutAttributes: (<){{jsxTagName}}?\s*(>)
17+
jsxClosingTag: (</){{jsxTagName}}?\s*(>)
18+
jsxTagStart: (<){{jsxTagName}}(?=({{typeArguments}})?\s+(?!\?)|\/?>)
19+
jsxTagStartLookahead: (?={{jsxTagStart}})
20+
jsxLookBehindInExpression: (?<=[({\[,?=>:*]|&&|\|\||\?|{{lookBehindReturn}}|{{lookBehindDefault}}|^)\s*
1321

1422
repository:
1523
# Additions:
@@ -34,18 +42,15 @@ repository:
3442

3543
#jsx tags
3644
jsx-tag-without-attributes-in-expression:
37-
begin: |-
38-
(?x)
39-
(?<=[({\[,?=>:*]|&&|\|\||\?|{{lookBehindReturn}}|{{lookBehindDefault}}|^)\s*
40-
(?=(<)\s*(?:([_$a-zA-Z][-$\w.]*)(?<!\.|-)(:))?((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\w.]*))(?<!\.|-))?\s*(>))
41-
end: (?!\s*(<)\s*(?:([_$a-zA-Z][-$\w.]*)(?<!\.|-)(:))?((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\w.]*))(?<!\.|-))?\s*(>))
45+
begin: '{{jsxLookBehindInExpression}}(?={{jsxOpeningTagWithoutAttributes}})'
46+
end: (?!{{jsxOpeningTagWithoutAttributes}})
4247
patterns:
4348
- include: '#jsx-tag-without-attributes'
4449

4550
jsx-tag-without-attributes:
4651
name: meta.tag.without-attributes.tsx
47-
begin: (<)\s*(?:([_$a-zA-Z][-$\w.]*)(?<!\.|-)(:))?((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\w.]*))(?<!\.|-))?\s*(>)
48-
end: (</)\s*(?:([_$a-zA-Z][-$\w.]*)(?<!\.|-)(:))?((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\w.]*))(?<!\.|-))?\s*(>)
52+
begin: '{{jsxOpeningTagWithoutAttributes}}'
53+
end: '{{jsxClosingTag}}'
4954
beginCaptures:
5055
'1': {name: punctuation.definition.tag.begin.tsx}
5156
'2': {name: entity.name.tag.namespace.tsx}
@@ -68,36 +73,18 @@ repository:
6873
# We need to differentiate between the relational '<' operator and the beginning of a tag using the surrounding context.
6974
begin: |-
7075
(?x)
71-
(?<=[({\[,?=>:*]|&&|\|\||\?|{{lookBehindReturn}}|{{lookBehindDefault}}|^)\s*
76+
{{jsxLookBehindInExpression}}
7277
(?!<\s*[_$[:alpha:]][_$[:alnum:]]*((\s+extends\s+[^=>])|,)) # look ahead is not type parameter of arrow
73-
(?=(<)\s*
74-
([_$a-zA-Z][-$\w.]*(?<!\.|-):)?
75-
([_$a-zA-Z][-$\w.]*(?<!\.|-))
76-
(?=\s+(?!\?)|/?>))
77-
end: (/>)|(?:(</)\s*(?:([_$a-zA-Z][-$\w.]*)(?<!\.|-)(:))?((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\w.]*))(?<!\.|-))\s*(>))
78-
endCaptures:
79-
'0': { name: meta.tag.tsx }
80-
'1': { name: punctuation.definition.tag.end.tsx }
81-
'2': { name: punctuation.definition.tag.begin.tsx }
82-
'3': { name: entity.name.tag.namespace.tsx }
83-
'4': { name: punctuation.separator.namespace.tsx }
84-
'5': { name: entity.name.tag.tsx }
85-
'6': { name: support.class.component.tsx }
86-
'7': { name: punctuation.definition.tag.end.tsx }
78+
{{jsxTagStartLookahead}}
79+
end: (?!{{jsxTagStart}})
8780
patterns:
8881
- include: '#jsx-tag'
8982

90-
jsx-child-tag:
91-
# Because this would be included from the jsx-children, this doesnt need to inspect surrounding context
92-
begin: |-
93-
(?x)
94-
(?=(<)\s*
95-
([_$a-zA-Z][-$\w.]*(?<!\.|-):)?
96-
([_$a-zA-Z][-$\w.]*(?<!\.|-))
97-
(?=\s+(?!\?)|/?>))
98-
end: (/>)|(?:(</)\s*(?:([_$a-zA-Z][-$\w.]*)(?<!\.|-)(:))?((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\w.]*))(?<!\.|-))\s*(>))
83+
jsx-tag:
84+
name: meta.tag.tsx
85+
begin: '{{jsxTagStartLookahead}}'
86+
end: (/>)|(?:{{jsxClosingTag}})
9987
endCaptures:
100-
'0': { name: meta.tag.tsx }
10188
'1': { name: punctuation.definition.tag.end.tsx }
10289
'2': { name: punctuation.definition.tag.begin.tsx }
10390
'3': { name: entity.name.tag.namespace.tsx }
@@ -106,36 +93,18 @@ repository:
10693
'6': { name: support.class.component.tsx }
10794
'7': { name: punctuation.definition.tag.end.tsx }
10895
patterns:
109-
- include: '#jsx-tag'
110-
111-
jsx-tag:
112-
name: meta.tag.tsx
113-
begin: |-
114-
(?x)
115-
(?=(<)\s*
116-
(?:([_$a-zA-Z][-$\w.]*)(?<!\.|-)(:))?
117-
([_$a-zA-Z][-$\w.]*(?<!\.|-))
118-
(?=\s+(?!\?)|/?>))
119-
end: (?=(/>)|(?:(</)\s*(?:([_$a-zA-Z][-$\w.]*)(?<!\.|-)(:))?([_$a-zA-Z][-$\w.]*(?<!\.|-))\s*(>)))
120-
patterns:
121-
- begin: |-
122-
(?x)
123-
(<)\s*
124-
(?:([_$a-zA-Z][-$\w.]*)(?<!\.|-)(:))?
125-
((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\w.]*))(?<!\.|-))
126-
(?=\s+(?!\?)|/?>)
96+
- begin: '{{jsxTagStart}}'
12797
beginCaptures:
12898
'1': { name: punctuation.definition.tag.begin.tsx }
12999
'2': { name: entity.name.tag.namespace.tsx }
130100
'3': { name: punctuation.separator.namespace.tsx }
131101
'4': { name: entity.name.tag.tsx }
132102
'5': { name: support.class.component.tsx }
133103
end: (?=[/]?>)
134-
contentName: meta.tag.attributes.tsx
135104
patterns:
136105
- include: '#comment'
106+
- include: '#type-arguments'
137107
- include: '#jsx-tag-attributes'
138-
- include: '#jsx-tag-attributes-illegal'
139108
- begin: (>)
140109
beginCaptures:
141110
'1': { name: punctuation.definition.tag.end.tsx }
@@ -148,7 +117,8 @@ repository:
148117
jsx-children:
149118
patterns:
150119
- include: '#jsx-tag-without-attributes'
151-
- include: '#jsx-child-tag'
120+
# Because this would be included from the jsx-children, this doesnt need to inspect surrounding context
121+
- include: '#jsx-tag'
152122
- include: '#jsx-evaluated-code'
153123
- include: '#jsx-entities'
154124

@@ -176,18 +146,22 @@ repository:
176146

177147
#jsx attributes
178148
jsx-tag-attributes:
149+
name: meta.tag.attributes.tsx
150+
begin: \s+
151+
end: (?=[/]?>)
179152
patterns:
180153
- include: '#jsx-tag-attribute-name'
181154
- include: '#jsx-tag-attribute-assignment'
182155
- include: '#jsx-string-double-quoted'
183156
- include: '#jsx-string-single-quoted'
184157
- include: '#jsx-evaluated-code'
158+
- include: '#jsx-tag-attributes-illegal'
185159

186160
jsx-tag-attribute-name:
187161
match: |-
188162
(?x)
189163
\s*
190-
(?:([_$a-zA-Z][-$\w.]*)(:))?
164+
(?:({{jsxTagOrAtrributeIdentifier}}*)(:))?
191165
([_$a-zA-Z][-$\w]*)
192166
(?=\s|=|/?>|/\*|//)
193167
captures:

0 commit comments

Comments
 (0)