Skip to content

Commit 6adbd18

Browse files
committed
[ASTGen] Add back TokenSyntax.bridgedIdentifier(in:) etc.
To avoid conflicts while migration. When all usage are migrated, this commit should be reverted.
1 parent eb4df38 commit 6adbd18

File tree

1 file changed

+82
-0
lines changed

1 file changed

+82
-0
lines changed

lib/ASTGen/Sources/ASTGen/Bridge.swift

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,3 +129,85 @@ extension BridgedStringRef {
129129
return self.data == nil && self.count == 0
130130
}
131131
}
132+
133+
extension SyntaxProtocol {
134+
/// Obtains the bridged start location of the node excluding leading trivia in the source buffer provided by `astgen`
135+
///
136+
/// - Parameter astgen: The visitor providing the source buffer.
137+
@available(*, deprecated, message: "use ASTContext.bridgedSourceLoc(syntax:)")
138+
@inline(__always)
139+
func bridgedSourceLoc(in astgen: ASTGenVisitor) -> BridgedSourceLoc {
140+
astgen.bridgedSourceLoc(syntax: self)
141+
}
142+
}
143+
144+
extension Optional where Wrapped: SyntaxProtocol {
145+
/// Obtains the bridged start location of the node excluding leading trivia in the source buffer provided by `astgen`.
146+
///
147+
/// - Parameter astgen: The visitor providing the source buffer.
148+
@available(*, deprecated, message: "use ASTContext.bridgedSourceLoc(syntax:)")
149+
@inline(__always)
150+
func bridgedSourceLoc(in astgen: ASTGenVisitor) -> BridgedSourceLoc {
151+
astgen.generateSourceLoc(self)
152+
}
153+
}
154+
155+
extension TokenSyntax {
156+
/// Obtains a bridged, `ASTContext`-owned copy of this token's text.
157+
///
158+
/// - Parameter astgen: The visitor providing the `ASTContext`.
159+
@available(*, deprecated, message: "use ASTContext.bridgedIdentifier(token:)")
160+
@inline(__always)
161+
func bridgedIdentifier(in astgen: ASTGenVisitor) -> BridgedIdentifier {
162+
astgen.generateIdentifier(self)
163+
}
164+
165+
/// Obtains a bridged, `ASTContext`-owned copy of this token's text, and its bridged start location in the
166+
/// source buffer provided by `astgen`.
167+
///
168+
/// - Parameter astgen: The visitor providing the `ASTContext` and source buffer.
169+
@available(*, deprecated, message: "use ASTContext.bridgedIdentifierAndSourceLoc(token:)")
170+
@inline(__always)
171+
func bridgedIdentifierAndSourceLoc(in astgen: ASTGenVisitor) -> (BridgedIdentifier, BridgedSourceLoc) {
172+
astgen.generateIdentifierAndSourceLoc(self)
173+
}
174+
175+
/// Obtains a bridged, `ASTContext`-owned copy of this token's text, and its bridged start location in the
176+
/// source buffer provided by `astgen`.
177+
///
178+
/// - Parameter astgen: The visitor providing the `ASTContext` and source buffer.
179+
@available(*, deprecated, message: "use ASTContext.bridgedIdentifierAndSourceLoc(token:)")
180+
@inline(__always)
181+
func bridgedIdentifierAndSourceLoc(in astgen: ASTGenVisitor) -> BridgedLocatedIdentifier {
182+
astgen.generateLocatedIdentifier(self)
183+
}
184+
}
185+
186+
extension Optional<TokenSyntax> {
187+
/// Obtains a bridged, `ASTContext`-owned copy of this token's text.
188+
///
189+
/// - Parameter astgen: The visitor providing the `ASTContext`.
190+
@available(*, deprecated, message: "use ASTContext.bridgedIdentifier(token:)")
191+
@inline(__always)
192+
func bridgedIdentifier(in astgen: ASTGenVisitor) -> BridgedIdentifier {
193+
astgen.generateIdentifier(self)
194+
}
195+
196+
/// Obtains a bridged, `ASTContext`-owned copy of this token's text, and its bridged start location in the
197+
/// source buffer provided by `astgen` excluding leading trivia.
198+
///
199+
/// - Parameter astgen: The visitor providing the `ASTContext` and source buffer.
200+
@available(*, deprecated, message: "use ASTContext.bridgedIdentifierAndSourceLoc(token:)")
201+
@inline(__always)
202+
func bridgedIdentifierAndSourceLoc(in astgen: ASTGenVisitor) -> (BridgedIdentifier, BridgedSourceLoc) {
203+
astgen.generateIdentifierAndSourceLoc(self)
204+
}
205+
}
206+
207+
extension BridgedSourceRange {
208+
@available(*, deprecated, message: "use ASTContext.bridgedSourceRange(startToken:endToken:)")
209+
@inline(__always)
210+
init(startToken: TokenSyntax, endToken: TokenSyntax, in astgen: ASTGenVisitor) {
211+
self = astgen.generateSourceRange(start: startToken, end: endToken)
212+
}
213+
}

0 commit comments

Comments
 (0)