Skip to content

Commit

Permalink
Swift: Added support for @propertyWrapper, @MainActor, and `@glob…
Browse files Browse the repository at this point in the history
…alActor` (#3009)
  • Loading branch information
AvdLee authored Jul 26, 2021
1 parent 4492b62 commit ce5e0f0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion components/prism-swift.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Prism.languages.swift = Prism.languages.extend('clike', {
'keyword': /\b(?:actor|as|associativity|async|await|break|case|catch|class|continue|convenience|default|defer|deinit|didSet|do|dynamic(?:Type)?|else|enum|extension|fallthrough|final|for|func|get|guard|if|import|in|infix|init|inout|internal|is|lazy|left|let|mutating|new|none|nonisolated|nonmutating|operator|optional|override|postfix|precedence|prefix|private|protocol|public|repeat|required|rethrows|return|right|safe|self|Self|set|some|static|struct|subscript|super|switch|throws?|try|Type|typealias|unowned|unsafe|var|weak|where|while|willSet|__(?:COLUMN__|FILE__|FUNCTION__|LINE__))\b/,
'number': /\b(?:[\d_]+(?:\.[\de_]+)?|0x[a-f0-9_]+(?:\.[a-f0-9p_]+)?|0b[01_]+|0o[0-7_]+)\b/i,
'constant': /\b(?:nil|[A-Z_]{2,}|k[A-Z][A-Za-z_]+)\b/,
'atrule': /@\b(?:IB(?:Outlet|Designable|Action|Inspectable)|class_protocol|exported|noreturn|NS(?:Copying|Managed)|objc|UIApplicationMain|auto_closure)\b/,
'atrule': /@\b(?:IB(?:Outlet|Designable|Action|Inspectable)|class_protocol|exported|globalActor|MainActor|noreturn|NS(?:Copying|Managed)|objc|propertyWrapper|UIApplicationMain|auto_closure)\b/,
'builtin': /\b(?:[A-Z]\S+|abs|advance|alignof(?:Value)?|assert|contains|count(?:Elements)?|debugPrint(?:ln)?|distance|drop(?:First|Last)|dump|enumerate|equal|filter|find|first|getVaList|indices|isEmpty|join|last|lexicographicalCompare|map|max(?:Element)?|min(?:Element)?|numericCast|overlaps|partition|print(?:ln)?|reduce|reflect|reverse|sizeof(?:Value)?|sort(?:ed)?|split|startsWith|stride(?:of(?:Value)?)?|suffix|swap|toDebugString|toString|transcode|underestimateCount|unsafeBitCast|with(?:ExtendedLifetime|Unsafe(?:MutablePointers?|Pointers?)|VaList))\b/
});
Prism.languages.swift['string'].inside['interpolation'].inside.rest = Prism.languages.swift;
2 changes: 1 addition & 1 deletion components/prism-swift.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions tests/languages/swift/atrule_feature.test
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@
@IBInspectable
@class_protocol
@exported
@globalActor
@MainActor
@noreturn
@NSCopying
@NSManaged
@objc
@propertyWrapper
@UIApplicationMain
@auto_closure

Expand All @@ -20,10 +23,13 @@
["atrule", "@IBInspectable"],
["atrule", "@class_protocol"],
["atrule", "@exported"],
["atrule", "@globalActor"],
["atrule", "@MainActor"],
["atrule", "@noreturn"],
["atrule", "@NSCopying"],
["atrule", "@NSManaged"],
["atrule", "@objc"],
["atrule", "@propertyWrapper"],
["atrule", "@UIApplicationMain"],
["atrule", "@auto_closure"]
]
Expand Down

0 comments on commit ce5e0f0

Please sign in to comment.