@@ -8,6 +8,8 @@ uuid: ef98eb90-bf9b-11e4-bb52-0800200c9a66
8
8
variables :
9
9
startOfIdentifier : (?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))
10
10
endOfIdentifier : (?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))
11
+ propertyAccess : (?:(\.)|(\?\.(?!\s*[[:digit:]])))
12
+ propertyAccessPreIdentifier : \??\.\s*
11
13
identifier : ' [_$[:alpha:]][_$[:alnum:]]*'
12
14
constantIdentifier : ' [[:upper:]][_$[:digit:][:upper:]]*'
13
15
quotedStrings : (\'([^\'\\]|\\\'|\\)*\')|(\"([^\"\\]|\\\"|\\)*\")
@@ -22,6 +24,7 @@ variables:
22
24
typeArgumentsStart : ({{typeParamersStart}}|(\'[^\']*\')|(\"[^\"]*\")|(\`[^\`]*\`))
23
25
typeArgumentsInnerExpressionPart : ' [^<>\(]|{{matchingParenthesis}}'
24
26
typeArguments : (<\s*{{typeArgumentsStart}}({{typeArgumentsInnerExpressionPart}}|\<\s*{{typeArgumentsStart}}({{typeArgumentsInnerExpressionPart}})*\>)*>\s*)
27
+ functionCallLookup : \s*(\?\.\s*)?{{typeArguments}}?\(
25
28
arrowLookup : |-
26
29
# sure shot arrow functions even if => is on new line
27
30
(
@@ -676,10 +679,11 @@ repository:
676
679
# match expressions before matching identifiers
677
680
- include : ' #expressionWithoutIdentifiers'
678
681
# identifiers are treated as inherited class
679
- - match : ({{identifier}})\s*(\.)( ?=\s*{{identifier}}(\s*\.\s*{{ identifier}})*\s*)
682
+ - match : ' ({{identifier}})\s*{{propertyAccess}}( ?=\s*{{identifier}}(\s*{{propertyAccessPreIdentifier}}{{ identifier}})*\s*)'
680
683
captures :
681
684
' 1 ' : { name: entity.name.type.module.ts }
682
685
' 2 ' : { name: punctuation.accessor.ts }
686
+ ' 3 ' : { name: punctuation.accessor.optional.ts }
683
687
- match : ({{identifier}})
684
688
captures :
685
689
' 1 ' : { name: entity.other.inherited-class.ts }
@@ -815,10 +819,11 @@ repository:
815
819
end : (?=;|$|^)
816
820
patterns :
817
821
- include : ' #comment'
818
- - match : ({{identifier}})\s*(\.)
822
+ - match : ({{identifier}})\s*{{propertyAccess}}
819
823
captures :
820
824
' 1 ' : { name: entity.name.type.module.ts }
821
825
' 2 ' : { name: punctuation.accessor.ts }
826
+ ' 3 ' : { name: punctuation.accessor.optional.ts }
822
827
- name : variable.other.readwrite.ts
823
828
match : ({{identifier}})
824
829
@@ -1037,9 +1042,9 @@ repository:
1037
1042
1038
1043
# ternary expression
1039
1044
ternary-expression :
1040
- begin : (\?)
1045
+ begin : (?!\?\.\s*[^[:digit:]])( \?)
1041
1046
beginCaptures :
1042
- ' 0 ' : { name: keyword.operator.ternary.ts }
1047
+ ' 1 ' : { name: keyword.operator.ternary.ts }
1043
1048
end : (:)
1044
1049
endCaptures :
1045
1050
' 0 ' : { name: keyword.operator.ternary.ts }
@@ -1048,12 +1053,12 @@ repository:
1048
1053
1049
1054
# function call and new expression
1050
1055
function-call :
1051
- begin : (?=(({{identifier}}\s*\.\s* )*|(\.\s* )?)({{identifier}})\s*{{typeArguments}}?\( )
1052
- end : (?<=\))(?!(({{identifier}}\s*\.\s* )*|(\.\s* )?)({{identifier}})\s*{{typeArguments}}?\( )
1056
+ begin : (?=(({{identifier}}\s*{{propertyAccessPreIdentifier}} )*|({{propertyAccessPreIdentifier}} )?)({{identifier}}){{functionCallLookup}} )
1057
+ end : (?<=\))(?!(({{identifier}}\s*{{propertyAccessPreIdentifier}} )*|({{propertyAccessPreIdentifier}} )?)({{identifier}}){{functionCallLookup}} )
1053
1058
patterns :
1054
1059
- name : meta.function-call.ts
1055
- begin : (?=(({{identifier}}\s*\.\s* )*|(\.\s* )?)({{identifier}}))
1056
- end : (?=\s*{{typeArguments}}?\( )
1060
+ begin : (?=(({{identifier}}\s*{{propertyAccessPreIdentifier}} )*|({{propertyAccessPreIdentifier}} )?)({{identifier}}))
1061
+ end : (?={{functionCallLookup}} )
1057
1062
patterns :
1058
1063
- include : ' #literal'
1059
1064
- include : ' #support-objects'
@@ -1064,6 +1069,8 @@ repository:
1064
1069
- name : entity.name.function.ts
1065
1070
match : ({{identifier}})
1066
1071
- include : ' #comment'
1072
+ - name : meta.function-call.ts punctuation.accessor.optional.ts
1073
+ match : \?\.
1067
1074
- name : meta.type.parameters.ts
1068
1075
begin : \<
1069
1076
beginCaptures :
@@ -1294,7 +1301,7 @@ repository:
1294
1301
isFinite|isNaN|parseFloat|parseInt|require|set(Interval|Timeout)|super|unescape|uneval)(?=\s*\()
1295
1302
# Math
1296
1303
- match : |-
1297
- (?x){{startOfIdentifier}}(Math)(?:\s*(\.) \s*(?:
1304
+ (?x){{startOfIdentifier}}(Math)(?:\s*{{propertyAccess}} \s*(?:
1298
1305
(abs|acos|acosh|asin|asinh|atan|atan2|atanh|cbrt|ceil|clz32|cos|cosh|exp|
1299
1306
expm1|floor|fround|hypot|imul|log|log10|log1p|log2|max|min|pow|random|
1300
1307
round|sign|sin|sinh|sqrt|tan|tanh|trunc)
@@ -1303,33 +1310,37 @@ repository:
1303
1310
captures:
1304
1311
'1': { name: support.constant.math.ts }
1305
1312
'2': { name: punctuation.accessor.ts }
1306
- '3': { name: support.function.math.ts }
1307
- '4': { name: support.constant.property.math.ts }
1313
+ '3': { name: punctuation.accessor.optional.ts }
1314
+ '4': { name: support.function.math.ts }
1315
+ '5': { name: support.constant.property.math.ts }
1308
1316
# console
1309
1317
- match : |-
1310
- (?x){{startOfIdentifier}}(console)(?:\s*(\.) \s*(
1318
+ (?x){{startOfIdentifier}}(console)(?:\s*{{propertyAccess}} \s*(
1311
1319
assert|clear|count|debug|dir|error|group|groupCollapsed|groupEnd|info|log
1312
1320
|profile|profileEnd|table|time|timeEnd|timeStamp|trace|warn))?\b(?!\$)
1313
1321
captures:
1314
1322
'1': { name: support.class.console.ts }
1315
1323
'2': { name: punctuation.accessor.ts }
1316
- '3': { name: support.function.console.ts }
1324
+ '3': { name: punctuation.accessor.optional.ts }
1325
+ '4': { name: support.function.console.ts }
1317
1326
# JSON
1318
- - match : ' {{startOfIdentifier}}(JSON)(?:\s*(\.) \s*(parse|stringify))?\b(?!\$)'
1327
+ - match : ' {{startOfIdentifier}}(JSON)(?:\s*{{propertyAccess}} \s*(parse|stringify))?\b(?!\$)'
1319
1328
captures :
1320
1329
' 1 ' : { name: support.constant.json.ts }
1321
1330
' 2 ' : { name: punctuation.accessor.ts }
1322
- ' 3 ' : { name: support.function.json.ts }
1331
+ ' 3 ' : { name: punctuation.accessor.optional.ts }
1332
+ ' 4 ' : { name: support.function.json.ts }
1323
1333
# DOM
1324
1334
- match : |-
1325
- (?x) (\.) \s* (?:
1335
+ (?x) {{propertyAccess}} \s* (?:
1326
1336
(constructor|length|prototype|__proto__)
1327
1337
|
1328
1338
(EPSILON|MAX_SAFE_INTEGER|MAX_VALUE|MIN_SAFE_INTEGER|MIN_VALUE|NEGATIVE_INFINITY|POSITIVE_INFINITY))\b(?!\$)
1329
1339
captures:
1330
1340
'1': { name: punctuation.accessor.ts }
1331
- '2': { name: support.variable.property.ts }
1332
- '3': { name: support.constant.ts }
1341
+ '2': { name: punctuation.accessor.optional.ts }
1342
+ '3': { name: support.variable.property.ts }
1343
+ '4': { name: support.constant.ts }
1333
1344
- match : |-
1334
1345
(?x) {{startOfIdentifier}} \b (?:
1335
1346
(document|event|navigator|performance|screen|window)
@@ -1397,7 +1408,7 @@ repository:
1397
1408
'1': { name: support.variable.dom.ts }
1398
1409
'2': { name: support.class.dom.ts }
1399
1410
- match : |-
1400
- (?x) (\.) \s* (?:
1411
+ (?x) {{propertyAccess}} \s* (?:
1401
1412
(ATTRIBUTE_NODE|CDATA_SECTION_NODE|COMMENT_NODE|DOCUMENT_FRAGMENT_NODE|DOCUMENT_NODE|DOCUMENT_TYPE_NODE
1402
1413
|DOMSTRING_SIZE_ERR|ELEMENT_NODE|ENTITY_NODE|ENTITY_REFERENCE_NODE|HIERARCHY_REQUEST_ERR|INDEX_SIZE_ERR
1403
1414
|INUSE_ATTRIBUTE_ERR|INVALID_CHARACTER_ERR|NO_DATA_ALLOWED_ERR|NO_MODIFICATION_ALLOWED_ERR|NOT_FOUND_ERR
@@ -1431,35 +1442,38 @@ repository:
1431
1442
|vAlign|value|valueType|vendor|vendorSub|version|visibility|vspace|whiteSpace|width|X[MS]LDocument|zIndex))\b(?!\$|\s*{{typeParameters}}?\()
1432
1443
captures:
1433
1444
'1': { name: punctuation.accessor.ts }
1434
- '2': { name: support.constant.dom.ts }
1435
- '3': { name: support.variable.property.dom.ts }
1445
+ '2': { name: punctuation.accessor.optional.ts }
1446
+ '3': { name: support.constant.dom.ts }
1447
+ '4': { name: support.variable.property.dom.ts }
1436
1448
# Node
1437
1449
- name : support.class.node.ts
1438
1450
match : |-
1439
1451
(?x){{startOfIdentifier}}(Buffer|EventEmitter|Server|Pipe|Socket|REPLServer|ReadStream|WriteStream|Stream
1440
1452
|Inflate|Deflate|InflateRaw|DeflateRaw|GZip|GUnzip|Unzip|Zip)\b(?!\$)
1441
1453
- match : |-
1442
- (?x){{startOfIdentifier}}(process)(?:(\.) (?:
1454
+ (?x){{startOfIdentifier}}(process)(?:{{propertyAccess}} (?:
1443
1455
(arch|argv|config|connected|env|execArgv|execPath|exitCode|mainModule|pid|platform|release|stderr|stdin|stdout|title|version|versions)
1444
1456
|
1445
1457
(abort|chdir|cwd|disconnect|exit|[sg]ete?[gu]id|send|[sg]etgroups|initgroups|kill|memoryUsage|nextTick|umask|uptime|hrtime)
1446
1458
))?\b(?!\$)
1447
1459
captures:
1448
1460
'1': { name: support.variable.object.process.ts }
1449
1461
'2': { name: punctuation.accessor.ts }
1450
- '3': { name: support.variable.property.process.ts }
1451
- '4': { name: support.function.process.ts }
1452
- - match : ' {{startOfIdentifier}}(?:(exports)|(module)(?:(\.)(exports|id|filename|loaded|parent|children))?)\b(?!\$)'
1462
+ '3': { name: punctuation.accessor.optional.ts }
1463
+ '4': { name: support.variable.property.process.ts }
1464
+ '5': { name: support.function.process.ts }
1465
+ - match : ' {{startOfIdentifier}}(?:(exports)|(module)(?:{{propertyAccess}}(exports|id|filename|loaded|parent|children))?)\b(?!\$)'
1453
1466
captures :
1454
1467
' 1 ' : { name: support.type.object.module.ts }
1455
1468
' 2 ' : { name: support.type.object.module.ts }
1456
1469
' 3 ' : { name: punctuation.accessor.ts }
1457
- ' 4 ' : { name: support.type.object.module.ts }
1470
+ ' 4 ' : { name: punctuation.accessor.optional.ts }
1471
+ ' 5 ' : { name: support.type.object.module.ts }
1458
1472
- name : support.variable.object.node.ts
1459
1473
match : ' {{startOfIdentifier}}(global|GLOBAL|root|__dirname|__filename)\b(?!\$)'
1460
1474
# method calls
1461
1475
- match : |-
1462
- (?x) (\.) \s*
1476
+ (?x) {{propertyAccess}} \s*
1463
1477
(?:
1464
1478
(on(?:Rowsinserted|Rowsdelete|Rowenter|Rowexit|Resize|Resizestart|Resizeend|Reset|
1465
1479
Readystatechange|Mouseout|Mouseover|Mousedown|Mouseup|Mousemove|
@@ -1536,29 +1550,33 @@ repository:
1536
1550
)(?=\s*\()
1537
1551
captures:
1538
1552
'1': { name: punctuation.accessor.ts }
1539
- '2': { name: support.function.event-handler.ts }
1540
- '3': { name: support.function.ts }
1541
- '4': { name: support.function.dom.ts }
1553
+ '2': { name: punctuation.accessor.optional.ts }
1554
+ '3': { name: support.function.event-handler.ts }
1555
+ '4': { name: support.function.ts }
1556
+ '5': { name: support.function.dom.ts }
1542
1557
1543
1558
identifiers :
1544
1559
patterns :
1545
1560
- include : ' #object-identifiers'
1546
1561
# function and method assignment
1547
1562
- match : |-
1548
- (?x)(?:(\.) \s*)?({{identifier}})(?=\s*={{functionOrArrowLookup}})
1563
+ (?x)(?:{{propertyAccess}} \s*)?({{identifier}})(?=\s*={{functionOrArrowLookup}})
1549
1564
captures:
1550
1565
'1': { name: punctuation.accessor.ts }
1551
- '2': { name: entity.name.function.ts }
1566
+ '2': { name: punctuation.accessor.optional.ts }
1567
+ '3': { name: entity.name.function.ts }
1552
1568
# const properties
1553
- - match : (\.)\ s*{{constantVar}}
1569
+ - match : ' {{propertyAccess}}\ s*{{constantVar}}'
1554
1570
captures :
1555
1571
' 1 ' : { name: punctuation.accessor.ts }
1556
- ' 2 ' : { name: variable.other.constant.property.ts }
1572
+ ' 2 ' : { name: punctuation.accessor.optional.ts }
1573
+ ' 3 ' : { name: variable.other.constant.property.ts }
1557
1574
# properties
1558
- - match : (\.)\ s*({{identifier}})
1575
+ - match : ' {{propertyAccess}}\ s*({{identifier}})'
1559
1576
captures :
1560
1577
' 1 ' : { name: punctuation.accessor.ts }
1561
- ' 2 ' : { name: variable.other.property.ts }
1578
+ ' 2 ' : { name: punctuation.accessor.optional.ts }
1579
+ ' 3 ' : { name: variable.other.property.ts }
1562
1580
# const
1563
1581
- name : variable.other.constant.ts
1564
1582
match : ' {{constantVar}}'
@@ -1570,23 +1588,24 @@ repository:
1570
1588
patterns :
1571
1589
# class
1572
1590
- name : support.class.ts
1573
- match : ({{identifier}})(?=\s*\.\s* prototype\b(?!\$))
1591
+ match : ({{identifier}})(?=\s*{{propertyAccessPreIdentifier}} prototype\b(?!\$))
1574
1592
# object properties
1575
1593
- match : |-
1576
- (?x)(\.) \s*(?:
1594
+ (?x){{propertyAccess}} \s*(?:
1577
1595
({{constantIdentifier}}) |
1578
1596
({{identifier}})
1579
- )(?=\s*\.\s* {{identifier}})
1597
+ )(?=\s*{{propertyAccessPreIdentifier}} {{identifier}})
1580
1598
captures:
1581
1599
'1': { name: punctuation.accessor.ts }
1582
- '2': { name: variable.other.constant.object.property.ts }
1583
- '3': { name: variable.other.object.property.ts }
1600
+ '2': { name: punctuation.accessor.optional.ts }
1601
+ '3': { name: variable.other.constant.object.property.ts }
1602
+ '4': { name: variable.other.object.property.ts }
1584
1603
# objects
1585
1604
- match : |-
1586
1605
(?x)(?:
1587
1606
({{constantIdentifier}}) |
1588
1607
({{identifier}})
1589
- )(?=\s*\.\s* {{identifier}})
1608
+ )(?=\s*{{propertyAccessPreIdentifier}} {{identifier}})
1590
1609
captures:
1591
1610
'1': { name: variable.other.constant.object.ts }
1592
1611
'2': { name: variable.other.object.ts }
@@ -1845,10 +1864,11 @@ repository:
1845
1864
# name of the type
1846
1865
type-name :
1847
1866
patterns :
1848
- - match : ({{identifier}})\s*(\.)
1867
+ - match : ({{identifier}})\s*{{propertyAccess}}
1849
1868
captures :
1850
1869
' 1 ' : { name: entity.name.type.module.ts }
1851
1870
' 2 ' : { name: punctuation.accessor.ts }
1871
+ ' 3 ' : { name: punctuation.accessor.optional.ts }
1852
1872
- name : entity.name.type.ts
1853
1873
match : ' {{identifier}}'
1854
1874
@@ -1862,8 +1882,10 @@ repository:
1862
1882
match : ' ;'
1863
1883
1864
1884
punctuation-accessor :
1865
- name : punctuation.accessor.ts
1866
- match : ' \.'
1885
+ match : ' {{propertyAccess}}'
1886
+ captures :
1887
+ ' 1 ' : { name: punctuation.accessor.ts }
1888
+ ' 2 ' : { name: punctuation.accessor.optional.ts }
1867
1889
1868
1890
# strings and template strings
1869
1891
string :
0 commit comments