Skip to content

Commit 366e545

Browse files
Implement SwiftFixIt — a library for deserializing diagnostics and applying fix-its (#8585)
### Motivation: This is part of the [migration tooling](swiftlang/swift-evolution#2673) initiative for Swift features. ### Modifications: For now, this API accepts a collection of `.dia` files, deserializes them, and applies fix-its in place. Eventually, it is expected to serve the upcoming `swift fixit` and `swift migrate` subcommands and support various filtering options, as well as a stateful, interactive workflow similar to `git add --patch`.
1 parent 879236b commit 366e545

File tree

4 files changed

+1061
-0
lines changed

4 files changed

+1061
-0
lines changed

Package.swift

+19
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,21 @@ let package = Package(
304304
]
305305
),
306306

307+
.target(
308+
/** API for deserializing diagnostics and applying fix-its */
309+
name: "SwiftFixIt",
310+
dependencies: [
311+
"Basics",
312+
.product(name: "TSCBasic", package: "swift-tools-support-core"),
313+
] + swiftSyntaxDependencies(
314+
["SwiftDiagnostics", "SwiftIDEUtils", "SwiftParser", "SwiftSyntax"]
315+
),
316+
exclude: ["CMakeLists.txt"],
317+
swiftSettings: commonExperimentalFeatures + [
318+
.unsafeFlags(["-static"]),
319+
]
320+
),
321+
307322
// MARK: Project Model
308323

309324
.target(
@@ -916,6 +931,10 @@ let package = Package(
916931
dependencies: ["SourceControl", "_InternalTestSupport"],
917932
exclude: ["Inputs/TestRepo.tgz"]
918933
),
934+
.testTarget(
935+
name: "SwiftFixItTests",
936+
dependencies: ["SwiftFixIt", "_InternalTestSupport"]
937+
),
919938
.testTarget(
920939
name: "XCBuildSupportTests",
921940
dependencies: ["XCBuildSupport", "_InternalTestSupport", "_InternalBuildTestSupport"],

Sources/SwiftFixIt/CMakeLists.txt

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# This source file is part of the Swift open source project
2+
#
3+
# Copyright (c) 2025 Apple Inc. and the Swift project authors
4+
# Licensed under Apache License v2.0 with Runtime Library Exception
5+
#
6+
# See http://swift.org/LICENSE.txt for license information
7+
# See http://swift.org/CONTRIBUTORS.txt for Swift project authors
8+
9+
add_library(SwiftFixIt STATIC
10+
SwiftFixIt.swift)
11+
target_link_libraries(SwiftFixIt PUBLIC
12+
Basics
13+
14+
SwiftSyntax::SwiftDiagnostics
15+
SwiftSyntax::SwiftIDEUtils
16+
SwiftSyntax::SwiftParser
17+
SwiftSyntax::SwiftSyntax
18+
19+
TSCBasic
20+
TSCUtility
21+
)
22+
23+
set_target_properties(SwiftFixIt PROPERTIES
24+
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY})

0 commit comments

Comments
 (0)