File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed
Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -287,6 +287,10 @@ private extension SwiftGrammar {
287287 var tokenType : TokenType { return . keyword }
288288
289289 func matches( _ segment: Segment ) -> Bool {
290+ if segment. tokens. current == " prefix " && segment. tokens. next == " func " {
291+ return true
292+ }
293+
290294 if segment. tokens. next == " : " {
291295 // Nil pattern matching inside of a switch statement case
292296 if segment. tokens. current == " nil " {
Original file line number Diff line number Diff line change @@ -955,6 +955,31 @@ final class DeclarationTests: SyntaxHighlighterTestCase {
955955 ] )
956956 }
957957
958+ func testPrefixFunctionDeclaration( ) {
959+ let components = highlighter. highlight ( " prefix func !(rhs: Bool) -> Bool { !rhs } " )
960+
961+ XCTAssertEqual ( components, [
962+ . token( " prefix " , . keyword) ,
963+ . whitespace( " " ) ,
964+ . token( " func " , . keyword) ,
965+ . whitespace( " " ) ,
966+ . plainText( " !(rhs: " ) ,
967+ . whitespace( " " ) ,
968+ . token( " Bool " , . type) ,
969+ . plainText( " ) " ) ,
970+ . whitespace( " " ) ,
971+ . plainText( " -> " ) ,
972+ . whitespace( " " ) ,
973+ . token( " Bool " , . type) ,
974+ . whitespace( " " ) ,
975+ . plainText( " { " ) ,
976+ . whitespace( " " ) ,
977+ . plainText( " !rhs " ) ,
978+ . whitespace( " " ) ,
979+ . plainText( " } " )
980+ ] )
981+ }
982+
958983 func testIndirectEnumDeclaration( ) {
959984 let components = highlighter. highlight ( """
960985 indirect enum Content {
@@ -1064,6 +1089,7 @@ extension DeclarationTests {
10641089 ( " testNonMutatingFunction " , testNonMutatingFunction) ,
10651090 ( " testRethrowingFunctionDeclaration " , testRethrowingFunctionDeclaration) ,
10661091 ( " testFunctionDeclarationWithOpaqueReturnType " , testFunctionDeclarationWithOpaqueReturnType) ,
1092+ ( " testPrefixFunctionDeclaration " , testPrefixFunctionDeclaration) ,
10671093 ( " testIndirectEnumDeclaration " , testIndirectEnumDeclaration) ,
10681094 ( " testWrappedPropertyDeclarations " , testWrappedPropertyDeclarations)
10691095 ]
You can’t perform that action at this time.
0 commit comments