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 {
130
130
// Consume the element, stopping at the first space.
131
131
return try consume ( using: { consumer in
132
132
switch consumer. peek {
133
- case let c where c . isSpaceOrTab:
133
+ case \ . isSpaceOrTab:
134
134
return false
135
135
case " \" " :
136
136
try consumer. consumeStringLiteral ( )
Original file line number Diff line number Diff line change @@ -46,13 +46,11 @@ fileprivate extension ByteScanner {
46
46
// Ninja uses '$' as the escape character.
47
47
if c == " $ " {
48
48
switch consumer. peek ( ahead: 1 ) {
49
- case let c? where c. isSpaceOrTab:
50
- fallthrough
51
- case " $ " , " : " :
49
+ case " $ " , " : " , \. isSpaceOrTab:
52
50
// Skip the '$' and take the unescaped character.
53
51
consumer. skip ( )
54
52
return consumer. eat ( )
55
- case let c ? where c . isNewline:
53
+ case \ . isNewline:
56
54
// This is a line continuation, skip the newline, and strip any
57
55
// following space.
58
56
consumer. skip ( untilAfter: \. isNewline)
@@ -160,7 +158,7 @@ extension NinjaParser.Lexer {
160
158
private mutating func consumeElement( ) -> String ? {
161
159
input. consumeUnescaped ( while: { char in
162
160
switch char {
163
- case let c where c . isNinjaOperator || c . isSpaceTabOrNewline:
161
+ case \ . isNinjaOperator, \ . isSpaceTabOrNewline:
164
162
false
165
163
default :
166
164
true
Original file line number Diff line number Diff line change @@ -29,18 +29,6 @@ extension Byte: Comparable {
29
29
}
30
30
}
31
31
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
-
44
32
extension Byte {
45
33
var isSpaceOrTab : Bool {
46
34
self == " " || self == " \t "
Original file line number Diff line number Diff line change @@ -132,3 +132,12 @@ extension String {
132
132
}
133
133
}
134
134
}
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