Skip to content

Commit b37d720

Browse files
committed
Delete OutputType from Parser
1 parent 1c5466b commit b37d720

File tree

5 files changed

+4
-80
lines changed

5 files changed

+4
-80
lines changed

Sources/XcbeautifyLib/CaptureGroups.swift

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ public protocol CaptureGroup {
66
init?(groups: [String])
77
}
88

9-
extension CaptureGroup {
9+
public extension CaptureGroup {
1010
var outputType: OutputType { Self.outputType }
11+
}
1112

13+
extension CaptureGroup {
1214
static var pattern: String { regex.pattern }
1315
var pattern: String { Self.regex.pattern }
1416
}

Sources/XcbeautifyLib/Parser.swift

-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import Foundation
22

33
package class Parser {
4-
package private(set) var outputType = OutputType.undefined
54

65
private lazy var captureGroupTypes: [CaptureGroup.Type] = [
76
AnalyzeCaptureGroup.self,
@@ -97,10 +96,6 @@ package class Parser {
9796
public func parse(line: String) -> CaptureGroup? {
9897
// Find first parser that can parse specified string
9998
guard let idx = captureGroupTypes.firstIndex(where: { $0.regex.match(string: line) }) else {
100-
// Some uncommon cases, which have additional logic and don't follow default flow
101-
102-
// Nothing found?
103-
outputType = OutputType.undefined
10499
return nil
105100
}
106101

@@ -115,8 +110,6 @@ package class Parser {
115110
return nil
116111
}
117112

118-
outputType = captureGroupType.outputType
119-
120113
// Move found parser to the top, so next time it will be checked first
121114
captureGroupTypes.insert(captureGroupTypes.remove(at: idx), at: 0)
122115

Sources/xcbeautify/Xcbeautify.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ struct Xcbeautify: ParsableCommand {
6666
continue
6767
}
6868
guard let formatted = formatter.format(captureGroup: captureGroup) else { continue }
69-
output.write(parser.outputType, formatted)
69+
output.write(captureGroup.outputType, formatted)
7070
}
7171

7272
if !report.isEmpty {

0 commit comments

Comments
 (0)