-
Notifications
You must be signed in to change notification settings - Fork 79
/
Copy pathPreviewMessages.swift
123 lines (97 loc) · 4.39 KB
/
PreviewMessages.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift open source project
//
// Copyright (c) 2025 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
public import SWBUtil
public struct PreviewInfoRequest: SessionChannelBuildMessage, RequestMessage, SerializableCodable, Equatable {
public typealias ResponseMessage = VoidResponse
public static let name = "PREVIEW_INFO_REQUESTED"
/// The identifier for the session to initiate the request in.
public let sessionHandle: String
/// The channel to communicate with the client on.
public let responseChannel: UInt64
/// The request itself.
public let request: BuildRequestMessagePayload
/// Which targets needs preview info?
public let targetIDs: [String]
/// The source file that is being edited during the preview.
public let sourceFile: Path
/// Suffix for disambiguating different thunk variants.
public let thunkVariantSuffix: String
public init(sessionHandle: String, responseChannel: UInt64, request: BuildRequestMessagePayload, targetID: String, sourceFile: Path, thunkVariantSuffix: String) {
self.sessionHandle = sessionHandle
self.responseChannel = responseChannel
self.request = request
self.targetIDs = [targetID]
self.sourceFile = sourceFile
self.thunkVariantSuffix = thunkVariantSuffix
}
public init(fromLegacy deserializer: any Deserializer) throws {
try deserializer.beginAggregate(6)
self.sessionHandle = try deserializer.deserialize()
self.responseChannel = try deserializer.deserialize()
self.request = try deserializer.deserialize()
self.targetIDs = try deserializer.deserialize()
self.sourceFile = try deserializer.deserialize()
self.thunkVariantSuffix = try deserializer.deserialize()
}
}
public struct PreviewInfoResponse: Message, Equatable {
public static let name = "PREVIEW_INFO_RECEIVED"
/// Which target requested this info?
public let targetIDs: [String]
/// A serialized representation of the payload.
public let output: [PreviewInfoMessagePayload]
public init(targetIDs: [String], output: [PreviewInfoMessagePayload]) {
self.targetIDs = targetIDs
self.output = output
}
public init(from deserializer: any Deserializer) throws {
try deserializer.beginAggregate(2)
self.targetIDs = try deserializer.deserialize()
self.output = try deserializer.deserialize()
}
public func serialize<T: Serializer>(to serializer: T) {
serializer.serializeAggregate(2) {
serializer.serialize(self.targetIDs)
serializer.serialize(self.output)
}
}
}
public struct PreviewTargetDependencyInfoRequest: SessionChannelBuildMessage, RequestMessage, SerializableCodable, Equatable {
public typealias ResponseMessage = VoidResponse
public static let name = "PREVIEW_TARGET_DEPENDENCY_INFO_REQUESTED"
/// The identifier for the session to initiate the request in.
public let sessionHandle: String
/// The channel to communicate with the client on.
public let responseChannel: UInt64
/// The request itself.
public let request: BuildRequestMessagePayload
/// Which targets needs preview info?
public let targetIDs: [String]
public init(sessionHandle: String, responseChannel: UInt64, request: BuildRequestMessagePayload, targetIDs: [String]) {
self.sessionHandle = sessionHandle
self.responseChannel = responseChannel
self.request = request
self.targetIDs = targetIDs
}
public init(fromLegacy deserializer: any Deserializer) throws {
try deserializer.beginAggregate(4)
self.sessionHandle = try deserializer.deserialize()
self.responseChannel = try deserializer.deserialize()
self.request = try deserializer.deserialize()
self.targetIDs = try [deserializer.deserialize()]
}
}
let previewInfoMessageTypes: [any Message.Type] = [
PreviewInfoRequest.self,
PreviewInfoResponse.self,
PreviewTargetDependencyInfoRequest.self,
]