expo-modules-macros 0.19.1 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/apple/ExpoModulesMacros +0 -0
- package/apple/Sources/ExpoModulesMacros/ClosureArguments.swift +1 -1
- package/apple/Sources/ExpoModulesMacros/DecorateModuleBuilder.swift +18 -10
- package/apple/Sources/ExpoModulesMacros/EventMacro.swift +12 -1
- package/apple/Sources/ExpoModulesMacros/RecordMacro.swift +26 -1
- package/apple/Sources/ExpoModulesMacros/UnionMacro.swift +14 -1
- package/apple/Sources/ExpoModulesScanner/Exports/Availability.swift +259 -0
- package/apple/Sources/ExpoModulesScanner/Exports/ExportedSurface.swift +151 -32
- package/apple/Sources/ExpoModulesScanner/Exports/ResolveRefs.swift +48 -65
- package/apple/Sources/ExpoModulesScanner/Exports/ScanExports.swift +1 -1
- package/apple/Sources/ExpoModulesScanner/Exports/SurfaceVisitor.swift +179 -46
- package/build/index.d.ts +12 -3
- package/build/index.js +18 -10
- package/build/types.d.ts +86 -19
- package/build/types.js +1 -1
- package/package.json +3 -3
|
@@ -2,6 +2,44 @@
|
|
|
2
2
|
/// `@Record` type, with the per-member detail a TypeScript type generator needs. Read syntactically
|
|
3
3
|
/// (like the macros): each boundary type becomes a structured `TypeNode` tree so the consumer walks a
|
|
4
4
|
/// tagged tree rather than re-parsing Swift type syntax.
|
|
5
|
+
///
|
|
6
|
+
/// Every declaration and member carries the `platforms` that build it, and the ones that can be
|
|
7
|
+
/// written with an access modifier carry the `accessLevel` they spell. A declaration no platform
|
|
8
|
+
/// builds is not reported.
|
|
9
|
+
|
|
10
|
+
/// One Apple OS that builds a declaration.
|
|
11
|
+
struct ExportedPlatform: Encodable, Equatable {
|
|
12
|
+
/// The OS, spelled as `os(...)` spells it: `iOS`, `macOS`, `tvOS`, `watchOS`, or `visionOS`.
|
|
13
|
+
let name: String
|
|
14
|
+
|
|
15
|
+
/// The version spelled in `@available` (`17.0` in `@available(iOS 17.0, *)`), or `nil` when no
|
|
16
|
+
/// attribute on the declaration or its enclosing types names one. The latest version wins when
|
|
17
|
+
/// several do.
|
|
18
|
+
let introduced: String?
|
|
19
|
+
|
|
20
|
+
/// How the declaration's own `@available` attributes deprecate it on this OS, or `nil` when they
|
|
21
|
+
/// don't. Enclosing types are not read: a member of a deprecated type is not itself reported as
|
|
22
|
+
/// deprecated.
|
|
23
|
+
var deprecated: ExportedDeprecation? = nil
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/// A deprecation from `@available`: `@available(*, deprecated, ...)` on every OS, or
|
|
27
|
+
/// `@available(iOS, deprecated: 16, obsoleted: 18, ...)` on one. Each field is `nil` when not written.
|
|
28
|
+
struct ExportedDeprecation: Encodable, Equatable {
|
|
29
|
+
/// The version from `deprecated: 16`; `nil` for a bare `deprecated`.
|
|
30
|
+
var since: String? = nil
|
|
31
|
+
|
|
32
|
+
/// The version from `obsoleted: 18`, from which the declaration is no longer available. A
|
|
33
|
+
/// declaration that is only obsoleted is still reported as deprecated.
|
|
34
|
+
var obsoleted: String? = nil
|
|
35
|
+
|
|
36
|
+
/// The `message:` text.
|
|
37
|
+
var message: String? = nil
|
|
38
|
+
|
|
39
|
+
/// The `renamed:` text: the Swift name of the replacement, as written (`newName`,
|
|
40
|
+
/// `other(value:)`). It is not resolved to a JS name.
|
|
41
|
+
var renamed: String? = nil
|
|
42
|
+
}
|
|
5
43
|
|
|
6
44
|
/// One parameter of a `@JS` function or `@JS init`.
|
|
7
45
|
struct ExportedParameter: Encodable, Equatable {
|
|
@@ -11,14 +49,18 @@ struct ExportedParameter: Encodable, Equatable {
|
|
|
11
49
|
/// The internal parameter name (the `second` name, else the same as `label`): `point` above.
|
|
12
50
|
let name: String
|
|
13
51
|
|
|
14
|
-
|
|
52
|
+
var type: TypeNode
|
|
15
53
|
|
|
16
54
|
/// True when the caller may omit it: a default value or an optional type. Distinct from the type
|
|
17
55
|
/// being `.optional` (a defaulted non-optional is also omittable). Encoded as `optional`.
|
|
18
56
|
let isOptional: Bool
|
|
19
57
|
|
|
58
|
+
/// The default value expression as source text (`1`, `"x"`, `.fast`), or `nil` when none is
|
|
59
|
+
/// written. Not evaluated: it may be any expression.
|
|
60
|
+
let defaultValue: String?
|
|
61
|
+
|
|
20
62
|
private enum CodingKeys: String, CodingKey {
|
|
21
|
-
case label, name, type
|
|
63
|
+
case label, name, type, defaultValue
|
|
22
64
|
case isOptional = "optional"
|
|
23
65
|
}
|
|
24
66
|
}
|
|
@@ -31,10 +73,10 @@ struct ExportedFunction: Encodable, Equatable {
|
|
|
31
73
|
/// The JS name it binds under: the `@JS("x")` override, else `name`.
|
|
32
74
|
let jsName: String
|
|
33
75
|
|
|
34
|
-
|
|
76
|
+
var parameters: [ExportedParameter]
|
|
35
77
|
|
|
36
78
|
/// The return type, or `nil` for `Void`. Named `returns` to pair with `parameters`.
|
|
37
|
-
|
|
79
|
+
var returns: TypeNode?
|
|
38
80
|
|
|
39
81
|
/// `async` (an async function is promise-returning in JS).
|
|
40
82
|
let isAsync: Bool
|
|
@@ -45,9 +87,14 @@ struct ExportedFunction: Encodable, Equatable {
|
|
|
45
87
|
/// `static`/`class` member.
|
|
46
88
|
let isStatic: Bool
|
|
47
89
|
|
|
90
|
+
/// The spelled access modifier, or `nil` when none is written.
|
|
91
|
+
let accessLevel: String?
|
|
92
|
+
|
|
93
|
+
let platforms: [ExportedPlatform]
|
|
94
|
+
|
|
48
95
|
/// The flags are encoded under their TS-keyword spellings.
|
|
49
96
|
private enum CodingKeys: String, CodingKey {
|
|
50
|
-
case name, jsName, parameters, returns
|
|
97
|
+
case name, jsName, parameters, returns, accessLevel, platforms
|
|
51
98
|
case isAsync = "async"
|
|
52
99
|
case isThrowing = "throws"
|
|
53
100
|
case isStatic = "static"
|
|
@@ -64,7 +111,7 @@ struct ExportedProperty: Encodable, Equatable {
|
|
|
64
111
|
|
|
65
112
|
/// The value type, or `nil` when undeterminable syntactically (no annotation and no literal
|
|
66
113
|
/// default), the case the macro binds getter-only.
|
|
67
|
-
|
|
114
|
+
var type: TypeNode?
|
|
68
115
|
|
|
69
116
|
/// True when JS can assign to it: a stored `var` or a computed `var` with a `set`. Encoded as its
|
|
70
117
|
/// inverse, `readonly`.
|
|
@@ -73,8 +120,17 @@ struct ExportedProperty: Encodable, Equatable {
|
|
|
73
120
|
/// `static`/`class` member. Encoded as `static`.
|
|
74
121
|
let isStatic: Bool
|
|
75
122
|
|
|
123
|
+
/// The initial value of a stored property as source text, or `nil` when none is written.
|
|
124
|
+
let defaultValue: String?
|
|
125
|
+
|
|
126
|
+
/// The spelled access modifier, or `nil` when none is written. A setter-only modifier like
|
|
127
|
+
/// `private(set)` is not the property's access level.
|
|
128
|
+
let accessLevel: String?
|
|
129
|
+
|
|
130
|
+
let platforms: [ExportedPlatform]
|
|
131
|
+
|
|
76
132
|
private enum CodingKeys: String, CodingKey {
|
|
77
|
-
case name, jsName, type
|
|
133
|
+
case name, jsName, type, defaultValue, accessLevel, platforms
|
|
78
134
|
case isReadonly = "readonly"
|
|
79
135
|
case isStatic = "static"
|
|
80
136
|
}
|
|
@@ -86,6 +142,9 @@ struct ExportedProperty: Encodable, Equatable {
|
|
|
86
142
|
try container.encodeIfPresent(type, forKey: .type)
|
|
87
143
|
try container.encode(!isSettable, forKey: .isReadonly)
|
|
88
144
|
try container.encode(isStatic, forKey: .isStatic)
|
|
145
|
+
try container.encodeIfPresent(defaultValue, forKey: .defaultValue)
|
|
146
|
+
try container.encodeIfPresent(accessLevel, forKey: .accessLevel)
|
|
147
|
+
try container.encode(platforms, forKey: .platforms)
|
|
89
148
|
}
|
|
90
149
|
}
|
|
91
150
|
|
|
@@ -96,23 +155,28 @@ struct ExportedRecordProperty: Encodable, Equatable {
|
|
|
96
155
|
let name: String
|
|
97
156
|
|
|
98
157
|
/// `@Record` requires a determinable type on every property, so this is never `nil`.
|
|
99
|
-
|
|
158
|
+
var type: TypeNode
|
|
100
159
|
|
|
101
160
|
/// Optional-typed. Encoded as `optional`.
|
|
102
161
|
let isOptional: Bool
|
|
103
162
|
|
|
104
|
-
///
|
|
105
|
-
|
|
106
|
-
|
|
163
|
+
/// The default value as source text, or `nil` when none is written. A field JS leaves out takes it.
|
|
164
|
+
let defaultValue: String?
|
|
165
|
+
|
|
166
|
+
/// The spelled access modifier, or `nil` when none is written. Never `private` or `fileprivate`,
|
|
167
|
+
/// since those exclude a property from the record.
|
|
168
|
+
let accessLevel: String?
|
|
169
|
+
|
|
170
|
+
let platforms: [ExportedPlatform]
|
|
107
171
|
|
|
108
172
|
/// Whether JS must supply this property, matching the macro's `RecordProperty.isRequired`. Encoded
|
|
109
173
|
/// as `required`.
|
|
110
174
|
var isRequired: Bool {
|
|
111
|
-
return
|
|
175
|
+
return defaultValue == nil && !isOptional
|
|
112
176
|
}
|
|
113
177
|
|
|
114
178
|
private enum CodingKeys: String, CodingKey {
|
|
115
|
-
case name, type
|
|
179
|
+
case name, type, defaultValue, accessLevel, platforms
|
|
116
180
|
case isOptional = "optional"
|
|
117
181
|
case isRequired = "required"
|
|
118
182
|
}
|
|
@@ -123,6 +187,9 @@ struct ExportedRecordProperty: Encodable, Equatable {
|
|
|
123
187
|
try container.encode(type, forKey: .type)
|
|
124
188
|
try container.encode(isOptional, forKey: .isOptional)
|
|
125
189
|
try container.encode(isRequired, forKey: .isRequired)
|
|
190
|
+
try container.encodeIfPresent(defaultValue, forKey: .defaultValue)
|
|
191
|
+
try container.encodeIfPresent(accessLevel, forKey: .accessLevel)
|
|
192
|
+
try container.encode(platforms, forKey: .platforms)
|
|
126
193
|
}
|
|
127
194
|
}
|
|
128
195
|
|
|
@@ -137,13 +204,18 @@ struct ExportedEvent: Encodable, Equatable {
|
|
|
137
204
|
let jsName: String
|
|
138
205
|
|
|
139
206
|
/// The single payload parameter's type, or `nil` for a no-payload `() -> Void` event.
|
|
140
|
-
|
|
207
|
+
var payload: TypeNode?
|
|
141
208
|
|
|
142
209
|
/// `@Event(sync: true)`, dispatching inline on the JS thread instead of scheduling.
|
|
143
210
|
let isSync: Bool
|
|
144
211
|
|
|
212
|
+
/// The spelled access modifier, or `nil` when none is written.
|
|
213
|
+
let accessLevel: String?
|
|
214
|
+
|
|
215
|
+
let platforms: [ExportedPlatform]
|
|
216
|
+
|
|
145
217
|
private enum CodingKeys: String, CodingKey {
|
|
146
|
-
case name, jsName, payload
|
|
218
|
+
case name, jsName, payload, accessLevel, platforms
|
|
147
219
|
case isSync = "sync"
|
|
148
220
|
}
|
|
149
221
|
|
|
@@ -153,6 +225,8 @@ struct ExportedEvent: Encodable, Equatable {
|
|
|
153
225
|
try container.encode(jsName, forKey: .jsName)
|
|
154
226
|
try container.encodeIfPresent(payload, forKey: .payload)
|
|
155
227
|
try container.encode(isSync, forKey: .isSync)
|
|
228
|
+
try container.encodeIfPresent(accessLevel, forKey: .accessLevel)
|
|
229
|
+
try container.encode(platforms, forKey: .platforms)
|
|
156
230
|
}
|
|
157
231
|
}
|
|
158
232
|
|
|
@@ -165,13 +239,18 @@ struct ExportedModule: Encodable, Equatable {
|
|
|
165
239
|
/// The JS module name: `@ExpoModule("Foo")` override, else the class name.
|
|
166
240
|
let jsName: String
|
|
167
241
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
242
|
+
var functions: [ExportedFunction]
|
|
243
|
+
var properties: [ExportedProperty]
|
|
244
|
+
var events: [ExportedEvent]
|
|
171
245
|
|
|
172
246
|
/// The classes listed in `@ExpoModule(classes: [...])`, in source order. Each is reachable from JS
|
|
173
247
|
/// as a member of the module.
|
|
174
|
-
|
|
248
|
+
var classes: [ExportedClass]
|
|
249
|
+
|
|
250
|
+
/// The spelled access modifier, or `nil` when none is written.
|
|
251
|
+
let accessLevel: String?
|
|
252
|
+
|
|
253
|
+
let platforms: [ExportedPlatform]
|
|
175
254
|
|
|
176
255
|
/// Absolute source path, matching `scan-modules`.
|
|
177
256
|
let file: String
|
|
@@ -190,6 +269,16 @@ struct ExportedClass: Encodable, Equatable {
|
|
|
190
269
|
let jsName: String?
|
|
191
270
|
}
|
|
192
271
|
|
|
272
|
+
/// The `@JS init` of a shared object: the constructor JS calls with `new`.
|
|
273
|
+
struct ExportedInitializer: Encodable, Equatable {
|
|
274
|
+
var parameters: [ExportedParameter]
|
|
275
|
+
|
|
276
|
+
/// The spelled access modifier, or `nil` when none is written.
|
|
277
|
+
let accessLevel: String?
|
|
278
|
+
|
|
279
|
+
let platforms: [ExportedPlatform]
|
|
280
|
+
}
|
|
281
|
+
|
|
193
282
|
/// A `@SharedObject` type: a JS class with an optional `@JS init` constructor plus its `@JS` members.
|
|
194
283
|
struct ExportedSharedObject: Encodable, Equatable {
|
|
195
284
|
/// The Swift class name, qualified with the types it is nested in (`Outer.Player`).
|
|
@@ -199,12 +288,18 @@ struct ExportedSharedObject: Encodable, Equatable {
|
|
|
199
288
|
/// types.
|
|
200
289
|
let jsName: String
|
|
201
290
|
|
|
202
|
-
/// The `@JS init
|
|
203
|
-
|
|
291
|
+
/// The `@JS init`, or `nil` when there's none. A shared object has at most one; the first is kept
|
|
292
|
+
/// if a malformed source has more. Not named `constructor`, which every JS object inherits.
|
|
293
|
+
var initializer: ExportedInitializer?
|
|
294
|
+
|
|
295
|
+
var functions: [ExportedFunction]
|
|
296
|
+
var properties: [ExportedProperty]
|
|
297
|
+
var events: [ExportedEvent]
|
|
204
298
|
|
|
205
|
-
|
|
206
|
-
let
|
|
207
|
-
|
|
299
|
+
/// The spelled access modifier, or `nil` when none is written.
|
|
300
|
+
let accessLevel: String?
|
|
301
|
+
|
|
302
|
+
let platforms: [ExportedPlatform]
|
|
208
303
|
|
|
209
304
|
let file: String
|
|
210
305
|
}
|
|
@@ -215,7 +310,12 @@ struct ExportedRecord: Encodable, Equatable {
|
|
|
215
310
|
/// (`Outer.Options`).
|
|
216
311
|
let name: String
|
|
217
312
|
|
|
218
|
-
|
|
313
|
+
var properties: [ExportedRecordProperty]
|
|
314
|
+
|
|
315
|
+
/// The spelled access modifier, or `nil` when none is written.
|
|
316
|
+
let accessLevel: String?
|
|
317
|
+
|
|
318
|
+
let platforms: [ExportedPlatform]
|
|
219
319
|
|
|
220
320
|
let file: String
|
|
221
321
|
}
|
|
@@ -237,14 +337,17 @@ struct ExportedEnumCase: Encodable, Equatable {
|
|
|
237
337
|
/// above.
|
|
238
338
|
let rawValue: String?
|
|
239
339
|
|
|
340
|
+
let platforms: [ExportedPlatform]
|
|
341
|
+
|
|
240
342
|
private enum CodingKeys: String, CodingKey {
|
|
241
|
-
case name, rawValue
|
|
343
|
+
case name, rawValue, platforms
|
|
242
344
|
}
|
|
243
345
|
|
|
244
346
|
func encode(to encoder: Encoder) throws {
|
|
245
347
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
|
246
348
|
try container.encode(name, forKey: .name)
|
|
247
349
|
try container.encodeIfPresent(rawValue, forKey: .rawValue)
|
|
350
|
+
try container.encode(platforms, forKey: .platforms)
|
|
248
351
|
}
|
|
249
352
|
}
|
|
250
353
|
|
|
@@ -264,10 +367,15 @@ struct ExportedEnum: Encodable, Equatable {
|
|
|
264
367
|
|
|
265
368
|
let cases: [ExportedEnumCase]
|
|
266
369
|
|
|
370
|
+
/// The spelled access modifier, or `nil` when none is written.
|
|
371
|
+
let accessLevel: String?
|
|
372
|
+
|
|
373
|
+
let platforms: [ExportedPlatform]
|
|
374
|
+
|
|
267
375
|
let file: String
|
|
268
376
|
|
|
269
377
|
private enum CodingKeys: String, CodingKey {
|
|
270
|
-
case name, rawType, cases, file
|
|
378
|
+
case name, rawType, cases, accessLevel, platforms, file
|
|
271
379
|
}
|
|
272
380
|
|
|
273
381
|
func encode(to encoder: Encoder) throws {
|
|
@@ -275,6 +383,8 @@ struct ExportedEnum: Encodable, Equatable {
|
|
|
275
383
|
try container.encode(name, forKey: .name)
|
|
276
384
|
try container.encodeIfPresent(rawType, forKey: .rawType)
|
|
277
385
|
try container.encode(cases, forKey: .cases)
|
|
386
|
+
try container.encodeIfPresent(accessLevel, forKey: .accessLevel)
|
|
387
|
+
try container.encode(platforms, forKey: .platforms)
|
|
278
388
|
try container.encode(file, forKey: .file)
|
|
279
389
|
}
|
|
280
390
|
}
|
|
@@ -288,10 +398,12 @@ struct ExportedUnionMember: Encodable, Equatable {
|
|
|
288
398
|
|
|
289
399
|
/// The associated value's type: what this alternative decodes from. Named `type` like every other
|
|
290
400
|
/// type-valued field here; `payload` already means an event's argument type on `ExportedEvent`.
|
|
291
|
-
|
|
401
|
+
var type: TypeNode
|
|
402
|
+
|
|
403
|
+
let platforms: [ExportedPlatform]
|
|
292
404
|
|
|
293
405
|
private enum CodingKeys: String, CodingKey {
|
|
294
|
-
case name, type
|
|
406
|
+
case name, type, platforms
|
|
295
407
|
}
|
|
296
408
|
}
|
|
297
409
|
|
|
@@ -307,7 +419,12 @@ struct ExportedUnion: Encodable, Equatable {
|
|
|
307
419
|
/// name.
|
|
308
420
|
let name: String
|
|
309
421
|
|
|
310
|
-
|
|
422
|
+
var members: [ExportedUnionMember]
|
|
423
|
+
|
|
424
|
+
/// The spelled access modifier, or `nil` when none is written.
|
|
425
|
+
let accessLevel: String?
|
|
426
|
+
|
|
427
|
+
let platforms: [ExportedPlatform]
|
|
311
428
|
|
|
312
429
|
let file: String
|
|
313
430
|
}
|
|
@@ -328,8 +445,10 @@ struct ExportedSurface: Encodable, Equatable {
|
|
|
328
445
|
/// and change for different reasons. Version 2 added `events` to modules and shared objects; version 3
|
|
329
446
|
/// added `enums`; version 4 added `unions`; version 5 resolves refs, adding `refKind` and correcting
|
|
330
447
|
/// an enum ref's `typeof`; version 6 added `classes` to modules; version 7 reports nested types under
|
|
331
|
-
/// qualified names and gives a resolved ref the name of its declaration
|
|
332
|
-
|
|
448
|
+
/// qualified names and gives a resolved ref the name of its declaration; version 8 reports
|
|
449
|
+
/// declarations in `#if` blocks, adds `platforms` (with deprecations), `accessLevel`, and
|
|
450
|
+
/// `defaultValue`, and replaces `constructorParameters` with `initializer`.
|
|
451
|
+
let scanExportsSchemaVersion = 8
|
|
333
452
|
|
|
334
453
|
/// The `scan-exports` result: the surface plus the run's stats. A distinct envelope from
|
|
335
454
|
/// `ScanModulesResult` (different consumer: TS generation vs. autolinking).
|
|
@@ -147,61 +147,51 @@ extension ExportedSurface {
|
|
|
147
147
|
let index = RefIndex(surface: self)
|
|
148
148
|
return ExportedSurface(
|
|
149
149
|
modules: modules.map { module in
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
},
|
|
163
|
-
file: module.file
|
|
164
|
-
)
|
|
150
|
+
var resolved = module
|
|
151
|
+
resolved.functions = module.functions.map { $0.resolvingRefs(using: index, in: module.name) }
|
|
152
|
+
resolved.properties = module.properties.map { $0.resolvingRefs(using: index, in: module.name) }
|
|
153
|
+
resolved.events = module.events.map { $0.resolvingRefs(using: index, in: module.name) }
|
|
154
|
+
resolved.classes = module.classes.map { exportedClass in
|
|
155
|
+
guard let entry = index.lookup(exportedClass.name, in: module.name),
|
|
156
|
+
entry.kind == .sharedObject else {
|
|
157
|
+
return exportedClass
|
|
158
|
+
}
|
|
159
|
+
return ExportedClass(name: entry.name, jsName: entry.jsName)
|
|
160
|
+
}
|
|
161
|
+
return resolved
|
|
165
162
|
},
|
|
166
163
|
sharedObjects: sharedObjects.map { sharedObject in
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
constructorParameters: sharedObject.constructorParameters?.map {
|
|
164
|
+
var resolved = sharedObject
|
|
165
|
+
if let initializer = sharedObject.initializer {
|
|
166
|
+
resolved.initializer?.parameters = initializer.parameters.map {
|
|
171
167
|
$0.resolvingRefs(using: index, in: sharedObject.name)
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
resolved.functions = sharedObject.functions.map { $0.resolvingRefs(using: index, in: sharedObject.name) }
|
|
171
|
+
resolved.properties = sharedObject.properties.map { $0.resolvingRefs(using: index, in: sharedObject.name) }
|
|
172
|
+
resolved.events = sharedObject.events.map { $0.resolvingRefs(using: index, in: sharedObject.name) }
|
|
173
|
+
return resolved
|
|
178
174
|
},
|
|
179
175
|
records: records.map { record in
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
hasDefault: property.hasDefault
|
|
188
|
-
)
|
|
189
|
-
},
|
|
190
|
-
file: record.file
|
|
191
|
-
)
|
|
176
|
+
var resolved = record
|
|
177
|
+
resolved.properties = record.properties.map { property in
|
|
178
|
+
var resolvedProperty = property
|
|
179
|
+
resolvedProperty.type = property.type.resolvingRefs(using: index, in: record.name)
|
|
180
|
+
return resolvedProperty
|
|
181
|
+
}
|
|
182
|
+
return resolved
|
|
192
183
|
},
|
|
193
184
|
// An enum's raw type is a primitive or an unscanned spelling, never a ref to another scanned
|
|
194
185
|
// type, so there is nothing in one to resolve.
|
|
195
186
|
enums: enums,
|
|
196
187
|
unions: unions.map { union in
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
)
|
|
188
|
+
var resolved = union
|
|
189
|
+
resolved.members = union.members.map { member in
|
|
190
|
+
var resolvedMember = member
|
|
191
|
+
resolvedMember.type = member.type.resolvingRefs(using: index, in: union.name)
|
|
192
|
+
return resolvedMember
|
|
193
|
+
}
|
|
194
|
+
return resolved
|
|
205
195
|
}
|
|
206
196
|
)
|
|
207
197
|
}
|
|
@@ -209,40 +199,33 @@ extension ExportedSurface {
|
|
|
209
199
|
|
|
210
200
|
extension ExportedParameter {
|
|
211
201
|
fileprivate func resolvingRefs(using index: RefIndex, in scope: String) -> ExportedParameter {
|
|
212
|
-
|
|
213
|
-
|
|
202
|
+
var resolved = self
|
|
203
|
+
resolved.type = type.resolvingRefs(using: index, in: scope)
|
|
204
|
+
return resolved
|
|
214
205
|
}
|
|
215
206
|
}
|
|
216
207
|
|
|
217
208
|
extension ExportedFunction {
|
|
218
209
|
fileprivate func resolvingRefs(using index: RefIndex, in scope: String) -> ExportedFunction {
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
returns: returns?.resolvingRefs(using: index, in: scope),
|
|
224
|
-
isAsync: isAsync,
|
|
225
|
-
isThrowing: isThrowing,
|
|
226
|
-
isStatic: isStatic
|
|
227
|
-
)
|
|
210
|
+
var resolved = self
|
|
211
|
+
resolved.parameters = parameters.map { $0.resolvingRefs(using: index, in: scope) }
|
|
212
|
+
resolved.returns = returns?.resolvingRefs(using: index, in: scope)
|
|
213
|
+
return resolved
|
|
228
214
|
}
|
|
229
215
|
}
|
|
230
216
|
|
|
231
217
|
extension ExportedProperty {
|
|
232
218
|
fileprivate func resolvingRefs(using index: RefIndex, in scope: String) -> ExportedProperty {
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
type: type?.resolvingRefs(using: index, in: scope),
|
|
237
|
-
isSettable: isSettable,
|
|
238
|
-
isStatic: isStatic
|
|
239
|
-
)
|
|
219
|
+
var resolved = self
|
|
220
|
+
resolved.type = type?.resolvingRefs(using: index, in: scope)
|
|
221
|
+
return resolved
|
|
240
222
|
}
|
|
241
223
|
}
|
|
242
224
|
|
|
243
225
|
extension ExportedEvent {
|
|
244
226
|
fileprivate func resolvingRefs(using index: RefIndex, in scope: String) -> ExportedEvent {
|
|
245
|
-
|
|
246
|
-
|
|
227
|
+
var resolved = self
|
|
228
|
+
resolved.payload = payload?.resolvingRefs(using: index, in: scope)
|
|
229
|
+
return resolved
|
|
247
230
|
}
|
|
248
231
|
}
|
|
@@ -46,7 +46,7 @@ func scanExports(paths: [String]) -> ScanExportsResult {
|
|
|
46
46
|
conformances: [enumerableConformanceName]
|
|
47
47
|
) { source, file in
|
|
48
48
|
let tree = Parser.parse(source: source)
|
|
49
|
-
let visitor = SurfaceVisitor(file: file)
|
|
49
|
+
let visitor = SurfaceVisitor(file: file, tree: tree)
|
|
50
50
|
visitor.walk(tree)
|
|
51
51
|
modules.append(contentsOf: visitor.modules)
|
|
52
52
|
sharedObjects.append(contentsOf: visitor.sharedObjects)
|