Skip to content

Commit 3b99c6f

Browse files
committed
Dependencies: Use better Regex/JSON decoding for parsing dependency trace files
1 parent 908f676 commit 3b99c6f

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Sources/SWBTaskExecution/TaskActions/ClangCompileTaskAction.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -617,8 +617,8 @@ public final class ClangNonModularCompileTaskAction: TaskAction {
617617
}
618618

619619
fileprivate func parseTraceData(_ data: Data) throws -> TraceData? {
620-
if let jsonObject = try JSONSerialization.jsonObject(with: data) as? [String: Any],
621-
let version = jsonObject["version"] as? String {
620+
let jsonObject = try PropertyList.fromJSONData(data)
621+
if let version = jsonObject.dictValue?["version"]?.stringValue {
622622
if version == "2.0.0" {
623623
return .V2(try JSONDecoder().decode(TraceData.TraceFileV2.self, from: data))
624624
}
@@ -631,12 +631,12 @@ fileprivate func parseTraceData(_ data: Data) throws -> TraceData? {
631631
}
632632

633633
fileprivate func parseTraceSourceLocation(_ locationStr: String) -> SWBUtil.Diagnostic.Location {
634-
guard let match = locationStr.wholeMatch(of: #/(.+):(\d+):(\d+)/#) else {
634+
guard let match = locationStr.wholeMatch(of: #/(?<filename>.+):(?<line>\d+):(?<column>\d+)/#) else {
635635
return .unknown
636636
}
637-
let filename = Path(match.1)
638-
let line = Int(match.2)
639-
let column = Int(match.3)
637+
let filename = Path(match.filename)
638+
let line = Int(match.line)
639+
let column = Int(match.column)
640640
if let line {
641641
return .path(filename, fileLocation: .textual(line: line, column: column))
642642
}

0 commit comments

Comments
 (0)