Don’t treat .init() as an enum
This change adds a special condition not to treat `.init()` as an enum (or any other kind of dot access), just like we previously had for `self`.
This commit is contained in:
parent
b72ba08cfc
commit
87437d7425
@ -286,7 +286,7 @@ private extension SwiftGrammar {
|
||||
return false
|
||||
}
|
||||
|
||||
guard segment.tokens.current != "self" else {
|
||||
guard !segment.tokens.current.isAny(of: "self", "init") else {
|
||||
return false
|
||||
}
|
||||
|
||||
|
@ -55,6 +55,24 @@ final class FunctionCallTests: SyntaxHighlighterTestCase {
|
||||
])
|
||||
}
|
||||
|
||||
func testDotSyntaxInitializerCall() {
|
||||
let components = highlighter.highlight("let string: String = .init()")
|
||||
|
||||
XCTAssertEqual(components, [
|
||||
.token("let", .keyword),
|
||||
.whitespace(" "),
|
||||
.plainText("string:"),
|
||||
.whitespace(" "),
|
||||
.token("String", .type),
|
||||
.whitespace(" "),
|
||||
.plainText("="),
|
||||
.whitespace(" "),
|
||||
.plainText("."),
|
||||
.token("init", .keyword),
|
||||
.plainText("()")
|
||||
])
|
||||
}
|
||||
|
||||
func testAccessingPropertyAfterFunctionCallWithoutArguments() {
|
||||
let components = highlighter.highlight("call().property")
|
||||
|
||||
@ -112,6 +130,7 @@ extension FunctionCallTests {
|
||||
("testFunctionCallWithIntegers", testFunctionCallWithIntegers),
|
||||
("testImplicitInitializerCall", testImplicitInitializerCall),
|
||||
("testExplicitInitializerCall", testExplicitInitializerCall),
|
||||
("testDotSyntaxInitializerCall", testDotSyntaxInitializerCall),
|
||||
("testAccessingPropertyAfterFunctionCallWithoutArguments", testAccessingPropertyAfterFunctionCallWithoutArguments),
|
||||
("testAccessingPropertyAfterFunctionCallWithArguments", testAccessingPropertyAfterFunctionCallWithArguments),
|
||||
("testCallingStaticMethodOnGenericType", testCallingStaticMethodOnGenericType),
|
||||
|
Loading…
x
Reference in New Issue
Block a user