/
source.swift.js
2644 lines (2643 loc) · 117 KB
/
source.swift.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// This is a TextMate grammar distributed by `starry-night`.
// This grammar is developed at
// <https://github.com/jtbandes/swift-tmlanguage>
// and licensed `mit`.
// See <https://github.com/wooorm/starry-night> for more info.
/** @type {import('../lib/index.js').Grammar} */
const grammar = {
extensions: ['.swift'],
names: ['swift'],
patterns: [{include: '#root'}],
repository: {
'async-throws': {
captures: {
1: {name: 'invalid.illegal.await-must-precede-throws.swift'},
2: {name: 'storage.modifier.exception.swift'},
3: {name: 'storage.modifier.async.swift'}
},
match:
'\\b(?:(throws\\s+async|rethrows\\s+async)|(throws|rethrows)|(async))\\b'
},
attributes: {
patterns: [
{
begin: '((@)available)(\\()',
beginCaptures: {
1: {name: 'storage.modifier.attribute.swift'},
2: {name: 'punctuation.definition.attribute.swift'},
3: {name: 'punctuation.definition.arguments.begin.swift'}
},
end: '\\)',
endCaptures: {
0: {name: 'punctuation.definition.arguments.end.swift'}
},
name: 'meta.attribute.available.swift',
patterns: [
{
captures: {
1: {name: 'keyword.other.platform.os.swift'},
2: {name: 'constant.numeric.swift'}
},
match:
'\\b(swift|(?:iOS|macOS|OSX|watchOS|tvOS|UIKitForMac)(?:ApplicationExtension)?)\\b(?:\\s+([0-9]+(?:\\.[0-9]+)*\\b))?'
},
{
begin: '\\b(introduced|deprecated|obsoleted)\\s*(:)\\s*',
beginCaptures: {
1: {name: 'keyword.other.swift'},
2: {name: 'punctuation.separator.key-value.swift'}
},
end: '(?!\\G)',
patterns: [
{
match: '\\b[0-9]+(?:\\.[0-9]+)*\\b',
name: 'constant.numeric.swift'
}
]
},
{
begin: '\\b(message|renamed)\\s*(:)\\s*(?=")',
beginCaptures: {
1: {name: 'keyword.other.swift'},
2: {name: 'punctuation.separator.key-value.swift'}
},
end: '(?!\\G)',
patterns: [{include: '#literals'}]
},
{
captures: {
1: {name: 'keyword.other.platform.all.swift'},
2: {name: 'keyword.other.swift'},
3: {name: 'invalid.illegal.character-not-allowed-here.swift'}
},
match:
'(?:(\\*)|\\b(deprecated|unavailable|noasync)\\b)\\s*(.*?)(?=[,)])'
}
]
},
{
begin: '((@)objc)(\\()',
beginCaptures: {
1: {name: 'storage.modifier.attribute.swift'},
2: {name: 'punctuation.definition.attribute.swift'},
3: {name: 'punctuation.definition.arguments.begin.swift'}
},
end: '\\)',
endCaptures: {
0: {name: 'punctuation.definition.arguments.end.swift'}
},
name: 'meta.attribute.objc.swift',
patterns: [
{
captures: {
1: {
name: 'invalid.illegal.missing-colon-after-selector-piece.swift'
}
},
match: '\\w*(?::(?:\\w*:)*(\\w*))?',
name: 'entity.name.function.swift'
}
]
},
{
begin: '(@)(?<q>`?)[\\p{L}_][\\p{L}_\\p{N}\\p{M}]*(\\k<q>)',
beginCaptures: {
0: {name: 'storage.modifier.attribute.swift'},
1: {name: 'punctuation.definition.attribute.swift'},
2: {name: 'punctuation.definition.identifier.swift'},
3: {name: 'punctuation.definition.identifier.swift'}
},
end: '(?!\\G\\()',
name: 'meta.attribute.swift',
patterns: [
{
begin: '\\(',
beginCaptures: {
0: {name: 'punctuation.definition.arguments.begin.swift'}
},
end: '\\)',
endCaptures: {
0: {name: 'punctuation.definition.arguments.end.swift'}
},
name: 'meta.arguments.attribute.swift',
patterns: [{include: '#expressions'}]
}
]
}
]
},
'builtin-functions': {
patterns: [
{
match:
'(?<=\\.)(?:s(?:ort(?:ed)?|plit)|contains|index|partition|f(?:i(?:lter|rst)|orEach|latMap)|with(?:MutableCharacters|CString|U(?:nsafe(?:Mutable(?:BufferPointer|Pointer(?:s|To(?:Header|Elements)))|BufferPointer)|TF8Buffer))|m(?:in|a(?:p|x)))(?=\\s*[({])\\b',
name: 'support.function.swift'
},
{
match:
'(?<=\\.)(?:s(?:ymmetricDifference|t(?:oreBytes|arts|ride)|ortInPlace|u(?:ccessor|ffix|btract(?:ing|InPlace|WithOverflow)?)|quareRoot|amePosition)|h(?:oldsUnique(?:Reference|OrPinnedReference)|as(?:Suffix|Prefix))|ne(?:gate(?:d)?|xt)|c(?:o(?:untByEnumerating|py(?:Bytes)?)|lamp(?:ed)?|reate)|t(?:o(?:IntMax|Opaque|UIntMax)|ake(?:RetainedValue|UnretainedValue)|r(?:uncatingRemainder|a(?:nscodedLength|ilSurrogate)))|i(?:s(?:MutableAndUniquelyReferenced(?:OrPinned)?|S(?:trictSu(?:perset(?:Of)?|bset(?:Of)?)|u(?:perset(?:Of)?|bset(?:Of)?))|Continuation|T(?:otallyOrdered|railSurrogate)|Disjoint(?:With)?|Unique(?:Reference|lyReferenced(?:OrPinned)?)|Equal|Le(?:ss(?:ThanOrEqualTo)?|adSurrogate))|n(?:sert(?:ContentsOf)?|tersect(?:ion|InPlace)?|itialize(?:Memory|From)?|dex(?:Of|ForKey)))|o(?:verlaps|bjectAt)|d(?:i(?:stance(?:To)?|vide(?:d|WithOverflow)?)|e(?:s(?:cendant|troy)|code(?:CString)?|initialize|alloc(?:ate(?:Capacity)?)?)|rop(?:First|Last))|u(?:n(?:ion(?:InPlace)?|derestimateCount|wrappedOrError)|p(?:date(?:Value)?|percased))|join(?:ed|WithSeparator)|p(?:op(?:First|Last)|ass(?:Retained|Unretained)|re(?:decessor|fix))|e(?:scape(?:d)?|n(?:code|umerate(?:d)?)|lementsEqual|xclusiveOr(?:InPlace)?)|f(?:orm(?:Remainder|S(?:ymmetricDifference|quareRoot)|TruncatingRemainder|In(?:tersection|dex)|Union)|latten|rom(?:CString(?:RepairingIllFormedUTF8)?|Opaque))|w(?:i(?:thMemoryRebound|dth)|rite(?:To)?)|l(?:o(?:wercased|ad)|e(?:adSurrogate|xicographical(?:Compare|lyPrecedes)))|a(?:ss(?:ign(?:BackwardFrom|From)?|umingMemoryBound)|d(?:d(?:ing(?:Product)?|Product|WithOverflow)?|vanced(?:By)?)|utorelease|ppend(?:ContentsOf)?|lloc(?:ate)?|bs)|r(?:ound(?:ed)?|e(?:serveCapacity|tain|duce|place(?:Range|Subrange)?|verse(?:d)?|quest(?:NativeBuffer|UniqueMutableBackingBuffer)|lease|m(?:ove(?:Range|Subrange|Value(?:ForKey)?|First|Last|A(?:tIndex|ll))?|ainder(?:WithOverflow)?)))|ge(?:nerate|t(?:Objects|Element))|m(?:in(?:imum(?:Magnitude)?|Element)|ove(?:Initialize(?:Memory|BackwardFrom|From)?|Assign(?:From)?)?|ultipl(?:y(?:WithOverflow)?|ied)|easure|a(?:ke(?:Iterator|Description)|x(?:imum(?:Magnitude)?|Element)))|bindMemory)(?=\\s*\\()',
name: 'support.function.swift'
},
{
match:
'(?<=\\.)(?:s(?:uperclassMirror|amePositionIn|tartsWith)|nextObject|c(?:haracterAtIndex|o(?:untByEnumeratingWithState|pyWithZone)|ustom(?:Mirror|PlaygroundQuickLook))|is(?:EmptyInput|ASCII)|object(?:Enumerator|ForKey|AtIndex)|join|put|keyEnumerator|withUnsafeMutablePointerToValue|length|getMirror|m(?:oveInitializeAssignFrom|ember))(?=\\s*\\()',
name: 'support.function.swift'
}
]
},
'builtin-global-functions': {
patterns: [
{
begin: '\\b(type)(\\()\\s*(of)(:)',
beginCaptures: {
1: {name: 'support.function.dynamic-type.swift'},
2: {name: 'punctuation.definition.arguments.begin.swift'},
3: {name: 'support.variable.parameter.swift'},
4: {name: 'punctuation.separator.argument-label.begin.swift'}
},
end: '\\)',
endCaptures: {
0: {name: 'punctuation.definition.arguments.end.swift'}
},
patterns: [{include: '#expressions'}]
},
{
match: '\\b(?:anyGenerator|autoreleasepool)(?=\\s*[({])\\b',
name: 'support.function.swift'
},
{
match:
'\\b(?:s(?:tride(?:of(?:Value)?)?|izeof(?:Value)?|equence|wap)|numericCast|transcode|is(?:UniquelyReferenced(?:NonObjC)?|KnownUniquelyReferenced)|zip|d(?:ump|ebugPrint)|unsafe(?:BitCast|Downcast|Unwrap|Address(?:Of)?)|pr(?:int|econdition(?:Failure)?)|fatalError|with(?:Unsafe(?:MutablePointer|Pointer)|ExtendedLifetime|VaList)|a(?:ssert(?:ionFailure)?|lignof(?:Value)?|bs)|re(?:peatElement|adLine)|getVaList|m(?:in|ax))(?=\\s*\\()',
name: 'support.function.swift'
},
{
match:
'\\b(?:s(?:ort|uffix|pli(?:ce|t))|insert|overlaps|d(?:istance|rop(?:First|Last))|join|prefix|extend|withUnsafe(?:MutablePointers|Pointers)|lazy|advance|re(?:flect|move(?:Range|Last|A(?:tIndex|ll))))(?=\\s*\\()',
name: 'support.function.swift'
}
]
},
'builtin-properties': {
patterns: [
{
match:
'(?<=^Process\\.|\\WProcess\\.|^CommandLine\\.|\\WCommandLine\\.)(arguments|argc|unsafeArgv)',
name: 'support.variable.swift'
},
{
match:
'(?<=\\.)(?:s(?:t(?:artIndex|ri(?:ngValue|de))|i(?:ze|gn(?:BitIndex|ificand(?:Bit(?:Count|Pattern)|Width)?|alingNaN)?)|u(?:perclassMirror|mmary|bscriptBaseAddress))|h(?:eader|as(?:hValue|PointerRepresentation))|n(?:ulTerminatedUTF8|ext(?:Down|Up)|a(?:n|tiveOwner))|c(?:haracters|ount(?:TrailingZeros)?|ustom(?:Mirror|PlaygroundQuickLook)|apacity)|i(?:s(?:S(?:ign(?:Minus|aling(?:NaN)?)|ubnormal)|N(?:ormal|aN)|Canonical|Infinite|Zero|Empty|Finite|ASCII)|n(?:dices|finity)|dentity)|owner|de(?:scription|bugDescription)|u(?:n(?:safelyUnwrapped|icodeScalar(?:s)?|derestimatedCount)|tf(?:16|8(?:Start|C(?:String|odeUnitCount))?)|intValue|ppercaseString|lp(?:OfOne)?)|p(?:i|ointee)|e(?:ndIndex|lements|xponent(?:Bit(?:Count|Pattern))?)|value(?:s)?|keys|quietNaN|f(?:irst(?:ElementAddress(?:IfContiguous)?)?|loatingPointClass)|l(?:ittleEndian|owercaseString|eastNo(?:nzeroMagnitude|rmalMagnitude)|a(?:st|zy))|a(?:l(?:ignment|l(?:ocatedElementCount|Zeros))|rray(?:PropertyIsNativeTypeChecked)?)|ra(?:dix|wValue)|greatestFiniteMagnitude|m(?:in|emory|ax)|b(?:yteS(?:ize|wapped)|i(?:nade|tPattern|gEndian)|uffer|ase(?:Address)?))\\b',
name: 'support.variable.swift'
},
{
match:
'(?<=\\.)(?:boolValue|disposition|end|objectIdentifier|quickLookObject|start|valueType)\\b',
name: 'support.variable.swift'
},
{
match:
'(?<=\\.)(?:s(?:calarValue|i(?:ze|gnalingNaN)|o(?:und|me)|uppressed|prite|et)|n(?:one|egative(?:Subnormal|Normal|Infinity|Zero))|c(?:ol(?:or|lection)|ustomized)|t(?:o(?:NearestOr(?:Even|AwayFromZero)|wardZero)|uple|ext)|i(?:nt|mage)|optional|d(?:ictionary|o(?:uble|wn))|u(?:Int|p|rl)|p(?:o(?:sitive(?:Subnormal|Normal|Infinity|Zero)|int)|lus)|e(?:rror|mptyInput)|view|quietNaN|float|a(?:ttributedString|wayFromZero)|r(?:ectangle|ange)|generated|minus|b(?:ool|ezierPath))\\b',
name: 'support.variable.swift'
}
]
},
'builtin-types': {
patterns: [
{include: '#builtin-types-builtin-class-type'},
{include: '#builtin-types-builtin-enum-type'},
{include: '#builtin-types-builtin-protocol-type'},
{include: '#builtin-types-builtin-struct-type'},
{include: '#builtin-types-builtin-typealias'},
{match: '\\bAny\\b', name: 'support.type.any.swift'}
]
},
'builtin-types-builtin-class-type': {
match:
'\\b(Managed(Buffer|ProtoBuffer)|NonObjectiveCBase|AnyGenerator)\\b',
name: 'support.class.swift'
},
'builtin-types-builtin-enum-type': {
patterns: [
{
match: '\\b(?:CommandLine|Process(?=\\.))\\b',
name: 'support.constant.swift'
},
{match: '\\bNever\\b', name: 'support.constant.never.swift'},
{
match:
'\\b(?:ImplicitlyUnwrappedOptional|Representation|MemoryLayout|FloatingPointClassification|SetIndexRepresentation|SetIteratorRepresentation|FloatingPointRoundingRule|UnicodeDecodingResult|Optional|DictionaryIndexRepresentation|AncestorRepresentation|DisplayStyle|PlaygroundQuickLook|Never|FloatingPointSign|Bit|DictionaryIteratorRepresentation)\\b',
name: 'support.type.swift'
},
{
match: '\\b(?:MirrorDisposition|QuickLookObject)\\b',
name: 'support.type.swift'
}
]
},
'builtin-types-builtin-protocol-type': {
patterns: [
{
match:
'\\b(?:Ra(?:n(?:domAccess(?:Collection|Indexable)|geReplaceable(?:Collection|Indexable))|wRepresentable)|M(?:irrorPath|utable(?:Collection|Indexable))|Bi(?:naryFloatingPoint|twiseOperations|directional(?:Collection|Indexable))|S(?:tr(?:ideable|eamable)|igned(?:Number|Integer)|e(?:tAlgebra|quence))|Hashable|C(?:o(?:llection|mparable)|ustom(?:Reflectable|StringConvertible|DebugStringConvertible|PlaygroundQuickLookable|LeafReflectable)|VarArg)|TextOutputStream|I(?:n(?:teger(?:Arithmetic)?|dexable(?:Base)?)|teratorProtocol)|OptionSet|Un(?:signedInteger|icodeCodec)|E(?:quatable|rror|xpressibleBy(?:BooleanLiteral|String(?:Interpolation|Literal)|NilLiteral|IntegerLiteral|DictionaryLiteral|UnicodeScalarLiteral|ExtendedGraphemeClusterLiteral|FloatLiteral|ArrayLiteral))|FloatingPoint|L(?:osslessStringConvertible|azy(?:SequenceProtocol|CollectionProtocol))|A(?:nyObject|bsoluteValuable))\\b',
name: 'support.type.swift'
},
{
match:
'\\b(?:Ran(?:domAccessIndexType|geReplaceableCollectionType)|GeneratorType|M(?:irror(?:Type|PathType)|utable(?:Sliceable|CollectionType))|B(?:i(?:twiseOperationsType|directionalIndexType)|oolean(?:Type|LiteralConvertible))|S(?:tring(?:InterpolationConvertible|LiteralConvertible)|i(?:nkType|gned(?:NumberType|IntegerType))|e(?:tAlgebraType|quenceType)|liceable)|NilLiteralConvertible|C(?:ollectionType|VarArgType)|Inte(?:rvalType|ger(?:Type|LiteralConvertible|ArithmeticType))|O(?:utputStreamType|ptionSetType)|DictionaryLiteralConvertible|Un(?:signedIntegerType|icode(?:ScalarLiteralConvertible|CodecType))|E(?:rrorType|xten(?:sibleCollectionType|dedGraphemeClusterLiteralConvertible))|F(?:orwardIndexType|loat(?:ingPointType|LiteralConvertible))|A(?:nyCollectionType|rrayLiteralConvertible))\\b',
name: 'support.type.swift'
}
]
},
'builtin-types-builtin-struct-type': {
patterns: [
{
match:
'\\b(?:R(?:e(?:peat(?:ed)?|versed(?:RandomAccess(?:Collection|Index)|Collection|Index))|an(?:domAccessSlice|ge(?:Replaceable(?:RandomAccessSlice|BidirectionalSlice|Slice)|Generator)?))|Generator(?:Sequence|OfOne)|M(?:irror|utable(?:Ran(?:domAccessSlice|geReplaceable(?:RandomAccessSlice|BidirectionalSlice|Slice))|BidirectionalSlice|Slice)|anagedBufferPointer)|B(?:idirectionalSlice|ool)|S(?:t(?:aticString|ri(?:ng|deT(?:hrough(?:Generator|Iterator)?|o(?:Generator|Iterator)?)))|et(?:I(?:ndex|terator))?|lice)|HalfOpenInterval|C(?:haracter(?:View)?|o(?:ntiguousArray|untable(?:Range|ClosedRange)|llectionOfOne)|OpaquePointer|losed(?:Range(?:I(?:ndex|terator))?|Interval)|VaListPointer)|I(?:n(?:t(?:16|8|32|64)?|d(?:ices|ex(?:ing(?:Generator|Iterator))?))|terator(?:Sequence|OverOne)?)|Zip2(?:Sequence|Iterator)|O(?:paquePointer|bjectIdentifier)|D(?:ictionary(?:I(?:ndex|terator)|Literal)?|ouble|efault(?:RandomAccessIndices|BidirectionalIndices|Indices))|U(?:n(?:safe(?:RawPointer|Mutable(?:RawPointer|BufferPointer|Pointer)|BufferPointer(?:Generator|Iterator)?|Pointer)|icodeScalar(?:View)?|foldSequence|managed)|TF(?:16(?:View)?|8(?:View)?|32)|Int(?:16|8|32|64)?)|Join(?:Generator|ed(?:Sequence|Iterator))|PermutationGenerator|E(?:numerate(?:Generator|Sequence|d(?:Sequence|Iterator))|mpty(?:Generator|Collection|Iterator))|Fl(?:oat(?:80)?|atten(?:Generator|BidirectionalCollection(?:Index)?|Sequence|Collection(?:Index)?|Iterator))|L(?:egacyChildren|azy(?:RandomAccessCollection|Map(?:RandomAccessCollection|Generator|BidirectionalCollection|Sequence|Collection|Iterator)|BidirectionalCollection|Sequence|Collection|Filter(?:Generator|BidirectionalCollection|Sequence|Collection|I(?:ndex|terator))))|A(?:ny(?:RandomAccessCollection|Generator|BidirectionalCollection|Sequence|Hashable|Collection|I(?:ndex|terator))|utoreleasingUnsafeMutablePointer|rray(?:Slice)?))\\b',
name: 'support.type.swift'
},
{
match:
'\\b(?:R(?:everse(?:RandomAccess(?:Collection|Index)|Collection|Index)|awByte)|Map(?:Generator|Sequence|Collection)|S(?:inkOf|etGenerator)|Zip2Generator|DictionaryGenerator|Filter(?:Generator|Sequence|Collection(?:Index)?)|LazyForwardCollection|Any(?:RandomAccessIndex|BidirectionalIndex|Forward(?:Collection|Index)))\\b',
name: 'support.type.swift'
}
]
},
'builtin-types-builtin-typealias': {
patterns: [
{
match:
'\\b(?:Raw(?:Significand|Exponent|Value)|B(?:ooleanLiteralType|uffer|ase)|S(?:t(?:orage|r(?:i(?:ngLiteralType|de)|eam(?:1|2)))|ubSequence)|NativeBuffer|C(?:hild(?:ren)?|Bool|S(?:hort|ignedChar)|odeUnit|Char(?:16|32)?|Int|Double|Unsigned(?:Short|Char|Int|Long(?:Long)?)|Float|WideChar|Long(?:Long)?)|I(?:n(?:t(?:Max|egerLiteralType)|d(?:ices|ex(?:Distance)?))|terator)|Distance|U(?:n(?:icodeScalar(?:Type|Index|View|LiteralType)|foldFirstSequence)|TF(?:16(?:Index|View)|8Index)|IntMax)|E(?:lement(?:s)?|x(?:tendedGraphemeCluster(?:Type|LiteralType)|ponent))|V(?:oid|alue)|Key|Float(?:32|LiteralType|64)|AnyClass)\\b',
name: 'support.type.swift'
},
{
match: '\\b(?:Generator|PlaygroundQuickLook|UWord|Word)\\b',
name: 'support.type.swift'
}
]
},
'code-block': {
begin: '\\{',
beginCaptures: {0: {name: 'punctuation.section.scope.begin.swift'}},
end: '\\}',
endCaptures: {0: {name: 'punctuation.section.scope.end.swift'}},
patterns: [{include: '$self'}]
},
comments: {
patterns: [
{
captures: {1: {name: 'punctuation.definition.comment.swift'}},
match: '\\A^(#!).*$\\n?',
name: 'comment.line.number-sign.swift'
},
{
begin: '/\\*\\*(?!/)',
beginCaptures: {
0: {name: 'punctuation.definition.comment.begin.swift'}
},
end: '\\*/',
endCaptures: {0: {name: 'punctuation.definition.comment.end.swift'}},
name: 'comment.block.documentation.swift',
patterns: [{include: '#comments-nested'}]
},
{
begin: '/\\*:',
beginCaptures: {
0: {name: 'punctuation.definition.comment.begin.swift'}
},
end: '\\*/',
endCaptures: {0: {name: 'punctuation.definition.comment.end.swift'}},
name: 'comment.block.documentation.playground.swift',
patterns: [{include: '#comments-nested'}]
},
{
begin: '/\\*',
beginCaptures: {
0: {name: 'punctuation.definition.comment.begin.swift'}
},
end: '\\*/',
endCaptures: {0: {name: 'punctuation.definition.comment.end.swift'}},
name: 'comment.block.swift',
patterns: [{include: '#comments-nested'}]
},
{
match: '\\*/',
name: 'invalid.illegal.unexpected-end-of-block-comment.swift'
},
{
begin: '(^[ \\t]+)?(?=//)',
beginCaptures: {
1: {name: 'punctuation.whitespace.comment.leading.swift'}
},
end: '(?!\\G)',
patterns: [
{
begin: '///',
beginCaptures: {
0: {name: 'punctuation.definition.comment.swift'}
},
end: '$',
name: 'comment.line.triple-slash.documentation.swift'
},
{
begin: '//:',
beginCaptures: {
0: {name: 'punctuation.definition.comment.swift'}
},
end: '$',
name: 'comment.line.double-slash.documentation.swift'
},
{
begin: '//',
beginCaptures: {
0: {name: 'punctuation.definition.comment.swift'}
},
end: '$',
name: 'comment.line.double-slash.swift'
}
]
}
]
},
'comments-nested': {
begin: '/\\*',
end: '\\*/',
patterns: [{include: '#comments-nested'}]
},
'compiler-control': {
patterns: [
{
begin: '^\\s*(#)(if|elseif)\\s+(false)\\b.*?(?=$|//|/\\*)',
beginCaptures: {
0: {name: 'meta.preprocessor.conditional.swift'},
1: {name: 'punctuation.definition.preprocessor.swift'},
2: {name: 'keyword.control.import.preprocessor.conditional.swift'},
3: {name: 'constant.language.boolean.swift'}
},
contentName: 'comment.block.preprocessor.swift',
end: '(?=^\\s*(#(elseif|else|endif)\\b))'
},
{
begin: '^\\s*(#)(if|elseif)\\s+',
captures: {
1: {name: 'punctuation.definition.preprocessor.swift'},
2: {name: 'keyword.control.import.preprocessor.conditional.swift'}
},
end: '(?=\\s*(?://|/\\*))|$',
name: 'meta.preprocessor.conditional.swift',
patterns: [
{match: '(&&|\\|\\|)', name: 'keyword.operator.logical.swift'},
{
match: '\\b(true|false)\\b',
name: 'constant.language.boolean.swift'
},
{
captures: {
1: {name: 'keyword.other.condition.swift'},
2: {name: 'punctuation.definition.parameters.begin.swift'},
3: {name: 'support.constant.platform.architecture.swift'},
4: {name: 'punctuation.definition.parameters.end.swift'}
},
match:
'\\b(arch)\\s*(\\()\\s*(?:(arm|arm64|powerpc64|powerpc64le|i386|x86_64|s390x)|\\w+)\\s*(\\))'
},
{
captures: {
1: {name: 'keyword.other.condition.swift'},
2: {name: 'punctuation.definition.parameters.begin.swift'},
3: {name: 'support.constant.platform.os.swift'},
4: {name: 'punctuation.definition.parameters.end.swift'}
},
match:
'\\b(os)\\s*(\\()\\s*(?:(macOS|OSX|iOS|tvOS|watchOS|Android|Linux|FreeBSD|Windows|PS4)|\\w+)\\s*(\\))'
},
{
captures: {
1: {name: 'keyword.other.condition.swift'},
2: {name: 'punctuation.definition.parameters.begin.swift'},
3: {name: 'entity.name.type.module.swift'},
4: {name: 'punctuation.definition.parameters.end.swift'}
},
match:
'\\b(canImport)\\s*(\\()([\\p{L}_][\\p{L}_\\p{N}\\p{M}]*)(\\))'
},
{
begin: '\\b(targetEnvironment)\\s*(\\()',
beginCaptures: {
1: {name: 'keyword.other.condition.swift'},
2: {name: 'punctuation.definition.parameters.begin.swift'}
},
end: '(\\))|$',
endCaptures: {
1: {name: 'punctuation.definition.parameters.end.swift'}
},
patterns: [
{
match: '\\b(simulator|UIKitForMac)\\b',
name: 'support.constant.platform.environment.swift'
}
]
},
{
begin: '\\b(swift|compiler)\\s*(\\()',
beginCaptures: {
1: {name: 'keyword.other.condition.swift'},
2: {name: 'punctuation.definition.parameters.begin.swift'}
},
end: '(\\))|$',
endCaptures: {
1: {name: 'punctuation.definition.parameters.end.swift'}
},
patterns: [
{match: '>=|<', name: 'keyword.operator.comparison.swift'},
{
match: '\\b[0-9]+(?:\\.[0-9]+)*\\b',
name: 'constant.numeric.swift'
}
]
}
]
},
{
captures: {
1: {name: 'punctuation.definition.preprocessor.swift'},
2: {name: 'keyword.control.import.preprocessor.conditional.swift'},
3: {
patterns: [
{
match: '\\S+',
name: 'invalid.illegal.character-not-allowed-here.swift'
}
]
}
},
match: '^\\s*(#)(else|endif)(.*?)(?=$|//|/\\*)',
name: 'meta.preprocessor.conditional.swift'
},
{
captures: {
1: {name: 'punctuation.definition.preprocessor.swift'},
2: {
name: 'keyword.control.import.preprocessor.sourcelocation.swift'
},
4: {name: 'punctuation.definition.parameters.begin.swift'},
5: {
patterns: [
{
begin: '(file)\\s*(:)\\s*(?=")',
beginCaptures: {
1: {name: 'support.variable.parameter.swift'},
2: {name: 'punctuation.separator.key-value.swift'}
},
end: '(?!\\G)',
patterns: [{include: '#literals'}]
},
{
captures: {
1: {name: 'support.variable.parameter.swift'},
2: {name: 'punctuation.separator.key-value.swift'},
3: {name: 'constant.numeric.integer.swift'}
},
match: '(line)\\s*(:)\\s*([0-9]+)'
},
{match: ',', name: 'punctuation.separator.parameters.swift'},
{
match: '\\S+',
name: 'invalid.illegal.character-not-allowed-here.swift'
}
]
},
6: {name: 'punctuation.definition.parameters.begin.swift'},
7: {
patterns: [
{
match: '\\S+',
name: 'invalid.illegal.character-not-allowed-here.swift'
}
]
}
},
match:
'^\\s*(#)(sourceLocation)((\\()([^)]*)(\\)))(.*?)(?=$|//|/\\*)',
name: 'meta.preprocessor.sourcelocation.swift'
}
]
},
conditionals: {
patterns: [
{
begin: '(?<!\\.)\\b(if|guard|switch|for)\\b',
beginCaptures: {1: {patterns: [{include: '#keywords'}]}},
end: '(?=\\{)',
patterns: [{include: '#expressions-without-trailing-closures'}]
},
{
begin: '(?<!\\.)\\b(while)\\b',
beginCaptures: {1: {patterns: [{include: '#keywords'}]}},
end: '(?=\\{)|$',
patterns: [{include: '#expressions-without-trailing-closures'}]
}
]
},
declarations: {
patterns: [
{include: '#declarations-function'},
{include: '#declarations-function-initializer'},
{include: '#declarations-function-subscript'},
{include: '#declarations-typed-variable-declaration'},
{include: '#declarations-import'},
{include: '#declarations-operator'},
{include: '#declarations-precedencegroup'},
{include: '#declarations-protocol'},
{include: '#declarations-type'},
{include: '#declarations-extension'},
{include: '#declarations-typealias'},
{include: '#declarations-macro'}
]
},
'declarations-available-types': {
patterns: [
{include: '#comments'},
{include: '#builtin-types'},
{include: '#attributes'},
{match: '\\basync\\b', name: 'storage.modifier.async.swift'},
{
match: '\\b(?:throws|rethrows)\\b',
name: 'storage.modifier.exception.swift'
},
{match: '\\bsome\\b', name: 'keyword.other.operator.type.opaque.swift'},
{
match: '\\bany\\b',
name: 'keyword.other.operator.type.existential.swift'
},
{match: '\\b(?:repeat|each)\\b', name: 'keyword.control.loop.swift'},
{
match: '\\b(?:inout|isolated|borrowing|consuming)\\b',
name: 'storage.modifier.swift'
},
{match: '\\bSelf\\b', name: 'variable.language.swift'},
{
captures: {1: {name: 'keyword.operator.type.function.swift'}},
match: '(?<![/=\\-+!*%<>&|\\^~.])(->)(?![/=\\-+!*%<>&|\\^~.])'
},
{
captures: {1: {name: 'keyword.operator.type.composition.swift'}},
match: '(?<![/=\\-+!*%<>&|\\^~.])(&)(?![/=\\-+!*%<>&|\\^~.])'
},
{match: '[?!]', name: 'keyword.operator.type.optional.swift'},
{
match: '\\.\\.\\.',
name: 'keyword.operator.function.variadic-parameter.swift'
},
{match: '\\bprotocol\\b', name: 'keyword.other.type.composition.swift'},
{
match: '(?<=\\.)(?:Protocol|Type)\\b',
name: 'keyword.other.type.metatype.swift'
},
{include: '#declarations-available-types-tuple-type'},
{include: '#declarations-available-types-collection-type'},
{include: '#declarations-generic-argument-clause'}
]
},
'declarations-available-types-collection-type': {
begin: '\\[',
beginCaptures: {
0: {name: 'punctuation.section.collection-type.begin.swift'}
},
end: '\\]|(?=[>){}])',
endCaptures: {0: {name: 'punctuation.section.collection-type.end.swift'}},
patterns: [
{include: '#declarations-available-types'},
{
begin: ':',
beginCaptures: {0: {name: 'punctuation.separator.key-value.swift'}},
end: '(?=\\]|[>){}])',
patterns: [
{
match: ':',
name: 'invalid.illegal.extra-colon-in-dictionary-type.swift'
},
{include: '#declarations-available-types'}
]
}
]
},
'declarations-available-types-tuple-type': {
begin: '\\(',
beginCaptures: {0: {name: 'punctuation.section.tuple-type.begin.swift'}},
end: '\\)|(?=[>\\]{}])',
endCaptures: {0: {name: 'punctuation.section.tuple-type.end.swift'}},
patterns: [{include: '#declarations-available-types'}]
},
'declarations-extension': {
begin:
'\\b(extension)\\s+((?<q>`?)[\\p{L}_][\\p{L}_\\p{N}\\p{M}]*(\\k<q>))',
beginCaptures: {
1: {name: 'storage.type.$1.swift'},
2: {
name: 'entity.name.type.swift',
patterns: [{include: '#declarations-available-types'}]
},
3: {name: 'punctuation.definition.identifier.swift'},
4: {name: 'punctuation.definition.identifier.swift'}
},
end: '(?<=\\})',
name: 'meta.definition.type.$1.swift',
patterns: [
{include: '#comments'},
{include: '#declarations-generic-where-clause'},
{include: '#declarations-inheritance-clause'},
{
begin: '\\{',
beginCaptures: {0: {name: 'punctuation.definition.type.begin.swift'}},
end: '\\}',
endCaptures: {0: {name: 'punctuation.definition.type.end.swift'}},
name: 'meta.definition.type.body.swift',
patterns: [{include: '$self'}]
}
]
},
'declarations-function': {
begin:
'(?x)\n\\b\n(func)\n\\s+\n(\n (?<q>`?)[\\p{L}_][\\p{L}_\\p{N}\\p{M}]*(\\k<q>)\n | (?:\n (\n (?<oph> # operator-head\n [/=\\-+!*%<>&|^~?]\n | [\\x{00A1}-\\x{00A7}]\n | [\\x{00A9}\\x{00AB}]\n | [\\x{00AC}\\x{00AE}]\n | [\\x{00B0}-\\x{00B1}\\x{00B6}\\x{00BB}\\x{00BF}\\x{00D7}\\x{00F7}]\n | [\\x{2016}-\\x{2017}\\x{2020}-\\x{2027}]\n | [\\x{2030}-\\x{203E}]\n | [\\x{2041}-\\x{2053}]\n | [\\x{2055}-\\x{205E}]\n | [\\x{2190}-\\x{23FF}]\n | [\\x{2500}-\\x{2775}]\n | [\\x{2794}-\\x{2BFF}]\n | [\\x{2E00}-\\x{2E7F}]\n | [\\x{3001}-\\x{3003}]\n | [\\x{3008}-\\x{3030}]\n )\n (\n \\g<oph>\n | (?<opc> # operator-character\n [\\x{0300}-\\x{036F}]\n | [\\x{1DC0}-\\x{1DFF}]\n | [\\x{20D0}-\\x{20FF}]\n | [\\x{FE00}-\\x{FE0F}]\n | [\\x{FE20}-\\x{FE2F}]\n | [\\x{E0100}-\\x{E01EF}]\n )\n )*\n )\n | ( \\. ( \\g<oph> | \\g<opc> | \\. )+ ) # Dot operators\n )\n)\n\\s*\n(?=\\(|<)',
beginCaptures: {
1: {name: 'storage.type.function.swift'},
2: {name: 'entity.name.function.swift'},
3: {name: 'punctuation.definition.identifier.swift'},
4: {name: 'punctuation.definition.identifier.swift'}
},
end: '(?<=\\})|$(?# functions in protocol declarations or generated interfaces have no body)',
name: 'meta.definition.function.swift',
patterns: [
{include: '#comments'},
{include: '#declarations-generic-parameter-clause'},
{include: '#declarations-parameter-clause'},
{include: '#declarations-function-result'},
{include: '#async-throws'},
{include: '#declarations-generic-where-clause'},
{
begin: '(\\{)',
beginCaptures: {
1: {name: 'punctuation.section.function.begin.swift'}
},
end: '(\\})',
endCaptures: {1: {name: 'punctuation.section.function.end.swift'}},
name: 'meta.definition.function.body.swift',
patterns: [{include: '$self'}]
}
]
},
'declarations-function-initializer': {
begin:
'(?<!\\.)\\b(init[?!]*(?# only one is valid, but we want the in⇥ snippet to produce something that looks good))\\s*(?=\\(|<)',
beginCaptures: {
1: {
name: 'storage.type.function.swift',
patterns: [
{
match: '(?<=[?!])[?!]+',
name: 'invalid.illegal.character-not-allowed-here.swift'
}
]
}
},
end: '(?<=\\})|$',
name: 'meta.definition.function.initializer.swift',
patterns: [
{include: '#comments'},
{include: '#declarations-generic-parameter-clause'},
{include: '#declarations-parameter-clause'},
{include: '#async-throws'},
{include: '#declarations-generic-where-clause'},
{
begin: '(\\{)',
beginCaptures: {
1: {name: 'punctuation.section.function.begin.swift'}
},
end: '(\\})',
endCaptures: {1: {name: 'punctuation.section.function.end.swift'}},
name: 'meta.definition.function.body.swift',
patterns: [{include: '$self'}]
}
]
},
'declarations-function-result': {
begin: '(?<![/=\\-+!*%<>&|\\^~.])(->)(?![/=\\-+!*%<>&|\\^~.])\\s*',
beginCaptures: {1: {name: 'keyword.operator.function-result.swift'}},
end: '(?!\\G)(?=\\{|\\bwhere\\b|;|=)|$',
name: 'meta.function-result.swift',
patterns: [{include: '#declarations-available-types'}]
},
'declarations-function-subscript': {
begin: '(?<!\\.)\\b(subscript)\\s*(?=\\(|<)',
beginCaptures: {1: {name: 'storage.type.function.swift'}},
end: '(?<=\\})|$',
name: 'meta.definition.function.subscript.swift',
patterns: [
{include: '#comments'},
{include: '#declarations-generic-parameter-clause'},
{include: '#declarations-parameter-clause'},
{include: '#declarations-function-result'},
{include: '#async-throws'},
{include: '#declarations-generic-where-clause'},
{
begin: '(\\{)',
beginCaptures: {
1: {name: 'punctuation.section.function.begin.swift'}
},
end: '(\\})',
endCaptures: {1: {name: 'punctuation.section.function.end.swift'}},
name: 'meta.definition.function.body.swift',
patterns: [{include: '$self'}]
}
]
},
'declarations-generic-argument-clause': {
begin: '<',
beginCaptures: {
0: {name: 'punctuation.separator.generic-argument-clause.begin.swift'}
},
end: '>|(?=[)\\]{}])',
endCaptures: {
0: {name: 'punctuation.separator.generic-argument-clause.end.swift'}
},
name: 'meta.generic-argument-clause.swift',
patterns: [{include: '#declarations-available-types'}]
},
'declarations-generic-parameter-clause': {
begin: '<',
beginCaptures: {
0: {name: 'punctuation.separator.generic-parameter-clause.begin.swift'}
},
end: ">|(?=[^\\w\\d:<>\\s,=&`])(?# characters besides these are never valid in a generic param list -- even if it's not really a valid clause, we should stop trying to parse it if we see one of them.)",
endCaptures: {
0: {name: 'punctuation.separator.generic-parameter-clause.end.swift'}
},
name: 'meta.generic-parameter-clause.swift',
patterns: [
{include: '#comments'},
{include: '#declarations-generic-where-clause'},
{match: '\\beach\\b', name: 'keyword.control.loop.swift'},
{
captures: {1: {name: 'variable.language.generic-parameter.swift'}},
match: '\\b((?!\\d)\\w[\\w\\d]*)\\b'
},
{match: ',', name: 'punctuation.separator.generic-parameters.swift'},
{
begin: '(:)\\s*',
beginCaptures: {
1: {
name: 'punctuation.separator.generic-parameter-constraint.swift'
}
},
end: '(?=[,>]|(?!\\G)\\bwhere\\b)',
name: 'meta.generic-parameter-constraint.swift',
patterns: [
{
begin: '\\G',
end: '(?=[,>]|(?!\\G)\\bwhere\\b)',
name: 'entity.other.inherited-class.swift',
patterns: [
{include: '#declarations-type-identifier'},
{include: '#declarations-type-operators'}
]
}
]
}
]
},
'declarations-generic-where-clause': {
begin: '\\b(where)\\b\\s*',
beginCaptures: {
1: {name: 'keyword.other.generic-constraint-introducer.swift'}
},
end: '(?!\\G)$|(?=[>{};\\n]|//|/\\*)',
name: 'meta.generic-where-clause.swift',
patterns: [
{include: '#comments'},
{include: '#declarations-generic-where-clause-requirement-list'}
]
},
'declarations-generic-where-clause-requirement-list': {
begin: '\\G|,\\s*',
end: '(?=[,>{};\\n]|//|/\\*)',
patterns: [
{include: '#comments'},
{include: '#constraint'},
{include: '#declarations-available-types'},
{
begin: '(?<![/=\\-+!*%<>&|\\^~.])(==)(?![/=\\-+!*%<>&|\\^~.])',
beginCaptures: {
1: {name: 'keyword.operator.generic-constraint.same-type.swift'}
},
end: '(?=\\s*[,>{};\\n]|//|/\\*)',
name: 'meta.generic-where-clause.same-type-requirement.swift',
patterns: [{include: '#declarations-available-types'}]
},
{
begin: '(?<![/=\\-+!*%<>&|\\^~.])(:)(?![/=\\-+!*%<>&|\\^~.])',
beginCaptures: {
1: {name: 'keyword.operator.generic-constraint.conforms-to.swift'}
},
end: '(?=\\s*[,>{};\\n]|//|/\\*)',
name: 'meta.generic-where-clause.conformance-requirement.swift',
patterns: [
{
begin: '\\G\\s*',
contentName: 'entity.other.inherited-class.swift',
end: '(?=\\s*[,>{};\\n]|//|/\\*)',
patterns: [{include: '#declarations-available-types'}]
}
]
}
]
},
'declarations-import': {
begin: '(?<!\\.)\\b(import)\\s+',
beginCaptures: {1: {name: 'keyword.control.import.swift'}},
end: '(;)|$\\n?|(?=//|/\\*)',
endCaptures: {1: {name: 'punctuation.terminator.statement.swift'}},
name: 'meta.import.swift',
patterns: [
{
begin:
'\\G(?!;|$|//|/\\*)(?:(typealias|struct|class|actor|enum|protocol|var|func)\\s+)?',
beginCaptures: {1: {name: 'storage.modifier.swift'}},
end: '(?=;|$|//|/\\*)',
patterns: [
{
captures: {
1: {name: 'punctuation.definition.identifier.swift'},
2: {name: 'punctuation.definition.identifier.swift'}
},
match:
'(?x)\n(?<=\\G|\\.)\n(?<q>`?)[\\p{L}_][\\p{L}_\\p{N}\\p{M}]*(\\k<q>)',
name: 'entity.name.type.swift'
},
{
match: '(?x)\n(?<=\\G|\\.)\n\\$[0-9]+',
name: 'entity.name.type.swift'
},
{
captures: {
1: {
patterns: [
{
match: '\\.',
name: 'invalid.illegal.dot-not-allowed-here.swift'
}
]
}
},
match:
'(?x)\n(?<=\\G|\\.)\n(?:\n (\n (?<oph> # operator-head\n [/=\\-+!*%<>&|^~?]\n | [\\x{00A1}-\\x{00A7}]\n | [\\x{00A9}\\x{00AB}]\n | [\\x{00AC}\\x{00AE}]\n | [\\x{00B0}-\\x{00B1}\\x{00B6}\\x{00BB}\\x{00BF}\\x{00D7}\\x{00F7}]\n | [\\x{2016}-\\x{2017}\\x{2020}-\\x{2027}]\n | [\\x{2030}-\\x{203E}]\n | [\\x{2041}-\\x{2053}]\n | [\\x{2055}-\\x{205E}]\n | [\\x{2190}-\\x{23FF}]\n | [\\x{2500}-\\x{2775}]\n | [\\x{2794}-\\x{2BFF}]\n | [\\x{2E00}-\\x{2E7F}]\n | [\\x{3001}-\\x{3003}]\n | [\\x{3008}-\\x{3030}]\n )\n (\n \\g<oph>\n | (?<opc> # operator-character\n [\\x{0300}-\\x{036F}]\n | [\\x{1DC0}-\\x{1DFF}]\n | [\\x{20D0}-\\x{20FF}]\n | [\\x{FE00}-\\x{FE0F}]\n | [\\x{FE20}-\\x{FE2F}]\n | [\\x{E0100}-\\x{E01EF}]\n )\n )*\n )\n | ( \\. ( \\g<oph> | \\g<opc> | \\. )+ ) # Dot operators\n)\n(?=\\.|;|$|//|/\\*|\\s)',
name: 'entity.name.type.swift'
},
{match: '\\.', name: 'punctuation.separator.import.swift'},
{
begin: '(?!\\s*(;|$|//|/\\*))',
end: '(?=\\s*(;|$|//|/\\*))',
name: 'invalid.illegal.character-not-allowed-here.swift'
}
]
}
]
},
'declarations-inheritance-clause': {
begin: '(:)(?=\\s*\\{)|(:)\\s*',
beginCaptures: {
1: {name: 'invalid.illegal.empty-inheritance-clause.swift'},
2: {name: 'punctuation.separator.inheritance-clause.swift'}
},
end: '(?!\\G)$|(?=[={}]|(?!\\G)\\bwhere\\b)',
name: 'meta.inheritance-clause.swift',
patterns: [
{
begin: '\\bclass\\b',
beginCaptures: {0: {name: 'storage.type.class.swift'}},
end: '(?=[={}]|(?!\\G)\\bwhere\\b)',
patterns: [
{include: '#comments'},
{include: '#declarations-inheritance-clause-more-types'}
]
},
{
begin: '\\G',
end: '(?!\\G)$|(?=[={}]|(?!\\G)\\bwhere\\b)',
patterns: [
{include: '#comments'},
{include: '#declarations-inheritance-clause-inherited-type'},
{include: '#declarations-inheritance-clause-more-types'},
{include: '#declarations-type-operators'}
]
}
]
},
'declarations-inheritance-clause-inherited-type': {
begin: '(?=[`\\p{L}_])',
end: '(?!\\G)',
name: 'entity.other.inherited-class.swift',
patterns: [{include: '#declarations-type-identifier'}]
},
'declarations-inheritance-clause-more-types': {
begin: ',\\s*',
end: '(?!\\G)(?!//|/\\*)|(?=[,={}]|(?!\\G)\\bwhere\\b)',
name: 'meta.inheritance-list.more-types',
patterns: [
{include: '#comments'},
{include: '#declarations-inheritance-clause-inherited-type'},
{include: '#declarations-inheritance-clause-more-types'},
{include: '#declarations-type-operators'}
]
},
'declarations-macro': {
begin:
'(?x)\n\\b\n(macro)\n\\s+\n((?<q>`?)[\\p{L}_][\\p{L}_\\p{N}\\p{M}]*(\\k<q>))\n\\s*\n(?=\\(|<|=)',
beginCaptures: {
1: {name: 'storage.type.function.swift'},
2: {name: 'entity.name.function.swift'},
3: {name: 'punctuation.definition.identifier.swift'},
4: {name: 'punctuation.definition.identifier.swift'}
},
end: '$|(?=;|//|/\\*|\\}|=)',
name: 'meta.definition.macro.swift',
patterns: [
{include: '#comments'},
{include: '#declarations-generic-parameter-clause'},
{include: '#declarations-parameter-clause'},
{include: '#declarations-function-result'},
{include: '#async-throws'},
{include: '#declarations-generic-where-clause'}
]
},
'declarations-operator': {
begin:
'(?x)\n(?:\n \\b(prefix|infix|postfix)\n \\s+\n)?\n\\b\n(operator)\n\\s+\n(\n (\n (?<oph> # operator-head\n [/=\\-+!*%<>&|^~?]\n | [\\x{00A1}-\\x{00A7}]\n | [\\x{00A9}\\x{00AB}]\n | [\\x{00AC}\\x{00AE}]\n | [\\x{00B0}-\\x{00B1}\\x{00B6}\\x{00BB}\\x{00BF}\\x{00D7}\\x{00F7}]\n | [\\x{2016}-\\x{2017}\\x{2020}-\\x{2027}]\n | [\\x{2030}-\\x{203E}]\n | [\\x{2041}-\\x{2053}]\n | [\\x{2055}-\\x{205E}]\n | [\\x{2190}-\\x{23FF}]\n | [\\x{2500}-\\x{2775}]\n | [\\x{2794}-\\x{2BFF}]\n | [\\x{2E00}-\\x{2E7F}]\n | [\\x{3001}-\\x{3003}]\n | [\\x{3008}-\\x{3030}]\n )\n (\n \\g<oph>\n | \\. # Invalid dot\n | (?<opc> # operator-character\n [\\x{0300}-\\x{036F}]\n | [\\x{1DC0}-\\x{1DFF}]\n | [\\x{20D0}-\\x{20FF}]\n | [\\x{FE00}-\\x{FE0F}]\n | [\\x{FE20}-\\x{FE2F}]\n | [\\x{E0100}-\\x{E01EF}]\n )\n )*+\n )\n | ( \\. ( \\g<oph> | \\g<opc> | \\. )++ ) # Dot operators\n)\n\\s*',
beginCaptures: {
1: {name: 'storage.modifier.swift'},
2: {name: 'storage.type.function.operator.swift'},
3: {name: 'entity.name.function.operator.swift'},
4: {
name: 'entity.name.function.operator.swift',
patterns: [
{match: '\\.', name: 'invalid.illegal.dot-not-allowed-here.swift'}
]
}
},
end: '(;)|$\\n?|(?=//|/\\*)',
endCaptures: {1: {name: 'punctuation.terminator.statement.swift'}},
name: 'meta.definition.operator.swift',
patterns: [
{include: '#declarations-operator-swift2'},
{include: '#declarations-operator-swift3'},
{
match: '((?!$|;|//|/\\*)\\S)+',
name: 'invalid.illegal.character-not-allowed-here.swift'
}
]
},
'declarations-operator-swift2': {
begin: '\\G(\\{)',
beginCaptures: {1: {name: 'punctuation.definition.operator.begin.swift'}},