Skip to content

Commit 3d230d3

Browse files
committed
2 parents 0e7a5b2 + ebd19c7 commit 3d230d3

12 files changed

+1175
-126
lines changed

TypeScript.YAML-tmLanguage

Lines changed: 48 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@ variables:
2626
lookBehindOf: '^of|{{nonPropertyLookBehind}}of'
2727
lookBehindTypeof: '^typeof|{{nonPropertyLookBehind}}typeof'
2828
lookBehindCase: '^case|{{nonPropertyLookBehind}}case'
29-
matchingParenthesis: (\([^\(\)]*\))
30-
matchingBraces: (\{[^\{\}]*\})
31-
matchingBrackets: (\[[^\[\]]*\])
29+
matchingParenthesis: (\(([^\(\)]|(\([^\(\)]*\)))*\))
30+
matchingBraces: (\{([^\{\}]|(\{[^\{\}]*\}))*\})
31+
matchingBrackets: (\[([^\[\]]|(\[[^\[\]]*\]))*\])
32+
inlineComment: \/\*([^\*]|(\*[^\/]))*\*\/
3233
# Identifier start | matching braces | matching parenthesis | matching square brackets
3334
typeParamersStart: ([_$[:alpha:]]|{{matchingBraces}}|{{matchingParenthesis}}|{{matchingBrackets}})
3435
typeParameters: (<\s*{{typeParamersStart}}([^=<>]|=[^<]|\<\s*{{typeParamersStart}}([^=<>]|=[^<])*\>)*>\s*)
@@ -462,6 +463,7 @@ repository:
462463
'5': { name: meta.definition.function.ts entity.name.function.ts }
463464
end: (?=$|^|;)|(?<=\})
464465
patterns:
466+
- include: '#function-name'
465467
- include: '#function-body'
466468

467469
function-expression:
@@ -474,15 +476,22 @@ repository:
474476
'4': { name: meta.definition.function.ts entity.name.function.ts }
475477
end: (?<=\})
476478
patterns:
479+
- include: '#function-name'
477480
- include: '#function-body'
478481

482+
function-name:
483+
name: meta.definition.function.ts entity.name.function.ts
484+
match: '{{identifier}}'
485+
479486
function-body:
480487
patterns:
481488
- include: '#comment'
482489
- include: '#type-parameters'
483490
- include: '#function-parameters'
484491
- include: '#return-type'
485492
- include: '#decl-block'
493+
- name: keyword.generator.asterisk.ts
494+
match: \*
486495

487496
method-declaration:
488497
patterns:
@@ -721,6 +730,7 @@ repository:
721730
- include: '#variable-initializer'
722731
- include: '#access-modifier'
723732
- include: '#property-accessor'
733+
- include: '#async-modifier'
724734
- include: '#after-operator-block-as-object-literal'
725735
- include: '#decl-block'
726736
- include: '#expression'
@@ -735,6 +745,10 @@ repository:
735745
name: storage.type.property.ts
736746
match: '{{startOfIdentifier}}(get|set){{endOfIdentifier}}'
737747

748+
async-modifier:
749+
name: storage.modifier.async.ts
750+
match: '{{startOfIdentifier}}(async){{endOfIdentifier}}'
751+
738752
#enum
739753
enum-declaration:
740754
name: meta.enum.declaration.ts
@@ -951,18 +965,24 @@ repository:
951965
- include: '#statements'
952966

953967
for-loop:
954-
begin: '{{startOfIdentifier}}(for)(?:\s+(await))?\s*(\()'
968+
begin: '{{startOfIdentifier}}for(?=((\s+|(\s*{{inlineComment}}\s*))await)?\s*({{inlineComment}}\s*)?(\())'
955969
beginCaptures:
956-
'1': { name: keyword.control.loop.ts }
957-
'2': { name: keyword.control.loop.ts }
958-
'3': { name: meta.brace.round.ts }
959-
end: \)
960-
endCaptures:
961-
'0': { name: meta.brace.round.ts }
970+
'0': { name: keyword.control.loop.ts }
971+
end: (?<=\))
962972
patterns:
963-
- include: '#var-expr'
964-
- include: '#expression'
965-
- include: '#punctuation-semicolon'
973+
- include: '#comment'
974+
- name: keyword.control.loop.ts
975+
match: await
976+
- begin: \(
977+
beginCaptures:
978+
'0': { name: meta.brace.round.ts }
979+
end: \)
980+
endCaptures:
981+
'0': { name: meta.brace.round.ts }
982+
patterns:
983+
- include: '#var-expr'
984+
- include: '#expression'
985+
- include: '#punctuation-semicolon'
966986

967987
#blocks
968988
decl-block:
@@ -1005,14 +1025,19 @@ repository:
10051025
- include: '#object-literal-method-declaration'
10061026
- name: meta.object.member.ts meta.object-literal.key.ts
10071027
begin: (?=\[)
1008-
end: (?=:)
1028+
end: (?=:)|((?<=[\]])(?=\s*[\(\<]))
10091029
patterns:
10101030
- include: '#array-literal'
10111031
- name: meta.object.member.ts meta.object-literal.key.ts
10121032
begin: (?=[\'\"])
1013-
end: (?=:)
1033+
end: (?=:)|((?<=[\'\"])(?=\s*[\(\<]))
10141034
patterns:
10151035
- include: '#string'
1036+
- name: meta.method.declaration.ts
1037+
begin: (?<=[\]\'\"])(?=\s*[\(\<])
1038+
end: (?=\}|;|,)|(?<=\})
1039+
patterns:
1040+
- include: '#function-body'
10161041
- name: meta.object.member.ts
10171042
match: (?![_$[:alpha:]])([[:digit:]]+)\s*(?=:)
10181043
captures:
@@ -1154,6 +1179,14 @@ repository:
11541179
patterns:
11551180
- name: keyword.control.flow.ts
11561181
match: '{{startOfIdentifier}}(await){{endOfIdentifier}}'
1182+
- begin: '{{startOfIdentifier}}(yield){{endOfIdentifier}}(?=\s*{{inlineComment}}\s*\*)'
1183+
beginCaptures:
1184+
'1': { name: keyword.control.flow.ts }
1185+
end: \*
1186+
endCaptures:
1187+
'0': { name: keyword.generator.asterisk.ts }
1188+
patterns:
1189+
- include: '#comment'
11571190
- match: '{{startOfIdentifier}}(yield){{endOfIdentifier}}(?:\s*(\*))?'
11581191
captures:
11591192
'1': { name: keyword.control.flow.ts }

0 commit comments

Comments
 (0)