Correctly highlight subclasses inheriting from a generic superclass (#108)
This change fixes syntax highlighting in situations when a subclass is inheriting from a superclass that’s generic.
This commit is contained in:
parent
3e400c0874
commit
ca9a1b7bff
|
@ -419,7 +419,7 @@ private extension SwiftGrammar {
|
|||
}
|
||||
|
||||
// Handling generic lists for parameters, rather than declarations
|
||||
if foundOpeningBracket && token == ":" {
|
||||
if foundOpeningBracket && token.isAny(of: ":", ">:") {
|
||||
return true
|
||||
}
|
||||
|
||||
|
|
|
@ -368,6 +368,23 @@ final class DeclarationTests: SyntaxHighlighterTestCase {
|
|||
])
|
||||
}
|
||||
|
||||
func testGenericSubclassDeclaration() {
|
||||
let components = highlighter.highlight("class Promise<Value>: Future<Value> {}")
|
||||
|
||||
XCTAssertEqual(components, [
|
||||
.token("class", .keyword),
|
||||
.whitespace(" "),
|
||||
.plainText("Promise<Value>:"),
|
||||
.whitespace(" "),
|
||||
.token("Future", .type),
|
||||
.plainText("<"),
|
||||
.token("Value", .type),
|
||||
.plainText(">"),
|
||||
.whitespace(" "),
|
||||
.plainText("{}")
|
||||
])
|
||||
}
|
||||
|
||||
func testProtocolDeclaration() {
|
||||
let components = highlighter.highlight("""
|
||||
protocol Hello {
|
||||
|
@ -1161,6 +1178,7 @@ extension DeclarationTests {
|
|||
("testClassDeclarationWithDeinit", testClassDeclarationWithDeinit),
|
||||
("testClassDeclarationWithMultipleProtocolConformances", testClassDeclarationWithMultipleProtocolConformances),
|
||||
("testSubclassDeclaration", testSubclassDeclaration),
|
||||
("testGenericSubclassDeclaration", testGenericSubclassDeclaration),
|
||||
("testProtocolDeclaration", testProtocolDeclaration),
|
||||
("testProtocolDeclarationWithAssociatedTypes", testProtocolDeclarationWithAssociatedTypes),
|
||||
("testExtensionDeclaration", testExtensionDeclaration),
|
||||
|
|
Loading…
Reference in New Issue