Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Xcode 14 logs #172

Merged
merged 2 commits into from
Jun 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Sources/XCLogParser/activityparser/ActivityParser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,8 @@ public class ActivityParser {
return try parseDVTDocumentLocation(iterator: &iterator)
} else if className == String(describing: IBDocumentMemberLocation.self) {
return try parseIBDocumentMemberLocation(iterator: &iterator)
} else if className == String(describing: DVTMemberDocumentLocation.self) {
return try parseDVTMemberDocumentLocation(iterator: &iterator)
}
throw XCLogParserError.parseError("Unexpected className found parsing DocumentLocation \(className)")
}
Expand Down Expand Up @@ -565,4 +567,11 @@ public class ActivityParser {
throw XCLogParserError.parseError("Unexpected token parsing Bool: \(token)")
}

private func parseDVTMemberDocumentLocation(iterator: inout IndexingIterator<[Token]>)
throws -> DVTMemberDocumentLocation {
return DVTMemberDocumentLocation(documentURLString: try parseAsString(token: iterator.next()),
timestamp: try parseAsDouble(token: iterator.next()),
member: try parseAsString(token: iterator.next()))
}

}
22 changes: 22 additions & 0 deletions Sources/XCLogParser/activityparser/IDEActivityModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -568,3 +568,25 @@ public class IBDocumentMemberLocation: DVTDocumentLocation {
try container.encode(attributeSearchLocation, forKey: .attributeSearchLocation)
}
}

// MARK: Added in Xcode 14

//// From DVTFoundation.framework
public class DVTMemberDocumentLocation: DVTDocumentLocation, Equatable {

public let member: String

public init(documentURLString: String, timestamp: Double, member: String) {
self.member = member
super.init(documentURLString: documentURLString, timestamp: timestamp)
}

// MARK: Equatable method

public static func == (lhs: DVTMemberDocumentLocation, rhs: DVTMemberDocumentLocation) -> Bool {
return lhs.documentURLString == rhs.documentURLString &&
lhs.timestamp == rhs.timestamp &&
lhs.member == rhs.member
}

}
2 changes: 1 addition & 1 deletion Sources/XCLogParser/commands/Version.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ import Foundation

public struct Version {

public static let current = "0.2.33"
public static let current = "0.2.34"

}
27 changes: 27 additions & 0 deletions Tests/XCLogParserTests/ActivityParserTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -348,4 +348,31 @@ class ActivityParserTests: XCTestCase {

XCTAssertEqual("file:///project/EntityComponentView.m", documentLocation.documentURLString)
}

let expectedDVTMemberDocumentLocation: DVTMemberDocumentLocation = DVTMemberDocumentLocation(
documentURLString: "file:///project/EntityComponentView.m",
timestamp: 2.2,
member: "abcdef")

let memberDocumentLocationTokens: [Token] = {
return [
Token.className("DVTMemberDocumentLocation"),
Token.classNameRef("DVTMemberDocumentLocation"),
Token.string("file:///project/EntityComponentView.m"),
Token.double(2.2),
Token.string("abcdef")]
}()

func testParseDVTMemberDocumentLocation() throws {
var iterator = memberDocumentLocationTokens.makeIterator()
let documentLocation = try parser.parseDocumentLocation(iterator: &iterator)
XCTAssert(documentLocation is DVTMemberDocumentLocation,
"Document location should be a DVTMemberDocumentLocation")

guard let documentMemberLocation = documentLocation as? DVTMemberDocumentLocation else {
return
}
XCTAssertEqual(expectedDVTMemberDocumentLocation, documentMemberLocation)
}

}