Skip to content

Commit 87aa92a

Browse files
committed
Scope function names from function calls and add scoping for ,
1 parent a63a0fb commit 87aa92a

File tree

71 files changed

+1208
-528
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+1208
-528
lines changed

TypeScript.YAML-tmLanguage

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ repository:
3636
- include: '#destructuring-variable'
3737
- include: '#var-single-variable'
3838
- include: '#comment'
39+
- include: '#punctuation-comma'
3940

4041
var-single-variable:
4142
name: meta.var-single-variable.expr.ts
@@ -168,13 +169,14 @@ repository:
168169
- include: '#class-or-interface-declaration'
169170
- include: '#arrow-function'
170171
- include: '#cast'
171-
- include: '#paren-expression'
172172
- include: '#ternary-expression'
173173
- include: '#new-expr'
174174
- include: '#object-literal'
175175
- include: '#expression-operator'
176176
- include: '#operators'
177177
- include: '#function-call'
178+
- include: '#paren-expression'
179+
- include: '#punctuation-comma'
178180

179181
control-statement:
180182
# TODO: convert this to actual statements instead
@@ -450,6 +452,7 @@ repository:
450452
- include: '#method-declaration'
451453
- include: '#indexer-declaration'
452454
- include: '#type-annotation'
455+
- include: '#punctuation-comma'
453456

454457
field-declaration:
455458
name: meta.field.declaration.ts
@@ -736,6 +739,8 @@ repository:
736739
- include: '#parameter-name'
737740
- include: '#type-annotation'
738741
- include: '#variable-initializer'
742+
- name: punctuation.separator.parameter.ts
743+
match: ','
739744

740745
type-primitive:
741746
name: support.type.primitive.ts
@@ -797,6 +802,7 @@ repository:
797802
'0': { name: meta.brace.square.ts }
798803
patterns:
799804
- include: '#type'
805+
- include: '#punctuation-comma'
800806

801807
type-name:
802808
patterns:
@@ -820,6 +826,7 @@ repository:
820826
- name: storage.modifier.ts
821827
match: '(?<!\.|\$)\b(extends)\b(?!\$)'
822828
- include: '#type'
829+
- include: '#punctuation-comma'
823830

824831
variable-initializer:
825832
begin: (?<!=|!)(=)(?!=)
@@ -883,25 +890,27 @@ repository:
883890
- include: '#switch-block'
884891

885892
function-call:
886-
name: functioncall.expr.ts
893+
#TODO: Scope function names and method names
894+
# Ideal expression that can give us arbitary number of another level of type argument allowed is:
895+
# (<)(?=(([^<>]+)|(\<[^<>]+\>))+>\s*\()
896+
# But this takes really long time and sometimes infinite time to parse negative cases like below:
897+
# if (this.PListCells.length<value && (!this.ListList || !this.DelayedUpdate))
898+
begin: '([_$[:alpha:]][_$[:alnum:]]*)\s*(?=(<[^<>]*(\<[^<>]+\>)*[^<>]*(\<[^<>]+\>)*[^<>]*>\s*)?\()'
899+
beginCaptures:
900+
'1': { name: entity.name.function.ts }
901+
end: (?=\()
887902
patterns:
903+
- include: '#comment'
888904
- name: meta.type.parameters.ts
889-
# Ideal expression that can give us arbitary number of another level of type argument allowed is:
890-
# (<)(?=(([^<>]+)|(\<[^<>]+\>))+>\s*\()
891-
# But this takes really long time and sometimes infinite time to parse negative cases like below:
892-
# if (this.PListCells.length<value && (!this.ListList || !this.DelayedUpdate))
893-
begin: '([_$[:alpha:]][_$[:alnum:]]*)\s*(<)(?=[^<>]*(\<[^<>]+\>)*[^<>]*(\<[^<>]+\>)*[^<>]*>\s*\()'
905+
begin: \<
894906
beginCaptures:
895-
'1': { name: entity.name.function.ts }
896-
'2': { name: punctuation.definition.typeparameters.begin.ts }
897-
end: '(>)'
907+
'0': { name: punctuation.definition.typeparameters.begin.ts }
908+
end: \>
898909
endCaptures:
899-
'1': { name: punctuation.definition.typeparameters.end.ts }
910+
'0': { name: punctuation.definition.typeparameters.end.ts }
900911
patterns:
901912
- include: '#type'
902-
#TODO: Scope function names and method names
903-
#TODO: Scope function call arguments better?
904-
- include: '#paren-expression'
913+
- include: '#punctuation-comma'
905914

906915
cast:
907916
name: cast.expr.ts
@@ -970,6 +979,7 @@ repository:
970979
match: ([_$[:alpha:]][_$[:alnum:]]*)\s*(?=,|\})
971980
captures:
972981
'1': { name: variable.other.readwrite.ts }
982+
- include: '#punctuation-comma'
973983

