Skip to content

Update to swift-syntax 600.0.0 #959

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ var dependencies: [Package.Dependency] {
branch: "main"),
.package(
url: "https://github.com/swiftlang/swift-syntax",
from: "600.0.0-latest")
from: "600.0.0")
]
}
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/FoundationMacros/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ if(NOT SwiftSyntax_FOUND)
# If building at desk, check out and link against the SwiftSyntax repo's targets
FetchContent_Declare(SwiftSyntax
GIT_REPOSITORY https://github.com/swiftlang/swift-syntax.git
GIT_TAG 4c6cc0a3b9e8f14b3ae2307c5ccae4de6167ac2c) # 600.0.0-prerelease-2024-06-12
GIT_TAG 600.0.0)
FetchContent_MakeAvailable(SwiftSyntax)
else()
message(STATUS "SwiftSyntax_DIR provided, using swift-syntax from ${SwiftSyntax_DIR}")
Expand Down
24 changes: 7 additions & 17 deletions Tests/FoundationMacrosTests/MacroTestUtilities.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ struct DiagnosticTest : ExpressibleByStringLiteral, Hashable, CustomStringConver

var mappedToExpression: Self {
DiagnosticTest(
message._replacing("Predicate", with: "Expression")._replacing("predicate", with: "expression"),
message.replacing("Predicate", with: "Expression").replacing("predicate", with: "expression"),
fixIts: fixIts.map {
FixItTest($0.message, result: $0.result._replacing("#Predicate", with: "#Expression"))
FixItTest($0.message, result: $0.result.replacing("#Predicate", with: "#Expression"))
}
)
}
Expand Down Expand Up @@ -125,7 +125,9 @@ func AssertMacroExpansion(macros: [String : Macro.Type], testModuleName: String
let origSourceFile = Parser.parse(source: source)
let expandedSourceFile: Syntax
do {
expandedSourceFile = try OperatorTable.standardOperators.foldAll(origSourceFile).expand(macros: macros, in: context)
expandedSourceFile = try OperatorTable.standardOperators.foldAll(origSourceFile).expand(macros: macros) { syntax in
BasicMacroExpansionContext(sharingWith: context, lexicalContext: [syntax])
}
} catch {
XCTFail("Operator folding on input source failed with error \(error)")
return
Expand Down Expand Up @@ -157,22 +159,10 @@ func AssertPredicateExpansion(_ source: String, _ result: String = "", diagnosti
)
AssertMacroExpansion(
macros: ["Expression" : FoundationMacros.ExpressionMacro.self],
source._replacing("#Predicate", with: "#Expression"),
result._replacing(".Predicate", with: ".Expression"),
source.replacing("#Predicate", with: "#Expression"),
result.replacing(".Predicate", with: ".Expression"),
diagnostics: Set(diagnostics.map(\.mappedToExpression)),
file: file,
line: line
)
}

extension String {
func _replacing(_ text: String, with other: String) -> Self {
if #available(macOS 13.0, *) {
// Use the stdlib API if available
self.replacing(text, with: other)
} else {
// Use the Foundation API on older OSes
self.replacingOccurrences(of: text, with: other, options: [.literal])
}
}
}