Skip to content

Commit

Permalink
Swift: Added support for new Swift 5.5 keywords (#2988)
Browse files Browse the repository at this point in the history
  • Loading branch information
AvdLee authored Jul 5, 2021
1 parent ea77675 commit bb93fac
Show file tree
Hide file tree
Showing 3 changed files with 10 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 @@ -16,7 +16,7 @@ Prism.languages.swift = Prism.languages.extend('clike', {
}
}
},
'keyword': /\b(?:as|associativity|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|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/,
'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/,
Expand Down
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.

8 changes: 8 additions & 0 deletions tests/languages/swift/keyword_feature.test
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
actor
as
associativity
async
await
break
case
catch
Expand Down Expand Up @@ -36,6 +39,7 @@ let
mutating
new;
none
nonisolated
nonmutating
operator
optional
Expand Down Expand Up @@ -81,8 +85,11 @@ __LINE__
----------------------------------------------------

[
["keyword", "actor"],
["keyword", "as"],
["keyword", "associativity"],
["keyword", "async"],
["keyword", "await"],
["keyword", "break"],
["keyword", "case"],
["keyword", "catch"],
Expand Down Expand Up @@ -119,6 +126,7 @@ __LINE__
["keyword", "mutating"],
["keyword", "new"], ["punctuation", ";"],
["keyword", "none"],
["keyword", "nonisolated"],
["keyword", "nonmutating"],
["keyword", "operator"],
["keyword", "optional"],
Expand Down

0 comments on commit bb93fac

Please sign in to comment.