974984
expression-operator:
975985
patterns:
@@ -1060,6 +1070,10 @@ repository:
10601070
- include: '#type-predicate-operator'
10611071
- include: '#type'
10621072

1073+
punctuation-comma:
1074+
name: punctuation.separator.comma.ts
1075+
match: ','
1076+
10631077
paren-expression:
10641078
begin: \(
10651079
beginCaptures:
@@ -1069,6 +1083,7 @@ repository:
10691083
'0': {name: meta.brace.round.ts }
10701084
patterns:
10711085
- include: '#expression'
1086+
- include: '#punctuation-comma'
10721087

10731088
qstring-double:
10741089
name: string.quoted.double.ts
@@ -1265,6 +1280,7 @@ repository:
12651280
'0': { name: meta.brace.square.ts }
12661281
patterns:
12671282
- include: '#expression'
1283+
- include: '#punctuation-comma'
12681284

12691285
numeric-literal:
12701286
patterns:

TypeScript.tmLanguage

Lines changed: 73 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,10 @@
146146
<key>include</key>
147147
<string>#expression</string>
148148
</dict>
149+
<dict>
150+
<key>include</key>
151+
<string>#punctuation-comma</string>
152+
</dict>
149153
</array>
150154
</dict>
151155
<key>arrow-function</key>
@@ -1200,10 +1204,6 @@
12001204
<key>include</key>
12011205
<string>#cast</string>
12021206
</dict>
1203-
<dict>
1204-
<key>include</key>
1205-
<string>#paren-expression</string>
1206-
</dict>
12071207
<dict>
12081208
<key>include</key>
12091209
<string>#ternary-expression</string>
@@ -1228,6 +1228,14 @@
12281228
<key>include</key>
12291229
<string>#function-call</string>
12301230
</dict>
1231+
<dict>
1232+
<key>include</key>
1233+
<string>#paren-expression</string>
1234+
</dict>
1235+
<dict>
1236+
<key>include</key>
1237+
<string>#punctuation-comma</string>
1238+
</dict>
12311239
</array>
12321240
</dict>
12331241
<key>expression-operator</key>
@@ -1393,31 +1401,40 @@
13931401
</dict>
13941402
<key>function-call</key>
13951403
<dict>
1396-
<key>name</key>
1397-
<string>functioncall.expr.ts</string>
1404+
<key>begin</key>
1405+
<string>([_$[:alpha:]][_$[:alnum:]]*)\s*(?=(&lt;[^&lt;&gt;]*(\&lt;[^&lt;&gt;]+\&gt;)*[^&lt;&gt;]*(\&lt;[^&lt;&gt;]+\&gt;)*[^&lt;&gt;]*&gt;\s*)?\()</string>
1406+
<key>beginCaptures</key>
1407+
<dict>
1408+
<key>1</key>
1409+
<dict>
1410+
<key>name</key>
1411+
<string>entity.name.function.ts</string>
1412+
</dict>
1413+
</dict>
1414+
<key>end</key>
1415+
<string>(?=\()</string>
13981416
<key>patterns</key>
13991417
<array>
1418+
<dict>
1419+
<key>include</key>
1420+
<string>#comment</string>
1421+
</dict>
14001422
<dict>
14011423
<key>begin</key>
1402-
<string>([_$[:alpha:]][_$[:alnum:]]*)\s*(&lt;)(?=[^&lt;&gt;]*(\&lt;[^&lt;&gt;]+\&gt;)*[^&lt;&gt;]*(\&lt;[^&lt;&gt;]+\&gt;)*[^&lt;&gt;]*&gt;\s*\()</string>
1424+
<string>\&lt;</string>
14031425
<key>beginCaptures</key>
14041426
<dict>
1405-
<key>1</key>
1406-
<dict>
1407-
<key>name</key>
1408-
<string>entity.name.function.ts</string>
1409-
</dict>
1410-
<key>2</key>
1427+
<key>0</key>
14111428
<dict>
14121429
<key>name</key>
14131430
<string>punctuation.definition.typeparameters.begin.ts</string>
14141431
</dict>
14151432
</dict>
14161433
<key>end</key>
1417-
<string>(&gt;)</string>
1434+
<string>\&gt;</string>
14181435
<key>endCaptures</key>
14191436
<dict>
1420-
<key>1</key>
1437+
<key>0</key>
14211438
<dict>
14221439
<key>name</key>
14231440
<string>punctuation.definition.typeparameters.end.ts</string>
@@ -1431,12 +1448,12 @@
14311448
<key>include</key>
14321449
<string>#type</string>
14331450
</dict>
1451+
<dict>
1452+
<key>include</key>
1453+
<string>#punctuation-comma</string>
1454+
</dict>
14341455
</array>
14351456
</dict>
1436-
<dict>
1437-
<key>include</key>
1438-
<string>#paren-expression</string>
1439-
</dict>
14401457
</array>
14411458
</dict>
14421459
<key>function-declaration</key>
@@ -1588,6 +1605,12 @@
15881605
<key>include</key>
15891606
<string>#variable-initializer</string>
15901607
</dict>
1608+
<dict>
1609+
<key>match</key>
1610+
<string>,</string>
1611+
<key>name</key>
1612+
<string>punctuation.separator.parameter.ts</string>
1613+
</dict>
15911614
</array>
15921615
</dict>
15931616
<key>import-declaration</key>
@@ -2560,6 +2583,10 @@
25602583
<key>name</key>
25612584
<string>meta.object.member.ts</string>
25622585
</dict>
2586+
<dict>
2587+
<key>include</key>
2588+
<string>#punctuation-comma</string>
2589+
</dict>
25632590
</array>
25642591
</dict>
25652592
<key>operators</key>
@@ -2832,6 +2859,10 @@
28322859
<key>include</key>
28332860
<string>#expression</string>
28342861
</dict>
2862+
<dict>
2863+
<key>include</key>
2864+
<string>#punctuation-comma</string>
2865+
</dict>
28352866
</array>
28362867
</dict>
28372868
<key>property-accessor</key>
@@ -2841,6 +2872,13 @@
28412872
<key>name</key>
28422873
<string>storage.type.property.ts</string>
28432874
</dict>
2875+
<key>punctuation-comma</key>
2876+
<dict>
2877+
<key>match</key>
2878+
<string>,</string>
2879+
<key>name</key>
2880+
<string>punctuation.separator.comma.ts</string>
2881+
</dict>
28442882
<key>qstring-double</key>
28452883
<dict>
28462884
<key>begin</key>
@@ -3819,6 +3857,10 @@
38193857
<key>include</key>
38203858
<string>#type-annotation</string>
38213859
</dict>
3860+
<dict>
3861+
<key>include</key>
3862+
<string>#punctuation-comma</string>
3863+
</dict>
38223864
</array>
38233865
</dict>
38243866
<key>type-operator</key>
@@ -3868,6 +3910,10 @@
38683910
<key>include</key>
38693911
<string>#type</string>
38703912
</dict>
3913+
<dict>
3914+
<key>include</key>
3915+
<string>#punctuation-comma</string>
3916+
</dict>
38713917
</array>
38723918
</dict>
38733919
<key>type-paren-or-function-parameters</key>
@@ -3955,6 +4001,10 @@
39554001
<key>include</key>
39564002
<string>#type</string>
39574003
</dict>
4004+
<dict>
4005+
<key>include</key>
4006+
<string>#punctuation-comma</string>
4007+
</dict>
39584008
</array>
39594009
</dict>
39604010
<key>typeof-operator</key>
@@ -4006,6 +4056,10 @@
40064056
<key>include</key>
40074057
<string>#comment</string>
40084058
</dict>
4059+
<dict>
4060+
<key>include</key>
4061+
<string>#punctuation-comma</string>
4062+
</dict>
40094063
</array>
40104064
</dict>
40114065
<key>var-single-variable</key>

0 commit comments

Comments
 (0)