Skip to content

Commit

Permalink
Add IDEActivityLogActionMessage support
Browse files Browse the repository at this point in the history
  • Loading branch information
mollyIV committed Oct 16, 2023
1 parent dfce1e4 commit b349363
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
21 changes: 21 additions & 0 deletions Sources/XCLogParser/activityparser/ActivityParser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,24 @@ public class ActivityParser {
endLocation: try parseDocumentLocation(iterator: &iterator))
}

public func parseIDEActivityLogActionMessage(iterator: inout IndexingIterator<[Token]>) throws
-> IDEActivityLogActionMessage {
return IDEActivityLogActionMessage(
title: try parseAsString(token: iterator.next()),
shortTitle: try parseAsString(token: iterator.next()),
timeEmitted: try Double(parseAsInt(token: iterator.next())),
rangeEndInSectionText: try parseAsInt(token: iterator.next()),
rangeStartInSectionText: try parseAsInt(token: iterator.next()),
subMessages: try parseMessages(iterator: &iterator),
severity: Int(try parseAsInt(token: iterator.next())),
type: try parseAsString(token: iterator.next()),
location: try parseDocumentLocation(iterator: &iterator),
categoryIdent: try parseAsString(token: iterator.next()),
secondaryLocations: try parseDocumentLocations(iterator: &iterator),
additionalDescription: try parseAsString(token: iterator.next()),
action: try parseAsString(token: iterator.next()))
}

private func getTokens(_ logURL: URL,
redacted: Bool,
withoutBuildSpecificInformation: Bool) throws -> [Token] {
Expand Down Expand Up @@ -337,6 +355,9 @@ public class ActivityParser {
if className == String(describing: IDEActivityLogAnalyzerEventStepMessage.self) {
return try parseIDEActivityLogAnalyzerEventStepMessage(iterator: &iterator)
}
if className == String(describing: IDEActivityLogActionMessage.self) {
return try parseIDEActivityLogActionMessage(iterator: &iterator)
}
throw XCLogParserError.parseError("Unexpected className found parsing IDEActivityLogMessage \(className)")
}

Expand Down
45 changes: 45 additions & 0 deletions Sources/XCLogParser/activityparser/IDEActivityModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,51 @@ public class IDEActivityLogAnalyzerEventStepMessage: IDEActivityLogMessage {
}
}

public class IDEActivityLogActionMessage: IDEActivityLogMessage {

public let action: String

public init(title: String,
shortTitle: String,
timeEmitted: Double,
rangeEndInSectionText: UInt64,
rangeStartInSectionText: UInt64,
subMessages: [IDEActivityLogMessage],
severity: Int,
type: String,
location: DVTDocumentLocation,
categoryIdent: String,
secondaryLocations: [DVTDocumentLocation],
additionalDescription: String,
action: String) {

self.action = action

super.init(title: title,
shortTitle: shortTitle,
timeEmitted: timeEmitted,
rangeEndInSectionText: rangeEndInSectionText,
rangeStartInSectionText: rangeStartInSectionText,
subMessages: subMessages,
severity: severity,
type: type,
location: location,
categoryIdent: categoryIdent,
secondaryLocations: secondaryLocations,
additionalDescription: additionalDescription)
}

private enum CodingKeys: String, CodingKey {
case action
}

override public func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(action, forKey: .action)
}
}

// MARK: IDEInterfaceBuilderKit

public class IBMemberID: Encodable {
Expand Down

0 comments on commit b349363

Please sign in to comment.