Skip to content

Commit fecf4e3

Browse files
committed
Handle comments inside type
Fixes #65
1 parent ddb2346 commit fecf4e3

File tree

6 files changed

+195
-58
lines changed

6 files changed

+195
-58
lines changed

TypeScript.YAML-tmLanguage

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,7 @@ repository:
689689
begin: '(?<=\))\s*:'
690690
end: (?<!:)((?=$)|(?=\{|;|//))
691691
patterns:
692+
- include: '#comment'
692693
# Handle returning of object type specifically here so as to not confuse it with the start of function block
693694
- name: meta.object.type.ts
694695
begin: (?<=:)\s*(\{)
@@ -706,13 +707,14 @@ repository:
706707
begin: ":"
707708
end: (?=$|[,);\}\]]|//)|(?==[^>])|(?<=[\}>\]\)]|[_$[:alpha:]])\s*(?=\{)
708709
patterns:
710+
- include: '#comment'
709711
- include: '#expression-operator'
710712
- include: '#type'
711-
- include: '#comment'
712713

713714
type:
714715
name: meta.type.ts
715716
patterns:
717+
- include: '#comment'
716718
- include: '#string'
717719
- include: '#type-primitive'
718720
- include: '#type-parameters'
@@ -757,7 +759,6 @@ repository:
757759
endCaptures:
758760
'0': { name: meta.brace.round.ts }
759761
patterns:
760-
- include: '#comment'
761762
- include: '#type'
762763
- include: '#function-parameters'
763764

@@ -772,6 +773,7 @@ repository:
772773
'0': { name: storage.type.function.arrow.ts }
773774
end: (?<!=>)(?=[,\]\)\{\}=;>]|//|$)
774775
patterns:
776+
- include: '#comment'
775777
# Handle returning of object type specifically here so as to not confuse it with the start of function block
776778
- name: meta.object.type.ts
777779
begin: (?<==>)\s*(\{)
@@ -794,7 +796,6 @@ repository:
794796
'0': { name: meta.brace.square.ts }
795797
patterns:
796798
- include: '#type'
797-
- include: '#comment'
798799

799800
type-name:
800801
patterns:
@@ -814,9 +815,9 @@ repository:
814815
endCaptures:
815816
'1': { name: punctuation.definition.typeparameters.end.ts }
816817
patterns:
818+
- include: '#comment'
817819
- name: storage.modifier.ts
818820
match: '(?<!\.|\$)\b(extends)\b(?!\$)'
819-
- include: '#comment'
820821
- include: '#type'
821822

822823
variable-initializer:
@@ -896,7 +897,6 @@ repository:
896897
endCaptures:
897898
'1': { name: punctuation.definition.typeparameters.end.ts }
898899
patterns:
899-
- include: '#comment'
900900
- include: '#type'
901901
#TODO: Scope function names and method names
902902
#TODO: Scope function call arguments better?
@@ -926,7 +926,6 @@ repository:
926926
end: '(?=[(;),]|$)'
927927
patterns:
928928
- include: '#type'
929-
- include: '#comment'
930929

931930
object-member:
932931
patterns:
@@ -998,6 +997,7 @@ repository:
998997
begin: (?x)(?<=return|throw|yield|await|async|[=(\[,:>*])\s*(?=\([^()]*(\([^()]*\))*[^()]*(\([^()]*\))*[^()]*\)(\s*:\s*(.)*)?\s*=>)
999998
end: (?==>)
1000999
patterns:
1000+
- include: '#comment'
10011001
- include: '#function-parameters'
10021002
# return type of the arrow
10031003
- include: '#arrow-return-type'

TypeScript.tmLanguage

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,10 @@
189189
<string>meta.arrow.ts</string>
190190
<key>patterns</key>
191191
<array>
192+
<dict>
193+
<key>include</key>
194+
<string>#comment</string>
195+
</dict>
192196
<dict>
193197
<key>include</key>
194198
<string>#function-parameters</string>
@@ -1415,10 +1419,6 @@
14151419
<string>meta.type.parameters.ts</string>
14161420
<key>patterns</key>
14171421
<array>
1418-
<dict>
1419-
<key>include</key>
1420-
<string>#comment</string>
1421-
</dict>
14221422
<dict>
14231423
<key>include</key>
14241424
<string>#type</string>
@@ -2190,10 +2190,6 @@
21902190
<key>include</key>
21912191
<string>#type</string>
21922192
</dict>
2193-
<dict>
2194-
<key>include</key>
2195-
<string>#comment</string>
2196-
</dict>
21972193
</array>
21982194
</dict>
21992195
<key>null-literal</key>
@@ -3067,6 +3063,10 @@
30673063
<string>meta.return.type.ts</string>
30683064
<key>patterns</key>
30693065
<array>
3066+
<dict>
3067+
<key>include</key>
3068+
<string>#comment</string>
3069+
</dict>
30703070
<dict>
30713071
<key>begin</key>
30723072
<string>(?&lt;=:)\s*(\{)</string>
@@ -3422,6 +3422,10 @@
34223422
<string>meta.type.ts</string>
34233423
<key>patterns</key>
34243424
<array>
3425+
<dict>
3426+
<key>include</key>
3427+
<string>#comment</string>
3428+
</dict>
34253429
<dict>
34263430
<key>include</key>
34273431
<string>#string</string>
@@ -3472,15 +3476,15 @@
34723476
<array>
34733477
<dict>
34743478
<key>include</key>
3475-
<string>#expression-operator</string>
3479+
<string>#comment</string>
34763480
</dict>
34773481
<dict>
34783482
<key>include</key>
3479-
<string>#type</string>
3483+
<string>#expression-operator</string>
34803484
</dict>
34813485
<dict>
34823486
<key>include</key>
3483-
<string>#comment</string>
3487+
<string>#type</string>
34843488
</dict>
34853489
</array>
34863490
</dict>
@@ -3550,6 +3554,10 @@
35503554
<string>meta.type.function.return.ts</string>
35513555
<key>patterns</key>
35523556
<array>
3557+
<dict>
3558+
<key>include</key>
3559+
<string>#comment</string>
3560+
</dict>
35533561
<dict>
35543562
<key>begin</key>
35553563
<string>(?&lt;==&gt;)\s*(\{)</string>
@@ -3707,16 +3715,16 @@
37073715
<string>meta.type.parameters.ts</string>
37083716
<key>patterns</key>
37093717
<array>
3718+
<dict>
3719+
<key>include</key>
3720+
<string>#comment</string>
3721+
</dict>
37103722
<dict>
37113723
<key>match</key>
37123724
<string>(?&lt;!\.|\$)\b(extends)\b(?!\$)</string>
37133725
<key>name</key>
37143726
<string>storage.modifier.ts</string>
37153727
</dict>
3716-
<dict>
3717-
<key>include</key>
3718-
<string>#comment</string>
3719-
</dict>
37203728
<dict>
37213729
<key>include</key>
37223730
<string>#type</string>
@@ -3754,10 +3762,6 @@
37543762
<string>meta.type.paren.cover.ts</string>
37553763
<key>patterns</key>
37563764
<array>
3757-
<dict>
3758-
<key>include</key>
3759-
<string>#comment</string>
3760-
</dict>
37613765
<dict>
37623766
<key>include</key>
37633767
<string>#type</string>
@@ -3805,10 +3809,6 @@
38053809
<key>include</key>
38063810
<string>#type</string>
38073811
</dict>
3808-
<dict>
3809-
<key>include</key>
3810-
<string>#comment</string>
3811-
</dict>
38123812
</array>
38133813
</dict>
38143814
<key>undefined-literal</key>

TypeScriptReact.YAML-tmLanguage

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,7 @@ repository:
693693
begin: '(?<=\))\s*:'
694694
end: (?<!:)((?=$)|(?=\{|;|//))
695695
patterns:
696+
- include: '#comment'
696697
# Handle returning of object type specifically here so as to not confuse it with the start of function block
697698
- name: meta.object.type.tsx
698699
begin: (?<=:)\s*(\{)
@@ -710,13 +711,14 @@ repository:
710711
begin: ":"
711712
end: (?=$|[,);\}\]]|//)|(?==[^>])|(?<=[\}>\]\)]|[_$[:alpha:]])\s*(?=\{)
712713
patterns:
714+
- include: '#comment'
713715
- include: '#expression-operator'
714716
- include: '#type'
715-
- include: '#comment'
716717

717718
type:
718719
name: meta.type.tsx
719720
patterns:
721+
- include: '#comment'
720722
- include: '#string'
721723
- include: '#type-primitive'
722724
- include: '#type-parameters'
@@ -761,7 +763,6 @@ repository:
761763
endCaptures:
762764
'0': { name: meta.brace.round.tsx }
763765
patterns:
764-
- include: '#comment'
765766
- include: '#type'
766767
- include: '#function-parameters'
767768

@@ -776,6 +777,7 @@ repository:
776777
'0': { name: storage.type.function.arrow.tsx }
777778
end: (?<!=>)(?=[,\]\)\{\}=;>]|//|$)
778779
patterns:
780+
- include: '#comment'
779781
# Handle returning of object type specifically here so as to not confuse it with the start of function block
780782
- name: meta.object.type.tsx
781783
begin: (?<==>)\s*(\{)
@@ -798,7 +800,6 @@ repository:
798800
'0': { name: meta.brace.square.tsx }
799801
patterns:
800802
- include: '#type'
801-
- include: '#comment'
802803

803804
type-name:
804805
patterns:
@@ -818,9 +819,9 @@ repository:
818819
endCaptures:
819820
'1': { name: punctuation.definition.typeparameters.end.tsx }
820821
patterns:
822+
- include: '#comment'
821823
- name: storage.modifier.tsx
822824
match: '(?<!\.|\$)\b(extends)\b(?!\$)'
823-
- include: '#comment'
824825
- include: '#type'
825826

826827
variable-initializer:
@@ -900,7 +901,6 @@ repository:
900901
endCaptures:
901902
'1': { name: punctuation.definition.typeparameters.end.tsx }
902903
patterns:
903-
- include: '#comment'
904904
- include: '#type'
905905
#TODO: Scope function names and method names
906906
#TODO: Scope function call arguments better?
@@ -915,7 +915,6 @@ repository:
915915
end: '(?=[(;),]|$)'
916916
patterns:
917917
- include: '#type'
918-
- include: '#comment'
919918

920919
object-member:
921920
patterns:
@@ -987,6 +986,7 @@ repository:
987986
begin: (?x)(?<=return|throw|yield|await|async|[=(\[,:>*])\s*(?=\([^()]*(\([^()]*\))*[^()]*(\([^()]*\))*[^()]*\)(\s*:\s*(.)*)?\s*=>)
988987
end: (?==>)
989988
patterns:
989+
- include: '#comment'
990990
- include: '#function-parameters'
991991
# return type of the arrow
992992
- include: '#arrow-return-type'

0 commit comments

Comments
 (0)