From 6855ba045bdb327e25a59a3c7b1a807285fb0f82 Mon Sep 17 00:00:00 2001 From: Jacob Bandes-Storch Date: Wed, 15 Nov 2023 06:59:29 -0800 Subject: [PATCH] Update Swift grammar and upstream repository (#197470) * Update Swift grammar and upstream repository * update grammar for bug fix * Update Swift cgmanifest --------- Co-authored-by: Alex Ross --- extensions/swift/LICENSE.md | 45 - extensions/swift/cgmanifest.json | 47 +- extensions/swift/package.json | 2 +- .../swift/syntaxes/swift.tmLanguage.json | 5708 ++++++++++------- 4 files changed, 3320 insertions(+), 2482 deletions(-) delete mode 100644 extensions/swift/LICENSE.md diff --git a/extensions/swift/LICENSE.md b/extensions/swift/LICENSE.md deleted file mode 100644 index 2a342e30ba8..00000000000 --- a/extensions/swift/LICENSE.md +++ /dev/null @@ -1,45 +0,0 @@ -Monarch definition & snippets: - -The MIT License (MIT) - -Copyright (c) 2015 David Owens II - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - -TextMate grammar: - -Copyright (c) 2014 Darin Morrison - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file diff --git a/extensions/swift/cgmanifest.json b/extensions/swift/cgmanifest.json index a6e26d57d7c..5e7fd05c637 100644 --- a/extensions/swift/cgmanifest.json +++ b/extensions/swift/cgmanifest.json @@ -1,5 +1,16 @@ { "registrations": [ + { + "component": { + "type": "git", + "git": { + "name": "jtbandes/swift-tmlanguage", + "repositoryUrl": "https://github.com/jtbandes/swift-tmlanguage", + "commitHash": "806e024d8ea2478596d7e0ab871d2b1436e6fead" + } + }, + "license": "MIT" + }, { "component": { "type": "git", @@ -32,42 +43,8 @@ "OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE." ], "license": "MIT", - "description": "The files in this folder are based on https://github.com/owensd/vscode-swift.", + "description": "The files in the 'snippets' subfolder in this folder are based on https://github.com/owensd/vscode-swift.", "version": "0.0.1" - }, - { - "component": { - "type": "git", - "git": { - "name": "freebroccolo/atom-language-swift", - "repositoryUrl": "https://github.com/freebroccolo/atom-language-swift", - "commitHash": "d8f4ed1f79cbb4d5d215e7a68fa8cc6b618e16e0" - } - }, - "licenseDetail": [ - "The MIT License (MIT)", - "", - "Copyright (c) 2014 Darin Morrison", - "", - "Permission is hereby granted, free of charge, to any person obtaining a copy", - "of this software and associated documentation files (the \"Software\"), to deal", - "in the Software without restriction, including without limitation the rights", - "to use, copy, modify, merge, publish, distribute, sublicense, and/or sell", - "copies of the Software, and to permit persons to whom the Software is", - "furnished to do so, subject to the following conditions:", - "", - "The above copyright notice and this permission notice shall be included in all", - "copies or substantial portions of the Software.", - "", - "THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR", - "IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,", - "FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE", - "AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER", - "LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,", - "OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE." - ], - "license": "MIT", - "version": "0.0.0" } ], "version": 1 diff --git a/extensions/swift/package.json b/extensions/swift/package.json index d8786ae14c6..fd1a76cbadd 100644 --- a/extensions/swift/package.json +++ b/extensions/swift/package.json @@ -9,7 +9,7 @@ "vscode": "*" }, "scripts": { - "update-grammar": "node ../node_modules/vscode-grammar-updater/bin textmate/swift.tmbundle Syntaxes/Swift.tmLanguage ./syntaxes/swift.tmLanguage.json" + "update-grammar": "node ../node_modules/vscode-grammar-updater/bin jtbandes/swift-tmlanguage Swift.tmLanguage.json ./syntaxes/swift.tmLanguage.json" }, "contributes": { "languages": [ diff --git a/extensions/swift/syntaxes/swift.tmLanguage.json b/extensions/swift/syntaxes/swift.tmLanguage.json index f63b127dc62..64aebc15bba 100644 --- a/extensions/swift/syntaxes/swift.tmLanguage.json +++ b/extensions/swift/syntaxes/swift.tmLanguage.json @@ -1,10 +1,10 @@ { "information_for_contributors": [ - "This file has been converted from https://github.com/textmate/swift.tmbundle/blob/master/Syntaxes/Swift.tmLanguage", + "This file has been converted from https://github.com/jtbandes/swift-tmlanguage/blob/master/Swift.tmLanguage.json", "If you want to provide a fix or improvement, please create a pull request against the original repository.", "Once accepted there, we are happy to receive an update request." ], - "version": "https://github.com/textmate/swift.tmbundle/commit/7a35637eb70aef3114b091c4ff6fbf6a2faa881b", + "version": "https://github.com/jtbandes/swift-tmlanguage/commit/806e024d8ea2478596d7e0ab871d2b1436e6fead", "name": "Swift", "scopeName": "source.swift", "comment": "See swift.tmbundle/grammar-test.swift for test cases.", @@ -15,23 +15,25 @@ ], "repository": { "async-throws": { + "match": "\\b(?:(throws\\s+async|rethrows\\s+async)|(throws|rethrows)|(async))\\b", "captures": { "1": { "name": "invalid.illegal.await-must-precede-throws.swift" }, "2": { - "name": "keyword.control.exception.swift" + "name": "storage.modifier.exception.swift" }, "3": { - "name": "keyword.control.async.swift" + "name": "storage.modifier.async.swift" } - }, - "match": "\\b(?:(throws\\s+async|rethrows\\s+async)|(throws|rethrows)|(async))\\b" + } }, "attributes": { "patterns": [ { + "name": "meta.attribute.available.swift", "begin": "((@)available)(\\()", + "end": "\\)", "beginCaptures": { "1": { "name": "storage.modifier.attribute.swift" @@ -43,15 +45,14 @@ "name": "punctuation.definition.arguments.begin.swift" } }, - "end": "\\)", "endCaptures": { "0": { "name": "punctuation.definition.arguments.end.swift" } }, - "name": "meta.attribute.available.swift", "patterns": [ { + "match": "\\b(swift|(?:iOS|macOS|OSX|watchOS|tvOS|UIKitForMac)(?:ApplicationExtension)?)\\b(?:\\s+([0-9]+(?:\\.[0-9]+)*\\b))?", "captures": { "1": { "name": "keyword.other.platform.os.swift" @@ -59,11 +60,11 @@ "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*", + "end": "(?!\\G)", "beginCaptures": { "1": { "name": "keyword.other.swift" @@ -72,16 +73,16 @@ "name": "punctuation.separator.key-value.swift" } }, - "end": "(?!\\G)", "patterns": [ { - "match": "\\b[0-9]+(?:\\.[0-9]+)*\\b", - "name": "constant.numeric.swift" + "name": "constant.numeric.swift", + "match": "\\b[0-9]+(?:\\.[0-9]+)*\\b" } ] }, { "begin": "\\b(message|renamed)\\s*(:)\\s*(?=\")", + "end": "(?!\\G)", "beginCaptures": { "1": { "name": "keyword.other.swift" @@ -90,7 +91,6 @@ "name": "punctuation.separator.key-value.swift" } }, - "end": "(?!\\G)", "patterns": [ { "include": "#literals" @@ -98,6 +98,7 @@ ] }, { + "match": "(?:(\\*)|\\b(deprecated|unavailable|noasync)\\b)\\s*(.*?)(?=[,)])", "captures": { "1": { "name": "keyword.other.platform.all.swift" @@ -108,13 +109,14 @@ "3": { "name": "invalid.illegal.character-not-allowed-here.swift" } - }, - "match": "(?:(\\*)|\\b(deprecated|unavailable|noasync)\\b)\\s*(.*?)(?=[,)])" + } } ] }, { + "name": "meta.attribute.objc.swift", "begin": "((@)objc)(\\()", + "end": "\\)", "beginCaptures": { "1": { "name": "storage.modifier.attribute.swift" @@ -126,27 +128,28 @@ "name": "punctuation.definition.arguments.begin.swift" } }, - "end": "\\)", "endCaptures": { "0": { "name": "punctuation.definition.arguments.end.swift" } }, - "name": "meta.attribute.objc.swift", "patterns": [ { + "name": "entity.name.function.swift", + "match": "\\w*(?::(?:\\w*:)*(\\w*))?", "captures": { "1": { "name": "invalid.illegal.missing-colon-after-selector-piece.swift" } - }, - "match": "\\w*(?::(?:\\w*:)*(\\w*))?", - "name": "entity.name.function.swift" + } } ] }, { + "comment": "any other attribute", + "name": "meta.attribute.swift", "begin": "(@)(?`?)[\\p{L}_][\\p{L}_\\p{N}\\p{M}]*(\\k)", + "end": "(?!\\G\\()", "beginCaptures": { "0": { "name": "storage.modifier.attribute.swift" @@ -161,24 +164,21 @@ "name": "punctuation.definition.identifier.swift" } }, - "comment": "any other attribute", - "end": "(?!\\G\\()", - "name": "meta.attribute.swift", "patterns": [ { + "name": "meta.arguments.attribute.swift", "begin": "\\(", + "end": "\\)", "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" @@ -193,18 +193,18 @@ "patterns": [ { "comment": "Member functions in the standard library in Swift 3 which may be used with trailing closures and no parentheses", - "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" + "name": "support.function.swift", + "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" }, { "comment": "Member functions in the standard library in Swift 3", - "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" + "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*\\()" }, { "comment": "Member functions in the standard library in Swift 2 only", - "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" + "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*\\()" } ] }, @@ -212,6 +212,7 @@ "patterns": [ { "begin": "\\b(type)(\\()\\s*(of)(:)", + "end": "\\)", "beginCaptures": { "1": { "name": "support.function.dynamic-type.swift" @@ -226,7 +227,6 @@ "name": "punctuation.separator.argument-label.begin.swift" } }, - "end": "\\)", "endCaptures": { "0": { "name": "punctuation.definition.arguments.end.swift" @@ -240,18 +240,18 @@ }, { "comment": "Global functions available in Swift 3 which may be used with trailing closures and no parentheses", - "match": "\\b(?:anyGenerator|autoreleasepool)(?=\\s*[({])\\b", - "name": "support.function.swift" + "name": "support.function.swift", + "match": "\\b(?:anyGenerator|autoreleasepool)(?=\\s*[({])\\b" }, { "comment": "Global functions available in Swift 3", - "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" + "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*\\()" }, { "comment": "Global functions available in Swift 2 only", - "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" + "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*\\()" } ] }, @@ -259,23 +259,23 @@ "patterns": [ { "comment": "The simpler (?<=\\bProcess\\.|\\bCommandLine\\.) breaks VS Code / Atom, see https://github.com/textmate/swift.tmbundle/issues/29", - "match": "(?<=^Process\\.|\\WProcess\\.|^CommandLine\\.|\\WCommandLine\\.)(arguments|argc|unsafeArgv)", - "name": "support.variable.swift" + "name": "support.variable.swift", + "match": "(?<=^Process\\.|\\WProcess\\.|^CommandLine\\.|\\WCommandLine\\.)(arguments|argc|unsafeArgv)" }, { "comment": "Properties in the standard library in Swift 3", - "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" + "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" }, { "comment": "Properties in the standard library in Swift 2 only", - "match": "(?<=\\.)(?:boolValue|disposition|end|objectIdentifier|quickLookObject|start|valueType)\\b", - "name": "support.variable.swift" + "name": "support.variable.swift", + "match": "(?<=\\.)(?:boolValue|disposition|end|objectIdentifier|quickLookObject|start|valueType)\\b" }, { "comment": "Enum cases in the standard library - note that there is some overlap between these and the properties", - "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" + "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" } ] }, @@ -283,107 +283,105 @@ "comment": "Types provided in the standard library", "patterns": [ { - "include": "#builtin-class-type" + "include": "#builtin-types-builtin-class-type" }, { - "include": "#builtin-enum-type" + "include": "#builtin-types-builtin-enum-type" }, { - "include": "#builtin-protocol-type" + "include": "#builtin-types-builtin-protocol-type" }, { - "include": "#builtin-struct-type" + "include": "#builtin-types-builtin-struct-type" }, { - "include": "#builtin-typealias" + "include": "#builtin-types-builtin-typealias" }, { - "match": "\\bAny\\b", - "name": "support.type.any.swift" + "name": "support.type.any.swift", + "match": "\\bAny\\b" } - ], - "repository": { - "builtin-class-type": { - "comment": "Builtin class types", - "match": "\\b(Managed(Buffer|ProtoBuffer)|NonObjectiveCBase|AnyGenerator)\\b", - "name": "support.class.swift" + ] + }, + "builtin-types-builtin-class-type": { + "comment": "Builtin class types", + "name": "support.class.swift", + "match": "\\b(Managed(Buffer|ProtoBuffer)|NonObjectiveCBase|AnyGenerator)\\b" + }, + "builtin-types-builtin-enum-type": { + "patterns": [ + { + "comment": "CommandLine is an enum, but it acts like a constant", + "name": "support.constant.swift", + "match": "\\b(?:CommandLine|Process(?=\\.))\\b" }, - "builtin-enum-type": { - "patterns": [ - { - "comment": "CommandLine is an enum, but it acts like a constant", - "match": "\\b(?:CommandLine|Process(?=\\.))\\b", - "name": "support.constant.swift" - }, - { - "comment": "The return type of a function that never returns", - "match": "\\bNever\\b", - "name": "support.constant.never.swift" - }, - { - "comment": "Enum types in the standard library in Swift 3", - "match": "\\b(?:ImplicitlyUnwrappedOptional|Representation|MemoryLayout|FloatingPointClassification|SetIndexRepresentation|SetIteratorRepresentation|FloatingPointRoundingRule|UnicodeDecodingResult|Optional|DictionaryIndexRepresentation|AncestorRepresentation|DisplayStyle|PlaygroundQuickLook|Never|FloatingPointSign|Bit|DictionaryIteratorRepresentation)\\b", - "name": "support.type.swift" - }, - { - "comment": "Enum types in the standard library in Swift 2 only", - "match": "\\b(?:MirrorDisposition|QuickLookObject)\\b", - "name": "support.type.swift" - } - ] + { + "comment": "The return type of a function that never returns", + "name": "support.constant.never.swift", + "match": "\\bNever\\b" }, - "builtin-protocol-type": { - "patterns": [ - { - "comment": "Protocols in the standard library in Swift 3", - "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" - }, - { - "comment": "Protocols in the standard library in Swift 2 only", - "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" - } - ] + { + "comment": "Enum types in the standard library in Swift 3", + "name": "support.type.swift", + "match": "\\b(?:ImplicitlyUnwrappedOptional|Representation|MemoryLayout|FloatingPointClassification|SetIndexRepresentation|SetIteratorRepresentation|FloatingPointRoundingRule|UnicodeDecodingResult|Optional|DictionaryIndexRepresentation|AncestorRepresentation|DisplayStyle|PlaygroundQuickLook|Never|FloatingPointSign|Bit|DictionaryIteratorRepresentation)\\b" }, - "builtin-struct-type": { - "patterns": [ - { - "comment": "Structs in the standard library in Swift 3", - "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" - }, - { - "comment": "Structs in the standard library in Swift 2 only", - "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-typealias": { - "patterns": [ - { - "comment": "Typealiases in the standard library in Swift 3", - "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" - }, - { - "comment": "Typealiases in the standard library in Swift 2 only", - "match": "\\b(?:Generator|PlaygroundQuickLook|UWord|Word)\\b", - "name": "support.type.swift" - } - ] + { + "comment": "Enum types in the standard library in Swift 2 only", + "name": "support.type.swift", + "match": "\\b(?:MirrorDisposition|QuickLookObject)\\b" } - } + ] + }, + "builtin-types-builtin-protocol-type": { + "patterns": [ + { + "comment": "Protocols in the standard library in Swift 3", + "name": "support.type.swift", + "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" + }, + { + "comment": "Protocols in the standard library in Swift 2 only", + "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" + } + ] + }, + "builtin-types-builtin-struct-type": { + "patterns": [ + { + "comment": "Structs in the standard library in Swift 3", + "name": "support.type.swift", + "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" + }, + { + "comment": "Structs in the standard library in Swift 2 only", + "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" + } + ] + }, + "builtin-types-builtin-typealias": { + "patterns": [ + { + "comment": "Typealiases in the standard library in Swift 3", + "name": "support.type.swift", + "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" + }, + { + "comment": "Typealiases in the standard library in Swift 2 only", + "name": "support.type.swift", + "match": "\\b(?:Generator|PlaygroundQuickLook|UWord|Word)\\b" + } + ] }, "code-block": { "begin": "\\{", + "end": "\\}", "beginCaptures": { "0": { "name": "punctuation.section.scope.begin.swift" } }, - "end": "\\}", "endCaptures": { "0": { "name": "punctuation.section.scope.end.swift" @@ -398,136 +396,136 @@ "comments": { "patterns": [ { + "name": "comment.line.number-sign.swift", + "match": "\\A^(#!).*$\\n?", "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": "#nested" - } - ] - }, - { - "begin": "/\\*:", + "begin": "/\\*\\*(?!/)", + "end": "\\*/", "beginCaptures": { "0": { "name": "punctuation.definition.comment.begin.swift" } }, - "end": "\\*/", "endCaptures": { "0": { "name": "punctuation.definition.comment.end.swift" } }, + "patterns": [ + { + "include": "#comments-nested" + } + ] + }, + { "name": "comment.block.documentation.playground.swift", - "patterns": [ - { - "include": "#nested" - } - ] - }, - { - "begin": "/\\*", + "begin": "/\\*:", + "end": "\\*/", "beginCaptures": { "0": { "name": "punctuation.definition.comment.begin.swift" } }, - "end": "\\*/", "endCaptures": { "0": { "name": "punctuation.definition.comment.end.swift" } }, - "name": "comment.block.swift", "patterns": [ { - "include": "#nested" + "include": "#comments-nested" } ] }, { - "match": "\\*/", - "name": "invalid.illegal.unexpected-end-of-block-comment.swift" + "name": "comment.block.swift", + "begin": "/\\*", + "end": "\\*/", + "beginCaptures": { + "0": { + "name": "punctuation.definition.comment.begin.swift" + } + }, + "endCaptures": { + "0": { + "name": "punctuation.definition.comment.end.swift" + } + }, + "patterns": [ + { + "include": "#comments-nested" + } + ] + }, + { + "name": "invalid.illegal.unexpected-end-of-block-comment.swift", + "match": "\\*/" }, { "begin": "(^[ \\t]+)?(?=//)", + "end": "(?!\\G)", "beginCaptures": { "1": { "name": "punctuation.whitespace.comment.leading.swift" } }, - "end": "(?!\\G)", "patterns": [ { + "name": "comment.line.triple-slash.documentation.swift", "begin": "///", + "end": "$", "beginCaptures": { "0": { "name": "punctuation.definition.comment.swift" } - }, - "end": "^", - "name": "comment.line.triple-slash.documentation.swift" + } }, { + "name": "comment.line.double-slash.documentation.swift", "begin": "//:", + "end": "$", "beginCaptures": { "0": { "name": "punctuation.definition.comment.swift" } - }, - "end": "^", - "name": "comment.line.double-slash.documentation.swift" + } }, { + "name": "comment.line.double-slash.swift", "begin": "//", + "end": "$", "beginCaptures": { "0": { "name": "punctuation.definition.comment.swift" } - }, - "end": "^", - "name": "comment.line.double-slash.swift" + } } ] } - ], - "repository": { - "nested": { - "begin": "/\\*", - "end": "\\*/", - "patterns": [ - { - "include": "#nested" - } - ] + ] + }, + "comments-nested": { + "begin": "/\\*", + "end": "\\*/", + "patterns": [ + { + "include": "#comments-nested" } - } + ] }, "compiler-control": { "patterns": [ { + "contentName": "comment.block.preprocessor.swift", "begin": "^\\s*(#)(if|elseif)\\s+(false)\\b.*?(?=$|//|/\\*)", + "end": "(?=^\\s*(#(elseif|else|endif)\\b))", "beginCaptures": { "0": { "name": "meta.preprocessor.conditional.swift" @@ -536,37 +534,36 @@ "name": "punctuation.definition.preprocessor.swift" }, "2": { - "name": "keyword.control.preprocessor.conditional.swift" + "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+", + "name": "meta.preprocessor.conditional.swift", "captures": { "1": { "name": "punctuation.definition.preprocessor.swift" }, "2": { - "name": "keyword.control.preprocessor.conditional.swift" + "name": "keyword.control.import.preprocessor.conditional.swift" } }, + "begin": "^\\s*(#)(if|elseif)\\s+", "end": "(?=\\s*(?://|/\\*))|$", - "name": "meta.preprocessor.conditional.swift", "patterns": [ { - "match": "(&&|\\|\\|)", - "name": "keyword.operator.logical.swift" + "name": "keyword.operator.logical.swift", + "match": "(&&|\\|\\|)" }, { - "match": "\\b(true|false)\\b", - "name": "constant.language.boolean.swift" + "name": "constant.language.boolean.swift", + "match": "\\b(true|false)\\b" }, { + "match": "\\b(arch)\\s*(\\()\\s*(?:(arm|arm64|powerpc64|powerpc64le|i386|x86_64|s390x)|\\w+)\\s*(\\))", "captures": { "1": { "name": "keyword.other.condition.swift" @@ -580,10 +577,10 @@ "4": { "name": "punctuation.definition.parameters.end.swift" } - }, - "match": "\\b(arch)\\s*(\\()\\s*(?:(arm|arm64|powerpc64|powerpc64le|i386|x86_64|s390x)|\\w+)\\s*(\\))" + } }, { + "match": "\\b(os)\\s*(\\()\\s*(?:(macOS|OSX|iOS|tvOS|watchOS|Android|Linux|FreeBSD|Windows|PS4)|\\w+)\\s*(\\))", "captures": { "1": { "name": "keyword.other.condition.swift" @@ -597,10 +594,10 @@ "4": { "name": "punctuation.definition.parameters.end.swift" } - }, - "match": "\\b(os)\\s*(\\()\\s*(?:(macOS|OSX|iOS|tvOS|watchOS|Android|Linux|FreeBSD|Windows|PS4)|\\w+)\\s*(\\))" + } }, { + "match": "\\b(canImport)\\s*(\\()([\\p{L}_][\\p{L}_\\p{N}\\p{M}]*)(\\))", "captures": { "1": { "name": "keyword.other.condition.swift" @@ -614,11 +611,11 @@ "4": { "name": "punctuation.definition.parameters.end.swift" } - }, - "match": "\\b(canImport)\\s*(\\()([\\p{L}_][\\p{L}_\\p{N}\\p{M}]*)(\\))" + } }, { "begin": "\\b(targetEnvironment)\\s*(\\()", + "end": "(\\))|$", "beginCaptures": { "1": { "name": "keyword.other.condition.swift" @@ -627,7 +624,6 @@ "name": "punctuation.definition.parameters.begin.swift" } }, - "end": "(\\))|$", "endCaptures": { "1": { "name": "punctuation.definition.parameters.end.swift" @@ -635,13 +631,14 @@ }, "patterns": [ { - "match": "\\b(simulator|UIKitForMac)\\b", - "name": "support.constant.platform.environment.swift" + "name": "support.constant.platform.environment.swift", + "match": "\\b(simulator|UIKitForMac)\\b" } ] }, { "begin": "\\b(swift|compiler)\\s*(\\()", + "end": "(\\))|$", "beginCaptures": { "1": { "name": "keyword.other.condition.swift" @@ -650,7 +647,6 @@ "name": "punctuation.definition.parameters.begin.swift" } }, - "end": "(\\))|$", "endCaptures": { "1": { "name": "punctuation.definition.parameters.end.swift" @@ -658,44 +654,46 @@ }, "patterns": [ { - "match": ">=|<", - "name": "keyword.operator.comparison.swift" + "name": "keyword.operator.comparison.swift", + "match": ">=|<" }, { - "match": "\\b[0-9]+(?:\\.[0-9]+)*\\b", - "name": "constant.numeric.swift" + "name": "constant.numeric.swift", + "match": "\\b[0-9]+(?:\\.[0-9]+)*\\b" } ] } ] }, { + "name": "meta.preprocessor.conditional.swift", + "match": "^\\s*(#)(else|endif)(.*?)(?=$|//|/\\*)", "captures": { "1": { "name": "punctuation.definition.preprocessor.swift" }, "2": { - "name": "keyword.control.preprocessor.conditional.swift" + "name": "keyword.control.import.preprocessor.conditional.swift" }, "3": { "patterns": [ { - "match": "\\S+", - "name": "invalid.illegal.character-not-allowed-here.swift" + "name": "invalid.illegal.character-not-allowed-here.swift", + "match": "\\S+" } ] } - }, - "match": "^\\s*(#)(else|endif)(.*?)(?=$|//|/\\*)", - "name": "meta.preprocessor.conditional.swift" + } }, { + "name": "meta.preprocessor.sourcelocation.swift", + "match": "^\\s*(#)(sourceLocation)((\\()([^)]*)(\\)))(.*?)(?=$|//|/\\*)", "captures": { "1": { "name": "punctuation.definition.preprocessor.swift" }, "2": { - "name": "keyword.control.preprocessor.sourcelocation.swift" + "name": "keyword.control.import.preprocessor.sourcelocation.swift" }, "4": { "name": "punctuation.definition.parameters.begin.swift" @@ -704,6 +702,7 @@ "patterns": [ { "begin": "(file)\\s*(:)\\s*(?=\")", + "end": "(?!\\G)", "beginCaptures": { "1": { "name": "support.variable.parameter.swift" @@ -712,7 +711,6 @@ "name": "punctuation.separator.key-value.swift" } }, - "end": "(?!\\G)", "patterns": [ { "include": "#literals" @@ -720,6 +718,7 @@ ] }, { + "match": "(line)\\s*(:)\\s*([0-9]+)", "captures": { "1": { "name": "support.variable.parameter.swift" @@ -730,16 +729,15 @@ "3": { "name": "constant.numeric.integer.swift" } - }, - "match": "(line)\\s*(:)\\s*([0-9]+)" + } }, { - "match": ",", - "name": "punctuation.separator.parameters.swift" + "name": "punctuation.separator.parameters.swift", + "match": "," }, { - "match": "\\S+", - "name": "invalid.illegal.character-not-allowed-here.swift" + "name": "invalid.illegal.character-not-allowed-here.swift", + "match": "\\S+" } ] }, @@ -749,1545 +747,1766 @@ "7": { "patterns": [ { - "match": "\\S+", - "name": "invalid.illegal.character-not-allowed-here.swift" + "name": "invalid.illegal.character-not-allowed-here.swift", + "match": "\\S+" + } + ] + } + } + } + ] + }, + "conditionals": { + "patterns": [ + { + "begin": "(?&|\\^~.])(->)(?![/=\\-+!*%<>&|\\^~.])" - }, - { - "captures": { - "1": { - "name": "keyword.operator.type.composition.swift" - } - }, - "comment": "Swift 3: A & B", - "match": "(?&|\\^~.])(&)(?![/=\\-+!*%<>&|\\^~.])" - }, - { - "match": "[?!]", - "name": "keyword.operator.type.optional.swift" - }, - { - "match": "\\.\\.\\.", - "name": "keyword.operator.function.variadic-parameter.swift" - }, - { - "comment": "Swift 2: protocol", - "match": "\\bprotocol\\b", + ] + }, + "declarations-available-types": { + "patterns": [ + { + "include": "#comments" + }, + { + "include": "#builtin-types" + }, + { + "include": "#attributes" + }, + { + "name": "storage.modifier.async.swift", + "match": "\\basync\\b" + }, + { + "name": "storage.modifier.exception.swift", + "match": "\\b(?:throws|rethrows)\\b" + }, + { + "name": "keyword.other.operator.type.opaque.swift", + "match": "\\bsome\\b" + }, + { + "name": "keyword.other.operator.type.existential.swift", + "match": "\\bany\\b" + }, + { + "name": "keyword.control.loop.swift", + "match": "\\b(?:repeat|each)\\b" + }, + { + "name": "storage.modifier.swift", + "match": "\\b(?:inout|isolated|borrowing|consuming)\\b" + }, + { + "name": "variable.language.swift", + "match": "\\bSelf\\b" + }, + { + "match": "(?&|\\^~.])(->)(?![/=\\-+!*%<>&|\\^~.])", + "captures": { + "1": { + "name": "keyword.operator.type.function.swift" + } + } + }, + { + "comment": "Swift 3: A & B", + "match": "(?&|\\^~.])(&)(?![/=\\-+!*%<>&|\\^~.])", + "captures": { + "1": { "name": "keyword.operator.type.composition.swift" - }, - { - "match": "(?<=\\.)(?:Protocol|Type)\\b", - "name": "keyword.operator.type.metatype.swift" - }, - { - "include": "#tuple-type" - }, - { - "include": "#collection-type" - }, - { - "include": "#generic-argument-clause" - } - ], - "repository": { - "collection-type": { - "begin": "\\[", - "beginCaptures": { - "0": { - "name": "punctuation.section.collection-type.begin.swift" - } - }, - "comment": "array and dictionary types [Value] and [Key: Value]", - "end": "\\]|(?=[>){}])", - "endCaptures": { - "0": { - "name": "punctuation.section.collection-type.end.swift" - } - }, - "patterns": [ - { - "include": "#available-types" - }, - { - "begin": ":", - "beginCaptures": { - "0": { - "name": "punctuation.separator.key-value.swift" - } - }, - "end": "(?=\\]|[>){}])", - "patterns": [ - { - "match": ":", - "name": "invalid.illegal.extra-colon-in-dictionary-type.swift" - }, - { - "include": "#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": "#available-types" - } - ] } } }, - "extension": { - "begin": "\\b(extension)\\s+((?`?)[\\p{L}_][\\p{L}_\\p{N}\\p{M}]*(\\k))", - "beginCaptures": { - "1": { - "name": "storage.type.$1.swift" - }, - "2": { - "name": "entity.name.type.swift", - "patterns": [ - { - "include": "#available-types" - } - ] - }, - "3": { - "name": "punctuation.definition.identifier.swift" - }, - "4": { - "name": "punctuation.definition.identifier.swift" - } - }, - "end": "(?<=\\})", - "name": "meta.definition.type.$1.swift", - "patterns": [ - { - "include": "#comments" - }, - { - "comment": "SE-0143: Conditional Conformances", - "include": "#generic-where-clause" - }, - { - "include": "#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" - } - ] - } - ] + { + "name": "keyword.operator.type.optional.swift", + "match": "[?!]" }, - "function": { - "begin": "(?x)\n\t\t\t\t\t\t\\b\n\t\t\t\t\t\t(?:(nonisolated)\\s+)?\n\t\t\t\t\t\t(func)\n\t\t\t\t\t\t\\s+\n\t\t\t\t\t\t(\n\t\t\t\t\t\t\t(?`?)[\\p{L}_][\\p{L}_\\p{N}\\p{M}]*(\\k)\n\t\t\t\t\t\t | (?:\n\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\t(?\t\t\t\t\t\t\t\t# operator-head\n\t\t\t\t\t\t\t\t\t\t[/=\\-+!*%<>&|^~?]\n\t\t\t\t\t\t\t\t\t | [\\x{00A1}-\\x{00A7}]\n\t\t\t\t\t\t\t\t\t | [\\x{00A9}\\x{00AB}]\n\t\t\t\t\t\t\t\t\t | [\\x{00AC}\\x{00AE}]\n\t\t\t\t\t\t\t\t\t | [\\x{00B0}-\\x{00B1}\\x{00B6}\\x{00BB}\\x{00BF}\\x{00D7}\\x{00F7}]\n\t\t\t\t\t\t\t\t\t | [\\x{2016}-\\x{2017}\\x{2020}-\\x{2027}]\n\t\t\t\t\t\t\t\t\t | [\\x{2030}-\\x{203E}]\n\t\t\t\t\t\t\t\t\t | [\\x{2041}-\\x{2053}]\n\t\t\t\t\t\t\t\t\t | [\\x{2055}-\\x{205E}]\n\t\t\t\t\t\t\t\t\t | [\\x{2190}-\\x{23FF}]\n\t\t\t\t\t\t\t\t\t | [\\x{2500}-\\x{2775}]\n\t\t\t\t\t\t\t\t\t | [\\x{2794}-\\x{2BFF}]\n\t\t\t\t\t\t\t\t\t | [\\x{2E00}-\\x{2E7F}]\n\t\t\t\t\t\t\t\t\t | [\\x{3001}-\\x{3003}]\n\t\t\t\t\t\t\t\t\t | [\\x{3008}-\\x{3030}]\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\t\t\\g\n\t\t\t\t\t\t\t\t\t | (?\t\t\t\t\t\t\t\t# operator-character\n\t\t\t\t\t\t\t\t\t\t\t[\\x{0300}-\\x{036F}]\n\t\t\t\t\t\t\t\t\t\t | [\\x{1DC0}-\\x{1DFF}]\n\t\t\t\t\t\t\t\t\t\t | [\\x{20D0}-\\x{20FF}]\n\t\t\t\t\t\t\t\t\t\t | [\\x{FE00}-\\x{FE0F}]\n\t\t\t\t\t\t\t\t\t\t | [\\x{FE20}-\\x{FE2F}]\n\t\t\t\t\t\t\t\t\t\t | [\\x{E0100}-\\x{E01EF}]\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t)*\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t | ( \\. ( \\g | \\g | \\. )+ )\t\t\t# Dot operators\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t)\n\t\t\t\t\t\t\\s*\n\t\t\t\t\t\t(?=\\(|<)\n\t\t\t\t\t", - "beginCaptures": { - "1": { - "name": "storage.modifier.swift" - }, - "2": { - "name": "storage.type.function.swift" - }, - "3": { - "name": "entity.name.function.swift" - }, - "4": { - "name": "punctuation.definition.identifier.swift" - }, - "5": { - "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": "#generic-parameter-clause" - }, - { - "include": "#parameter-clause" - }, - { - "include": "#function-result" - }, - { - "include": "#async-throws" - }, - { - "comment": "Swift 3: generic constraints after the parameters and return type", - "include": "#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" - } - ] - } - ] + { + "name": "keyword.operator.function.variadic-parameter.swift", + "match": "\\.\\.\\." }, - "function-initializer": { - "begin": "(?", + "name": "keyword.other.type.composition.swift", + "match": "\\bprotocol\\b" }, - "function-result": { - "begin": "(?&|\\^~.])(->)(?![/=\\-+!*%<>&|\\^~.])\\s*", - "beginCaptures": { - "1": { - "name": "keyword.operator.function-result.swift" - } - }, - "end": "(?!\\G)(?=\\{|\\bwhere\\b|;)|$", - "name": "meta.function-result.swift", - "patterns": [ - { - "include": "#available-types" - } - ] + { + "name": "keyword.other.type.metatype.swift", + "match": "(?<=\\.)(?:Protocol|Type)\\b" }, - "generic-argument-clause": { - "begin": "<", + { + "include": "#declarations-available-types-tuple-type" + }, + { + "include": "#declarations-available-types-collection-type" + }, + { + "include": "#declarations-generic-argument-clause" + } + ] + }, + "declarations-available-types-collection-type": { + "comment": "array and dictionary types [Value] and [Key: Value]", + "begin": "\\[", + "end": "\\]|(?=[>){}])", + "beginCaptures": { + "0": { + "name": "punctuation.section.collection-type.begin.swift" + } + }, + "endCaptures": { + "0": { + "name": "punctuation.section.collection-type.end.swift" + } + }, + "patterns": [ + { + "include": "#declarations-available-types" + }, + { + "begin": ":", + "end": "(?=\\]|[>){}])", "beginCaptures": { "0": { - "name": "punctuation.separator.generic-argument-clause.begin.swift" + "name": "punctuation.separator.key-value.swift" + } + }, + "patterns": [ + { + "name": "invalid.illegal.extra-colon-in-dictionary-type.swift", + "match": ":" + }, + { + "include": "#declarations-available-types" + } + ] + } + ] + }, + "declarations-available-types-tuple-type": { + "begin": "\\(", + "end": "\\)|(?=[>\\]{}])", + "beginCaptures": { + "0": { + "name": "punctuation.section.tuple-type.begin.swift" + } + }, + "endCaptures": { + "0": { + "name": "punctuation.section.tuple-type.end.swift" + } + }, + "patterns": [ + { + "include": "#declarations-available-types" + } + ] + }, + "declarations-extension": { + "name": "meta.definition.type.$1.swift", + "begin": "\\b(extension)\\s+((?`?)[\\p{L}_][\\p{L}_\\p{N}\\p{M}]*(\\k))", + "end": "(?<=\\})", + "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" + } + }, + "patterns": [ + { + "include": "#comments" + }, + { + "comment": "SE-0143: Conditional Conformances", + "include": "#declarations-generic-where-clause" + }, + { + "include": "#declarations-inheritance-clause" + }, + { + "name": "meta.definition.type.body.swift", + "begin": "\\{", + "end": "\\}", + "beginCaptures": { + "0": { + "name": "punctuation.definition.type.begin.swift" } }, - "end": ">|(?=[)\\]{}])", "endCaptures": { "0": { - "name": "punctuation.separator.generic-argument-clause.end.swift" + "name": "punctuation.definition.type.end.swift" } }, - "name": "meta.generic-argument-clause.swift", "patterns": [ { - "include": "#available-types" + "include": "$self" } ] + } + ] + }, + "declarations-function": { + "name": "meta.definition.function.swift", + "begin": "(?x)\n\\b\n(func)\n\\s+\n(\n (?`?)[\\p{L}_][\\p{L}_\\p{N}\\p{M}]*(\\k)\n | (?:\n (\n (? # 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\n | (? # 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 | \\g | \\. )+ ) # Dot operators\n )\n)\n\\s*\n(?=\\(|<)", + "end": "(?<=\\})|$(?# functions in protocol declarations or generated interfaces have no body)", + "beginCaptures": { + "1": { + "name": "storage.type.function.swift" }, - "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" - }, - { - "comment": "Swift 2: constraints inside the generic param list", - "include": "#generic-where-clause" - }, - { - "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": "#type-identifier" - } - ] - } - ] - } - ] + "2": { + "name": "entity.name.function.swift" }, - "generic-where-clause": { - "begin": "\\b(where)\\b\\s*", + "3": { + "name": "punctuation.definition.identifier.swift" + }, + "4": { + "name": "punctuation.definition.identifier.swift" + } + }, + "patterns": [ + { + "include": "#comments" + }, + { + "include": "#declarations-generic-parameter-clause" + }, + { + "include": "#declarations-parameter-clause" + }, + { + "include": "#declarations-function-result" + }, + { + "include": "#async-throws" + }, + { + "comment": "Swift 3: generic constraints after the parameters and return type", + "include": "#declarations-generic-where-clause" + }, + { + "name": "meta.definition.function.body.swift", + "begin": "(\\{)", + "end": "(\\})", "beginCaptures": { "1": { - "name": "keyword.other.generic-constraint-introducer.swift" + "name": "punctuation.section.function.begin.swift" + } + }, + "endCaptures": { + "1": { + "name": "punctuation.section.function.end.swift" } }, - "end": "(?!\\G)$|(?=[>{};\\n]|//|/\\*)", - "name": "meta.generic-where-clause.swift", "patterns": [ { - "include": "#comments" - }, - { - "include": "#requirement-list" + "include": "$self" } - ], - "repository": { - "requirement-list": { - "begin": "\\G|,\\s*", - "end": "(?=[,>{};\\n]|//|/\\*)", - "patterns": [ - { - "include": "#comments" - }, - { - "include": "#constraint" - }, - { - "include": "#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": "#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": "#available-types" - } - ] - } - ] - } - ] + ] + } + ] + }, + "declarations-function-initializer": { + "name": "meta.definition.function.initializer.swift", + "begin": "(?&|\\^~.])(->)(?![/=\\-+!*%<>&|\\^~.])\\s*", + "end": "(?!\\G)(?=\\{|\\bwhere\\b|;|=)|$", + "beginCaptures": { + "1": { + "name": "keyword.operator.function-result.swift" + } + }, + "patterns": [ + { + "include": "#declarations-available-types" + } + ] + }, + "declarations-function-subscript": { + "name": "meta.definition.function.subscript.swift", + "begin": "(?|(?=[)\\]{}])", + "beginCaptures": { + "0": { + "name": "punctuation.separator.generic-argument-clause.begin.swift" + } + }, + "endCaptures": { + "0": { + "name": "punctuation.separator.generic-argument-clause.end.swift" + } + }, + "patterns": [ + { + "include": "#declarations-available-types" + } + ] + }, + "declarations-generic-parameter-clause": { + "name": "meta.generic-parameter-clause.swift", + "begin": "<", + "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.)", + "beginCaptures": { + "0": { + "name": "punctuation.separator.generic-parameter-clause.begin.swift" + } + }, + "endCaptures": { + "0": { + "name": "punctuation.separator.generic-parameter-clause.end.swift" + } + }, + "patterns": [ + { + "include": "#comments" + }, + { + "comment": "Swift 2: constraints inside the generic param list", + "include": "#declarations-generic-where-clause" + }, + { + "name": "keyword.control.loop.swift", + "match": "\\beach\\b" + }, + { + "match": "\\b((?!\\d)\\w[\\w\\d]*)\\b", + "captures": { + "1": { + "name": "variable.language.generic-parameter.swift" } } }, - "import": { - "begin": "(?`?)[\\p{L}_][\\p{L}_\\p{N}\\p{M}]*(\\k)\n\t\t\t\t\t\t\t\t\t", - "name": "entity.name.type.swift" - }, - { - "match": "(?x)\n\t\t\t\t\t\t\t\t\t\t(?<=\\G|\\.)\n\t\t\t\t\t\t\t\t\t\t\\$[0-9]+\n\t\t\t\t\t\t\t\t\t", - "name": "entity.name.type.swift" - }, - { - "captures": { - "1": { - "patterns": [ - { - "match": "\\.", - "name": "invalid.illegal.dot-not-allowed-here.swift" - } - ] - } - }, - "match": "(?x)\n\t\t\t\t\t\t\t\t\t\t(?<=\\G|\\.)\n\t\t\t\t\t\t\t\t\t\t(?:\n\t\t\t\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\t\t\t\t(?\t\t\t\t\t\t\t\t# operator-head\n\t\t\t\t\t\t\t\t\t\t\t\t\t[/=\\-+!*%<>&|^~?]\n\t\t\t\t\t\t\t\t\t\t\t\t | [\\x{00A1}-\\x{00A7}]\n\t\t\t\t\t\t\t\t\t\t\t\t | [\\x{00A9}\\x{00AB}]\n\t\t\t\t\t\t\t\t\t\t\t\t | [\\x{00AC}\\x{00AE}]\n\t\t\t\t\t\t\t\t\t\t\t\t | [\\x{00B0}-\\x{00B1}\\x{00B6}\\x{00BB}\\x{00BF}\\x{00D7}\\x{00F7}]\n\t\t\t\t\t\t\t\t\t\t\t\t | [\\x{2016}-\\x{2017}\\x{2020}-\\x{2027}]\n\t\t\t\t\t\t\t\t\t\t\t\t | [\\x{2030}-\\x{203E}]\n\t\t\t\t\t\t\t\t\t\t\t\t | [\\x{2041}-\\x{2053}]\n\t\t\t\t\t\t\t\t\t\t\t\t | [\\x{2055}-\\x{205E}]\n\t\t\t\t\t\t\t\t\t\t\t\t | [\\x{2190}-\\x{23FF}]\n\t\t\t\t\t\t\t\t\t\t\t\t | [\\x{2500}-\\x{2775}]\n\t\t\t\t\t\t\t\t\t\t\t\t | [\\x{2794}-\\x{2BFF}]\n\t\t\t\t\t\t\t\t\t\t\t\t | [\\x{2E00}-\\x{2E7F}]\n\t\t\t\t\t\t\t\t\t\t\t\t | [\\x{3001}-\\x{3003}]\n\t\t\t\t\t\t\t\t\t\t\t\t | [\\x{3008}-\\x{3030}]\n\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\\g\n\t\t\t\t\t\t\t\t\t\t\t\t | (?\t\t\t\t\t\t\t\t# operator-character\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t[\\x{0300}-\\x{036F}]\n\t\t\t\t\t\t\t\t\t\t\t\t\t | [\\x{1DC0}-\\x{1DFF}]\n\t\t\t\t\t\t\t\t\t\t\t\t\t | [\\x{20D0}-\\x{20FF}]\n\t\t\t\t\t\t\t\t\t\t\t\t\t | [\\x{FE00}-\\x{FE0F}]\n\t\t\t\t\t\t\t\t\t\t\t\t\t | [\\x{FE20}-\\x{FE2F}]\n\t\t\t\t\t\t\t\t\t\t\t\t\t | [\\x{E0100}-\\x{E01EF}]\n\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\t)*\n\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t | ( \\. ( \\g | \\g | \\. )+ )\t\t\t# Dot operators\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t(?=\\.|;|$|//|/\\*|\\s)\n\t\t\t\t\t\t\t\t\t", - "name": "entity.name.type.swift" - }, - { - "match": "\\.", - "name": "punctuation.separator.import.swift" - }, - { - "begin": "(?!\\s*(;|$|//|/\\*))", - "end": "(?=\\s*(;|$|//|/\\*))", - "name": "invalid.illegal.character-not-allowed-here.swift" - } - ] - } - ] + { + "name": "punctuation.separator.generic-parameters.swift", + "match": "," }, - "inheritance-clause": { - "begin": "(:)(?=\\s*\\{)|(:)\\s*", + { + "name": "meta.generic-parameter-constraint.swift", + "begin": "(:)\\s*", + "end": "(?=[,>]|(?!\\G)\\bwhere\\b)", "beginCaptures": { "1": { - "name": "invalid.illegal.empty-inheritance-clause.swift" - }, - "2": { - "name": "punctuation.separator.inheritance-clause.swift" + "name": "punctuation.separator.generic-parameter-constraint.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": "#more-types" - } - ] - }, - { - "begin": "\\G", - "end": "(?!\\G)$|(?=[={}]|(?!\\G)\\bwhere\\b)", - "patterns": [ - { - "include": "#comments" - }, - { - "include": "#inherited-type" - }, - { - "include": "#more-types" - } - ] - } - ], - "repository": { - "inherited-type": { - "begin": "(?=[`\\p{L}_])", - "end": "(?!\\G)", "name": "entity.other.inherited-class.swift", + "begin": "\\G", + "end": "(?=[,>]|(?!\\G)\\bwhere\\b)", "patterns": [ { - "include": "#type-identifier" - } - ] - }, - "more-types": { - "begin": ",\\s*", - "end": "(?!\\G)(?!//|/\\*)|(?=[,={}]|(?!\\G)\\bwhere\\b)", - "name": "meta.inheritance-list.more-types", - "patterns": [ - { - "include": "#comments" + "include": "#declarations-type-identifier" }, { - "include": "#inherited-type" - }, - { - "include": "#more-types" + "include": "#declarations-type-operators" } ] } - } + ] + } + ] + }, + "declarations-generic-where-clause": { + "name": "meta.generic-where-clause.swift", + "begin": "\\b(where)\\b\\s*", + "end": "(?!\\G)$|(?=[>{};\\n]|//|/\\*)", + "beginCaptures": { + "1": { + "name": "keyword.other.generic-constraint-introducer.swift" + } + }, + "patterns": [ + { + "include": "#comments" }, - "operator": { - "begin": "(?x)\n\t\t\t\t\t\t(?:\n\t\t\t\t\t\t\t\\b(prefix|infix|postfix)\n\t\t\t\t\t\t\t\\s+\n\t\t\t\t\t\t)?\n\t\t\t\t\t\t\\b\n\t\t\t\t\t\t(operator)\n\t\t\t\t\t\t\\s+\n\t\t\t\t\t\t(\n\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t(?\t\t\t\t\t\t\t\t\t# operator-head\n\t\t\t\t\t\t\t\t\t[/=\\-+!*%<>&|^~?]\n\t\t\t\t\t\t\t\t | [\\x{00A1}-\\x{00A7}]\n\t\t\t\t\t\t\t\t | [\\x{00A9}\\x{00AB}]\n\t\t\t\t\t\t\t\t | [\\x{00AC}\\x{00AE}]\n\t\t\t\t\t\t\t\t | [\\x{00B0}-\\x{00B1}\\x{00B6}\\x{00BB}\\x{00BF}\\x{00D7}\\x{00F7}]\n\t\t\t\t\t\t\t\t | [\\x{2016}-\\x{2017}\\x{2020}-\\x{2027}]\n\t\t\t\t\t\t\t\t | [\\x{2030}-\\x{203E}]\n\t\t\t\t\t\t\t\t | [\\x{2041}-\\x{2053}]\n\t\t\t\t\t\t\t\t | [\\x{2055}-\\x{205E}]\n\t\t\t\t\t\t\t\t | [\\x{2190}-\\x{23FF}]\n\t\t\t\t\t\t\t\t | [\\x{2500}-\\x{2775}]\n\t\t\t\t\t\t\t\t | [\\x{2794}-\\x{2BFF}]\n\t\t\t\t\t\t\t\t | [\\x{2E00}-\\x{2E7F}]\n\t\t\t\t\t\t\t\t | [\\x{3001}-\\x{3003}]\n\t\t\t\t\t\t\t\t | [\\x{3008}-\\x{3030}]\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\t\\g\n\t\t\t\t\t\t\t\t | \\.\t\t\t\t\t\t\t\t\t# Invalid dot\n\t\t\t\t\t\t\t\t | (?\t\t\t\t\t\t\t\t# operator-character\n\t\t\t\t\t\t\t\t\t\t[\\x{0300}-\\x{036F}]\n\t\t\t\t\t\t\t\t\t | [\\x{1DC0}-\\x{1DFF}]\n\t\t\t\t\t\t\t\t\t | [\\x{20D0}-\\x{20FF}]\n\t\t\t\t\t\t\t\t\t | [\\x{FE00}-\\x{FE0F}]\n\t\t\t\t\t\t\t\t\t | [\\x{FE20}-\\x{FE2F}]\n\t\t\t\t\t\t\t\t\t | [\\x{E0100}-\\x{E01EF}]\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t)*+\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t | ( \\. ( \\g | \\g | \\. )++ )\t\t\t# Dot operators\n\t\t\t\t\t\t)\n\t\t\t\t\t\t\\s*\n\t\t\t\t\t", + { + "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" + }, + { + "name": "meta.generic-where-clause.same-type-requirement.swift", + "begin": "(?&|\\^~.])(==)(?![/=\\-+!*%<>&|\\^~.])", + "end": "(?=\\s*[,>{};\\n]|//|/\\*)", "beginCaptures": { + "1": { + "name": "keyword.operator.generic-constraint.same-type.swift" + } + }, + "patterns": [ + { + "include": "#declarations-available-types" + } + ] + }, + { + "name": "meta.generic-where-clause.conformance-requirement.swift", + "begin": "(?&|\\^~.])(:)(?![/=\\-+!*%<>&|\\^~.])", + "end": "(?=\\s*[,>{};\\n]|//|/\\*)", + "beginCaptures": { + "1": { + "name": "keyword.operator.generic-constraint.conforms-to.swift" + } + }, + "patterns": [ + { + "contentName": "entity.other.inherited-class.swift", + "begin": "\\G\\s*", + "end": "(?=\\s*[,>{};\\n]|//|/\\*)", + "patterns": [ + { + "include": "#declarations-available-types" + } + ] + } + ] + } + ] + }, + "declarations-import": { + "name": "meta.import.swift", + "begin": "(?`?)[\\p{L}_][\\p{L}_\\p{N}\\p{M}]*(\\k)", + "captures": { + "1": { + "name": "punctuation.definition.identifier.swift" + }, + "2": { + "name": "punctuation.definition.identifier.swift" + } + } + }, + { + "name": "entity.name.type.swift", + "match": "(?x)\n(?<=\\G|\\.)\n\\$[0-9]+" + }, + { + "name": "entity.name.type.swift", + "match": "(?x)\n(?<=\\G|\\.)\n(?:\n (\n (? # 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\n | (? # 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 | \\g | \\. )+ ) # Dot operators\n)\n(?=\\.|;|$|//|/\\*|\\s)", + "captures": { + "1": { + "patterns": [ + { + "name": "invalid.illegal.dot-not-allowed-here.swift", + "match": "\\." + } + ] + } + } + }, + { + "name": "punctuation.separator.import.swift", + "match": "\\." + }, + { + "name": "invalid.illegal.character-not-allowed-here.swift", + "begin": "(?!\\s*(;|$|//|/\\*))", + "end": "(?=\\s*(;|$|//|/\\*))" + } + ] + } + ] + }, + "declarations-inheritance-clause": { + "name": "meta.inheritance-clause.swift", + "begin": "(:)(?=\\s*\\{)|(:)\\s*", + "end": "(?!\\G)$|(?=[={}]|(?!\\G)\\bwhere\\b)", + "beginCaptures": { + "1": { + "name": "invalid.illegal.empty-inheritance-clause.swift" + }, + "2": { + "name": "punctuation.separator.inheritance-clause.swift" + } + }, + "patterns": [ + { + "begin": "\\bclass\\b", + "end": "(?=[={}]|(?!\\G)\\bwhere\\b)", + "beginCaptures": { + "0": { + "name": "storage.type.class.swift" + } + }, + "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": { + "name": "entity.other.inherited-class.swift", + "begin": "(?=[`\\p{L}_])", + "end": "(?!\\G)", + "patterns": [ + { + "include": "#declarations-type-identifier" + } + ] + }, + "declarations-inheritance-clause-more-types": { + "name": "meta.inheritance-list.more-types", + "begin": ",\\s*", + "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-macro": { + "name": "meta.definition.macro.swift", + "begin": "(?x)\n\\b\n(macro)\n\\s+\n((?`?)[\\p{L}_][\\p{L}_\\p{N}\\p{M}]*(\\k))\n\\s*\n(?=\\(|<|=)", + "end": "$|(?=;|//|/\\*|\\}|=)", + "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" + } + }, + "patterns": [ + { + "include": "#comments" + }, + { + "include": "#declarations-generic-parameter-clause" + }, + { + "include": "#declarations-parameter-clause" + }, + { + "include": "#declarations-function-result" + }, + { + "include": "#async-throws" + }, + { + "comment": "Swift 3: generic constraints after the parameters and return type", + "include": "#declarations-generic-where-clause" + } + ] + }, + "declarations-operator": { + "name": "meta.definition.operator.swift", + "begin": "(?x)\n(?:\n \\b(prefix|infix|postfix)\n \\s+\n)?\n\\b\n(operator)\n\\s+\n(\n (\n (? # 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\n | \\. # Invalid dot\n | (? # 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 | \\g | \\. )++ ) # Dot operators\n)\n\\s*", + "end": "(;)|$\\n?|(?=//|/\\*)", + "beginCaptures": { + "1": { + "name": "storage.modifier.swift" + }, + "2": { + "name": "storage.type.function.operator.swift" + }, + "3": { + "name": "entity.name.function.operator.swift" + }, + "4": { + "comment": "workaround for https://github.com/microsoft/vscode-textmate/issues/140#issuecomment-1793610346", + "name": "entity.name.function.operator.swift", + "patterns": [ + { + "name": "invalid.illegal.dot-not-allowed-here.swift", + "match": "\\." + } + ] + } + }, + "endCaptures": { + "1": { + "name": "punctuation.terminator.statement.swift" + } + }, + "patterns": [ + { + "include": "#declarations-operator-swift2" + }, + { + "include": "#declarations-operator-swift3" + }, + { + "name": "invalid.illegal.character-not-allowed-here.swift", + "match": "((?!$|;|//|/\\*)\\S)+" + } + ] + }, + "declarations-operator-swift2": { + "begin": "\\G(\\{)", + "end": "(\\})", + "beginCaptures": { + "1": { + "name": "punctuation.definition.operator.begin.swift" + } + }, + "endCaptures": { + "1": { + "name": "punctuation.definition.operator.end.swift" + } + }, + "patterns": [ + { + "include": "#comments" + }, + { + "match": "\\b(associativity)\\s+(left|right)\\b", + "captures": { "1": { "name": "storage.modifier.swift" }, "2": { - "name": "storage.type.function.operator.swift" - }, - "3": { - "name": "entity.name.function.operator.swift" - }, - "4": { - "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": "#swift2" - }, - { - "include": "#swift3" - }, - { - "match": "((?!$|;|//|/\\*)\\S)+", - "name": "invalid.illegal.character-not-allowed-here.swift" - } - ], - "repository": { - "swift2": { - "begin": "\\G(\\{)", - "beginCaptures": { - "1": { - "name": "punctuation.definition.operator.begin.swift" - } - }, - "end": "(\\})", - "endCaptures": { - "1": { - "name": "punctuation.definition.operator.end.swift" - } - }, - "patterns": [ - { - "include": "#comments" - }, - { - "captures": { - "1": { - "name": "storage.modifier.swift" - }, - "2": { - "name": "keyword.other.operator.associativity.swift" - } - }, - "match": "\\b(associativity)\\s+(left|right)\\b" - }, - { - "captures": { - "1": { - "name": "storage.modifier.swift" - }, - "2": { - "name": "constant.numeric.integer.swift" - } - }, - "match": "\\b(precedence)\\s+([0-9]+)\\b" - }, - { - "captures": { - "1": { - "name": "storage.modifier.swift" - } - }, - "match": "\\b(assignment)\\b" - } - ] - }, - "swift3": { - "captures": { - "2": { - "name": "entity.other.inherited-class.swift", - "patterns": [ - { - "include": "#types-precedencegroup" - } - ] - }, - "3": { - "name": "punctuation.definition.identifier.swift" - }, - "4": { - "name": "punctuation.definition.identifier.swift" - } - }, - "match": "\\G(:)\\s*((?`?)[\\p{L}_][\\p{L}_\\p{N}\\p{M}]*(\\k))" + "name": "keyword.other.operator.associativity.swift" } } }, - "parameter-clause": { - "begin": "(\\()", - "beginCaptures": { + { + "match": "\\b(precedence)\\s+([0-9]+)\\b", + "captures": { "1": { - "name": "punctuation.definition.parameters.begin.swift" - } - }, - "end": "(\\))(?:\\s*(async)\\b)?", - "endCaptures": { - "1": { - "name": "punctuation.definition.parameters.end.swift" + "name": "storage.modifier.swift" }, "2": { - "name": "keyword.control.async.swift" - } - }, - "name": "meta.parameter-clause.swift", - "patterns": [ - { - "include": "#parameter-list" - } - ] - }, - "parameter-list": { - "patterns": [ - { - "captures": { - "1": { - "name": "entity.name.function.swift" - }, - "2": { - "name": "punctuation.definition.identifier.swift" - }, - "3": { - "name": "punctuation.definition.identifier.swift" - }, - "4": { - "name": "variable.parameter.function.swift" - }, - "5": { - "name": "punctuation.definition.identifier.swift" - }, - "6": { - "name": "punctuation.definition.identifier.swift" - } - }, - "comment": "External parameter labels are considered part of the function name", - "match": "((?`?)[\\p{L}_][\\p{L}_\\p{N}\\p{M}]*(\\k))\\s+((?`?)[\\p{L}_][\\p{L}_\\p{N}\\p{M}]*(\\k))(?=\\s*:)" - }, - { - "captures": { - "1": { - "name": "variable.parameter.function.swift" - }, - "2": { - "name": "entity.name.function.swift" - }, - "3": { - "name": "punctuation.definition.identifier.swift" - }, - "4": { - "name": "punctuation.definition.identifier.swift" - } - }, - "comment": "If no external label is given, the name is both the external label and the internal variable name", - "match": "(((?`?)[\\p{L}_][\\p{L}_\\p{N}\\p{M}]*(\\k)))(?=\\s*:)" - }, - { - "begin": ":\\s*(?!\\s)", - "end": "(?=[,)])", - "patterns": [ - { - "include": "#available-types" - }, - { - "match": ":", - "name": "invalid.illegal.extra-colon-in-parameter-list.swift" - }, - { - "begin": "=", - "beginCaptures": { - "0": { - "name": "keyword.operator.assignment.swift" - } - }, - "comment": "a parameter's default value", - "end": "(?=[,)])", - "patterns": [ - { - "include": "#expressions" - } - ] - } - ] - } - ] - }, - "precedencegroup": { - "begin": "\\b(precedencegroup)\\s+((?`?)[\\p{L}_][\\p{L}_\\p{N}\\p{M}]*(\\k))\\s*(?=\\{)", - "beginCaptures": { - "1": { - "name": "storage.type.precedencegroup.swift" - }, - "2": { - "name": "entity.name.type.precedencegroup.swift" - }, - "3": { - "name": "punctuation.definition.identifier.swift" - }, - "4": { - "name": "punctuation.definition.identifier.swift" - } - }, - "end": "(?!\\G)", - "name": "meta.definition.precedencegroup.swift", - "patterns": [ - { - "begin": "\\{", - "beginCaptures": { - "0": { - "name": "punctuation.definition.precedencegroup.begin.swift" - } - }, - "end": "\\}", - "endCaptures": { - "0": { - "name": "punctuation.definition.precedencegroup.end.swift" - } - }, - "patterns": [ - { - "include": "#comments" - }, - { - "captures": { - "1": { - "name": "storage.modifier.swift" - }, - "2": { - "name": "entity.other.inherited-class.swift", - "patterns": [ - { - "include": "#types-precedencegroup" - } - ] - }, - "3": { - "name": "punctuation.definition.identifier.swift" - }, - "4": { - "name": "punctuation.definition.identifier.swift" - } - }, - "match": "\\b(higherThan|lowerThan)\\s*:\\s*((?`?)[\\p{L}_][\\p{L}_\\p{N}\\p{M}]*(\\k))" - }, - { - "captures": { - "1": { - "name": "storage.modifier.swift" - }, - "2": { - "name": "keyword.other.operator.associativity.swift" - } - }, - "match": "\\b(associativity)\\b(?:\\s*:\\s*(right|left|none)\\b)?" - }, - { - "captures": { - "1": { - "name": "storage.modifier.swift" - }, - "2": { - "name": "constant.language.boolean.swift" - } - }, - "match": "\\b(assignment)\\b(?:\\s*:\\s*(true|false)\\b)?" - } - ] - } - ] - }, - "protocol": { - "begin": "\\b(protocol)\\s+((?`?)[\\p{L}_][\\p{L}_\\p{N}\\p{M}]*(\\k))", - "beginCaptures": { - "1": { - "name": "storage.type.$1.swift" - }, - "2": { - "name": "entity.name.type.$1.swift" - }, - "3": { - "name": "punctuation.definition.identifier.swift" - }, - "4": { - "name": "punctuation.definition.identifier.swift" - } - }, - "end": "(?<=\\})", - "name": "meta.definition.type.protocol.swift", - "patterns": [ - { - "include": "#comments" - }, - { - "include": "#inheritance-clause" - }, - { - "comment": "SE-0142: Permit where clauses to constrain associated types", - "include": "#generic-where-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": "#protocol-method" - }, - { - "include": "#protocol-initializer" - }, - { - "include": "#associated-type" - }, - { - "include": "$self" - } - ] - } - ], - "repository": { - "associated-type": { - "begin": "\\b(associatedtype)\\s+((?`?)[\\p{L}_][\\p{L}_\\p{N}\\p{M}]*(\\k))\\s*", - "beginCaptures": { - "1": { - "name": "keyword.other.declaration-specifier.swift" - }, - "2": { - "name": "variable.language.associatedtype.swift" - }, - "3": { - "name": "punctuation.definition.identifier.swift" - }, - "4": { - "name": "punctuation.definition.identifier.swift" - } - }, - "end": "(?!\\G)$|(?=[;}]|$)", - "name": "meta.definition.associatedtype.swift", - "patterns": [ - { - "include": "#inheritance-clause" - }, - { - "comment": "SE-0142: Permit where clauses to constrain associated types", - "include": "#generic-where-clause" - }, - { - "include": "#typealias-assignment" - } - ] - }, - "protocol-initializer": { - "begin": "(?`?)[\\p{L}_][\\p{L}_\\p{N}\\p{M}]*(\\k)\n\t\t \t\t\t\t\t\t | (?:\n\t\t \t\t\t\t\t\t\t\t(\n\t\t \t\t\t\t\t\t\t\t\t(?\t\t\t\t\t\t\t\t# operator-head\n\t\t \t\t\t\t\t\t\t\t\t\t[/=\\-+!*%<>&|^~?]\n\t\t \t\t\t\t\t\t\t\t\t | [\\x{00A1}-\\x{00A7}]\n\t\t \t\t\t\t\t\t\t\t\t | [\\x{00A9}\\x{00AB}]\n\t\t \t\t\t\t\t\t\t\t\t | [\\x{00AC}\\x{00AE}]\n\t\t \t\t\t\t\t\t\t\t\t | [\\x{00B0}-\\x{00B1}\\x{00B6}\\x{00BB}\\x{00BF}\\x{00D7}\\x{00F7}]\n\t\t \t\t\t\t\t\t\t\t\t | [\\x{2016}-\\x{2017}\\x{2020}-\\x{2027}]\n\t\t \t\t\t\t\t\t\t\t\t | [\\x{2030}-\\x{203E}]\n\t\t \t\t\t\t\t\t\t\t\t | [\\x{2041}-\\x{2053}]\n\t\t \t\t\t\t\t\t\t\t\t | [\\x{2055}-\\x{205E}]\n\t\t \t\t\t\t\t\t\t\t\t | [\\x{2190}-\\x{23FF}]\n\t\t \t\t\t\t\t\t\t\t\t | [\\x{2500}-\\x{2775}]\n\t\t \t\t\t\t\t\t\t\t\t | [\\x{2794}-\\x{2BFF}]\n\t\t \t\t\t\t\t\t\t\t\t | [\\x{2E00}-\\x{2E7F}]\n\t\t \t\t\t\t\t\t\t\t\t | [\\x{3001}-\\x{3003}]\n\t\t \t\t\t\t\t\t\t\t\t | [\\x{3008}-\\x{3030}]\n\t\t \t\t\t\t\t\t\t\t\t)\n\t\t \t\t\t\t\t\t\t\t\t(\n\t\t \t\t\t\t\t\t\t\t\t\t\\g\n\t\t \t\t\t\t\t\t\t\t\t | (?\t\t\t\t\t\t\t\t# operator-character\n\t\t \t\t\t\t\t\t\t\t\t\t\t[\\x{0300}-\\x{036F}]\n\t\t \t\t\t\t\t\t\t\t\t\t | [\\x{1DC0}-\\x{1DFF}]\n\t\t \t\t\t\t\t\t\t\t\t\t | [\\x{20D0}-\\x{20FF}]\n\t\t \t\t\t\t\t\t\t\t\t\t | [\\x{FE00}-\\x{FE0F}]\n\t\t \t\t\t\t\t\t\t\t\t\t | [\\x{FE20}-\\x{FE2F}]\n\t\t \t\t\t\t\t\t\t\t\t\t | [\\x{E0100}-\\x{E01EF}]\n\t\t \t\t\t\t\t\t\t\t\t\t)\n\t\t \t\t\t\t\t\t\t\t\t)*\n\t\t \t\t\t\t\t\t\t\t)\n\t\t \t\t\t\t\t\t\t | ( \\. ( \\g | \\g | \\. )+ )\t\t\t# Dot operators\n\t\t \t\t\t\t\t\t\t)\n\t\t \t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\\s*\n\t\t\t\t\t\t\t\t(?=\\(|<)\n\t\t\t\t\t\t\t", - "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.function.swift", - "patterns": [ - { - "include": "#comments" - }, - { - "include": "#generic-parameter-clause" - }, - { - "include": "#parameter-clause" - }, - { - "include": "#function-result" - }, - { - "include": "#async-throws" - }, - { - "comment": "Swift 3: generic constraints after the parameters and return type", - "include": "#generic-where-clause" - }, - { - "begin": "\\{", - "beginCaptures": { - "0": { - "name": "punctuation.section.function.begin.swift" - } - }, - "end": "\\}", - "endCaptures": { - "0": { - "name": "punctuation.section.function.end.swift" - } - }, - "name": "invalid.illegal.function-body-not-allowed-in-protocol.swift", - "patterns": [ - { - "include": "$self" - } - ] - } - ] + "name": "constant.numeric.integer.swift" } } }, - "type": { - "patterns": [ - { - "begin": "\\b(class(?!\\s+(?:func|var|let)\\b)|struct|actor)\\s+((?`?)[\\p{L}_][\\p{L}_\\p{N}\\p{M}]*(\\k))", - "beginCaptures": { - "1": { - "name": "storage.type.$1.swift" - }, - "2": { - "name": "entity.name.type.$1.swift" - }, - "3": { - "name": "punctuation.definition.identifier.swift" - }, - "4": { - "name": "punctuation.definition.identifier.swift" - } - }, - "end": "(?<=\\})", - "name": "meta.definition.type.$1.swift", - "patterns": [ - { - "include": "#comments" - }, - { - "include": "#generic-parameter-clause" - }, - { - "comment": "Swift 3: generic constraints after the generic param list", - "include": "#generic-where-clause" - }, - { - "include": "#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" - } - ] - } - ] - }, - { - "include": "#type-enum" - } - ] - }, - "type-enum": { - "begin": "\\b(enum)\\s+((?`?)[\\p{L}_][\\p{L}_\\p{N}\\p{M}]*(\\k))", - "beginCaptures": { + { + "match": "\\b(assignment)\\b", + "captures": { "1": { - "name": "storage.type.$1.swift" - }, - "2": { - "name": "entity.name.type.$1.swift" - }, - "3": { - "name": "punctuation.definition.identifier.swift" - }, - "4": { - "name": "punctuation.definition.identifier.swift" - } - }, - "end": "(?<=\\})", - "name": "meta.definition.type.$1.swift", - "patterns": [ - { - "include": "#comments" - }, - { - "include": "#generic-parameter-clause" - }, - { - "comment": "Swift 3: generic constraints after the generic param list", - "include": "#generic-where-clause" - }, - { - "include": "#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": "#enum-case-clause" - }, - { - "include": "$self" - } - ] - } - ], - "repository": { - "associated-values": { - "begin": "\\G\\(", - "beginCaptures": { - "0": { - "name": "punctuation.definition.parameters.begin.swift" - } - }, - "end": "\\)", - "endCaptures": { - "0": { - "name": "punctuation.definition.parameters.end.swift" - } - }, - "patterns": [ - { - "include": "#comments" - }, - { - "begin": "(?x)\n\t\t\t\t\t\t\t\t\t\t(?:(_)|((?`?)[\\p{L}_][\\p{L}_\\p{N}\\p{M}]*\\k))\n\t\t\t\t\t\t\t\t\t\t\\s+\n\t\t\t\t\t\t\t\t\t\t(((?`?)[\\p{L}_][\\p{L}_\\p{N}\\p{M}]*\\k))\n\t\t\t\t\t\t\t\t\t\t\\s*(:)", - "beginCaptures": { - "1": { - "name": "entity.name.function.swift" - }, - "2": { - "name": "invalid.illegal.distinct-labels-not-allowed.swift" - }, - "5": { - "name": "variable.parameter.function.swift" - }, - "7": { - "name": "punctuation.separator.argument-label.swift" - } - }, - "end": "(?=[,)\\]])", - "patterns": [ - { - "include": "#available-types" - } - ] - }, - { - "begin": "(((?`?)[\\p{L}_][\\p{L}_\\p{N}\\p{M}]*\\k))\\s*(:)", - "beginCaptures": { - "1": { - "name": "entity.name.function.swift" - }, - "2": { - "name": "variable.parameter.function.swift" - }, - "4": { - "name": "punctuation.separator.argument-label.swift" - } - }, - "end": "(?=[,)\\]])", - "patterns": [ - { - "include": "#available-types" - } - ] - }, - { - "begin": "(?![,)\\]])(?=\\S)", - "comment": "an element without a label (i.e. anything else)", - "end": "(?=[,)\\]])", - "patterns": [ - { - "include": "#available-types" - }, - { - "match": ":", - "name": "invalid.illegal.extra-colon-in-parameter-list.swift" - } - ] - } - ] - }, - "enum-case": { - "begin": "(?x)((?`?)[\\p{L}_][\\p{L}_\\p{N}\\p{M}]*(\\k))\\s*", - "beginCaptures": { - "1": { - "name": "constant.other.swift" - } - }, - "end": "(?<=\\))|(?![=(])", - "patterns": [ - { - "include": "#comments" - }, - { - "include": "#associated-values" - }, - { - "include": "#raw-value-assignment" - } - ] - }, - "enum-case-clause": { - "begin": "\\b(case)\\b\\s*", - "beginCaptures": { - "1": { - "name": "storage.type.enum.case.swift" - } - }, - "end": "(?=[;}])|(?!\\G)(?!//|/\\*)(?=[^\\s,])", - "patterns": [ - { - "include": "#comments" - }, - { - "include": "#enum-case" - }, - { - "include": "#more-cases" - } - ] - }, - "more-cases": { - "begin": ",\\s*", - "end": "(?!\\G)(?!//|/\\*)(?=[;}]|[^\\s,])", - "name": "meta.enum-case.more-cases", - "patterns": [ - { - "include": "#comments" - }, - { - "include": "#enum-case" - }, - { - "include": "#more-cases" - } - ] - }, - "raw-value-assignment": { - "begin": "(=)\\s*", - "beginCaptures": { - "1": { - "name": "keyword.operator.assignment.swift" - } - }, - "end": "(?!\\G)", - "patterns": [ - { - "include": "#comments" - }, - { - "include": "#literals" - } - ] + "name": "storage.modifier.swift" } } - }, - "type-identifier": { - "begin": "((?`?)[\\p{L}_][\\p{L}_\\p{N}\\p{M}]*(\\k))\\s*", - "beginCaptures": { - "1": { - "name": "meta.type-name.swift", - "patterns": [ - { - "include": "#builtin-types" - } - ] - }, - "2": { - "name": "punctuation.definition.identifier.swift" - }, - "3": { - "name": "punctuation.definition.identifier.swift" - } - }, - "end": "(?!<)", + } + ] + }, + "declarations-operator-swift3": { + "match": "\\G(:)\\s*((?`?)[\\p{L}_][\\p{L}_\\p{N}\\p{M}]*(\\k))", + "captures": { + "2": { + "name": "entity.other.inherited-class.swift", "patterns": [ { - "begin": "(?=<)", - "end": "(?!\\G)", - "patterns": [ - { - "include": "#generic-argument-clause" - } - ] + "include": "#declarations-types-precedencegroup" } ] }, - "typealias": { - "begin": "\\b(typealias)\\s+((?`?)[\\p{L}_][\\p{L}_\\p{N}\\p{M}]*(\\k))\\s*", - "beginCaptures": { - "1": { - "name": "keyword.other.declaration-specifier.swift" - }, - "2": { - "name": "entity.name.type.typealias.swift" - }, - "3": { - "name": "punctuation.definition.identifier.swift" - }, - "4": { - "name": "punctuation.definition.identifier.swift" - } - }, - "end": "(?!\\G)$|(?=;|//|/\\*|$)", - "name": "meta.definition.typealias.swift", - "patterns": [ - { - "begin": "\\G(?=<)", - "end": "(?!\\G)", - "patterns": [ - { - "include": "#generic-parameter-clause" - } - ] - }, - { - "include": "#typealias-assignment" - } - ] + "3": { + "name": "punctuation.definition.identifier.swift" }, - "typealias-assignment": { - "begin": "(=)\\s*", - "beginCaptures": { - "1": { - "name": "keyword.operator.assignment.swift" - } - }, - "end": "(?!\\G)$|(?=;|//|/\\*|$)", - "patterns": [ - { - "include": "#available-types" - } - ] - }, - "typed-variable-declaration": { - "begin": "(?x)\n\t\t\t\t\t\t\\b(?:(async)\\s+)?(let|var)\\b\\s+\n\t\t\t\t\t\t(?`?)[\\p{L}_][\\p{L}_\\p{N}\\p{M}]*(\\k)\\s*\n\t\t\t\t\t\t:\n\t\t\t\t\t", - "beginCaptures": { - "1": { - "name": "keyword.control.async.swift" - }, - "2": { - "name": "keyword.other.declaration-specifier.swift" - } - }, - "end": "(?=$|[={])", - "patterns": [ - { - "include": "#available-types" - } - ] - }, - "types-precedencegroup": { - "patterns": [ - { - "comment": "Precedence groups in the standard library", - "match": "\\b(?:BitwiseShift|Assignment|RangeFormation|Casting|Addition|NilCoalescing|Comparison|LogicalConjunction|LogicalDisjunction|Default|Ternary|Multiplication|FunctionArrow)Precedence\\b", - "name": "support.type.swift" - } - ] + "4": { + "name": "punctuation.definition.identifier.swift" } } }, + "declarations-parameter-clause": { + "name": "meta.parameter-clause.swift", + "begin": "(\\()", + "end": "(\\))(?:\\s*(async)\\b)?", + "beginCaptures": { + "1": { + "name": "punctuation.definition.parameters.begin.swift" + } + }, + "endCaptures": { + "1": { + "name": "punctuation.definition.parameters.end.swift" + }, + "2": { + "name": "storage.modifier.async.swift" + } + }, + "patterns": [ + { + "include": "#declarations-parameter-list" + } + ] + }, + "declarations-parameter-list": { + "patterns": [ + { + "comment": "External parameter labels are considered part of the function name", + "match": "((?`?)[\\p{L}_][\\p{L}_\\p{N}\\p{M}]*(\\k))\\s+((?`?)[\\p{L}_][\\p{L}_\\p{N}\\p{M}]*(\\k))(?=\\s*:)", + "captures": { + "1": { + "name": "entity.name.function.swift" + }, + "2": { + "name": "punctuation.definition.identifier.swift" + }, + "3": { + "name": "punctuation.definition.identifier.swift" + }, + "4": { + "name": "variable.parameter.function.swift" + }, + "5": { + "name": "punctuation.definition.identifier.swift" + }, + "6": { + "name": "punctuation.definition.identifier.swift" + } + } + }, + { + "comment": "If no external label is given, the name is both the external label and the internal variable name", + "match": "(((?`?)[\\p{L}_][\\p{L}_\\p{N}\\p{M}]*(\\k)))(?=\\s*:)", + "captures": { + "1": { + "name": "variable.parameter.function.swift" + }, + "2": { + "name": "entity.name.function.swift" + }, + "3": { + "name": "punctuation.definition.identifier.swift" + }, + "4": { + "name": "punctuation.definition.identifier.swift" + } + } + }, + { + "begin": ":\\s*(?!\\s)", + "end": "(?=[,)])", + "patterns": [ + { + "include": "#declarations-available-types" + }, + { + "name": "invalid.illegal.extra-colon-in-parameter-list.swift", + "match": ":" + }, + { + "comment": "a parameter's default value", + "begin": "=", + "end": "(?=[,)])", + "beginCaptures": { + "0": { + "name": "keyword.operator.assignment.swift" + } + }, + "patterns": [ + { + "include": "#expressions" + } + ] + } + ] + } + ] + }, + "declarations-precedencegroup": { + "name": "meta.definition.precedencegroup.swift", + "begin": "\\b(precedencegroup)\\s+((?`?)[\\p{L}_][\\p{L}_\\p{N}\\p{M}]*(\\k))\\s*(?=\\{)", + "end": "(?!\\G)", + "beginCaptures": { + "1": { + "name": "storage.type.precedencegroup.swift" + }, + "2": { + "name": "entity.name.type.precedencegroup.swift" + }, + "3": { + "name": "punctuation.definition.identifier.swift" + }, + "4": { + "name": "punctuation.definition.identifier.swift" + } + }, + "patterns": [ + { + "begin": "\\{", + "end": "\\}", + "beginCaptures": { + "0": { + "name": "punctuation.definition.precedencegroup.begin.swift" + } + }, + "endCaptures": { + "0": { + "name": "punctuation.definition.precedencegroup.end.swift" + } + }, + "patterns": [ + { + "include": "#comments" + }, + { + "match": "\\b(higherThan|lowerThan)\\s*:\\s*((?`?)[\\p{L}_][\\p{L}_\\p{N}\\p{M}]*(\\k))", + "captures": { + "1": { + "name": "storage.modifier.swift" + }, + "2": { + "name": "entity.other.inherited-class.swift", + "patterns": [ + { + "include": "#declarations-types-precedencegroup" + } + ] + }, + "3": { + "name": "punctuation.definition.identifier.swift" + }, + "4": { + "name": "punctuation.definition.identifier.swift" + } + } + }, + { + "match": "\\b(associativity)\\b(?:\\s*:\\s*(right|left|none)\\b)?", + "captures": { + "1": { + "name": "storage.modifier.swift" + }, + "2": { + "name": "keyword.other.operator.associativity.swift" + } + } + }, + { + "match": "\\b(assignment)\\b(?:\\s*:\\s*(true|false)\\b)?", + "captures": { + "1": { + "name": "storage.modifier.swift" + }, + "2": { + "name": "constant.language.boolean.swift" + } + } + } + ] + } + ] + }, + "declarations-protocol": { + "name": "meta.definition.type.protocol.swift", + "begin": "\\b(protocol)\\s+((?`?)[\\p{L}_][\\p{L}_\\p{N}\\p{M}]*(\\k))", + "end": "(?<=\\})", + "beginCaptures": { + "1": { + "name": "storage.type.$1.swift" + }, + "2": { + "name": "entity.name.type.$1.swift" + }, + "3": { + "name": "punctuation.definition.identifier.swift" + }, + "4": { + "name": "punctuation.definition.identifier.swift" + } + }, + "patterns": [ + { + "include": "#comments" + }, + { + "include": "#declarations-inheritance-clause" + }, + { + "comment": "SE-0142: Permit where clauses to constrain associated types", + "include": "#declarations-generic-where-clause" + }, + { + "name": "meta.definition.type.body.swift", + "begin": "\\{", + "end": "\\}", + "beginCaptures": { + "0": { + "name": "punctuation.definition.type.begin.swift" + } + }, + "endCaptures": { + "0": { + "name": "punctuation.definition.type.end.swift" + } + }, + "patterns": [ + { + "include": "#declarations-protocol-protocol-method" + }, + { + "include": "#declarations-protocol-protocol-initializer" + }, + { + "include": "#declarations-protocol-associated-type" + }, + { + "include": "$self" + } + ] + } + ] + }, + "declarations-protocol-associated-type": { + "name": "meta.definition.associatedtype.swift", + "begin": "\\b(associatedtype)\\s+((?`?)[\\p{L}_][\\p{L}_\\p{N}\\p{M}]*(\\k))\\s*", + "end": "(?!\\G)$|(?=[;}]|$)", + "beginCaptures": { + "1": { + "name": "keyword.other.declaration-specifier.swift" + }, + "2": { + "name": "variable.language.associatedtype.swift" + }, + "3": { + "name": "punctuation.definition.identifier.swift" + }, + "4": { + "name": "punctuation.definition.identifier.swift" + } + }, + "patterns": [ + { + "include": "#declarations-inheritance-clause" + }, + { + "comment": "SE-0142: Permit where clauses to constrain associated types", + "include": "#declarations-generic-where-clause" + }, + { + "include": "#declarations-typealias-assignment" + } + ] + }, + "declarations-protocol-protocol-initializer": { + "name": "meta.definition.function.initializer.swift", + "begin": "(?`?)[\\p{L}_][\\p{L}_\\p{N}\\p{M}]*(\\k)\n | (?:\n (\n (? # 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\n | (? # 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 | \\g | \\. )+ ) # Dot operators\n )\n )\n\\s*\n(?=\\(|<)", + "end": "$|(?=;|//|/\\*|\\})", + "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" + } + }, + "patterns": [ + { + "include": "#comments" + }, + { + "include": "#declarations-generic-parameter-clause" + }, + { + "include": "#declarations-parameter-clause" + }, + { + "include": "#declarations-function-result" + }, + { + "include": "#async-throws" + }, + { + "comment": "Swift 3: generic constraints after the parameters and return type", + "include": "#declarations-generic-where-clause" + }, + { + "name": "invalid.illegal.function-body-not-allowed-in-protocol.swift", + "begin": "\\{", + "end": "\\}", + "beginCaptures": { + "0": { + "name": "punctuation.section.function.begin.swift" + } + }, + "endCaptures": { + "0": { + "name": "punctuation.section.function.end.swift" + } + }, + "patterns": [ + { + "include": "$self" + } + ] + } + ] + }, + "declarations-type": { + "patterns": [ + { + "name": "meta.definition.type.$1.swift", + "begin": "\\b(class(?!\\s+(?:func|var|let)\\b)|struct|actor)\\b\\s*((?`?)[\\p{L}_][\\p{L}_\\p{N}\\p{M}]*(\\k))", + "end": "(?<=\\})", + "beginCaptures": { + "1": { + "name": "storage.type.$1.swift" + }, + "2": { + "name": "entity.name.type.$1.swift" + }, + "3": { + "name": "punctuation.definition.identifier.swift" + }, + "4": { + "name": "punctuation.definition.identifier.swift" + } + }, + "patterns": [ + { + "include": "#comments" + }, + { + "include": "#declarations-generic-parameter-clause" + }, + { + "comment": "Swift 3: generic constraints after the generic param list", + "include": "#declarations-generic-where-clause" + }, + { + "include": "#declarations-inheritance-clause" + }, + { + "name": "meta.definition.type.body.swift", + "begin": "\\{", + "end": "\\}", + "beginCaptures": { + "0": { + "name": "punctuation.definition.type.begin.swift" + } + }, + "endCaptures": { + "0": { + "name": "punctuation.definition.type.end.swift" + } + }, + "patterns": [ + { + "include": "$self" + } + ] + } + ] + }, + { + "include": "#declarations-type-enum" + } + ] + }, + "declarations-type-enum": { + "name": "meta.definition.type.$1.swift", + "begin": "\\b(enum)\\s+((?`?)[\\p{L}_][\\p{L}_\\p{N}\\p{M}]*(\\k))", + "end": "(?<=\\})", + "beginCaptures": { + "1": { + "name": "storage.type.$1.swift" + }, + "2": { + "name": "entity.name.type.$1.swift" + }, + "3": { + "name": "punctuation.definition.identifier.swift" + }, + "4": { + "name": "punctuation.definition.identifier.swift" + } + }, + "patterns": [ + { + "include": "#comments" + }, + { + "include": "#declarations-generic-parameter-clause" + }, + { + "comment": "Swift 3: generic constraints after the generic param list", + "include": "#declarations-generic-where-clause" + }, + { + "include": "#declarations-inheritance-clause" + }, + { + "name": "meta.definition.type.body.swift", + "begin": "\\{", + "end": "\\}", + "beginCaptures": { + "0": { + "name": "punctuation.definition.type.begin.swift" + } + }, + "endCaptures": { + "0": { + "name": "punctuation.definition.type.end.swift" + } + }, + "patterns": [ + { + "include": "#declarations-type-enum-enum-case-clause" + }, + { + "include": "$self" + } + ] + } + ] + }, + "declarations-type-enum-associated-values": { + "begin": "\\G\\(", + "end": "\\)", + "beginCaptures": { + "0": { + "name": "punctuation.definition.parameters.begin.swift" + } + }, + "endCaptures": { + "0": { + "name": "punctuation.definition.parameters.end.swift" + } + }, + "patterns": [ + { + "include": "#comments" + }, + { + "begin": "(?x)\n(?:(_)|((?`?)[\\p{L}_][\\p{L}_\\p{N}\\p{M}]*\\k))\n\\s+\n(((?`?)[\\p{L}_][\\p{L}_\\p{N}\\p{M}]*\\k))\n\\s*(:)", + "end": "(?=[,)\\]])", + "beginCaptures": { + "1": { + "name": "entity.name.function.swift" + }, + "2": { + "name": "invalid.illegal.distinct-labels-not-allowed.swift" + }, + "5": { + "name": "variable.parameter.function.swift" + }, + "7": { + "name": "punctuation.separator.argument-label.swift" + } + }, + "patterns": [ + { + "include": "#declarations-available-types" + } + ] + }, + { + "begin": "(((?`?)[\\p{L}_][\\p{L}_\\p{N}\\p{M}]*\\k))\\s*(:)", + "end": "(?=[,)\\]])", + "beginCaptures": { + "1": { + "name": "entity.name.function.swift" + }, + "2": { + "name": "variable.parameter.function.swift" + }, + "4": { + "name": "punctuation.separator.argument-label.swift" + } + }, + "patterns": [ + { + "include": "#declarations-available-types" + } + ] + }, + { + "comment": "an element without a label (i.e. anything else)", + "begin": "(?![,)\\]])(?=\\S)", + "end": "(?=[,)\\]])", + "patterns": [ + { + "include": "#declarations-available-types" + }, + { + "name": "invalid.illegal.extra-colon-in-parameter-list.swift", + "match": ":" + } + ] + } + ] + }, + "declarations-type-enum-enum-case": { + "begin": "(?x)((?`?)[\\p{L}_][\\p{L}_\\p{N}\\p{M}]*(\\k))\\s*", + "end": "(?<=\\))|(?![=(])", + "beginCaptures": { + "1": { + "name": "variable.other.enummember.swift" + } + }, + "patterns": [ + { + "include": "#comments" + }, + { + "include": "#declarations-type-enum-associated-values" + }, + { + "include": "#declarations-type-enum-raw-value-assignment" + } + ] + }, + "declarations-type-enum-enum-case-clause": { + "begin": "\\b(case)\\b\\s*", + "end": "(?=[;}])|(?!\\G)(?!//|/\\*)(?=[^\\s,])", + "beginCaptures": { + "1": { + "name": "storage.type.enum.case.swift" + } + }, + "patterns": [ + { + "include": "#comments" + }, + { + "include": "#declarations-type-enum-enum-case" + }, + { + "include": "#declarations-type-enum-more-cases" + } + ] + }, + "declarations-type-enum-more-cases": { + "name": "meta.enum-case.more-cases", + "begin": ",\\s*", + "end": "(?!\\G)(?!//|/\\*)(?=[;}]|[^\\s,])", + "patterns": [ + { + "include": "#comments" + }, + { + "include": "#declarations-type-enum-enum-case" + }, + { + "include": "#declarations-type-enum-more-cases" + } + ] + }, + "declarations-type-enum-raw-value-assignment": { + "begin": "(=)\\s*", + "end": "(?!\\G)", + "beginCaptures": { + "1": { + "name": "keyword.operator.assignment.swift" + } + }, + "patterns": [ + { + "include": "#comments" + }, + { + "include": "#literals" + } + ] + }, + "declarations-type-identifier": { + "begin": "((?`?)[\\p{L}_][\\p{L}_\\p{N}\\p{M}]*(\\k))\\s*", + "end": "(?!<)", + "beginCaptures": { + "1": { + "name": "meta.type-name.swift", + "patterns": [ + { + "include": "#builtin-types" + } + ] + }, + "2": { + "name": "punctuation.definition.identifier.swift" + }, + "3": { + "name": "punctuation.definition.identifier.swift" + } + }, + "patterns": [ + { + "begin": "(?=<)", + "end": "(?!\\G)", + "patterns": [ + { + "include": "#declarations-generic-argument-clause" + } + ] + } + ] + }, + "declarations-type-operators": { + "patterns": [ + { + "comment": "Swift 3: A & B", + "match": "(?&|\\^~.])(&)(?![/=\\-+!*%<>&|\\^~.])", + "captures": { + "1": { + "name": "keyword.operator.type.composition.swift" + } + } + }, + { + "comment": "SE-0390: Noncopyable structs and enums", + "match": "(?&|\\^~.])(~)(?![/=\\-+!*%<>&|\\^~.])", + "captures": { + "1": { + "name": "keyword.operator.type.requirement-suppression.swift" + } + } + } + ] + }, + "declarations-typealias": { + "name": "meta.definition.typealias.swift", + "begin": "\\b(typealias)\\s+((?`?)[\\p{L}_][\\p{L}_\\p{N}\\p{M}]*(\\k))\\s*", + "end": "(?!\\G)$|(?=;|//|/\\*|$)", + "beginCaptures": { + "1": { + "name": "keyword.other.declaration-specifier.swift" + }, + "2": { + "name": "entity.name.type.typealias.swift" + }, + "3": { + "name": "punctuation.definition.identifier.swift" + }, + "4": { + "name": "punctuation.definition.identifier.swift" + } + }, + "patterns": [ + { + "begin": "\\G(?=<)", + "end": "(?!\\G)", + "patterns": [ + { + "include": "#declarations-generic-parameter-clause" + } + ] + }, + { + "include": "#declarations-typealias-assignment" + } + ] + }, + "declarations-typealias-assignment": { + "begin": "(=)\\s*", + "end": "(?!\\G)$|(?=;|//|/\\*|$)", + "beginCaptures": { + "1": { + "name": "keyword.operator.assignment.swift" + } + }, + "patterns": [ + { + "include": "#declarations-available-types" + } + ] + }, + "declarations-typed-variable-declaration": { + "begin": "(?x)\n\\b(?:(async)\\s+)?(let|var)\\b\\s+\n(?`?)[\\p{L}_][\\p{L}_\\p{N}\\p{M}]*(\\k)\\s*\n:", + "end": "(?=$|[={])", + "beginCaptures": { + "1": { + "name": "storage.modifier.async.swift" + }, + "2": { + "name": "keyword.other.declaration-specifier.swift" + } + }, + "patterns": [ + { + "include": "#declarations-available-types" + } + ] + }, + "declarations-types-precedencegroup": { + "patterns": [ + { + "comment": "Precedence groups in the standard library", + "name": "support.type.swift", + "match": "\\b(?:BitwiseShift|Assignment|RangeFormation|Casting|Addition|NilCoalescing|Comparison|LogicalConjunction|LogicalDisjunction|Default|Ternary|Multiplication|FunctionArrow)Precedence\\b" + } + ] + }, "expressions": { + "comment": "trailing closures need to be parsed before other member references", + "patterns": [ + { + "include": "#expressions-without-trailing-closures-or-member-references" + }, + { + "include": "#expressions-trailing-closure" + }, + { + "include": "#member-reference" + } + ] + }, + "expressions-trailing-closure": { + "patterns": [ + { + "comment": "foo { body } -- a call with a trailing closure and no argument clause", + "name": "meta.function-call.trailing-closure-only.swift", + "match": "(#?(?`?)[\\p{L}_][\\p{L}_\\p{N}\\p{M}]*(\\k))(?=\\s*\\{)", + "captures": { + "1": { + "name": "support.function.any-method.swift" + }, + "2": { + "name": "punctuation.definition.identifier.swift" + }, + "3": { + "name": "punctuation.definition.identifier.swift" + } + } + }, + { + "comment": "foo: { body } -- labeled-trailing-closure (SE-0279)", + "match": "((?`?)[\\p{L}_][\\p{L}_\\p{N}\\p{M}]*(\\k))\\s*(:)(?=\\s*\\{)", + "captures": { + "1": { + "name": "support.function.any-method.trailing-closure-label.swift" + }, + "2": { + "name": "punctuation.definition.identifier.swift" + }, + "3": { + "name": "punctuation.definition.identifier.swift" + }, + "4": { + "name": "punctuation.separator.argument-label.swift" + } + } + } + ] + }, + "expressions-without-trailing-closures": { + "patterns": [ + { + "include": "#expressions-without-trailing-closures-or-member-references" + }, + { + "include": "#member-references" + } + ] + }, + "expressions-without-trailing-closures-or-member-references": { "patterns": [ { "include": "#comments" @@ -2299,7 +2518,7 @@ "include": "#attributes" }, { - "include": "#closure-parameter" + "include": "#expressions-without-trailing-closures-or-member-references-closure-parameter" }, { "include": "#literals" @@ -2320,294 +2539,287 @@ "include": "#builtin-properties" }, { - "include": "#compound-name" + "include": "#expressions-without-trailing-closures-or-member-references-compound-name" + }, + { + "include": "#conditionals" }, { "include": "#keywords" }, { - "include": "#function-call-expression" + "include": "#expressions-without-trailing-closures-or-member-references-availability-condition" }, { - "include": "#subscript-expression" + "include": "#expressions-without-trailing-closures-or-member-references-function-or-macro-call-expression" }, { - "include": "#parenthesized-expression" + "include": "#expressions-without-trailing-closures-or-member-references-macro-expansion" }, { - "include": "#member-reference" + "include": "#expressions-without-trailing-closures-or-member-references-subscript-expression" }, { - "include": "#availability-condition" + "include": "#expressions-without-trailing-closures-or-member-references-parenthesized-expression" }, { - "match": "\\b_\\b", - "name": "support.variable.discard-value.swift" + "name": "support.variable.discard-value.swift", + "match": "\\b_\\b" } - ], - "repository": { - "availability-condition": { - "begin": "\\B(#(?:un)?available)(\\()", - "beginCaptures": { - "1": { - "name": "support.function.availability-condition.swift" - }, - "2": { - "name": "punctuation.definition.arguments.begin.swift" - } - }, - "end": "\\)", - "endCaptures": { - "0": { - "name": "punctuation.definition.arguments.end.swift" - } - }, - "patterns": [ - { - "captures": { - "1": { - "name": "keyword.other.platform.os.swift" - }, - "2": { - "name": "constant.numeric.swift" - } - }, - "match": "\\s*\\b((?:iOS|macOS|OSX|watchOS|tvOS|UIKitForMac)(?:ApplicationExtension)?)\\b(?:\\s+([0-9]+(?:\\.[0-9]+)*\\b))" - }, - { - "captures": { - "1": { - "name": "keyword.other.platform.all.swift" - }, - "2": { - "name": "invalid.illegal.character-not-allowed-here.swift" - } - }, - "match": "(\\*)\\s*(.*?)(?=[,)])" - }, - { - "match": "[^\\s,)]+", - "name": "invalid.illegal.character-not-allowed-here.swift" - } - ] + ] + }, + "expressions-without-trailing-closures-or-member-references-availability-condition": { + "begin": "\\B(#(?:un)?available)(\\()", + "end": "\\)", + "beginCaptures": { + "1": { + "name": "support.function.availability-condition.swift" }, - "closure-parameter": { - "match": "\\$[0-9]+", - "name": "variable.language.closure-parameter.swift" - }, - "compound-name": { + "2": { + "name": "punctuation.definition.arguments.begin.swift" + } + }, + "endCaptures": { + "0": { + "name": "punctuation.definition.arguments.end.swift" + } + }, + "patterns": [ + { + "match": "\\s*\\b((?:iOS|macOS|OSX|watchOS|tvOS|UIKitForMac)(?:ApplicationExtension)?)\\b(?:\\s+([0-9]+(?:\\.[0-9]+)*\\b))", "captures": { "1": { - "name": "entity.name.function.compound-name.swift" + "name": "keyword.other.platform.os.swift" }, "2": { - "name": "punctuation.definition.entity.swift" - }, - "3": { - "name": "punctuation.definition.entity.swift" - }, - "4": { - "patterns": [ - { - "captures": { - "1": { - "name": "punctuation.definition.entity.swift" - }, - "2": { - "name": "punctuation.definition.entity.swift" - } - }, - "match": "(?`?)(?!_:)[\\p{L}_][\\p{L}_\\p{N}\\p{M}]*(\\k):", - "name": "entity.name.function.compound-name.swift" - } - ] + "name": "constant.numeric.swift" } - }, - "comment": "a reference to a function with disambiguating argument labels, such as foo(_:), foo(bar:), etc.", - "match": "(?x)\n\t\t\t\t\t\t((?`?)[\\p{L}_][\\p{L}_\\p{N}\\p{M}]*(\\k)) \t\t# function name\n\t\t\t\t\t\t\\(\n\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\t((?`?)[\\p{L}_][\\p{L}_\\p{N}\\p{M}]*(\\k)) \t# argument label\n\t\t\t\t\t\t\t\t\t:\t\t\t\t\t\t\t\t\t\t\t\t# colon\n\t\t\t\t\t\t\t\t)+\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\\)\n\t\t\t\t\t" + } }, - "expression-element-list": { - "patterns": [ - { - "include": "#comments" - }, - { - "begin": "((?`?)[\\p{L}_][\\p{L}_\\p{N}\\p{M}]*(\\k))\\s*(:)", - "beginCaptures": { - "1": { - "name": "support.function.any-method.swift" - }, - "2": { - "name": "punctuation.definition.identifier.swift" - }, - "3": { - "name": "punctuation.definition.identifier.swift" - }, - "4": { - "name": "punctuation.separator.argument-label.swift" - } - }, - "comment": "an element with a label", - "end": "(?=[,)\\]])", - "patterns": [ - { - "include": "#expressions" - } - ] - }, - { - "begin": "(?![,)\\]])(?=\\S)", - "comment": "an element without a label (i.e. anything else)", - "end": "(?=[,)\\]])", - "patterns": [ - { - "include": "#expressions" - } - ] - } - ] - }, - "function-call-expression": { - "patterns": [ - { - "begin": "((?`?)[\\p{L}_][\\p{L}_\\p{N}\\p{M}]*(\\k))\\s*(\\()", - "beginCaptures": { - "1": { - "name": "support.function.any-method.swift" - }, - "2": { - "name": "punctuation.definition.identifier.swift" - }, - "3": { - "name": "punctuation.definition.identifier.swift" - }, - "4": { - "name": "punctuation.definition.arguments.begin.swift" - } - }, - "comment": "foo(args) -- a call whose callee is a highlightable name", - "end": "\\)", - "endCaptures": { - "0": { - "name": "punctuation.definition.arguments.end.swift" - } - }, - "name": "meta.function-call.swift", - "patterns": [ - { - "include": "#expression-element-list" - } - ] - }, - { - "begin": "(?<=[`\\])}>\\p{L}_\\p{N}\\p{M}])\\s*(\\()", - "beginCaptures": { - "1": { - "name": "punctuation.definition.arguments.begin.swift" - } - }, - "comment": "[Int](args) -- a call whose callee is a more complicated expression", - "end": "\\)", - "endCaptures": { - "0": { - "name": "punctuation.definition.arguments.end.swift" - } - }, - "name": "meta.function-call.swift", - "patterns": [ - { - "include": "#expression-element-list" - } - ] - } - ] - }, - "member-reference": { + { + "match": "(\\*)\\s*(.*?)(?=[,)])", + "captures": { + "1": { + "name": "keyword.other.platform.all.swift" + }, + "2": { + "name": "invalid.illegal.character-not-allowed-here.swift" + } + } + }, + { + "name": "invalid.illegal.character-not-allowed-here.swift", + "match": "[^\\s,)]+" + } + ] + }, + "expressions-without-trailing-closures-or-member-references-closure-parameter": { + "name": "variable.language.closure-parameter.swift", + "match": "\\$[0-9]+" + }, + "expressions-without-trailing-closures-or-member-references-compound-name": { + "comment": "a reference to a function with disambiguating argument labels, such as foo(_:), foo(bar:), etc.", + "match": "(?x)\n((?`?)[\\p{L}_][\\p{L}_\\p{N}\\p{M}]*(\\k)) # function name\n\\(\n (\n (\n ((?`?)[\\p{L}_][\\p{L}_\\p{N}\\p{M}]*(\\k)) # argument label\n : # colon\n )+\n )\n\\)", + "captures": { + "1": { + "name": "entity.name.function.compound-name.swift" + }, + "2": { + "name": "punctuation.definition.entity.swift" + }, + "3": { + "name": "punctuation.definition.entity.swift" + }, + "4": { "patterns": [ { + "name": "entity.name.function.compound-name.swift", + "match": "(?`?)(?!_:)[\\p{L}_][\\p{L}_\\p{N}\\p{M}]*(\\k):", "captures": { "1": { - "name": "variable.other.swift" + "name": "punctuation.definition.entity.swift" }, "2": { - "name": "punctuation.definition.identifier.swift" - }, - "3": { - "name": "punctuation.definition.identifier.swift" + "name": "punctuation.definition.entity.swift" } - }, - "match": "(?<=\\.)((?`?)[\\p{L}_][\\p{L}_\\p{N}\\p{M}]*(\\k))" - } - ] - }, - "parenthesized-expression": { - "begin": "\\(", - "beginCaptures": { - "0": { - "name": "punctuation.section.tuple.begin.swift" - } - }, - "comment": "correctly matching closure expressions is too hard (depends on trailing \"in\") so we just tack on some basics to the end of parenthesized-expression", - "end": "(\\))\\s*((?:\\b(?:async|throws|rethrows)\\s)*)", - "endCaptures": { - "1": { - "name": "punctuation.section.tuple.end.swift" - }, - "2": { - "patterns": [ - { - "match": "\\brethrows\\b", - "name": "invalid.illegal.rethrows-only-allowed-on-function-declarations.swift" - }, - { - "include": "#async-throws" - } - ] - } - }, - "patterns": [ - { - "include": "#expression-element-list" - } - ] - }, - "subscript-expression": { - "begin": "(?<=[`\\p{L}_\\p{N}\\p{M}])\\s*(\\[)", - "beginCaptures": { - "1": { - "name": "punctuation.definition.arguments.begin.swift" - } - }, - "end": "\\]", - "endCaptures": { - "0": { - "name": "punctuation.definition.arguments.end.swift" - } - }, - "name": "meta.subscript-expression.swift", - "patterns": [ - { - "include": "#expression-element-list" + } } ] } } }, + "expressions-without-trailing-closures-or-member-references-expression-element-list": { + "patterns": [ + { + "include": "#comments" + }, + { + "comment": "an element with a label", + "begin": "((?`?)[\\p{L}_][\\p{L}_\\p{N}\\p{M}]*(\\k))\\s*(:)", + "end": "(?=[,)\\]])", + "beginCaptures": { + "1": { + "name": "support.function.any-method.swift" + }, + "2": { + "name": "punctuation.definition.identifier.swift" + }, + "3": { + "name": "punctuation.definition.identifier.swift" + }, + "4": { + "name": "punctuation.separator.argument-label.swift" + } + }, + "patterns": [ + { + "include": "#expressions" + } + ] + }, + { + "comment": "an element without a label (i.e. anything else)", + "begin": "(?![,)\\]])(?=\\S)", + "end": "(?=[,)\\]])", + "patterns": [ + { + "include": "#expressions" + } + ] + } + ] + }, + "expressions-without-trailing-closures-or-member-references-function-or-macro-call-expression": { + "patterns": [ + { + "comment": "foo(args) -- a call whose callee is a highlightable name", + "name": "meta.function-call.swift", + "begin": "(#?(?`?)[\\p{L}_][\\p{L}_\\p{N}\\p{M}]*(\\k))\\s*(\\()", + "end": "\\)", + "beginCaptures": { + "1": { + "name": "support.function.any-method.swift" + }, + "2": { + "name": "punctuation.definition.identifier.swift" + }, + "3": { + "name": "punctuation.definition.identifier.swift" + }, + "4": { + "name": "punctuation.definition.arguments.begin.swift" + } + }, + "endCaptures": { + "0": { + "name": "punctuation.definition.arguments.end.swift" + } + }, + "patterns": [ + { + "include": "#expressions-without-trailing-closures-or-member-references-expression-element-list" + } + ] + }, + { + "comment": "[Int](args) -- a call whose callee is a more complicated expression", + "name": "meta.function-call.swift", + "begin": "(?<=[`\\])}>\\p{L}_\\p{N}\\p{M}])\\s*(\\()", + "end": "\\)", + "beginCaptures": { + "1": { + "name": "punctuation.definition.arguments.begin.swift" + } + }, + "endCaptures": { + "0": { + "name": "punctuation.definition.arguments.end.swift" + } + }, + "patterns": [ + { + "include": "#expressions-without-trailing-closures-or-member-references-expression-element-list" + } + ] + } + ] + }, + "expressions-without-trailing-closures-or-member-references-macro-expansion": { + "name": "support.function.any-method.swift", + "match": "(#(?`?)[\\p{L}_][\\p{L}_\\p{N}\\p{M}]*(\\k))" + }, + "expressions-without-trailing-closures-or-member-references-parenthesized-expression": { + "comment": "correctly matching closure expressions is too hard (depends on trailing \"in\") so we just tack on some basics to the end of parenthesized-expression", + "begin": "\\(", + "end": "(\\))\\s*((?:\\b(?:async|throws|rethrows)\\s)*)", + "beginCaptures": { + "0": { + "name": "punctuation.section.tuple.begin.swift" + } + }, + "endCaptures": { + "1": { + "name": "punctuation.section.tuple.end.swift" + }, + "2": { + "patterns": [ + { + "name": "invalid.illegal.rethrows-only-allowed-on-function-declarations.swift", + "match": "\\brethrows\\b" + }, + { + "include": "#async-throws" + } + ] + } + }, + "patterns": [ + { + "include": "#expressions-without-trailing-closures-or-member-references-expression-element-list" + } + ] + }, + "expressions-without-trailing-closures-or-member-references-subscript-expression": { + "name": "meta.subscript-expression.swift", + "begin": "(?<=[`\\p{L}_\\p{N}\\p{M}])\\s*(\\[)", + "end": "\\]", + "beginCaptures": { + "1": { + "name": "punctuation.definition.arguments.begin.swift" + } + }, + "endCaptures": { + "0": { + "name": "punctuation.definition.arguments.end.swift" + } + }, + "patterns": [ + { + "include": "#expressions-without-trailing-closures-or-member-references-expression-element-list" + } + ] + }, "keywords": { "patterns": [ { - "match": "(?\n (?> # no backtracking, avoids issues with negative lookbehind at end\n (?:\n \\\\Q\n (?:(?!\\\\E)(?!/\\2).)*+\n (?:\\\\E\n # A quoted sequence may not have a closing E, in which case it extends to the end of the regex\n | (?(3)|(?\\{)?+(?\\{)?+(?\\{)?+(?\\{)?+(?\\{)?+\n .+?\n \\}(?()\\})(?()\\})(?()\\})(?()\\})(?()\\})\n (?:\\[(?!\\d)\\w+\\])?\n [X<>]?\n \\)\n | (?\\[ (?:\\\\. | [^\\[\\]] | \\g)+ \\])\n | \\(\\g?+\\)\n | (?:(?!/\\2)[^()\\[\\\\])+ # any character (until end)\n )+\n )\n)?+\n# may end with a space only if it is an extended literal or contains only a single escaped space\n(?(3)|(?(5)(?'\n \"\\k'\" NamedOrNumberRef \"'\"\n '\\g<' NamedOrNumberRef '>'\n \"\\g'\" NamedOrNumberRef \"'\"", + "match": "(?x)(\\\\[gk](<)|\\\\[gk]') (?: ((?!\\d)\\w+) (?:([+-])(\\d+))? | ([+-]?\\d+) (?:([+-])(\\d+))? ) ((?(2)>|'))", + "captures": { + "1": { + "name": "constant.character.escape.backslash.regexp" + }, + "3": { + "name": "variable.other.group-name.regexp" + }, + "4": { + "name": "keyword.operator.recursion-level.regexp" + }, + "5": { + "name": "constant.numeric.integer.decimal.regexp" + }, + "6": { + "name": "constant.numeric.integer.decimal.regexp" + }, + "7": { + "name": "keyword.operator.recursion-level.regexp" + }, + "8": { + "name": "constant.numeric.integer.decimal.regexp" + }, + "9": { + "name": "constant.character.escape.backslash.regexp" + } + } + }, + { + "comment": "'\\k{' NamedRef '}'", + "match": "(?x)(\\\\k\\{) ((?!\\d)\\w+) (?:([+-])(\\d+))? (\\})", + "captures": { + "1": { + "name": "constant.character.escape.backslash.regexp" + }, + "2": { + "name": "variable.other.group-name.regexp" + }, + "3": { + "name": "keyword.operator.recursion-level.regexp" + }, + "4": { + "name": "constant.numeric.integer.decimal.regexp" + }, + "5": { + "name": "constant.character.escape.backslash.regexp" + } + } + }, + { + "name": "keyword.other.back-reference.regexp", + "match": "\\\\[1-9][0-9]+" + }, + { + "comment": "'(?P=' NamedRef ')'", + "match": "(?x)(\\(\\?(?:P[=>]|&)) ((?!\\d)\\w+) (?:([+-])(\\d+))? (\\))", + "captures": { + "1": { + "name": "keyword.other.back-reference.regexp" + }, + "2": { + "name": "variable.other.group-name.regexp" + }, + "3": { + "name": "keyword.operator.recursion-level.regexp" + }, + "4": { + "name": "constant.numeric.integer.decimal.regexp" + }, + "5": { + "name": "keyword.other.back-reference.regexp" + } + } + }, + { + "name": "keyword.other.back-reference.regexp", + "match": "\\(\\?R\\)" + }, + { + "comment": "'(?' NumberRef ')'", + "match": "(?x)(\\(\\?) ([+-]?\\d+) (?:([+-])(\\d+))? (\\))", + "captures": { + "1": { + "name": "keyword.other.back-reference.regexp" + }, + "2": { + "name": "constant.numeric.integer.decimal.regexp" + }, + "3": { + "name": "keyword.operator.recursion-level.regexp" + }, + "4": { + "name": "constant.numeric.integer.decimal.regexp" + }, + "5": { + "name": "keyword.other.back-reference.regexp" + } + } + } + ] + }, + "literals-regular-expression-literal-backtracking-directive-or-global-matching-option": { + "match": "(?x)\n(\\(\\*)\n(?:\n (ACCEPT|FAIL|F|MARK(?=:)|(?=:)|COMMIT|PRUNE|SKIP|THEN)\n (?:(:)([^)]+))?\n | (?:(LIMIT_(?:DEPTH|HEAP|MATCH))(=)(\\d+))\n | (\n CRLF | CR | ANYCRLF | ANY | LF | NUL\n | BSR_ANYCRLF | BSR_UNICODE\n | NOTEMPTY_ATSTART | NOTEMPTY\n | NO_AUTO_POSSESS | NO_DOTSTAR_ANCHOR\n | NO_JIT | NO_START_OPT | UTF | UCP\n )\n)\n(\\))", + "captures": { + "1": { + "name": "keyword.control.directive.regexp" + }, + "2": { + "name": "keyword.control.directive.regexp" + }, + "3": { + "name": "keyword.control.directive.regexp" + }, + "4": { + "name": "variable.language.tag.regexp" + }, + "5": { + "name": "keyword.control.directive.regexp" + }, + "6": { + "name": "keyword.operator.assignment.regexp" + }, + "7": { + "name": "constant.numeric.integer.decimal.regexp" + }, + "8": { + "name": "keyword.control.directive.regexp" + }, + "9": { + "name": "keyword.control.directive.regexp" + } } }, + "literals-regular-expression-literal-callout": { + "name": "meta.callout.regexp", + "match": "(?x)\n# PCRECallout\n(\\()(?\\?C)\n (?:\n (?\\d+)\n | `(?(?:[^`]|``)*)`\n | '(?(?:[^']|'')*)'\n | \"(?(?:[^\"]|\"\")*)\"\n | \\^(?(?:[^\\^]|\\^\\^)*)\\^\n | %(?(?:[^%]|%%)*)%\n | \\#(?(?:[^#]|\\#\\#)*)\\#\n | \\$(?(?:[^$]|\\$\\$)*)\\$\n | \\{(?(?:[^}]|\\}\\})*)\\}\n )?\n(\\))\n# NamedCallout\n| (\\()(?\\*)\n (?(?!\\d)\\w+)\n (?:\\[(?(?!\\d)\\w+)\\])?\n (?:\\{ [^,}]+ (?:,[^,}]+)* \\})?\n (\\))\n# InterpolatedCallout\n| (\\()(?\\?)\n # we only support a fixed maximum number of braces because otherwise we can't balance the number of open and close braces\n (\\{(?\\{)?+(?\\{)?+(?\\{)?+(?\\{)?+(?\\{)?+) .+? \\}(?()\\})(?()\\})(?()\\})(?()\\})(?()\\})\n (?:\\[(?(?!\\d)\\w+)\\])?\n (?[X<>]?)\n (\\))", + "captures": { + "1": { + "name": "punctuation.definition.group.regexp" + }, + "2": { + "name": "keyword.control.callout.regexp" + }, + "3": { + "name": "constant.numeric.integer.decimal.regexp" + }, + "4": { + "name": "entity.name.function.callout.regexp" + }, + "5": { + "name": "entity.name.function.callout.regexp" + }, + "6": { + "name": "entity.name.function.callout.regexp" + }, + "7": { + "name": "entity.name.function.callout.regexp" + }, + "8": { + "name": "entity.name.function.callout.regexp" + }, + "9": { + "name": "entity.name.function.callout.regexp" + }, + "10": { + "name": "entity.name.function.callout.regexp" + }, + "11": { + "name": "entity.name.function.callout.regexp" + }, + "12": { + "name": "punctuation.definition.group.regexp" + }, + "13": { + "name": "punctuation.definition.group.regexp" + }, + "14": { + "name": "keyword.control.callout.regexp" + }, + "15": { + "name": "entity.name.function.callout.regexp" + }, + "16": { + "name": "variable.language.tag-name.regexp" + }, + "17": { + "name": "punctuation.definition.group.regexp" + }, + "18": { + "name": "punctuation.definition.group.regexp" + }, + "19": { + "name": "keyword.control.callout.regexp" + }, + "26": { + "name": "variable.language.tag-name.regexp" + }, + "27": { + "name": "keyword.control.callout.regexp" + }, + "28": { + "name": "punctuation.definition.group.regexp" + } + } + }, + "literals-regular-expression-literal-character-properties": { + "name": "constant.other.character-class.set.regexp", + "match": "(?x)\n\\\\[pP]\\{ ([\\s\\w-]+(?:=[\\s\\w-]+)?) \\}\n| (\\[:) ([\\s\\w-]+(?:=[\\s\\w-]+)?) (:\\])", + "captures": { + "1": { + "name": "support.variable.character-property.regexp" + }, + "2": { + "name": "punctuation.definition.character-class.regexp" + }, + "3": { + "name": "support.variable.character-property.regexp" + }, + "4": { + "name": "punctuation.definition.character-class.regexp" + } + } + }, + "literals-regular-expression-literal-custom-char-class": { + "patterns": [ + { + "name": "constant.other.character-class.set.regexp", + "begin": "(\\[)(\\^)?", + "end": "\\]", + "beginCaptures": { + "1": { + "name": "punctuation.definition.character-class.regexp" + }, + "2": { + "name": "keyword.operator.negation.regexp" + } + }, + "endCaptures": { + "0": { + "name": "punctuation.definition.character-class.regexp" + } + }, + "patterns": [ + { + "include": "#literals-regular-expression-literal-custom-char-class-members" + } + ] + } + ] + }, + "literals-regular-expression-literal-custom-char-class-members": { + "comment": "TODO: should also include atoms?", + "patterns": [ + { + "comment": "\\b inside a character class represents a backspace", + "name": "constant.character.escape.backslash.regexp", + "match": "\\\\b" + }, + { + "include": "#literals-regular-expression-literal-custom-char-class" + }, + { + "include": "#literals-regular-expression-literal-quote" + }, + { + "include": "#literals-regular-expression-literal-set-operators" + }, + { + "include": "#literals-regular-expression-literal-unicode-scalars" + }, + { + "include": "#literals-regular-expression-literal-character-properties" + } + ] + }, + "literals-regular-expression-literal-group-option-toggle": { + "comment": "A matching option sequence may be part of an \"isolated group\" which has an implicit scope that wraps the remaining elements of the current group", + "name": "keyword.other.option-toggle.regexp", + "match": "(?x)\n\\(\\?\n(?:\n \\^(?:[iJmnsUxwDPSW]|xx|y\\{[gw]\\})*\n | (?:[iJmnsUxwDPSW]|xx|y\\{[gw]\\})+\n | (?:[iJmnsUxwDPSW]|xx|y\\{[gw]\\})* - (?:[iJmnsUxwDPSW]|xx|y\\{[gw]\\})*\n)\n\\)" + }, + "literals-regular-expression-literal-group-or-conditional": { + "patterns": [ + { + "name": "meta.group.absent.regexp", + "begin": "(\\()(\\?~)", + "end": "\\)", + "beginCaptures": { + "1": { + "name": "punctuation.definition.group.regexp" + }, + "2": { + "name": "keyword.control.conditional.absent.regexp" + } + }, + "endCaptures": { + "0": { + "name": "punctuation.definition.group.regexp" + } + }, + "patterns": [ + { + "include": "#literals-regular-expression-literal-regex-guts" + } + ] + }, + { + "name": "meta.group.conditional.regexp", + "begin": "(?x)\n# KnownConditionalStart\n(\\() (?\\?\\()\n (?:\n (? (?[+-]?\\d+)(?:(?[+-])(?\\d+))? )\n | (?R) \\g?\n | (?R&) (? (?(?!\\d)\\w+) (?:(?[+-])(?\\d+))? )\n | (?<) (?:\\g|\\g) (?>)\n | (?') (?:\\g|\\g) (?')\n | (?DEFINE)\n | (?VERSION)(?>?=)(?\\d+\\.\\d+)\n )\n(?\\))\n| (\\()(?\\?)(?=\\()", + "end": "\\)", + "beginCaptures": { + "1": { + "name": "punctuation.definition.group.regexp" + }, + "2": { + "name": "keyword.control.conditional.regexp" + }, + "4": { + "name": "constant.numeric.integer.decimal.regexp" + }, + "5": { + "name": "keyword.operator.recursion-level.regexp" + }, + "6": { + "name": "constant.numeric.integer.decimal.regexp" + }, + "7": { + "name": "keyword.control.conditional.regexp" + }, + "8": { + "name": "keyword.control.conditional.regexp" + }, + "10": { + "name": "variable.other.group-name.regexp" + }, + "11": { + "name": "keyword.operator.recursion-level.regexp" + }, + "12": { + "name": "constant.numeric.integer.decimal.regexp" + }, + "13": { + "name": "keyword.control.conditional.regexp" + }, + "14": { + "name": "keyword.control.conditional.regexp" + }, + "15": { + "name": "keyword.control.conditional.regexp" + }, + "16": { + "name": "keyword.control.conditional.regexp" + }, + "17": { + "name": "keyword.control.conditional.regexp" + }, + "18": { + "name": "keyword.control.conditional.regexp" + }, + "19": { + "name": "keyword.operator.comparison.regexp" + }, + "20": { + "name": "constant.numeric.integer.decimal.regexp" + }, + "21": { + "name": "keyword.control.conditional.regexp" + }, + "22": { + "name": "punctuation.definition.group.regexp" + }, + "23": { + "name": "keyword.control.conditional.regexp" + } + }, + "endCaptures": { + "0": { + "name": "punctuation.definition.group.regexp" + } + }, + "patterns": [ + { + "include": "#literals-regular-expression-literal-regex-guts" + } + ] + }, + { + "name": "meta.group.regexp", + "begin": "(?x)\n(\\()\n(\n # BasicGroupKind\n (\\?)\n (?:\n ([:|>=!*] | <[=!*])\n # named groups\n | P?< (?:((?!\\d)\\w+) (-))? ((?!\\d)\\w+) >\n | ' (?:((?!\\d)\\w+) (-))? ((?!\\d)\\w+) '\n # matching options\n | (?:\n \\^(?:[iJmnsUxwDPSW]|xx|y\\{[gw]\\})*\n | (?:[iJmnsUxwDPSW]|xx|y\\{[gw]\\})+\n | (?:[iJmnsUxwDPSW]|xx|y\\{[gw]\\})* - (?:[iJmnsUxwDPSW]|xx|y\\{[gw]\\})*\n ): # case without : is handled by group-option-toggle\n )\n # PCRE2GroupKind\n | \\*(\n atomic\n |pla|positive_lookahead\n |nla|negative_lookahead\n |plb|positive_lookbehind\n |nlb|negative_lookbehind\n |napla|non_atomic_positive_lookahead\n |naplb|non_atomic_positive_lookbehind\n |sr|script_run\n |asr|atomic_script_run\n ):\n)?+", + "end": "\\)", + "beginCaptures": { + "1": { + "name": "punctuation.definition.group.regexp" + }, + "2": { + "name": "keyword.other.group-options.regexp" + }, + "3": { + "name": "punctuation.definition.group.regexp" + }, + "4": { + "name": "punctuation.definition.group.regexp" + }, + "5": { + "name": "variable.other.group-name.regexp" + }, + "6": { + "name": "keyword.operator.balancing-group.regexp" + }, + "7": { + "name": "variable.other.group-name.regexp" + }, + "8": { + "name": "variable.other.group-name.regexp" + }, + "9": { + "name": "keyword.operator.balancing-group.regexp" + }, + "10": { + "name": "variable.other.group-name.regexp" + } + }, + "endCaptures": { + "0": { + "name": "punctuation.definition.group.regexp" + } + }, + "patterns": [ + { + "include": "#literals-regular-expression-literal-regex-guts" + } + ] + } + ] + }, + "literals-regular-expression-literal-line-comment": { + "name": "comment.line.regexp", + "match": "(\\#).*$", + "captures": { + "1": { + "name": "punctuation.definition.comment.regexp" + } + } + }, + "literals-regular-expression-literal-quote": { + "name": "string.quoted.other.regexp.swift", + "begin": "\\\\Q", + "end": "\\\\E|(\\n)", + "beginCaptures": { + "0": { + "name": "constant.character.escape.backslash.regexp" + } + }, + "endCaptures": { + "0": { + "name": "constant.character.escape.backslash.regexp" + }, + "1": { + "name": "invalid.illegal.returns-not-allowed.regexp" + } + } + }, + "literals-regular-expression-literal-regex-guts": { + "patterns": [ + { + "include": "#literals-regular-expression-literal-quote" + }, + { + "name": "comment.block.regexp", + "begin": "\\(\\?\\#", + "end": "\\)", + "beginCaptures": { + "0": { + "name": "punctuation.definition.comment.begin.regexp" + } + }, + "endCaptures": { + "0": { + "name": "punctuation.definition.comment.end.regexp" + } + } + }, + { + "name": "meta.embedded.expression.regexp", + "begin": "<\\{", + "end": "\\}>", + "beginCaptures": { + "0": { + "name": "punctuation.section.embedded.begin.regexp" + } + }, + "endCaptures": { + "0": { + "name": "punctuation.section.embedded.end.regexp" + } + } + }, + { + "include": "#literals-regular-expression-literal-unicode-scalars" + }, + { + "include": "#literals-regular-expression-literal-character-properties" + }, + { + "name": "keyword.control.anchor.regexp", + "match": "[$^]|\\\\[AbBGyYzZ]|\\\\K" + }, + { + "include": "#literals-regular-expression-literal-backtracking-directive-or-global-matching-option" + }, + { + "include": "#literals-regular-expression-literal-callout" + }, + { + "include": "#literals-regular-expression-literal-backreference-or-subpattern" + }, + { + "name": "constant.character.character-class.regexp", + "match": "\\.|\\\\[CdDhHNORsSvVwWX]" + }, + { + "name": "constant.character.entity.control-character.regexp", + "match": "\\\\c." + }, + { + "name": "constant.character.escape.backslash.regexp", + "match": "\\\\[^c]" + }, + { + "name": "keyword.operator.or.regexp", + "match": "\\|" + }, + { + "name": "keyword.operator.quantifier.regexp", + "match": "[*+?]" + }, + { + "name": "keyword.operator.quantifier.regexp", + "match": "\\{\\s*\\d+\\s*(?:,\\s*\\d*\\s*)?\\}|\\{\\s*,\\s*\\d+\\s*\\}" + }, + { + "include": "#literals-regular-expression-literal-custom-char-class" + }, + { + "include": "#literals-regular-expression-literal-group-option-toggle" + }, + { + "include": "#literals-regular-expression-literal-group-or-conditional" + } + ] + }, + "literals-regular-expression-literal-set-operators": { + "patterns": [ + { + "name": "keyword.operator.intersection.regexp.swift", + "match": "&&" + }, + { + "name": "keyword.operator.subtraction.regexp.swift", + "match": "--" + }, + { + "name": "keyword.operator.symmetric-difference.regexp.swift", + "match": "\\~\\~" + } + ] + }, + "literals-regular-expression-literal-unicode-scalars": { + "name": "constant.character.numeric.regexp", + "match": "(?x)\n\\\\u\\{\\s*(?:[0-9a-fA-F]+\\s*)+\\}\n| \\\\u[0-9a-fA-F]{4}\n| \\\\x\\{[0-9a-fA-F]+\\}\n| \\\\x[0-9a-fA-F]{0,2}\n| \\\\U[0-9a-fA-F]{8}\n| \\\\o\\{[0-7]+\\}\n| \\\\0[0-7]{0,3}\n| \\\\N\\{(?:U\\+[0-9a-fA-F]{1,8} | [\\s\\w-]+)\\}" + }, + "literals-string": { + "patterns": [ + { + "comment": "SE-0168: Multi-Line String Literals", + "name": "string.quoted.double.block.swift", + "begin": "\"\"\"", + "end": "\"\"\"(#*)", + "beginCaptures": { + "0": { + "name": "punctuation.definition.string.begin.swift" + } + }, + "endCaptures": { + "0": { + "name": "punctuation.definition.string.end.swift" + }, + "1": { + "name": "invalid.illegal.extra-closing-delimiter.swift" + } + }, + "patterns": [ + { + "name": "invalid.illegal.content-after-opening-delimiter.swift", + "match": "\\G.+(?=\"\"\")|\\G.+" + }, + { + "name": "constant.character.escape.newline.swift", + "match": "\\\\\\s*\\n" + }, + { + "include": "#literals-string-string-guts" + }, + { + "comment": "Allow \\(\"\"\"...\"\"\") to appear inside a block string", + "name": "invalid.illegal.content-before-closing-delimiter.swift", + "match": "\\S((?!\\\\\\().)*(?=\"\"\")" + } + ] + }, + { + "name": "string.quoted.double.block.raw.swift", + "begin": "#\"\"\"", + "end": "\"\"\"#(#*)", + "beginCaptures": { + "0": { + "name": "punctuation.definition.string.begin.swift" + } + }, + "endCaptures": { + "0": { + "name": "punctuation.definition.string.end.swift" + }, + "1": { + "name": "invalid.illegal.extra-closing-delimiter.swift" + } + }, + "patterns": [ + { + "name": "invalid.illegal.content-after-opening-delimiter.swift", + "match": "\\G.+(?=\"\"\")|\\G.+" + }, + { + "name": "constant.character.escape.newline.swift", + "match": "\\\\#\\s*\\n" + }, + { + "include": "#literals-string-raw-string-guts" + }, + { + "comment": "Allow \\(\"\"\"...\"\"\") to appear inside a block string", + "name": "invalid.illegal.content-before-closing-delimiter.swift", + "match": "\\S((?!\\\\#\\().)*(?=\"\"\")" + } + ] + }, + { + "name": "string.quoted.double.block.raw.swift", + "begin": "(##+)\"\"\"", + "end": "\"\"\"\\1(#*)", + "beginCaptures": { + "0": { + "name": "punctuation.definition.string.begin.swift" + } + }, + "endCaptures": { + "0": { + "name": "punctuation.definition.string.end.swift" + }, + "1": { + "name": "invalid.illegal.extra-closing-delimiter.swift" + } + }, + "patterns": [ + { + "name": "invalid.illegal.content-after-opening-delimiter.swift", + "match": "\\G.+(?=\"\"\")|\\G.+" + } + ] + }, + { + "name": "string.quoted.double.single-line.swift", + "begin": "\"", + "end": "\"(#*)", + "beginCaptures": { + "0": { + "name": "punctuation.definition.string.begin.swift" + } + }, + "endCaptures": { + "0": { + "name": "punctuation.definition.string.end.swift" + }, + "1": { + "name": "invalid.illegal.extra-closing-delimiter.swift" + } + }, + "patterns": [ + { + "name": "invalid.illegal.returns-not-allowed.swift", + "match": "\\r|\\n" + }, + { + "include": "#literals-string-string-guts" + } + ] + }, + { + "comment": "SE-0168: raw string literals (more than one #, grammar limitations prevent us from supporting escapes)", + "name": "string.quoted.double.single-line.raw.swift", + "begin": "(##+)\"", + "end": "\"\\1(#*)", + "beginCaptures": { + "0": { + "name": "punctuation.definition.string.begin.raw.swift" + } + }, + "endCaptures": { + "0": { + "name": "punctuation.definition.string.end.raw.swift" + }, + "1": { + "name": "invalid.illegal.extra-closing-delimiter.swift" + } + }, + "patterns": [ + { + "name": "invalid.illegal.returns-not-allowed.swift", + "match": "\\r|\\n" + } + ] + }, + { + "comment": "SE-0168: raw string literals (one #, escapes supported)", + "name": "string.quoted.double.single-line.raw.swift", + "begin": "#\"", + "end": "\"#(#*)", + "beginCaptures": { + "0": { + "name": "punctuation.definition.string.begin.raw.swift" + } + }, + "endCaptures": { + "0": { + "name": "punctuation.definition.string.end.raw.swift" + }, + "1": { + "name": "invalid.illegal.extra-closing-delimiter.swift" + } + }, + "patterns": [ + { + "name": "invalid.illegal.returns-not-allowed.swift", + "match": "\\r|\\n" + }, + { + "include": "#literals-string-raw-string-guts" + } + ] + } + ] + }, + "literals-string-raw-string-guts": { + "comment": "the same as #string-guts but with # in escapes", + "patterns": [ + { + "name": "constant.character.escape.swift", + "match": "\\\\#[0\\\\tnr\"']" + }, + { + "name": "constant.character.escape.unicode.swift", + "match": "\\\\#u\\{[0-9a-fA-F]{1,8}\\}" + }, + { + "contentName": "source.swift", + "name": "meta.embedded.line.swift", + "begin": "\\\\#\\(", + "end": "(\\))", + "beginCaptures": { + "0": { + "name": "punctuation.section.embedded.begin.swift" + } + }, + "endCaptures": { + "0": { + "name": "punctuation.section.embedded.end.swift" + }, + "1": { + "name": "source.swift" + } + }, + "patterns": [ + { + "include": "$self" + }, + { + "comment": "Nested parens", + "begin": "\\(", + "end": "\\)" + } + ] + }, + { + "name": "invalid.illegal.escape-not-recognized", + "match": "\\\\#." + } + ] + }, + "literals-string-string-guts": { + "patterns": [ + { + "name": "constant.character.escape.swift", + "match": "\\\\[0\\\\tnr\"']" + }, + { + "name": "constant.character.escape.unicode.swift", + "match": "\\\\u\\{[0-9a-fA-F]{1,8}\\}" + }, + { + "contentName": "source.swift", + "name": "meta.embedded.line.swift", + "begin": "\\\\\\(", + "end": "(\\))", + "beginCaptures": { + "0": { + "name": "punctuation.section.embedded.begin.swift" + } + }, + "endCaptures": { + "0": { + "name": "punctuation.section.embedded.end.swift" + }, + "1": { + "name": "source.swift" + } + }, + "patterns": [ + { + "include": "$self" + }, + { + "comment": "Nested parens", + "begin": "\\(", + "end": "\\)" + } + ] + }, + { + "name": "invalid.illegal.escape-not-recognized", + "match": "\\\\." + } + ] + }, + "member-reference": { + "patterns": [ + { + "match": "(?<=\\.)((?`?)[\\p{L}_][\\p{L}_\\p{N}\\p{M}]*(\\k))", + "captures": { + "1": { + "name": "variable.other.swift" + }, + "2": { + "name": "punctuation.definition.identifier.swift" + }, + "3": { + "name": "punctuation.definition.identifier.swift" + } + } + } + ] + }, "operators": { "patterns": [ { "comment": "Type casting", - "match": "\\b(is\\b|as([!?]\\B|\\b))", - "name": "keyword.operator.type-casting.swift" + "name": "keyword.operator.type-casting.swift", + "match": "\\b(is\\b|as([!?]\\B|\\b))" }, { - "begin": "(?x)\n\t\t\t\t\t\t(?=\n\t\t\t\t\t\t\t(?\t\t\t\t\t\t\t\t# operator-head\n\t\t\t\t\t\t\t\t[/=\\-+!*%<>&|^~?]\n\t\t\t\t\t\t\t | [\\x{00A1}-\\x{00A7}]\n\t\t\t\t\t\t\t | [\\x{00A9}\\x{00AB}]\n\t\t\t\t\t\t\t | [\\x{00AC}\\x{00AE}]\n\t\t\t\t\t\t\t | [\\x{00B0}-\\x{00B1}\\x{00B6}\\x{00BB}\\x{00BF}\\x{00D7}\\x{00F7}]\n\t\t\t\t\t\t\t | [\\x{2016}-\\x{2017}\\x{2020}-\\x{2027}]\n\t\t\t\t\t\t\t | [\\x{2030}-\\x{203E}]\n\t\t\t\t\t\t\t | [\\x{2041}-\\x{2053}]\n\t\t\t\t\t\t\t | [\\x{2055}-\\x{205E}]\n\t\t\t\t\t\t\t | [\\x{2190}-\\x{23FF}]\n\t\t\t\t\t\t\t | [\\x{2500}-\\x{2775}]\n\t\t\t\t\t\t\t | [\\x{2794}-\\x{2BFF}]\n\t\t\t\t\t\t\t | [\\x{2E00}-\\x{2E7F}]\n\t\t\t\t\t\t\t | [\\x{3001}-\\x{3003}]\n\t\t\t\t\t\t\t | [\\x{3008}-\\x{3030}]\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t | \\.\n\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\\g\t\t\t\t\t\t\t# operator-head\n\t\t\t\t\t\t\t | \\.\n\t\t\t\t\t\t\t | [\\x{0300}-\\x{036F}]\t\t\t\t# operator-character\n\t\t\t\t\t\t\t | [\\x{1DC0}-\\x{1DFF}]\n\t\t\t\t\t\t\t | [\\x{20D0}-\\x{20FF}]\n\t\t\t\t\t\t\t | [\\x{FE00}-\\x{FE0F}]\n\t\t\t\t\t\t\t | [\\x{FE20}-\\x{FE2F}]\n\t\t\t\t\t\t\t | [\\x{E0100}-\\x{E01EF}]\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t)\n\t\t\t\t\t", "comment": "This rule helps us speed up the matching.", + "begin": "(?x)\n(?=\n (? # 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 (\n \\g # operator-head\n | \\.\n | [\\x{0300}-\\x{036F}] # operator-character\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)", "end": "(?!\\G)", "patterns": [ { - "captures": { - "0": { - "patterns": [ - { - "match": "\\G(\\+\\+|\\-\\-)$", - "name": "keyword.operator.increment-or-decrement.swift" - }, - { - "match": "\\G(\\+|\\-)$", - "name": "keyword.operator.arithmetic.unary.swift" - }, - { - "match": "\\G!$", - "name": "keyword.operator.logical.not.swift" - }, - { - "match": "\\G~$", - "name": "keyword.operator.bitwise.not.swift" - }, - { - "match": ".+", - "name": "keyword.operator.custom.prefix.swift" - } - ] - } - }, "comment": "Prefix unary operator", - "match": "(?x)\n\t\t\t\t\t\t\t\t\\G\t\t\t\t\t\t\t\t\t\t# Matching from the beginning ensures\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t# that we start with operator-head\n\t\t\t\t\t\t\t\t(?<=^|[\\s(\\[{,;:])\n\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\t(?!(//|/\\*|\\*/))\n\t\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\t\t[/=\\-+!*%<>&|^~?]\t\t\t\t# operator-head\n\t\t\t\t\t\t\t\t\t | [\\x{00A1}-\\x{00A7}]\n\t\t\t\t\t\t\t\t\t | [\\x{00A9}\\x{00AB}]\n\t\t\t\t\t\t\t\t\t | [\\x{00AC}\\x{00AE}]\n\t\t\t\t\t\t\t\t\t | [\\x{00B0}-\\x{00B1}\\x{00B6}\\x{00BB}\\x{00BF}\\x{00D7}\\x{00F7}]\n\t\t\t\t\t\t\t\t\t | [\\x{2016}-\\x{2017}\\x{2020}-\\x{2027}]\n\t\t\t\t\t\t\t\t\t | [\\x{2030}-\\x{203E}]\n\t\t\t\t\t\t\t\t\t | [\\x{2041}-\\x{2053}]\n\t\t\t\t\t\t\t\t\t | [\\x{2055}-\\x{205E}]\n\t\t\t\t\t\t\t\t\t | [\\x{2190}-\\x{23FF}]\n\t\t\t\t\t\t\t\t\t | [\\x{2500}-\\x{2775}]\n\t\t\t\t\t\t\t\t\t | [\\x{2794}-\\x{2BFF}]\n\t\t\t\t\t\t\t\t\t | [\\x{2E00}-\\x{2E7F}]\n\t\t\t\t\t\t\t\t\t | [\\x{3001}-\\x{3003}]\n\t\t\t\t\t\t\t\t\t | [\\x{3008}-\\x{3030}]\n\t\t\t\t\t\t\t\t \n\t\t\t\t\t\t\t\t\t | [\\x{0300}-\\x{036F}]\t\t\t\t# operator-character\n\t\t\t\t\t\t\t\t\t | [\\x{1DC0}-\\x{1DFF}]\n\t\t\t\t\t\t\t\t\t | [\\x{20D0}-\\x{20FF}]\n\t\t\t\t\t\t\t\t\t | [\\x{FE00}-\\x{FE0F}]\n\t\t\t\t\t\t\t\t\t | [\\x{FE20}-\\x{FE2F}]\n\t\t\t\t\t\t\t\t\t | [\\x{E0100}-\\x{E01EF}]\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t)++\n\t\t\t\t\t\t\t\t(?![\\s)\\]},;:]|\\z)\n\t\t\t\t\t\t\t" - }, - { + "match": "(?x)\n\\G # Matching from the beginning ensures\n # that we start with operator-head\n(?<=^|[\\s(\\[{,;:])\n(\n (?!(//|/\\*|\\*/))\n (\n [/=\\-+!*%<>&|^~?] # operator-head\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 | [\\x{0300}-\\x{036F}] # operator-character\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(?![\\s)\\]},;:]|\\z)", "captures": { "0": { "patterns": [ { - "match": "\\G(\\+\\+|\\-\\-)$", - "name": "keyword.operator.increment-or-decrement.swift" + "name": "keyword.operator.increment-or-decrement.swift", + "match": "\\G(\\+\\+|\\-\\-)$" }, { - "match": "\\G!$", - "name": "keyword.operator.increment-or-decrement.swift" + "name": "keyword.operator.arithmetic.unary.swift", + "match": "\\G(\\+|\\-)$" }, { - "match": ".+", - "name": "keyword.operator.custom.postfix.swift" + "name": "keyword.operator.logical.not.swift", + "match": "\\G!$" + }, + { + "name": "keyword.operator.bitwise.not.swift", + "match": "\\G~$" + }, + { + "name": "keyword.operator.custom.prefix.swift", + "match": ".+" } ] } - }, + } + }, + { "comment": "Postfix unary operator", - "match": "(?x)\n\t\t\t\t\t\t\t\t\\G\t\t\t\t\t\t\t\t\t\t# Matching from the beginning ensures\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t# that we start with operator-head\n\t\t\t\t\t\t\t\t(?&|^~?]\t\t\t\t# operator-head\n\t\t\t\t\t\t\t\t\t | [\\x{00A1}-\\x{00A7}]\n\t\t\t\t\t\t\t\t\t | [\\x{00A9}\\x{00AB}]\n\t\t\t\t\t\t\t\t\t | [\\x{00AC}\\x{00AE}]\n\t\t\t\t\t\t\t\t\t | [\\x{00B0}-\\x{00B1}\\x{00B6}\\x{00BB}\\x{00BF}\\x{00D7}\\x{00F7}]\n\t\t\t\t\t\t\t\t\t | [\\x{2016}-\\x{2017}\\x{2020}-\\x{2027}]\n\t\t\t\t\t\t\t\t\t | [\\x{2030}-\\x{203E}]\n\t\t\t\t\t\t\t\t\t | [\\x{2041}-\\x{2053}]\n\t\t\t\t\t\t\t\t\t | [\\x{2055}-\\x{205E}]\n\t\t\t\t\t\t\t\t\t | [\\x{2190}-\\x{23FF}]\n\t\t\t\t\t\t\t\t\t | [\\x{2500}-\\x{2775}]\n\t\t\t\t\t\t\t\t\t | [\\x{2794}-\\x{2BFF}]\n\t\t\t\t\t\t\t\t\t | [\\x{2E00}-\\x{2E7F}]\n\t\t\t\t\t\t\t\t\t | [\\x{3001}-\\x{3003}]\n\t\t\t\t\t\t\t\t\t | [\\x{3008}-\\x{3030}]\n\t\t\t\t\t\t\t\t \n\t\t\t\t\t\t\t\t\t | [\\x{0300}-\\x{036F}]\t\t\t\t# operator-character\n\t\t\t\t\t\t\t\t\t | [\\x{1DC0}-\\x{1DFF}]\n\t\t\t\t\t\t\t\t\t | [\\x{20D0}-\\x{20FF}]\n\t\t\t\t\t\t\t\t\t | [\\x{FE00}-\\x{FE0F}]\n\t\t\t\t\t\t\t\t\t | [\\x{FE20}-\\x{FE2F}]\n\t\t\t\t\t\t\t\t\t | [\\x{E0100}-\\x{E01EF}]\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t)++\n\t\t\t\t\t\t\t\t(?=[\\s)\\]},;:]|\\z)\n\t\t\t\t\t\t\t" - }, - { + "match": "(?x)\n\\G # Matching from the beginning ensures\n # that we start with operator-head\n(?&|^~?] # operator-head\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 | [\\x{0300}-\\x{036F}] # operator-character\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(?=[\\s)\\]},;:]|\\z)", "captures": { "0": { "patterns": [ { - "match": "\\G=$", - "name": "keyword.operator.assignment.swift" + "name": "keyword.operator.increment-or-decrement.swift", + "match": "\\G(\\+\\+|\\-\\-)$" }, { - "match": "\\G(\\+|\\-|\\*|/|%|<<|>>|&|\\^|\\||&&|\\|\\|)=$", - "name": "keyword.operator.assignment.compound.swift" + "name": "keyword.operator.increment-or-decrement.swift", + "match": "\\G!$" }, { - "match": "\\G(\\+|\\-|\\*|/)$", - "name": "keyword.operator.arithmetic.swift" - }, - { - "match": "\\G&(\\+|\\-|\\*)$", - "name": "keyword.operator.arithmetic.overflow.swift" - }, - { - "match": "\\G%$", - "name": "keyword.operator.arithmetic.remainder.swift" - }, - { - "match": "\\G(==|!=|>|<|>=|<=|~=)$", - "name": "keyword.operator.comparison.swift" - }, - { - "match": "\\G\\?\\?$", - "name": "keyword.operator.coalescing.swift" - }, - { - "match": "\\G(&&|\\|\\|)$", - "name": "keyword.operator.logical.swift" - }, - { - "match": "\\G(&|\\||\\^|<<|>>)$", - "name": "keyword.operator.bitwise.swift" - }, - { - "match": "\\G(===|!==)$", - "name": "keyword.operator.bitwise.swift" - }, - { - "match": "\\G\\?$", - "name": "keyword.operator.ternary.swift" - }, - { - "match": ".+", - "name": "keyword.operator.custom.infix.swift" + "name": "keyword.operator.custom.postfix.swift", + "match": ".+" } ] } - }, + } + }, + { "comment": "Infix operator", - "match": "(?x)\n\t\t\t\t\t\t\t\t\\G\t\t\t\t\t\t\t\t\t\t# Matching from the beginning ensures\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t# that we start with operator-head\n\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\t(?!(//|/\\*|\\*/))\n\t\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\t\t[/=\\-+!*%<>&|^~?]\t\t\t\t# operator-head\n\t\t\t\t\t\t\t\t\t | [\\x{00A1}-\\x{00A7}]\n\t\t\t\t\t\t\t\t\t | [\\x{00A9}\\x{00AB}]\n\t\t\t\t\t\t\t\t\t | [\\x{00AC}\\x{00AE}]\n\t\t\t\t\t\t\t\t\t | [\\x{00B0}-\\x{00B1}\\x{00B6}\\x{00BB}\\x{00BF}\\x{00D7}\\x{00F7}]\n\t\t\t\t\t\t\t\t\t | [\\x{2016}-\\x{2017}\\x{2020}-\\x{2027}]\n\t\t\t\t\t\t\t\t\t | [\\x{2030}-\\x{203E}]\n\t\t\t\t\t\t\t\t\t | [\\x{2041}-\\x{2053}]\n\t\t\t\t\t\t\t\t\t | [\\x{2055}-\\x{205E}]\n\t\t\t\t\t\t\t\t\t | [\\x{2190}-\\x{23FF}]\n\t\t\t\t\t\t\t\t\t | [\\x{2500}-\\x{2775}]\n\t\t\t\t\t\t\t\t\t | [\\x{2794}-\\x{2BFF}]\n\t\t\t\t\t\t\t\t\t | [\\x{2E00}-\\x{2E7F}]\n\t\t\t\t\t\t\t\t\t | [\\x{3001}-\\x{3003}]\n\t\t\t\t\t\t\t\t\t | [\\x{3008}-\\x{3030}]\n\t\t\t\t\t\t\t\t \n\t\t\t\t\t\t\t\t\t | [\\x{0300}-\\x{036F}]\t\t\t\t# operator-character\n\t\t\t\t\t\t\t\t\t | [\\x{1DC0}-\\x{1DFF}]\n\t\t\t\t\t\t\t\t\t | [\\x{20D0}-\\x{20FF}]\n\t\t\t\t\t\t\t\t\t | [\\x{FE00}-\\x{FE0F}]\n\t\t\t\t\t\t\t\t\t | [\\x{FE20}-\\x{FE2F}]\n\t\t\t\t\t\t\t\t\t | [\\x{E0100}-\\x{E01EF}]\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t)++\n\t\t\t\t\t\t\t" - }, - { + "match": "(?x)\n\\G # Matching from the beginning ensures\n # that we start with operator-head\n(\n (?!(//|/\\*|\\*/))\n (\n [/=\\-+!*%<>&|^~?] # operator-head\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 | [\\x{0300}-\\x{036F}] # operator-character\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)++", "captures": { "0": { "patterns": [ { - "match": ".+", - "name": "keyword.operator.custom.prefix.dot.swift" - } - ] - } - }, - "comment": "Dot prefix unary operator", - "match": "(?x)\n\t\t\t\t\t\t\t\t\\G\t\t\t\t\t\t\t\t\t\t# Matching from the beginning ensures\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t# that we start with operator-head\n\t\t\t\t\t\t\t\t(?<=^|[\\s(\\[{,;:])\n\t\t\t\t\t\t\t\t\\.\t\t\t\t\t\t\t\t\t\t# dot\n\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\t(?!(//|/\\*|\\*/))\n\t\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\t\t\\.\t\t\t\t\t\t\t\t# dot\n\t\t\t\t\t\t\t\t\t | [/=\\-+!*%<>&|^~?]\t\t\t\t# operator-head\n\t\t\t\t\t\t\t\t\t | [\\x{00A1}-\\x{00A7}]\n\t\t\t\t\t\t\t\t\t | [\\x{00A9}\\x{00AB}]\n\t\t\t\t\t\t\t\t\t | [\\x{00AC}\\x{00AE}]\n\t\t\t\t\t\t\t\t\t | [\\x{00B0}-\\x{00B1}\\x{00B6}\\x{00BB}\\x{00BF}\\x{00D7}\\x{00F7}]\n\t\t\t\t\t\t\t\t\t | [\\x{2016}-\\x{2017}\\x{2020}-\\x{2027}]\n\t\t\t\t\t\t\t\t\t | [\\x{2030}-\\x{203E}]\n\t\t\t\t\t\t\t\t\t | [\\x{2041}-\\x{2053}]\n\t\t\t\t\t\t\t\t\t | [\\x{2055}-\\x{205E}]\n\t\t\t\t\t\t\t\t\t | [\\x{2190}-\\x{23FF}]\n\t\t\t\t\t\t\t\t\t | [\\x{2500}-\\x{2775}]\n\t\t\t\t\t\t\t\t\t | [\\x{2794}-\\x{2BFF}]\n\t\t\t\t\t\t\t\t\t | [\\x{2E00}-\\x{2E7F}]\n\t\t\t\t\t\t\t\t\t | [\\x{3001}-\\x{3003}]\n\t\t\t\t\t\t\t\t\t | [\\x{3008}-\\x{3030}]\n\t\t\t\t\t\t\t\t \n\t\t\t\t\t\t\t\t\t | [\\x{0300}-\\x{036F}]\t\t\t\t# operator-character\n\t\t\t\t\t\t\t\t\t | [\\x{1DC0}-\\x{1DFF}]\n\t\t\t\t\t\t\t\t\t | [\\x{20D0}-\\x{20FF}]\n\t\t\t\t\t\t\t\t\t | [\\x{FE00}-\\x{FE0F}]\n\t\t\t\t\t\t\t\t\t | [\\x{FE20}-\\x{FE2F}]\n\t\t\t\t\t\t\t\t\t | [\\x{E0100}-\\x{E01EF}]\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t)++\n\t\t\t\t\t\t\t\t(?![\\s)\\]},;:]|\\z)\n\t\t\t\t\t\t\t" - }, - { - "captures": { - "0": { - "patterns": [ - { - "match": ".+", - "name": "keyword.operator.custom.postfix.dot.swift" - } - ] - } - }, - "comment": "Dot postfix unary operator", - "match": "(?x)\n\t\t\t\t\t\t\t\t\\G\t\t\t\t\t\t\t\t\t\t# Matching from the beginning ensures\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t# that we start with operator-head\n\t\t\t\t\t\t\t\t(?&|^~?]\t\t\t\t# operator-head\n\t\t\t\t\t\t\t\t\t | [\\x{00A1}-\\x{00A7}]\n\t\t\t\t\t\t\t\t\t | [\\x{00A9}\\x{00AB}]\n\t\t\t\t\t\t\t\t\t | [\\x{00AC}\\x{00AE}]\n\t\t\t\t\t\t\t\t\t | [\\x{00B0}-\\x{00B1}\\x{00B6}\\x{00BB}\\x{00BF}\\x{00D7}\\x{00F7}]\n\t\t\t\t\t\t\t\t\t | [\\x{2016}-\\x{2017}\\x{2020}-\\x{2027}]\n\t\t\t\t\t\t\t\t\t | [\\x{2030}-\\x{203E}]\n\t\t\t\t\t\t\t\t\t | [\\x{2041}-\\x{2053}]\n\t\t\t\t\t\t\t\t\t | [\\x{2055}-\\x{205E}]\n\t\t\t\t\t\t\t\t\t | [\\x{2190}-\\x{23FF}]\n\t\t\t\t\t\t\t\t\t | [\\x{2500}-\\x{2775}]\n\t\t\t\t\t\t\t\t\t | [\\x{2794}-\\x{2BFF}]\n\t\t\t\t\t\t\t\t\t | [\\x{2E00}-\\x{2E7F}]\n\t\t\t\t\t\t\t\t\t | [\\x{3001}-\\x{3003}]\n\t\t\t\t\t\t\t\t\t | [\\x{3008}-\\x{3030}]\n\t\t\t\t\t\t\t\t \n\t\t\t\t\t\t\t\t\t | [\\x{0300}-\\x{036F}]\t\t\t\t# operator-character\n\t\t\t\t\t\t\t\t\t | [\\x{1DC0}-\\x{1DFF}]\n\t\t\t\t\t\t\t\t\t | [\\x{20D0}-\\x{20FF}]\n\t\t\t\t\t\t\t\t\t | [\\x{FE00}-\\x{FE0F}]\n\t\t\t\t\t\t\t\t\t | [\\x{FE20}-\\x{FE2F}]\n\t\t\t\t\t\t\t\t\t | [\\x{E0100}-\\x{E01EF}]\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t)++\n\t\t\t\t\t\t\t\t(?=[\\s)\\]},;:]|\\z)\n\t\t\t\t\t\t\t" - }, - { - "captures": { - "0": { - "patterns": [ - { - "match": "\\G\\.\\.[.<]$", - "name": "keyword.operator.range.swift" + "name": "keyword.operator.assignment.swift", + "match": "\\G=$" }, { - "match": ".+", - "name": "keyword.operator.custom.infix.dot.swift" + "name": "keyword.operator.assignment.compound.swift", + "match": "\\G(\\+|\\-|\\*|/|%|<<|>>|&|\\^|\\||&&|\\|\\|)=$" + }, + { + "name": "keyword.operator.arithmetic.swift", + "match": "\\G(\\+|\\-|\\*|/)$" + }, + { + "name": "keyword.operator.arithmetic.overflow.swift", + "match": "\\G&(\\+|\\-|\\*)$" + }, + { + "name": "keyword.operator.arithmetic.remainder.swift", + "match": "\\G%$" + }, + { + "name": "keyword.operator.comparison.swift", + "match": "\\G(==|!=|>|<|>=|<=|~=)$" + }, + { + "name": "keyword.operator.coalescing.swift", + "match": "\\G\\?\\?$" + }, + { + "name": "keyword.operator.logical.swift", + "match": "\\G(&&|\\|\\|)$" + }, + { + "name": "keyword.operator.bitwise.swift", + "match": "\\G(&|\\||\\^|<<|>>)$" + }, + { + "name": "keyword.operator.bitwise.swift", + "match": "\\G(===|!==)$" + }, + { + "name": "keyword.operator.ternary.swift", + "match": "\\G\\?$" + }, + { + "name": "keyword.operator.custom.infix.swift", + "match": ".+" } ] } - }, + } + }, + { + "comment": "Dot prefix unary operator", + "match": "(?x)\n\\G # Matching from the beginning ensures\n # that we start with operator-head\n(?<=^|[\\s(\\[{,;:])\n\\. # dot\n(\n (?!(//|/\\*|\\*/))\n (\n \\. # dot\n | [/=\\-+!*%<>&|^~?] # operator-head\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 | [\\x{0300}-\\x{036F}] # operator-character\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(?![\\s)\\]},;:]|\\z)", + "captures": { + "0": { + "patterns": [ + { + "name": "keyword.operator.custom.prefix.dot.swift", + "match": ".+" + } + ] + } + } + }, + { + "comment": "Dot postfix unary operator", + "match": "(?x)\n\\G # Matching from the beginning ensures\n # that we start with operator-head\n(?&|^~?] # operator-head\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 | [\\x{0300}-\\x{036F}] # operator-character\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(?=[\\s)\\]},;:]|\\z)", + "captures": { + "0": { + "patterns": [ + { + "name": "keyword.operator.custom.postfix.dot.swift", + "match": ".+" + } + ] + } + } + }, + { "comment": "Dot infix operator", - "match": "(?x)\n\t\t\t\t\t\t\t\t\\G\t\t\t\t\t\t\t\t\t\t# Matching from the beginning ensures\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t# that we start with operator-head\n\t\t\t\t\t\t\t\t\\.\t\t\t\t\t\t\t\t\t\t# dot\n\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\t(?!(//|/\\*|\\*/))\n\t\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\t\t\\.\t\t\t\t\t\t\t\t# dot\n\t\t\t\t\t\t\t\t\t | [/=\\-+!*%<>&|^~?]\t\t\t\t# operator-head\n\t\t\t\t\t\t\t\t\t | [\\x{00A1}-\\x{00A7}]\n\t\t\t\t\t\t\t\t\t | [\\x{00A9}\\x{00AB}]\n\t\t\t\t\t\t\t\t\t | [\\x{00AC}\\x{00AE}]\n\t\t\t\t\t\t\t\t\t | [\\x{00B0}-\\x{00B1}\\x{00B6}\\x{00BB}\\x{00BF}\\x{00D7}\\x{00F7}]\n\t\t\t\t\t\t\t\t\t | [\\x{2016}-\\x{2017}\\x{2020}-\\x{2027}]\n\t\t\t\t\t\t\t\t\t | [\\x{2030}-\\x{203E}]\n\t\t\t\t\t\t\t\t\t | [\\x{2041}-\\x{2053}]\n\t\t\t\t\t\t\t\t\t | [\\x{2055}-\\x{205E}]\n\t\t\t\t\t\t\t\t\t | [\\x{2190}-\\x{23FF}]\n\t\t\t\t\t\t\t\t\t | [\\x{2500}-\\x{2775}]\n\t\t\t\t\t\t\t\t\t | [\\x{2794}-\\x{2BFF}]\n\t\t\t\t\t\t\t\t\t | [\\x{2E00}-\\x{2E7F}]\n\t\t\t\t\t\t\t\t\t | [\\x{3001}-\\x{3003}]\n\t\t\t\t\t\t\t\t\t | [\\x{3008}-\\x{3030}]\n\t\t\t\t\t\t\t\t \n\t\t\t\t\t\t\t\t\t | [\\x{0300}-\\x{036F}]\t\t\t\t# operator-character\n\t\t\t\t\t\t\t\t\t | [\\x{1DC0}-\\x{1DFF}]\n\t\t\t\t\t\t\t\t\t | [\\x{20D0}-\\x{20FF}]\n\t\t\t\t\t\t\t\t\t | [\\x{FE00}-\\x{FE0F}]\n\t\t\t\t\t\t\t\t\t | [\\x{FE20}-\\x{FE2F}]\n\t\t\t\t\t\t\t\t\t | [\\x{E0100}-\\x{E01EF}]\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t)++\n\t\t\t\t\t\t\t" + "match": "(?x)\n\\G # Matching from the beginning ensures\n # that we start with operator-head\n\\. # dot\n(\n (?!(//|/\\*|\\*/))\n (\n \\. # dot\n | [/=\\-+!*%<>&|^~?] # operator-head\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 | [\\x{0300}-\\x{036F}] # operator-character\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)++", + "captures": { + "0": { + "patterns": [ + { + "name": "keyword.operator.range.swift", + "match": "\\G\\.\\.[.<]$" + }, + { + "name": "keyword.operator.custom.infix.dot.swift", + "match": ".+" + } + ] + } + } } ] }, { - "match": ":", - "name": "keyword.operator.ternary.swift" + "name": "keyword.operator.ternary.swift", + "match": ":" } ] },