@@ -17,17 +17,6 @@ import SwiftSyntaxBuilder
17
17
/// Interface to extract information about the context in which a given
18
18
/// macro is expanded.
19
19
public protocol MacroExpansionContext : AnyObject {
20
- /// Generate a unique name for use in the macro.
21
- ///
22
- /// - Parameters:
23
- /// - name: The name to use as a basis for the uniquely-generated name,
24
- /// which will appear in the unique name that's produced here.
25
- ///
26
- /// - Returns: an identifier token containing a unique name that will not
27
- /// conflict with any other name in a well-formed program.
28
- @available ( * , renamed: " makeUniqueName(_:) " )
29
- func createUniqueName( _ name: String ) -> TokenSyntax
30
-
31
20
/// Generate a unique name for use in the macro.
32
21
///
33
22
/// - Parameters:
@@ -53,26 +42,6 @@ public protocol MacroExpansionContext: AnyObject {
53
42
/// - Returns: the source location within the given node, or `nil` if the
54
43
/// given syntax node is not rooted in a source file that the macro
55
44
/// expansion context knows about.
56
- @available ( * , deprecated, message: " Please use AbstractSourceLocation version " )
57
- func location< Node: SyntaxProtocol > (
58
- of node: Node ,
59
- at position: PositionInSyntaxNode ,
60
- filePathMode: SourceLocationFilePathMode
61
- ) -> SourceLocation ?
62
-
63
- /// Retrieve a source location for the given syntax node.
64
- ///
65
- /// - Parameters:
66
- /// - node: The syntax node whose source location to produce.
67
- /// - position: The position within the syntax node for the resulting
68
- /// location.
69
- /// - filePathMode: How the file name contained in the source location is
70
- /// formed.
71
- ///
72
- /// - Returns: the source location within the given node, or `nil` if the
73
- /// given syntax node is not rooted in a source file that the macro
74
- /// expansion context knows about.
75
- @_disfavoredOverload
76
45
func location< Node: SyntaxProtocol > (
77
46
of node: Node ,
78
47
at position: PositionInSyntaxNode ,
@@ -90,87 +59,13 @@ extension MacroExpansionContext {
90
59
/// - Returns: the source location within the given node, or `nil` if the
91
60
/// given syntax node is not rooted in a source file that the macro
92
61
/// expansion context knows about.
93
- @available ( * , deprecated, message: " Please use AbstractSourceLocation version " )
94
- public func location< Node: SyntaxProtocol > (
95
- of node: Node
96
- ) -> SourceLocation ? {
97
- return location ( of: node, at: . afterLeadingTrivia, filePathMode: . fileID)
98
- }
99
-
100
- /// Retrieve a source location for the given syntax node's starting token
101
- /// (after leading trivia) using file naming according to `#fileID`.
102
- ///
103
- /// - Parameters:
104
- /// - node: The syntax node whose source location to produce.
105
- ///
106
- /// - Returns: the source location within the given node, or `nil` if the
107
- /// given syntax node is not rooted in a source file that the macro
108
- /// expansion context knows about.
109
- @_disfavoredOverload
110
62
public func location< Node: SyntaxProtocol > (
111
63
of node: Node
112
64
) -> AbstractSourceLocation ? {
113
65
return location ( of: node, at: . afterLeadingTrivia, filePathMode: . fileID)
114
66
}
115
67
}
116
68
117
- extension MacroExpansionContext {
118
- /// Retrieve a source location for the given syntax node.
119
- ///
120
- /// - Parameters:
121
- /// - node: The syntax node whose source location to produce.
122
- /// - position: The position within the syntax node for the resulting
123
- /// location.
124
- /// - filePathMode: How the file name contained in the source location is
125
- /// formed.
126
- ///
127
- /// - Returns: the source location within the given node, or `nil` if the
128
- /// given syntax node is not rooted in a source file that the macro
129
- /// expansion context knows about.
130
- @_disfavoredOverload
131
- @available ( * , deprecated, message: " Please use AbstractSourceLocation version " )
132
- public func location< Node: SyntaxProtocol > (
133
- of node: Node ,
134
- at position: PositionInSyntaxNode ,
135
- filePathMode: SourceLocationFilePathMode
136
- ) -> AbstractSourceLocation ? {
137
- guard let sourceLoc: SourceLocation = location ( of: node, at: position, filePathMode: filePathMode) else {
138
- return nil
139
- }
140
-
141
- return AbstractSourceLocation (
142
- file: " \( literal: sourceLoc. file) " ,
143
- line: " \( literal: sourceLoc. line) " ,
144
- column: " \( literal: sourceLoc. column) "
145
- )
146
- }
147
-
148
- /// Generate a unique name for use in the macro.
149
- ///
150
- /// - Parameters:
151
- /// - name: The name to use as a basis for the uniquely-generated name,
152
- /// which will appear in the unique name that's produced here.
153
- ///
154
- /// - Returns: an identifier token containing a unique name that will not
155
- /// conflict with any other name in a well-formed program.
156
- @available ( * , renamed: " makeUniqueName(_:) " )
157
- public func createUniqueName( _ name: String ) -> TokenSyntax {
158
- makeUniqueName ( name)
159
- }
160
-
161
- /// Generate a unique name for use in the macro.
162
- ///
163
- /// - Parameters:
164
- /// - name: The name to use as a basis for the uniquely-generated name,
165
- /// which will appear in the unique name that's produced here.
166
- ///
167
- /// - Returns: an identifier token containing a unique name that will not
168
- /// conflict with any other name in a well-formed program.
169
- public func makeUniqueName( _ name: String ) -> TokenSyntax {
170
- createUniqueName ( name)
171
- }
172
- }
173
-
174
69
/// Diagnostic message used for thrown errors.
175
70
private struct ThrownErrorDiagnostic : DiagnosticMessage {
176
71
let message : String
0 commit comments