Skip to content

Commit acc5861

Browse files
committed
Generate BuildableBaseProtocols with SwiftSyntaxBuilderGeneration
- Stub out BuildableBaseProtocolsFile - Generate buildable protocols too - Generate default implementations in BuildableBaseProtocols - Generate rest of BuildableBaseProtocols - Remove gyb-generated BuildableBaseProtocols
1 parent eedcf8f commit acc5861

File tree

6 files changed

+386
-357
lines changed

6 files changed

+386
-357
lines changed

Package.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ let package = Package(
7878
exclude: [
7979
"gyb_helpers",
8080
"ExpressibleAsProtocols.swift.gyb",
81-
"BuildableBaseProtocols.swift.gyb",
8281
"BuildableCollectionNodes.swift.gyb",
8382
"BuildableNodes.swift.gyb",
8483
"ResultBuilders.swift.gyb",

Sources/SwiftSyntaxBuilder/BuildableBaseProtocols.swift.gyb

Lines changed: 0 additions & 85 deletions
This file was deleted.
Lines changed: 217 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,217 @@
1+
2+
//// Automatically Generated by SwiftSyntaxBuilderGeneration
3+
//// Do Not Edit Directly!
4+
//===----------------------------------------------------------------------===//
5+
//
6+
// This source file is part of the Swift.org open source project
7+
//
8+
// Copyright (c) 2014 - 2022 Apple Inc. and the Swift project authors
9+
// Licensed under Apache License v2.0 with Runtime Library Exception
10+
//
11+
// See https://swift.org/LICENSE.txt for license information
12+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
13+
//
14+
//===----------------------------------------------------------------------===//
15+
16+
import SwiftSyntax
17+
public protocol PatternListBuildable: SyntaxBuildable{
18+
/// Builds list of `PatternSyntax`s.
19+
/// - Parameter format: The `Format` to use.
20+
/// - Parameter leadingTrivia: Replaces the last leading trivia if not nil.
21+
func buildPatternList(format: Format, leadingTrivia: Trivia?)-> [PatternSyntax]
22+
}
23+
public protocol PatternBuildable: ExpressibleAsPatternBuildable, PatternListBuildable, SyntaxListBuildable{
24+
/// Builds list of `PatternSyntax`s.
25+
/// - Parameter format: The `Format` to use.
26+
/// - Parameter leadingTrivia: Replaces the last leading trivia if not nil.
27+
func buildPattern(format: Format, leadingTrivia: Trivia?)-> PatternSyntax
28+
}
29+
public extension PatternBuildable{
30+
/// Satisfies conformance to `ExpressibleAsPatternBuildable`.
31+
func createPatternBuildable()-> PatternBuildable{
32+
return self
33+
}
34+
/// Builds list of `PatternSyntax`s.
35+
/// - Parameter format: The `Format` to use.
36+
/// - Parameter leadingTrivia: Replaces the last leading trivia if not nil.
37+
///
38+
/// Satisfies conformance to `PatternListBuildable`
39+
func buildPatternList(format: Format, leadingTrivia: Trivia? = nil)-> [PatternSyntax]{
40+
return [buildPattern(format: format, leadingTrivia: leadingTrivia)]
41+
}
42+
/// Builds a `PatternSyntax`.
43+
/// - Parameter format: The `Format` to use.
44+
/// - Parameter leadingTrivia: Replaces the last leading trivia if not nil.
45+
/// - Returns: A new `Syntax` with the built `PatternSyntax`.
46+
///
47+
/// Satisfies conformance to `SyntaxBuildable`.
48+
func buildSyntax(format: Format, leadingTrivia: Trivia? = nil)-> Syntax{
49+
return Syntax(buildPattern(format: format, leadingTrivia: leadingTrivia))
50+
}
51+
}
52+
public protocol TypeListBuildable: SyntaxBuildable{
53+
/// Builds list of `TypeSyntax`s.
54+
/// - Parameter format: The `Format` to use.
55+
/// - Parameter leadingTrivia: Replaces the last leading trivia if not nil.
56+
func buildTypeList(format: Format, leadingTrivia: Trivia?)-> [TypeSyntax]
57+
}
58+
public protocol TypeBuildable: ExpressibleAsTypeBuildable, TypeListBuildable, SyntaxListBuildable{
59+
/// Builds list of `TypeSyntax`s.
60+
/// - Parameter format: The `Format` to use.
61+
/// - Parameter leadingTrivia: Replaces the last leading trivia if not nil.
62+
func buildType(format: Format, leadingTrivia: Trivia?)-> TypeSyntax
63+
}
64+
public extension TypeBuildable{
65+
/// Satisfies conformance to `ExpressibleAsTypeBuildable`.
66+
func createTypeBuildable()-> TypeBuildable{
67+
return self
68+
}
69+
/// Builds list of `TypeSyntax`s.
70+
/// - Parameter format: The `Format` to use.
71+
/// - Parameter leadingTrivia: Replaces the last leading trivia if not nil.
72+
///
73+
/// Satisfies conformance to `TypeListBuildable`
74+
func buildTypeList(format: Format, leadingTrivia: Trivia? = nil)-> [TypeSyntax]{
75+
return [buildType(format: format, leadingTrivia: leadingTrivia)]
76+
}
77+
/// Builds a `TypeSyntax`.
78+
/// - Parameter format: The `Format` to use.
79+
/// - Parameter leadingTrivia: Replaces the last leading trivia if not nil.
80+
/// - Returns: A new `Syntax` with the built `TypeSyntax`.
81+
///
82+
/// Satisfies conformance to `SyntaxBuildable`.
83+
func buildSyntax(format: Format, leadingTrivia: Trivia? = nil)-> Syntax{
84+
return Syntax(buildType(format: format, leadingTrivia: leadingTrivia))
85+
}
86+
}
87+
public protocol SyntaxListBuildable{
88+
/// Builds list of `Syntax`s.
89+
/// - Parameter format: The `Format` to use.
90+
/// - Parameter leadingTrivia: Replaces the last leading trivia if not nil.
91+
func buildSyntaxList(format: Format, leadingTrivia: Trivia?)-> [Syntax]
92+
}
93+
public protocol SyntaxBuildable: ExpressibleAsSyntaxBuildable, SyntaxListBuildable{
94+
/// Builds list of `Syntax`s.
95+
/// - Parameter format: The `Format` to use.
96+
/// - Parameter leadingTrivia: Replaces the last leading trivia if not nil.
97+
func buildSyntax(format: Format, leadingTrivia: Trivia?)-> Syntax
98+
}
99+
public extension SyntaxBuildable{
100+
/// Satisfies conformance to `ExpressibleAsSyntaxBuildable`.
101+
func createSyntaxBuildable()-> SyntaxBuildable{
102+
return self
103+
}
104+
/// Builds list of `Syntax`s.
105+
/// - Parameter format: The `Format` to use.
106+
/// - Parameter leadingTrivia: Replaces the last leading trivia if not nil.
107+
///
108+
/// Satisfies conformance to `SyntaxListBuildable`
109+
func buildSyntaxList(format: Format, leadingTrivia: Trivia? = nil)-> [Syntax]{
110+
return [buildSyntax(format: format, leadingTrivia: leadingTrivia)]
111+
}
112+
}
113+
public protocol StmtListBuildable: SyntaxBuildable{
114+
/// Builds list of `StmtSyntax`s.
115+
/// - Parameter format: The `Format` to use.
116+
/// - Parameter leadingTrivia: Replaces the last leading trivia if not nil.
117+
func buildStmtList(format: Format, leadingTrivia: Trivia?)-> [StmtSyntax]
118+
}
119+
public protocol StmtBuildable: ExpressibleAsStmtBuildable, StmtListBuildable, SyntaxListBuildable{
120+
/// Builds list of `StmtSyntax`s.
121+
/// - Parameter format: The `Format` to use.
122+
/// - Parameter leadingTrivia: Replaces the last leading trivia if not nil.
123+
func buildStmt(format: Format, leadingTrivia: Trivia?)-> StmtSyntax
124+
}
125+
public extension StmtBuildable{
126+
/// Satisfies conformance to `ExpressibleAsStmtBuildable`.
127+
func createStmtBuildable()-> StmtBuildable{
128+
return self
129+
}
130+
/// Builds list of `StmtSyntax`s.
131+
/// - Parameter format: The `Format` to use.
132+
/// - Parameter leadingTrivia: Replaces the last leading trivia if not nil.
133+
///
134+
/// Satisfies conformance to `StmtListBuildable`
135+
func buildStmtList(format: Format, leadingTrivia: Trivia? = nil)-> [StmtSyntax]{
136+
return [buildStmt(format: format, leadingTrivia: leadingTrivia)]
137+
}
138+
/// Builds a `StmtSyntax`.
139+
/// - Parameter format: The `Format` to use.
140+
/// - Parameter leadingTrivia: Replaces the last leading trivia if not nil.
141+
/// - Returns: A new `Syntax` with the built `StmtSyntax`.
142+
///
143+
/// Satisfies conformance to `SyntaxBuildable`.
144+
func buildSyntax(format: Format, leadingTrivia: Trivia? = nil)-> Syntax{
145+
return Syntax(buildStmt(format: format, leadingTrivia: leadingTrivia))
146+
}
147+
}
148+
public protocol ExprListBuildable: SyntaxBuildable{
149+
/// Builds list of `ExprSyntax`s.
150+
/// - Parameter format: The `Format` to use.
151+
/// - Parameter leadingTrivia: Replaces the last leading trivia if not nil.
152+
func buildExprList(format: Format, leadingTrivia: Trivia?)-> [ExprSyntax]
153+
}
154+
public protocol ExprBuildable: ExpressibleAsExprBuildable, ExprListBuildable, SyntaxListBuildable{
155+
/// Builds list of `ExprSyntax`s.
156+
/// - Parameter format: The `Format` to use.
157+
/// - Parameter leadingTrivia: Replaces the last leading trivia if not nil.
158+
func buildExpr(format: Format, leadingTrivia: Trivia?)-> ExprSyntax
159+
}
160+
public extension ExprBuildable{
161+
/// Satisfies conformance to `ExpressibleAsExprBuildable`.
162+
func createExprBuildable()-> ExprBuildable{
163+
return self
164+
}
165+
/// Builds list of `ExprSyntax`s.
166+
/// - Parameter format: The `Format` to use.
167+
/// - Parameter leadingTrivia: Replaces the last leading trivia if not nil.
168+
///
169+
/// Satisfies conformance to `ExprListBuildable`
170+
func buildExprList(format: Format, leadingTrivia: Trivia? = nil)-> [ExprSyntax]{
171+
return [buildExpr(format: format, leadingTrivia: leadingTrivia)]
172+
}
173+
/// Builds a `ExprSyntax`.
174+
/// - Parameter format: The `Format` to use.
175+
/// - Parameter leadingTrivia: Replaces the last leading trivia if not nil.
176+
/// - Returns: A new `Syntax` with the built `ExprSyntax`.
177+
///
178+
/// Satisfies conformance to `SyntaxBuildable`.
179+
func buildSyntax(format: Format, leadingTrivia: Trivia? = nil)-> Syntax{
180+
return Syntax(buildExpr(format: format, leadingTrivia: leadingTrivia))
181+
}
182+
}
183+
public protocol DeclListBuildable: SyntaxBuildable{
184+
/// Builds list of `DeclSyntax`s.
185+
/// - Parameter format: The `Format` to use.
186+
/// - Parameter leadingTrivia: Replaces the last leading trivia if not nil.
187+
func buildDeclList(format: Format, leadingTrivia: Trivia?)-> [DeclSyntax]
188+
}
189+
public protocol DeclBuildable: ExpressibleAsDeclBuildable, DeclListBuildable, SyntaxListBuildable{
190+
/// Builds list of `DeclSyntax`s.
191+
/// - Parameter format: The `Format` to use.
192+
/// - Parameter leadingTrivia: Replaces the last leading trivia if not nil.
193+
func buildDecl(format: Format, leadingTrivia: Trivia?)-> DeclSyntax
194+
}
195+
public extension DeclBuildable{
196+
/// Satisfies conformance to `ExpressibleAsDeclBuildable`.
197+
func createDeclBuildable()-> DeclBuildable{
198+
return self
199+
}
200+
/// Builds list of `DeclSyntax`s.
201+
/// - Parameter format: The `Format` to use.
202+
/// - Parameter leadingTrivia: Replaces the last leading trivia if not nil.
203+
///
204+
/// Satisfies conformance to `DeclListBuildable`
205+
func buildDeclList(format: Format, leadingTrivia: Trivia? = nil)-> [DeclSyntax]{
206+
return [buildDecl(format: format, leadingTrivia: leadingTrivia)]
207+
}
208+
/// Builds a `DeclSyntax`.
209+
/// - Parameter format: The `Format` to use.
210+
/// - Parameter leadingTrivia: Replaces the last leading trivia if not nil.
211+
/// - Returns: A new `Syntax` with the built `DeclSyntax`.
212+
///
213+
/// Satisfies conformance to `SyntaxBuildable`.
214+
func buildSyntax(format: Format, leadingTrivia: Trivia? = nil)-> Syntax{
215+
return Syntax(buildDecl(format: format, leadingTrivia: leadingTrivia))
216+
}
217+
}

0 commit comments

Comments
 (0)