@@ -85,7 +85,7 @@ fileprivate enum RawSyntaxData {
85
85
/// Represents the raw tree structure underlying the syntax tree. These nodes
86
86
/// have no notion of identity and only provide structure to the tree. They
87
87
/// are immutable and can be freely shared between syntax nodes.
88
- struct RawSyntax {
88
+ final class RawSyntax {
89
89
fileprivate let data : RawSyntaxData
90
90
let presence : SourcePresence
91
91
@@ -124,6 +124,13 @@ struct RawSyntax {
124
124
}
125
125
} ) . value
126
126
}
127
+
128
+ /// Creates a copy of `other`.
129
+ init ( _ other: RawSyntax ) {
130
+ self . data = other. data
131
+ self . presence = other. presence
132
+ self . id = other. id
133
+ }
127
134
128
135
init ( kind: SyntaxKind , layout: [ RawSyntax ? ] , presence: SourcePresence ,
129
136
id: SyntaxNodeId ? = nil ) {
@@ -336,7 +343,7 @@ extension RawSyntax {
336
343
337
344
extension RawSyntax : Codable {
338
345
/// Creates a RawSyntax from the provided Foundation Decoder.
339
- init ( from decoder: Decoder ) throws {
346
+ required convenience init ( from decoder: Decoder ) throws {
340
347
let container = try decoder. container ( keyedBy: CodingKeys . self)
341
348
let id = try container. decodeIfPresent ( SyntaxNodeId . self, forKey: . id)
342
349
let omitted = try container. decodeIfPresent ( Bool . self, forKey: . omitted) ?? false
@@ -352,7 +359,7 @@ extension RawSyntax: Codable {
352
359
guard let lookupNode = lookupFunc ( id) else {
353
360
throw IncrementalDecodingError . nodeLookupFailed ( id)
354
361
}
355
- self = lookupNode
362
+ self . init ( lookupNode)
356
363
return
357
364
}
358
365
0 commit comments