File tree Expand file tree Collapse file tree 2 files changed +8
-1
lines changed
Sources/SwiftSyntaxBuilderGeneration Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -100,7 +100,7 @@ extension Child {
100
100
assertChoices. append ( SequenceExpr {
101
101
MemberAccessExpr ( base: type. forceUnwrapped ( expr: varName) , name: " text " )
102
102
BinaryOperatorExpr ( " == " )
103
- StringLiteralExpr ( textChoice . replacingOccurrences ( of : " \\ " , with : " \\ \\ " ) )
103
+ StringLiteralExpr ( literalEscaped ( string : textChoice ) )
104
104
} )
105
105
}
106
106
let disjunction = ExprList ( assertChoices. flatMap { [ $0, BinaryOperatorExpr ( " || " ) ] } . dropLast ( ) )
Original file line number Diff line number Diff line change @@ -70,3 +70,10 @@ func flattened(indentedDocumentation: String) -> String {
70
70
. replacingOccurrences ( of: " \n " , with: " " )
71
71
. trimmingCharacters ( in: . whitespacesAndNewlines)
72
72
}
73
+
74
+ /// Escapes a string for use in a string literal.
75
+ func literalEscaped( string: String ) -> String {
76
+ string
77
+ . replacingOccurrences ( of: " \\ " , with: " \\ \\ " )
78
+ . replacingOccurrences ( of: " \" " , with: " \\ \" " )
79
+ }
You can’t perform that action at this time.
0 commit comments