Skip to content

Commit

Permalink
update swift syntax to 5.9.2
Browse files Browse the repository at this point in the history
  • Loading branch information
yume190@gmail.com committed Dec 29, 2023
1 parent c8627e6 commit 2e01c7e
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 14 deletions.
4 changes: 2 additions & 2 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-syntax.git",
"state" : {
"revision" : "67c5007099d9ffdd292f421f81f4efe5ee42963e",
"version" : "509.0.0-swift-DEVELOPMENT-SNAPSHOT-2023-07-10-a"
"revision" : "6ad4ea24b01559dde0773e3d091f1b9e36175036",
"version" : "509.0.2"
}
}
],
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ let package = Package(
dependencies: [
.package(
url: "https://github.com/apple/swift-syntax.git",
from: "509.0.0-swift-DEVELOPMENT-SNAPSHOT-2023-07-10-a"
from: "509.0.2"
),
],
targets: [
Expand Down
2 changes: 1 addition & 1 deletion Package@swift-5.9.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ let package = Package(
dependencies: [
.package(
url: "https://github.com/apple/swift-syntax.git",
from: "509.0.0-swift-DEVELOPMENT-SNAPSHOT-2023-07-10-a"
from: "509.0.2"
),
],
targets: [
Expand Down
12 changes: 6 additions & 6 deletions Sources/TemporaryVariablePlugin/InfoMacro.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public struct InfoMacro: ExpressionMacro {

let closure = ClosureExprSyntax(statements: list)
let functionCall = FunctionCallExprSyntax(
callee: IdentifierExprSyntax(identifier: "info"),
callee: DeclReferenceExprSyntax(baseName: "info"),
trailingClosure: closure
)

Expand Down Expand Up @@ -104,7 +104,7 @@ final class InfoRewriter<Context: MacroExpansionContext>: SyntaxRewriter {
/// call(...)
private final func withBase(_ node: FunctionCallExprSyntax) -> ExprSyntax {
/// call(r1, r2, ...)
let newNode = node.with(\.argumentList, visit(node.argumentList))
let newNode = node.with(\.arguments, visit(node.arguments))
.with(\.leadingTrivia, .spaces(0))
.with(\.trailingTrivia, .spaces(0))

Expand All @@ -116,13 +116,13 @@ final class InfoRewriter<Context: MacroExpansionContext>: SyntaxRewriter {
""")

/// r0
return .init(IdentifierExprSyntax(identifier: variable))
return .init(DeclReferenceExprSyntax(baseName: variable))
}

/// withoutBase: .call(...)
private final func withoutBase(_ node: FunctionCallExprSyntax) -> ExprSyntax {
/// .call(r1, r2, ...)
let newNode = node.with(\.argumentList, visit(node.argumentList))
let newNode = node.with(\.arguments, visit(node.arguments))
.with(\.leadingTrivia, .spaces(0))
.with(\.trailingTrivia, .spaces(0))

Expand All @@ -134,7 +134,7 @@ final class InfoRewriter<Context: MacroExpansionContext>: SyntaxRewriter {
guard let functionCall = node.value.as(FunctionCallExprSyntax.self) else {
return node
}
let newFunctionCall = functionCall.with(\.argumentList, visit(functionCall.argumentList))
let newFunctionCall = functionCall.with(\.arguments, visit(functionCall.arguments))
return node.with(\.value, .init(newFunctionCall))
}

Expand All @@ -143,7 +143,7 @@ final class InfoRewriter<Context: MacroExpansionContext>: SyntaxRewriter {
/// skip call(...)
/// ex: print(...)
if let functionCall = node.item.as(FunctionCallExprSyntax.self) {
let newItem = functionCall.with(\.argumentList, visit(functionCall.argumentList))
let newItem = functionCall.with(\.arguments, visit(functionCall.arguments))
return node.with(\.item, .init(newItem))
}

Expand Down
6 changes: 2 additions & 4 deletions Tests/TemporaryVariableTests/TemporaryVariableTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ import SwiftSyntaxMacrosTestSupport
final class InfoFailTests: XCTestCase {
final func testWithFail() {
assertMacroExpansion(
"""
#info
""",
expandedSource: "",
"#info",
expandedSource: "#info",
diagnostics: [
DiagnosticSpec(message: "Can't find trail closure", line: 1, column: 1)
],
Expand Down

0 comments on commit 2e01c7e

Please sign in to comment.