Skip to content

Commit

Permalink
Add support for the 'any' keyword (JohnSundell#129)
Browse files Browse the repository at this point in the history
The newly added `any` keyword is now correctly highlighted.
  • Loading branch information
JohnSundell authored Jun 8, 2022
1 parent c30a827 commit e92d451
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Sources/Splash/Grammar/SwiftGrammar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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> = [
Expand Down
15 changes: 15 additions & 0 deletions Tests/SplashTests/Tests/DeclarationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 }")

Expand Down

0 comments on commit e92d451

Please sign in to comment.