Skip to content

Commit d5fdfa7

Browse files
authored
Merge pull request #65383 from ahoppen/ahoppen/no-deprecation
[Macros] Remove usages of deprecated methods in SwiftSyntaxMacros
2 parents 12f2c2e + 3b0dc8d commit d5fdfa7

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

Diff for: lib/ASTGen/Sources/ASTGen/SourceManager+MacroExpansionContext.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ extension SourceManager.MacroExpansionContext: MacroExpansionContext {
8888
of node: Node,
8989
at position: PositionInSyntaxNode,
9090
filePathMode: SourceLocationFilePathMode
91-
) -> SourceLocation? {
91+
) -> AbstractSourceLocation? {
9292
guard let (sourceFile, rootPosition) = sourceManager.rootSourceFile(of: node),
9393
let exportedSourceFile =
9494
sourceManager.exportedSourceFilesBySyntax[sourceFile]?.pointee
@@ -127,6 +127,6 @@ extension SourceManager.MacroExpansionContext: MacroExpansionContext {
127127

128128
// Do the location lookup.
129129
let converter = SourceLocationConverter(file: fileName, tree: sourceFile)
130-
return converter.location(for: rootPosition.advanced(by: offsetWithinSyntaxNode))
130+
return AbstractSourceLocation(converter.location(for: rootPosition.advanced(by: offsetWithinSyntaxNode)))
131131
}
132132
}

Diff for: test/Macros/Inputs/syntax_macro_definitions.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public struct FileIDMacro: ExpressionMacro {
4242
throw CustomError.message("can't find location for macro")
4343
}
4444

45-
let fileLiteral: ExprSyntax = "\(literal: sourceLoc.file)"
45+
let fileLiteral: ExprSyntax = "\(sourceLoc.file)"
4646
return fileLiteral.with(\.leadingTrivia, macro.leadingTrivia)
4747
}
4848
}
@@ -565,7 +565,7 @@ public struct AddExtMembers: MemberMacro {
565565
providingMembersOf decl: some DeclGroupSyntax,
566566
in context: some MacroExpansionContext
567567
) throws -> [DeclSyntax] {
568-
let uniqueClassName = context.createUniqueName("uniqueClass")
568+
let uniqueClassName = context.makeUniqueName("uniqueClass")
569569

570570
let instanceMethod: DeclSyntax =
571571
"""

Diff for: test/Macros/macro_expand.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,8 @@ func testAddBlocker(a: Int, b: Int, c: Int, oa: OnlyAdds) {
237237

238238
// Test source location information.
239239
func testSourceLocations(x: Int, yolo: Int, zulu: Int) {
240-
// CHECK-MACRO-PRINTED: Source range for LHS is MacroUser/macro_expand.swift: [[@LINE+3]]:5-[[@LINE+3]]:13
241-
// CHECK-MACRO-PRINTED: Source range for LHS is MacroUser/macro_expand.swift: [[@LINE+2]]:5-[[@LINE+2]]:6
240+
// CHECK-MACRO-PRINTED: Source range for LHS is "MacroUser/macro_expand.swift": [[@LINE+3]]:5-[[@LINE+3]]:13
241+
// CHECK-MACRO-PRINTED: Source range for LHS is "MacroUser/macro_expand.swift": [[@LINE+2]]:5-[[@LINE+2]]:6
242242
_ = #leftHandOperandFinder(
243243
x + yolo + zulu
244244
)

0 commit comments

Comments
 (0)