Correctly highlight projected property wrapper values (#114)

Such as when passing a property wrapper using `self.$value`.
This commit is contained in:
John Sundell 2020-06-28 13:41:09 +02:00 committed by GitHub
parent 73a4cf178b
commit bda4fe71b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 2 deletions

View File

@ -625,6 +625,6 @@ private extension Segment {
return false
}
return firstCharacter == "_" || firstCharacter.isLetter
return firstCharacter == "_" || firstCharacter == "$" || firstCharacter.isLetter
}
}

View File

@ -183,6 +183,19 @@ final class FunctionCallTests: SyntaxHighlighterTestCase {
])
}
func testCallingFunctionWithProjectedPropertyWrapperValue() {
let components = highlighter.highlight("call(self.$value)")
XCTAssertEqual(components, [
.token("call", .call),
.plainText("("),
.token("self", .keyword),
.plainText("."),
.token("$value", .property),
.plainText(")")
])
}
func testAllTestsRunOnLinux() {
XCTAssertTrue(TestCaseVerifier.verifyLinuxTests((type(of: self)).allTests))
}
@ -203,7 +216,8 @@ extension FunctionCallTests {
("testPassingBoolToUnnamedArgument", testPassingBoolToUnnamedArgument),
("testIndentedFunctionCalls", testIndentedFunctionCalls),
("testXCTAssertCalls", testXCTAssertCalls),
("testUsingTryKeywordWithinFunctionCall", testUsingTryKeywordWithinFunctionCall)
("testUsingTryKeywordWithinFunctionCall", testUsingTryKeywordWithinFunctionCall),
("testCallingFunctionWithProjectedPropertyWrapperValue", testCallingFunctionWithProjectedPropertyWrapperValue)
]
}
}