Skip to content

Commit e4f897e

Browse files
authored
Revert "Replace ExpressibleAs protocols by ExpressibleBy protocols"
1 parent 32786eb commit e4f897e

10 files changed

+1665
-1665
lines changed

Sources/SwiftSyntaxBuilder/Buildables.swift.gyb

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from gyb_syntax_support.kinds import lowercase_first_word
44
from gyb_syntax_support.kinds import SYNTAX_BASE_KINDS
55
from gyb_syntax_support.kinds import syntax_buildable_child_type, syntax_buildable_default_init_value
6-
from gyb_syntax_support.protocolsMap import SYNTAX_BUILDABLE_EXPRESSIBLE_BY_CONFORMANCES
6+
from gyb_syntax_support.protocolsMap import SYNTAX_BUILDABLE_EXPRESSIBLE_AS_CONFORMANCES
77
# -*- mode: Swift -*-
88
# Ignore the following admonition it applies to the resulting .swift file only
99
}%
@@ -41,20 +41,20 @@ public protocol ${kind}ListBuildable: SyntaxListBuildable {
4141
}
4242

4343
% buildable_type = kind + 'Buildable'
44-
% expressible_by_type = 'ExpressibleBy' + buildable_type
45-
% expressible_by_protocols = SYNTAX_BUILDABLE_EXPRESSIBLE_BY_CONFORMANCES.get(expressible_by_type)
46-
% if expressible_by_protocols:
47-
public protocol ${expressible_by_type}: ${', '.join(expressible_by_protocols)} {
44+
% expressible_as_type = 'ExpressibleAs' + buildable_type
45+
% expressible_as_protocols = SYNTAX_BUILDABLE_EXPRESSIBLE_AS_CONFORMANCES.get(expressible_as_type)
46+
% if expressible_as_protocols:
47+
public protocol ${expressible_as_type}: ${', '.join(expressible_as_protocols)} {
4848
% else:
49-
public protocol ${expressible_by_type} {
49+
public protocol ${expressible_as_type} {
5050
% end
5151
func create${buildable_type}() -> ${buildable_type}
5252
}
5353

5454
% if kind == 'Syntax':
55-
public protocol ${buildable_type}: ExpressibleBy${buildable_type}, ${kind}ListBuildable {
55+
public protocol ${buildable_type}: ExpressibleAs${buildable_type}, ${kind}ListBuildable {
5656
% else:
57-
public protocol ${buildable_type}: ExpressibleBy${buildable_type}, SyntaxBuildable, ${kind}ListBuildable {
57+
public protocol ${buildable_type}: ExpressibleAs${buildable_type}, SyntaxBuildable, ${kind}ListBuildable {
5858
% end
5959
/// Builds a `${build_kind}`.
6060
/// - Parameter format: The `Format` to use.
@@ -124,7 +124,7 @@ public struct ${node.syntax_kind}: ${node.base_kind}Buildable {
124124
% child_token = SYNTAX_TOKEN_MAP.get(child.syntax_kind)
125125
% param_type = syntax_buildable_child_type(child.type_name, child.syntax_kind, child.is_token(), child.is_optional)
126126
% default_value = syntax_buildable_default_init_value(child, child_token)
127-
% init_parameters.append("%s: ExpressibleBy%s%s" % (child.swift_name, param_type, default_value))
127+
% init_parameters.append("%s: ExpressibleAs%s%s" % (child.swift_name, param_type, default_value))
128128
% end
129129
${',\n '.join(init_parameters)}
130130
) {
@@ -188,7 +188,7 @@ public struct ${node.syntax_kind}: ${node.base_kind}Buildable {
188188
public struct ${node.syntax_kind}: SyntaxBuildable {
189189
let elements: [${element_type}]
190190

191-
public init(_ elements: [ExpressibleBy${element_type}]) {
191+
public init(_ elements: [ExpressibleAs${element_type}]) {
192192
self.elements = elements.map { $0.create${element_type}() }
193193
}
194194

@@ -219,62 +219,62 @@ public struct ${node.syntax_kind}: SyntaxBuildable {
219219

220220
% end
221221
% if node.is_buildable() or node.is_syntax_collection():
222-
% expressible_by_type = 'ExpressibleBy' + node.syntax_kind
223-
% expressible_by_protocols = SYNTAX_BUILDABLE_EXPRESSIBLE_BY_CONFORMANCES.get(expressible_by_type)
224-
% if expressible_by_protocols:
225-
public protocol ${expressible_by_type}: ${', '.join(expressible_by_protocols)} {
222+
% expressible_as_type = 'ExpressibleAs' + node.syntax_kind
223+
% expressible_as_protocols = SYNTAX_BUILDABLE_EXPRESSIBLE_AS_CONFORMANCES.get(expressible_as_type)
224+
% if expressible_as_protocols:
225+
public protocol ${expressible_as_type}: ${', '.join(expressible_as_protocols)} {
226226
% else:
227-
public protocol ${expressible_by_type} {
227+
public protocol ${expressible_as_type} {
228228
% end
229229
func create${node.syntax_kind}() -> ${node.syntax_kind}
230230
}
231231

232-
extension ${node.syntax_kind}: ${expressible_by_type} {
232+
extension ${node.syntax_kind}: ${expressible_as_type} {
233233
public func create${node.syntax_kind}() -> ${node.syntax_kind} {
234234
self
235235
}
236236
}
237237

238238
% end
239239
% end
240-
public protocol ExpressibleByTokenSyntax {
240+
public protocol ExpressibleAsTokenSyntax {
241241
func createTokenSyntax() -> TokenSyntax
242242
}
243243

244-
extension TokenSyntax: ExpressibleByTokenSyntax {
244+
extension TokenSyntax: ExpressibleAsTokenSyntax {
245245
public func createTokenSyntax() -> TokenSyntax {
246246
self
247247
}
248248
}
249249

250-
// MARK: - Syntax buildable expressible by conformances
250+
// MARK: - Syntax buildable expressible as conformances
251251

252-
% for protocol, conformances in SYNTAX_BUILDABLE_EXPRESSIBLE_BY_CONFORMANCES.items():
253-
% if 'ExpressibleByConditionElementList' in conformances:
252+
% for protocol, conformances in SYNTAX_BUILDABLE_EXPRESSIBLE_AS_CONFORMANCES.items():
253+
% if 'ExpressibleAsConditionElementList' in conformances:
254254
extension ${protocol} {
255255
public func createConditionElementList() -> ConditionElementList {
256256
ConditionElementList([self])
257257
}
258258
}
259259

260260
% end
261-
% if 'ExpressibleByConditionElement' in conformances:
261+
% if 'ExpressibleAsConditionElement' in conformances:
262262
extension ${protocol} {
263263
public func createConditionElement() -> ConditionElement {
264264
ConditionElement(condition: self)
265265
}
266266
}
267267

268268
% end
269-
% if 'ExpressibleByCodeBlockItem' in conformances:
269+
% if 'ExpressibleAsCodeBlockItem' in conformances:
270270
extension ${protocol} {
271271
public func createCodeBlockItem() -> CodeBlockItem {
272272
CodeBlockItem(item: self)
273273
}
274274
}
275275

276276
% end
277-
% if 'ExpressibleByMemberDeclListItem' in conformances:
277+
% if 'ExpressibleAsMemberDeclListItem' in conformances:
278278
extension ${protocol} {
279279
public func createMemberDeclListItem() -> MemberDeclListItem {
280280
MemberDeclListItem(decl: self)

Sources/SwiftSyntaxBuilder/BuildablesConvenienceInitializers.swift.gyb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ extension ${node.syntax_kind} {
4444
% if child_node and child_node.is_syntax_collection():
4545
% # Allow initializing syntax collections with result builders
4646
% default_value = "? = { nil }" if child.is_optional else " = { %s.empty }" % (child.syntax_kind)
47-
% init_result_builder_parameters.append("@%sBuilder %sBuilder: () -> ExpressibleBy%s%s" % (child.syntax_kind, child.swift_name, child.syntax_kind, default_value))
47+
% init_result_builder_parameters.append("@%sBuilder %sBuilder: () -> ExpressibleAs%s%s" % (child.syntax_kind, child.swift_name, child.syntax_kind, default_value))
4848
% elif child_token and not child_token.text:
4949
% # Allow initializing identifier or a token without a text with String value
5050
% param_type = "String?" if child.is_optional else "String"
@@ -53,7 +53,7 @@ extension ${node.syntax_kind} {
5353
% # When type is not handled above, use default value
5454
% param_type = syntax_buildable_child_type(child.type_name, child.syntax_kind, child.is_token(), child.is_optional)
5555
% default_value = syntax_buildable_default_init_value(child, child_token)
56-
% init_parameters.append("%s: ExpressibleBy%s%s" % (child.swift_name, param_type, default_value))
56+
% init_parameters.append("%s: ExpressibleAs%s%s" % (child.swift_name, param_type, default_value))
5757
% end
5858
% end
5959
${',\n '.join(init_parameters + init_result_builder_parameters)}

Sources/SwiftSyntaxBuilder/FunctionCallExprConvenienceInitializers.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ import Foundation
1616
extension FunctionCallExpr {
1717
public init(
1818
_ calledExpression: IdentifierExpr,
19-
leftParen: ExpressibleByTokenSyntax? = nil,
20-
rightParen: ExpressibleByTokenSyntax? = nil,
21-
trailingClosure: ExpressibleByClosureExpr? = nil,
19+
leftParen: ExpressibleAsTokenSyntax? = nil,
20+
rightParen: ExpressibleAsTokenSyntax? = nil,
21+
trailingClosure: ExpressibleAsClosureExpr? = nil,
2222
@TupleExprElementListBuilder argumentListBuilder: () -> TupleExprElementList = { .empty },
2323
@MultipleTrailingClosureElementListBuilder additionalTrailingClosuresBuilder: () -> MultipleTrailingClosureElementList? = { nil }
2424
) {

Sources/SwiftSyntaxBuilder/ResultBuilders.swift.gyb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ public struct ${node.syntax_kind}Builder {
2929

3030
/// The type of individual statement expressions in the transformed function,
3131
/// which defaults to Component if buildExpression() is not provided.
32-
public typealias Expression = ExpressibleBy${element_type}
32+
public typealias Expression = ExpressibleAs${element_type}
3333

3434
/// The type of a partial result, which will be carried through all of the
3535
/// build methods.
36-
public typealias Component = [ExpressibleBy${element_type}]
36+
public typealias Component = [ExpressibleAs${element_type}]
3737

3838
/// The type of the final returned result, which defaults to Component if
3939
/// buildFinalResult() is not provided.

Sources/SwiftSyntaxBuilder/Tokens.swift.gyb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import SwiftSyntax
2222

2323
/// Namespace for commonly used tokens with default trivia.
24-
public extension ExpressibleByTokenSyntax where Self == TokenSyntax {
24+
public extension ExpressibleAsTokenSyntax where Self == TokenSyntax {
2525
% for token in SYNTAX_TOKENS:
2626
% if token.is_keyword:
2727
/// The `${token.text.encode('utf-8').decode('unicode_escape')}` keyword

0 commit comments

Comments
 (0)