Merge pull request #10 from JohnSundell/enum-subscripting
Highlight enums used as subscripting keys
This commit is contained in:
commit
fd160ba1ef
@ -262,7 +262,7 @@ private extension SwiftGrammar {
|
||||
var tokenType: TokenType { return .dotAccess }
|
||||
|
||||
func matches(_ segment: Segment) -> Bool {
|
||||
guard segment.tokens.previous.isAny(of: ".", "(.") else {
|
||||
guard segment.tokens.previous.isAny(of: ".", "(.", "[.") else {
|
||||
return false
|
||||
}
|
||||
|
||||
|
@ -48,6 +48,16 @@ final class EnumTests: SyntaxHighlighterTestCase {
|
||||
])
|
||||
}
|
||||
|
||||
func testUsingEnumInSubscript() {
|
||||
let components = highlighter.highlight("dictionary[.key]")
|
||||
|
||||
XCTAssertEqual(components, [
|
||||
.plainText("dictionary[."),
|
||||
.token("key", .dotAccess),
|
||||
.plainText("]")
|
||||
])
|
||||
}
|
||||
|
||||
func testAllTestsRunOnLinux() {
|
||||
XCTAssertTrue(TestCaseVerifier.verifyLinuxTests((type(of: self)).allTests))
|
||||
}
|
||||
@ -58,7 +68,8 @@ extension EnumTests {
|
||||
return [
|
||||
("testEnumDotSyntaxInAssignment", testEnumDotSyntaxInAssignment),
|
||||
("testEnumDotSyntaxAsArgument", testEnumDotSyntaxAsArgument),
|
||||
("testEnumDotSyntaxWithAssociatedValue", testEnumDotSyntaxWithAssociatedValue)
|
||||
("testEnumDotSyntaxWithAssociatedValue", testEnumDotSyntaxWithAssociatedValue),
|
||||
("testUsingEnumInSubscript", testUsingEnumInSubscript)
|
||||
]
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user