@@ -58,6 +58,12 @@ extension ABI {
58
58
/// - Warning: Errors are not yet part of the JSON schema.
59
59
var _error : EncodedError < V > ?
60
60
61
+ /// The comment associated with the call to `withKnownIssue()` that
62
+ /// generated this issue.
63
+ ///
64
+ /// - Warning: This field is not yet part of the JSON schema.
65
+ var _knownIssueComment : String ?
66
+
61
67
init ( encoding issue: borrowing Issue , in eventContext: borrowing Event . Context ) {
62
68
// >= v0
63
69
isKnown = issue. isKnown
@@ -80,6 +86,9 @@ extension ABI {
80
86
if let error = issue. error {
81
87
_error = EncodedError ( encoding: error, in: eventContext)
82
88
}
89
+ if let knownIssueContext = issue. knownIssueContext {
90
+ _knownIssueComment = knownIssueContext. comment? . rawValue
91
+ }
83
92
}
84
93
}
85
94
}
@@ -89,47 +98,3 @@ extension ABI {
89
98
90
99
extension ABI . EncodedIssue : Codable { }
91
100
extension ABI . EncodedIssue . Severity : Codable { }
92
-
93
- // MARK: - Converting back to an Issue
94
-
95
- extension Issue {
96
- /// Attempt to reconstruct an instance of ``Issue`` from the given encoded
97
- /// event.
98
- ///
99
- /// - Parameters:
100
- /// - event: The event that may contain an encoded issue.
101
- ///
102
- /// If `event` does not represent an issue, this initializer returns `nil`.
103
- init ? < V> ( _ event: ABI . EncodedEvent < V > ) {
104
- guard let issue = event. issue else {
105
- return nil
106
- }
107
-
108
- // Translate the issue back into a "real" issue and record it
109
- // in the parent process. This translation is, of course, lossy
110
- // due to the process boundary, but we make a best effort.
111
- let comments : [ Comment ] = event. messages. map ( \. text) . map ( Comment . init ( rawValue: ) )
112
- let issueKind : Issue . Kind = if let error = issue. _error {
113
- . errorCaught( error)
114
- } else {
115
- // TODO: improve fidelity of issue kind reporting (especially those without associated values)
116
- . unconditional
117
- }
118
- let severity : Issue . Severity = switch issue. severity {
119
- case . warning:
120
- . warning
121
- case nil , . error:
122
- . error
123
- }
124
- let sourceContext = SourceContext (
125
- backtrace: nil , // `issue._backtrace` will have the wrong address space.
126
- sourceLocation: issue. sourceLocation
127
- )
128
- self . init ( kind: issueKind, severity: severity, comments: comments, sourceContext: sourceContext)
129
- if issue. isKnown {
130
- // The known issue comment, if there was one, is already included in
131
- // the `comments` array above.
132
- knownIssueContext = Issue . KnownIssueContext ( )
133
- }
134
- }
135
- }
0 commit comments