Skip to content

Commit d368cb0

Browse files
authored
[Commands] Adjust swift package migrate to only apply fix-its to th… (#8629)
…e selected features ### Motivation: Use new ability of `SwiftFixIt` to filter by category, to make sure that the command only applies fix-its that are related to the selected features and nothing else. ### Modifications: - `swift package migrate` - Add an argument to `SwiftFixIt` API that lists all of the features selected by the user. ### Result: Even if there are other warnings with a single fix-it the command is not going to apply them i.e. for `var` -> `let` or `<name>` to `_`.
1 parent 97fad74 commit d368cb0

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

Fixtures/SwiftMigrate/ExistentialAnyMigration/Sources/Fixed/Test.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,7 @@ func test2(_: (any P).Protocol) {
1010
func test3() {
1111
let _: [(any P)?] = []
1212
}
13+
14+
func test4() {
15+
var x = 42
16+
}

Fixtures/SwiftMigrate/ExistentialAnyMigration/Sources/Test.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,7 @@ func test2(_: P.Protocol) {
1010
func test3() {
1111
let _: [P?] = []
1212
}
13+
14+
func test4() {
15+
var x = 42
16+
}

Sources/Commands/PackageCommands/Migrate.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ extension SwiftPackageCommand {
126126
for module in modules {
127127
let fixit = try SwiftFixIt(
128128
diagnosticFiles: module.diagnosticFiles,
129+
categories: Set(features.map(\.name)),
129130
fileSystem: swiftCommandState.fileSystem
130131
)
131132
try fixit.applyFixIts()

0 commit comments

Comments
 (0)