Skip to content

Prepare SwiftSyntaxBuilder to be used in Code-Generation #854

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ private func createBuildableNodeFormatFunction(node: Node) -> FunctionDecl {
"result"
AssignmentExpr()
FunctionCallExpr(MemberAccessExpr(base: "result", name: "withLeadingTrivia")) {
TupleExprElement(expression: FunctionCallExpr(MemberAccessExpr(base: "leadingTrivia", name: "addingSpacingAfterNewlinesIfNeeded")))
TupleExprElement(expression: "leadingTrivia")
}
}
}
Expand All @@ -203,8 +203,7 @@ private func createBuildableCollectionNodeFormatFunction(node: Node) -> Function
MemberAccessExpr(base: "syntax", name: "map"),
trailingClosure: ClosureExpr {
FunctionCallExpr(MemberAccessExpr(base: "$0", name: "withLeadingTrivia")) {
TupleExprElement(expression: FunctionCallExpr(MemberAccessExpr(
base: TupleExpr {
TupleExprElement(expression: TupleExpr {
SequenceExpr {
"indentedNewline"
BinaryOperatorExpr("+")
Expand All @@ -216,9 +215,8 @@ private func createBuildableCollectionNodeFormatFunction(node: Node) -> Function
}
}
}
},
name: "addingSpacingAfterNewlinesIfNeeded"
)))
}
)
}
}
))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,14 @@ private func createBuildFunction(node: Node, trivias: [String]) -> FunctionDecl
)
)
) {
ReturnStmt(expression: "node")
ReturnStmt(expression: FunctionCallExpr(MemberAccessExpr(base: "Indenter", name: "indent")) {
TupleExprElement(expression: "node")
TupleExprElement(
label: "indentation",
expression: MemberAccessExpr(base: "format", name: "indentTrivia")
)
}
)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,21 +137,36 @@ func createTriviaAttachment(varName: ExpressibleAsExprBuildable, triviaVarName:
)
}
) {
VariableDecl(
.let,
name: "trivia",
initializer: FunctionCallExpr(MemberAccessExpr(
base: TupleExpr {
SequenceExpr {
triviaVarName
BinaryOperatorExpr("+")
TupleExpr {
SequenceExpr {
MemberAccessExpr(base: varName, name: trivia)
BinaryOperatorExpr("??")
ArrayExpr()
}
}
}
},
name: "indented"
)) {
TupleExprElement(
label: "indentation",
expression: MemberAccessExpr(base: "format", name: "indentTrivia")
)
}
)
SequenceExpr {
varName
AssignmentExpr()
FunctionCallExpr(MemberAccessExpr(base: varName, name: "with\(trivia.withFirstCharacterUppercased)")) {
TupleExprElement(expression: SequenceExpr {
triviaVarName
BinaryOperatorExpr("+")
TupleExpr {
SequenceExpr {
MemberAccessExpr(base: varName, name: trivia)
BinaryOperatorExpr("??")
ArrayExpr()
}
}
})
TupleExprElement(expression: "trivia")
}
}
}
Expand Down
1 change: 0 additions & 1 deletion Sources/SwiftBasicFormat/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
# See http://swift.org/CONTRIBUTORS.txt for Swift project authors

add_library(SwiftBasicFormat STATIC
Trivia+Extension.swift
generated/Format.swift
)

Expand Down
52 changes: 0 additions & 52 deletions Sources/SwiftBasicFormat/Trivia+Extension.swift

This file was deleted.

Loading