Correctly highlight properties after function calls
This patch fixes highlighting in the following scenarios: ``` call().property call(argument).property ```
This commit is contained in:
parent
8645db8de0
commit
896a56b682
@ -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
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
guard segment.tokens.previous.isAny(of: ".", "?.") else {
|
guard segment.tokens.previous.isAny(of: ".", "?.", "().", ").") else {
|
||||||
return false
|
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() {
|
func testAllTestsRunOnLinux() {
|
||||||
XCTAssertTrue(TestCaseVerifier.verifyLinuxTests((type(of: self)).allTests))
|
XCTAssertTrue(TestCaseVerifier.verifyLinuxTests((type(of: self)).allTests))
|
||||||
}
|
}
|
||||||
@ -65,7 +85,9 @@ extension FunctionCallTests {
|
|||||||
return [
|
return [
|
||||||
("testFunctionCallWithIntegers", testFunctionCallWithIntegers),
|
("testFunctionCallWithIntegers", testFunctionCallWithIntegers),
|
||||||
("testImplicitInitializerCall", testImplicitInitializerCall),
|
("testImplicitInitializerCall", testImplicitInitializerCall),
|
||||||
("testExplicitInitializerCall", testExplicitInitializerCall)
|
("testExplicitInitializerCall", testExplicitInitializerCall),
|
||||||
|
("testAccessingPropertyAfterFunctionCallWithoutArguments", testAccessingPropertyAfterFunctionCallWithoutArguments),
|
||||||
|
("testAccessingPropertyAfterFunctionCallWithArguments", testAccessingPropertyAfterFunctionCallWithArguments)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user