|
3 | 3 | from gyb_syntax_support.kinds import lowercase_first_word |
4 | 4 | from gyb_syntax_support.kinds import SYNTAX_BASE_KINDS |
5 | 5 | 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_AS_CONFORMANCES |
| 6 | + from gyb_syntax_support.protocolsMap import SYNTAX_BUILDABLE_EXPRESSIBLE_BY_CONFORMANCES |
7 | 7 | # -*- mode: Swift -*- |
8 | 8 | # Ignore the following admonition it applies to the resulting .swift file only |
9 | 9 | }% |
@@ -41,20 +41,20 @@ public protocol ${kind}ListBuildable: SyntaxListBuildable { |
41 | 41 | } |
42 | 42 |
|
43 | 43 | % buildable_type = kind + 'Buildable' |
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)} { |
| 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)} { |
48 | 48 | % else: |
49 | | -public protocol ${expressible_as_type} { |
| 49 | +public protocol ${expressible_by_type} { |
50 | 50 | % end |
51 | 51 | func create${buildable_type}() -> ${buildable_type} |
52 | 52 | } |
53 | 53 |
|
54 | 54 | % if kind == 'Syntax': |
55 | | -public protocol ${buildable_type}: ExpressibleAs${buildable_type}, ${kind}ListBuildable { |
| 55 | +public protocol ${buildable_type}: ExpressibleBy${buildable_type}, ${kind}ListBuildable { |
56 | 56 | % else: |
57 | | -public protocol ${buildable_type}: ExpressibleAs${buildable_type}, SyntaxBuildable, ${kind}ListBuildable { |
| 57 | +public protocol ${buildable_type}: ExpressibleBy${buildable_type}, SyntaxBuildable, ${kind}ListBuildable { |
58 | 58 | % end |
59 | 59 | /// Builds a `${build_kind}`. |
60 | 60 | /// - Parameter format: The `Format` to use. |
@@ -124,7 +124,7 @@ public struct ${node.syntax_kind}: ${node.base_kind}Buildable { |
124 | 124 | % child_token = SYNTAX_TOKEN_MAP.get(child.syntax_kind) |
125 | 125 | % param_type = syntax_buildable_child_type(child.type_name, child.syntax_kind, child.is_token(), child.is_optional) |
126 | 126 | % default_value = syntax_buildable_default_init_value(child, child_token) |
127 | | -% init_parameters.append("%s: ExpressibleAs%s%s" % (child.swift_name, param_type, default_value)) |
| 127 | +% init_parameters.append("%s: ExpressibleBy%s%s" % (child.swift_name, param_type, default_value)) |
128 | 128 | % end |
129 | 129 | ${',\n '.join(init_parameters)} |
130 | 130 | ) { |
@@ -188,7 +188,7 @@ public struct ${node.syntax_kind}: ${node.base_kind}Buildable { |
188 | 188 | public struct ${node.syntax_kind}: SyntaxBuildable { |
189 | 189 | let elements: [${element_type}] |
190 | 190 |
|
191 | | - public init(_ elements: [ExpressibleAs${element_type}]) { |
| 191 | + public init(_ elements: [ExpressibleBy${element_type}]) { |
192 | 192 | self.elements = elements.map { $0.create${element_type}() } |
193 | 193 | } |
194 | 194 |
|
@@ -219,62 +219,62 @@ public struct ${node.syntax_kind}: SyntaxBuildable { |
219 | 219 |
|
220 | 220 | % end |
221 | 221 | % if node.is_buildable() or node.is_syntax_collection(): |
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)} { |
| 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)} { |
226 | 226 | % else: |
227 | | -public protocol ${expressible_as_type} { |
| 227 | +public protocol ${expressible_by_type} { |
228 | 228 | % end |
229 | 229 | func create${node.syntax_kind}() -> ${node.syntax_kind} |
230 | 230 | } |
231 | 231 |
|
232 | | -extension ${node.syntax_kind}: ${expressible_as_type} { |
| 232 | +extension ${node.syntax_kind}: ${expressible_by_type} { |
233 | 233 | public func create${node.syntax_kind}() -> ${node.syntax_kind} { |
234 | 234 | self |
235 | 235 | } |
236 | 236 | } |
237 | 237 |
|
238 | 238 | % end |
239 | 239 | % end |
240 | | -public protocol ExpressibleAsTokenSyntax { |
| 240 | +public protocol ExpressibleByTokenSyntax { |
241 | 241 | func createTokenSyntax() -> TokenSyntax |
242 | 242 | } |
243 | 243 |
|
244 | | -extension TokenSyntax: ExpressibleAsTokenSyntax { |
| 244 | +extension TokenSyntax: ExpressibleByTokenSyntax { |
245 | 245 | public func createTokenSyntax() -> TokenSyntax { |
246 | 246 | self |
247 | 247 | } |
248 | 248 | } |
249 | 249 |
|
250 | | -// MARK: - Syntax buildable expressible as conformances |
| 250 | +// MARK: - Syntax buildable expressible by conformances |
251 | 251 |
|
252 | | -% for protocol, conformances in SYNTAX_BUILDABLE_EXPRESSIBLE_AS_CONFORMANCES.items(): |
253 | | -% if 'ExpressibleAsConditionElementList' in conformances: |
| 252 | +% for protocol, conformances in SYNTAX_BUILDABLE_EXPRESSIBLE_BY_CONFORMANCES.items(): |
| 253 | +% if 'ExpressibleByConditionElementList' in conformances: |
254 | 254 | extension ${protocol} { |
255 | 255 | public func createConditionElementList() -> ConditionElementList { |
256 | 256 | ConditionElementList([self]) |
257 | 257 | } |
258 | 258 | } |
259 | 259 |
|
260 | 260 | % end |
261 | | -% if 'ExpressibleAsConditionElement' in conformances: |
| 261 | +% if 'ExpressibleByConditionElement' in conformances: |
262 | 262 | extension ${protocol} { |
263 | 263 | public func createConditionElement() -> ConditionElement { |
264 | 264 | ConditionElement(condition: self) |
265 | 265 | } |
266 | 266 | } |
267 | 267 |
|
268 | 268 | % end |
269 | | -% if 'ExpressibleAsCodeBlockItem' in conformances: |
| 269 | +% if 'ExpressibleByCodeBlockItem' in conformances: |
270 | 270 | extension ${protocol} { |
271 | 271 | public func createCodeBlockItem() -> CodeBlockItem { |
272 | 272 | CodeBlockItem(item: self) |
273 | 273 | } |
274 | 274 | } |
275 | 275 |
|
276 | 276 | % end |
277 | | -% if 'ExpressibleAsMemberDeclListItem' in conformances: |
| 277 | +% if 'ExpressibleByMemberDeclListItem' in conformances: |
278 | 278 | extension ${protocol} { |
279 | 279 | public func createMemberDeclListItem() -> MemberDeclListItem { |
280 | 280 | MemberDeclListItem(decl: self) |
|
0 commit comments