Merge pull request #1 from JohnSundell/function-call-property-fix
Correctly highlight properties after function calls
This commit is contained in:
commit
54598263bb
@ -193,7 +193,7 @@ private extension SwiftGrammar {
|
||||
}
|
||||
}
|
||||
|
||||
return segment.tokens.next.isAny(of: "(", "()", "())", "(.", "({")
|
||||
return segment.tokens.next.isAny(of: "(", "()", "())", "(.", "({", "().")
|
||||
}
|
||||
}
|
||||
|
||||
@ -268,7 +268,7 @@ private extension SwiftGrammar {
|
||||
return false
|
||||
}
|
||||
|
||||
guard segment.tokens.previous.isAny(of: ".", "?.") else {
|
||||
guard segment.tokens.previous.isAny(of: ".", "?.", "().", ").") else {
|
||||
return false
|
||||
}
|
||||
|
||||
|
@ -55,6 +55,26 @@ final class FunctionCallTests: SyntaxHighlighterTestCase {
|
||||
])
|
||||
}
|
||||
|
||||
func testAccessingPropertyAfterFunctionCallWithoutArguments() {
|
||||
let components = highlighter.highlight("call().property")
|
||||
|
||||
XCTAssertEqual(components, [
|
||||
.token("call", .call),
|
||||
.plainText("()."),
|
||||
.token("property", .property)
|
||||
])
|
||||
}
|
||||
|
||||
func testAccessingPropertyAfterFunctionCallWithArguments() {
|
||||
let components = highlighter.highlight("call(argument).property")
|
||||
|
||||
XCTAssertEqual(components, [
|
||||
.token("call", .call),
|
||||
.plainText("(argument)."),
|
||||
.token("property", .property)
|
||||
])
|
||||
}
|
||||
|
||||
func testAllTestsRunOnLinux() {
|
||||
XCTAssertTrue(TestCaseVerifier.verifyLinuxTests((type(of: self)).allTests))
|
||||
}
|
||||
@ -65,7 +85,9 @@ extension FunctionCallTests {
|
||||
return [
|
||||
("testFunctionCallWithIntegers", testFunctionCallWithIntegers),
|
||||
("testImplicitInitializerCall", testImplicitInitializerCall),
|
||||
("testExplicitInitializerCall", testExplicitInitializerCall)
|
||||
("testExplicitInitializerCall", testExplicitInitializerCall),
|
||||
("testAccessingPropertyAfterFunctionCallWithoutArguments", testAccessingPropertyAfterFunctionCallWithoutArguments),
|
||||
("testAccessingPropertyAfterFunctionCallWithArguments", testAccessingPropertyAfterFunctionCallWithArguments)
|
||||
]
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user