Correctly highlight enum cases called “some” (#100)
Was previously highlighted as a keyword.
This commit is contained in:
parent
2d55b33529
commit
3b546b7dd0
|
@ -307,6 +307,12 @@ private extension SwiftGrammar {
|
|||
return true
|
||||
}
|
||||
|
||||
if segment.tokens.current == "some" {
|
||||
guard segment.tokens.previous != "case" else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
if segment.tokens.next == ":" {
|
||||
// Nil pattern matching inside of a switch statement case
|
||||
if segment.tokens.current == "nil" {
|
||||
|
|
|
@ -1023,6 +1023,26 @@ final class DeclarationTests: SyntaxHighlighterTestCase {
|
|||
])
|
||||
}
|
||||
|
||||
func testEnumDeclarationWithSomeCase() {
|
||||
let components = highlighter.highlight("""
|
||||
enum MyEnum { case some }
|
||||
""")
|
||||
|
||||
XCTAssertEqual(components, [
|
||||
.token("enum", .keyword),
|
||||
.whitespace(" "),
|
||||
.plainText("MyEnum"),
|
||||
.whitespace(" "),
|
||||
.plainText("{"),
|
||||
.whitespace(" "),
|
||||
.token("case", .keyword),
|
||||
.whitespace(" "),
|
||||
.plainText("some"),
|
||||
.whitespace(" "),
|
||||
.plainText("}")
|
||||
])
|
||||
}
|
||||
|
||||
func testIndirectEnumDeclaration() {
|
||||
let components = highlighter.highlight("""
|
||||
indirect enum Content {
|
||||
|
@ -1135,6 +1155,7 @@ extension DeclarationTests {
|
|||
("testRethrowingFunctionDeclaration", testRethrowingFunctionDeclaration),
|
||||
("testFunctionDeclarationWithOpaqueReturnType", testFunctionDeclarationWithOpaqueReturnType),
|
||||
("testPrefixFunctionDeclaration", testPrefixFunctionDeclaration),
|
||||
("testEnumDeclarationWithSomeCase", testEnumDeclarationWithSomeCase),
|
||||
("testIndirectEnumDeclaration", testIndirectEnumDeclaration),
|
||||
("testWrappedPropertyDeclarations", testWrappedPropertyDeclarations)
|
||||
]
|
||||
|
|
Loading…
Reference in New Issue