File tree Expand file tree Collapse file tree 4 files changed +13
-18
lines changed
utils/swift-xcodegen/Sources/SwiftXcodeGen Expand file tree Collapse file tree 4 files changed +13
-18
lines changed Original file line number Diff line number Diff line change @@ -130,7 +130,7 @@ fileprivate extension ByteScanner {
130130 // Consume the element, stopping at the first space.
131131 return try consume ( using: { consumer in
132132 switch consumer. peek {
133- case let c where c . isSpaceOrTab:
133+ case \ . isSpaceOrTab:
134134 return false
135135 case " \" " :
136136 try consumer. consumeStringLiteral ( )
Original file line number Diff line number Diff line change @@ -46,13 +46,11 @@ fileprivate extension ByteScanner {
4646 // Ninja uses '$' as the escape character.
4747 if c == " $ " {
4848 switch consumer. peek ( ahead: 1 ) {
49- case let c? where c. isSpaceOrTab:
50- fallthrough
51- case " $ " , " : " :
49+ case " $ " , " : " , \. isSpaceOrTab:
5250 // Skip the '$' and take the unescaped character.
5351 consumer. skip ( )
5452 return consumer. eat ( )
55- case let c ? where c . isNewline:
53+ case \ . isNewline:
5654 // This is a line continuation, skip the newline, and strip any
5755 // following space.
5856 consumer. skip ( untilAfter: \. isNewline)
@@ -160,7 +158,7 @@ extension NinjaParser.Lexer {
160158 private mutating func consumeElement( ) -> String ? {
161159 input. consumeUnescaped ( while: { char in
162160 switch char {
163- case let c where c . isNinjaOperator || c . isSpaceTabOrNewline:
161+ case \ . isNinjaOperator, \ . isSpaceTabOrNewline:
164162 false
165163 default :
166164 true
Original file line number Diff line number Diff line change @@ -29,18 +29,6 @@ extension Byte: Comparable {
2929 }
3030}
3131
32- extension Byte ? {
33- var isSpaceOrTab : Bool {
34- self ? . isSpaceOrTab == true
35- }
36- var isNewline : Bool {
37- self ? . isNewline == true
38- }
39- var isSpaceTabOrNewline : Bool {
40- self ? . isSpaceTabOrNewline == true
41- }
42- }
43-
4432extension Byte {
4533 var isSpaceOrTab : Bool {
4634 self == " " || self == " \t "
Original file line number Diff line number Diff line change @@ -132,3 +132,12 @@ extension String {
132132 }
133133 }
134134}
135+
136+ /// Pattern match by `is` property. E.g. `case \.isNewline: ...`
137+ func ~= < T> ( keyPath: KeyPath < T , Bool > , subject: T ) -> Bool {
138+ return subject [ keyPath: keyPath]
139+ }
140+
141+ func ~= < T> ( keyPath: KeyPath < T , Bool > , subject: T ? ) -> Bool {
142+ return subject ? [ keyPath: keyPath] == true
143+ }
You can’t perform that action at this time.
0 commit comments