New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generate @resultbuilder
with SwiftSyntaxBuilder
#479
Conversation
239cf69
to
674aa55
Compare
Sources/SwiftSyntaxBuilderGeneration/Templates/ResultBuildersFile.swift
Outdated
Show resolved
Hide resolved
8bae013
to
bfddb19
Compare
110ee66
to
af7f529
Compare
c5d7ecc
to
3c93b41
Compare
89ca58c
to
6e0d3e9
Compare
d2c2965
to
f392841
Compare
f392841
to
22d6d5e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few style nitpicks, but otherwise this looks good! 👍
Sources/SwiftSyntaxBuilderGeneration/Templates/ResultBuildersFile.swift
Outdated
Show resolved
Hide resolved
Sources/SwiftSyntaxBuilderGeneration/Templates/ResultBuildersFile.swift
Outdated
Show resolved
Hide resolved
Sources/SwiftSyntaxBuilderGeneration/Templates/ResultBuildersFile.swift
Outdated
Show resolved
Hide resolved
22d6d5e
to
520be78
Compare
fd637f7
to
683348d
Compare
f15d0e9
to
d92b600
Compare
0299cb3
to
7c0c02c
Compare
2455f59
to
d3b66f0
Compare
@@ -16,73 +17,61 @@ import SwiftSyntax | |||
|
|||
@resultBuilder | |||
public struct CodeBlockItemListBuilder { | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a way with the new API to add new lines, without should adding a empty line at the beginning of each Decl
@swift-ci please test |
d3b66f0
to
afcff8f
Compare
/// Required by every result builder to build combined results from | ||
/// statement blocks. | ||
public static func buildBlock(_ components: Component...) -> Component { | ||
return components.flatMap { $0 } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since all of these functions return single expressions, we could omit the return
here (and in the other builder functions).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had the discussion with @ahoppen at some point.
We decided on going with explicit return, if remember correctly.
Not sure if that opinion have changed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a general preference for explicit return
, but that might be personal. I gave up actively fighting against implicit returns 😆
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally I also like returns in methods as it read better IMO 😬
|
||
FunctionDecl( | ||
leadingTrivia: [ | ||
.newlines(1), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.newlines(1)
be shortened to .newline
IIRC
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's on Trivia
At least I get Type 'TriviaPiece' has no member 'newline'
CodeGeneration/Sources/generate-swiftsyntaxbuilder/ResultBuildersFile.swift
Outdated
Show resolved
Hide resolved
Sources/SwiftSyntaxBuilder/ClosureParamConvenienceInitializer.swift
Outdated
Show resolved
Hide resolved
e6a4933
to
98140cb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wohoo. This was so easy to review.
@swift-ci Please test |
98140cb
to
f3f331a
Compare
@swift-ci please test |
Depends on
SyntaxBuildableWrappers
to Swift #485This is still WIP, and there is still some way to go!
With gyb
With SwiftSyntaxBuilderGeneration