Merge pull request #42 from JohnSundell/deinit

Support the deinit keyword
This commit is contained in:
John Sundell 2019-03-08 22:04:19 +01:00 committed by GitHub
commit 88650438c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 1 deletions

View File

@ -47,7 +47,8 @@ private extension SwiftGrammar {
"override", "where", "_", "default", "break",
"#selector", "required", "willSet", "didSet",
"lazy", "subscript", "defer", "inout", "while",
"continue", "fallthrough", "repeat", "indirect"
"continue", "fallthrough", "repeat", "indirect",
"deinit"
] as Set<String>).union(accessControlKeywords)
static let accessControlKeywords: Set<String> = [

View File

@ -221,6 +221,24 @@ final class DeclarationTests: SyntaxHighlighterTestCase {
])
}
func testClassDeclarationWithDeinit() {
let components = highlighter.highlight("class Foo { deinit {} }")
XCTAssertEqual(components, [
.token("class", .keyword),
.whitespace(" "),
.plainText("Foo"),
.whitespace(" "),
.plainText("{"),
.whitespace(" "),
.token("deinit", .keyword),
.whitespace(" "),
.plainText("{}"),
.whitespace(" "),
.plainText("}")
])
}
func testClassDeclarationWithMultipleProtocolConformances() {
let components = highlighter.highlight("class MyClass: ProtocolA, ProtocolB {}")
@ -690,6 +708,7 @@ extension DeclarationTests {
("testGenericStructDeclaration", testGenericStructDeclaration),
("testClassDeclaration", testClassDeclaration),
("testCompactClassDeclarationWithInitializer", testCompactClassDeclarationWithInitializer),
("testClassDeclarationWithDeinit", testClassDeclarationWithDeinit),
("testClassDeclarationWithMultipleProtocolConformances", testClassDeclarationWithMultipleProtocolConformances),
("testSubclassDeclaration", testSubclassDeclaration),
("testProtocolDeclaration", testProtocolDeclaration),