Add support for the 'any' keyword (#129)

The newly added `any` keyword is now correctly highlighted.
This commit is contained in:
John Sundell 2022-06-08 21:50:21 +02:00 committed by GitHub
parent c30a8277f7
commit e92d451f82
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 1 deletions

View File

@ -82,7 +82,7 @@ private extension SwiftGrammar {
"continue", "fallthrough", "repeat", "indirect",
"deinit", "is", "#file", "#line", "#function",
"dynamic", "some", "#available", "convenience", "unowned",
"async", "await", "actor"
"async", "await", "actor", "any"
] as Set<String>).union(accessControlKeywords)
static let accessControlKeywords: Set<String> = [

View File

@ -1104,6 +1104,21 @@ final class DeclarationTests: SyntaxHighlighterTestCase {
])
}
func testFunctionDeclarationWithAnyParameter() {
let components = highlighter.highlight("func process(value: any Value)")
XCTAssertEqual(components, [
.token("func", .keyword),
.whitespace(" "),
.plainText("process(value:"),
.whitespace(" "),
.token("any", .keyword),
.whitespace(" "),
.token("Value", .type),
.plainText(")")
])
}
func testPrefixFunctionDeclaration() {
let components = highlighter.highlight("prefix func !(rhs: Bool) -> Bool { !rhs }")