Adding support for rethrows keyword (#56)
This commit is contained in:
parent
9485a4e762
commit
60c06cc385
@ -41,7 +41,7 @@ private extension SwiftGrammar {
|
|||||||
"final", "class", "struct", "enum", "protocol",
|
"final", "class", "struct", "enum", "protocol",
|
||||||
"extension", "let", "var", "func", "typealias",
|
"extension", "let", "var", "func", "typealias",
|
||||||
"init", "guard", "if", "else", "return", "get",
|
"init", "guard", "if", "else", "return", "get",
|
||||||
"throw", "throws", "for", "in", "open", "weak",
|
"throw", "throws", "rethrows", "for", "in", "open", "weak",
|
||||||
"import", "mutating", "nonmutating", "associatedtype",
|
"import", "mutating", "nonmutating", "associatedtype",
|
||||||
"case", "switch", "static", "do", "try", "catch", "as",
|
"case", "switch", "static", "do", "try", "catch", "as",
|
||||||
"super", "self", "set", "true", "false", "nil",
|
"super", "self", "set", "true", "false", "nil",
|
||||||
|
@ -635,7 +635,7 @@ final class DeclarationTests: SyntaxHighlighterTestCase {
|
|||||||
.token("inout", .keyword),
|
.token("inout", .keyword),
|
||||||
.whitespace(" "),
|
.whitespace(" "),
|
||||||
.token("Int", .type),
|
.token("Int", .type),
|
||||||
.plainText(")"),
|
.plainText(")"),
|
||||||
.whitespace(" "),
|
.whitespace(" "),
|
||||||
.plainText("{"),
|
.plainText("{"),
|
||||||
.whitespace(" "),
|
.whitespace(" "),
|
||||||
@ -750,6 +750,40 @@ final class DeclarationTests: SyntaxHighlighterTestCase {
|
|||||||
])
|
])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func testRethrowingFunctionDeclaration() {
|
||||||
|
let components = highlighter.highlight("""
|
||||||
|
func map<T>(_ transform: (Element) throws -> T) rethrows -> [T]
|
||||||
|
""")
|
||||||
|
|
||||||
|
XCTAssertEqual(components, [
|
||||||
|
.token("func", .keyword),
|
||||||
|
.whitespace(" "),
|
||||||
|
.plainText("map<T>("),
|
||||||
|
.token("_", .keyword),
|
||||||
|
.whitespace(" "),
|
||||||
|
.plainText("transform:"),
|
||||||
|
.whitespace(" "),
|
||||||
|
.plainText("("),
|
||||||
|
.token("Element", .type),
|
||||||
|
.plainText(")"),
|
||||||
|
.whitespace(" "),
|
||||||
|
.token("throws", .keyword),
|
||||||
|
.whitespace(" "),
|
||||||
|
.plainText("->"),
|
||||||
|
.whitespace(" "),
|
||||||
|
.token("T", .type),
|
||||||
|
.plainText(")"),
|
||||||
|
.whitespace(" "),
|
||||||
|
.token("rethrows", .keyword),
|
||||||
|
.whitespace(" "),
|
||||||
|
.plainText("->"),
|
||||||
|
.whitespace(" "),
|
||||||
|
.plainText("["),
|
||||||
|
.token("T", .type),
|
||||||
|
.plainText("]")
|
||||||
|
])
|
||||||
|
}
|
||||||
|
|
||||||
func testIndirectEnumDeclaration() {
|
func testIndirectEnumDeclaration() {
|
||||||
let components = highlighter.highlight("""
|
let components = highlighter.highlight("""
|
||||||
indirect enum Content {
|
indirect enum Content {
|
||||||
@ -822,6 +856,7 @@ extension DeclarationTests {
|
|||||||
("testFunctionDeclarationWithEscapedKeywordAsName", testFunctionDeclarationWithEscapedKeywordAsName),
|
("testFunctionDeclarationWithEscapedKeywordAsName", testFunctionDeclarationWithEscapedKeywordAsName),
|
||||||
("testFunctionDeclarationWithPreProcessors", testFunctionDeclarationWithPreProcessors),
|
("testFunctionDeclarationWithPreProcessors", testFunctionDeclarationWithPreProcessors),
|
||||||
("testNonMutatingFunction", testNonMutatingFunction),
|
("testNonMutatingFunction", testNonMutatingFunction),
|
||||||
|
("testRethrowingFunctionDeclaration", testRethrowingFunctionDeclaration),
|
||||||
("testIndirectEnumDeclaration", testIndirectEnumDeclaration)
|
("testIndirectEnumDeclaration", testIndirectEnumDeclaration)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user