@@ -18,11 +18,14 @@ import SwiftSyntaxBuilder
18
18
public struct AddPackageTarget : ManifestEditRefactoringProvider {
19
19
public struct Context {
20
20
public let target : PackageTarget
21
- public let configuration : Configuration
21
+ public var testHarness : TestHarness
22
22
23
- public init ( target: PackageTarget , configuration: Configuration = . init( ) ) {
23
+ public init (
24
+ target: PackageTarget ,
25
+ testHarness: TestHarness = . default
26
+ ) {
24
27
self . target = target
25
- self . configuration = configuration
28
+ self . testHarness = testHarness
26
29
}
27
30
}
28
31
@@ -50,27 +53,13 @@ public struct AddPackageTarget: ManifestEditRefactoringProvider {
50
53
public static let `default` : TestHarness = . swiftTesting
51
54
}
52
55
53
- /// Additional configuration information to guide the package editing
54
- /// process.
55
- public struct Configuration {
56
- /// The test harness to use.
57
- public var testHarness : TestHarness
58
-
59
- public init (
60
- testHarness: TestHarness = . default
61
- ) {
62
- self . testHarness = testHarness
63
- }
64
- }
65
-
66
56
/// Add the given target to the manifest, producing a set of edit results
67
57
/// that updates the manifest and adds some source files to stub out the
68
58
/// new target.
69
59
public static func manifestRefactor(
70
60
syntax manifest: SourceFileSyntax ,
71
61
in context: Context
72
62
) throws -> PackageEdit {
73
- let configuration = context. configuration
74
63
guard let packageCall = manifest. findCall ( calleeName: " Package " ) else {
75
64
throw ManifestEditError . cannotFindPackage
76
65
}
@@ -120,7 +109,7 @@ public struct AddPackageTarget: ManifestEditRefactoringProvider {
120
109
addPrimarySourceFile (
121
110
outerPath: outerPath,
122
111
target: target,
123
- configuration : configuration ,
112
+ in : context ,
124
113
to: & auxiliaryFiles
125
114
)
126
115
@@ -176,7 +165,7 @@ public struct AddPackageTarget: ManifestEditRefactoringProvider {
176
165
fileprivate static func addPrimarySourceFile(
177
166
outerPath: String ,
178
167
target: PackageTarget ,
179
- configuration : Configuration ,
168
+ in context : Context ,
180
169
to auxiliaryFiles: inout AuxiliaryFiles
181
170
) {
182
171
let sourceFilePath = " \( outerPath) / \( target. name) / \( target. name) .swift "
@@ -188,7 +177,7 @@ public struct AddPackageTarget: ManifestEditRefactoringProvider {
188
177
189
178
// Add appropriate test module dependencies.
190
179
if target. type == . test {
191
- switch configuration . testHarness {
180
+ switch context . testHarness {
192
181
case . none:
193
182
break
194
183
@@ -229,7 +218,7 @@ public struct AddPackageTarget: ManifestEditRefactoringProvider {
229
218
"""
230
219
231
220
case . test:
232
- switch configuration . testHarness {
221
+ switch context . testHarness {
233
222
case . none:
234
223
sourceFileText = """
235
224
\( imports)
0 commit comments