Merge pull request #35 from JohnSundell/init-dot-syntax
Don’t treat .init() as an enum
This commit is contained in:
commit
50a4c6a15e
@ -286,7 +286,7 @@ private extension SwiftGrammar {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
guard segment.tokens.current != "self" else {
|
guard !segment.tokens.current.isAny(of: "self", "init") else {
|
||||||
return false
|
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() {
|
func testAccessingPropertyAfterFunctionCallWithoutArguments() {
|
||||||
let components = highlighter.highlight("call().property")
|
let components = highlighter.highlight("call().property")
|
||||||
|
|
||||||
@ -112,6 +130,7 @@ extension FunctionCallTests {
|
|||||||
("testFunctionCallWithIntegers", testFunctionCallWithIntegers),
|
("testFunctionCallWithIntegers", testFunctionCallWithIntegers),
|
||||||
("testImplicitInitializerCall", testImplicitInitializerCall),
|
("testImplicitInitializerCall", testImplicitInitializerCall),
|
||||||
("testExplicitInitializerCall", testExplicitInitializerCall),
|
("testExplicitInitializerCall", testExplicitInitializerCall),
|
||||||
|
("testDotSyntaxInitializerCall", testDotSyntaxInitializerCall),
|
||||||
("testAccessingPropertyAfterFunctionCallWithoutArguments", testAccessingPropertyAfterFunctionCallWithoutArguments),
|
("testAccessingPropertyAfterFunctionCallWithoutArguments", testAccessingPropertyAfterFunctionCallWithoutArguments),
|
||||||
("testAccessingPropertyAfterFunctionCallWithArguments", testAccessingPropertyAfterFunctionCallWithArguments),
|
("testAccessingPropertyAfterFunctionCallWithArguments", testAccessingPropertyAfterFunctionCallWithArguments),
|
||||||
("testCallingStaticMethodOnGenericType", testCallingStaticMethodOnGenericType),
|
("testCallingStaticMethodOnGenericType", testCallingStaticMethodOnGenericType),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user