From e862f00bfa87589efa6f3da2a180cade38411d32 Mon Sep 17 00:00:00 2001 From: kitasuke Date: Tue, 30 Apr 2019 22:05:44 +0100 Subject: [PATCH 1/4] Fix syntax structure change of ExpressionSegmentSyntax (cherry picked from commit 40f11a98446939e4888f44996226581d1ba2b4e1) --- lit_tests/output/print_verify_tree.swift.withkind | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lit_tests/output/print_verify_tree.swift.withkind b/lit_tests/output/print_verify_tree.swift.withkind index c777e466b44..02d52fb4311 100644 --- a/lit_tests/output/print_verify_tree.swift.withkind +++ b/lit_tests/output/print_verify_tree.swift.withkind @@ -4,8 +4,8 @@ func foo() { #if swift(>=3.2) - components.append("-b \"\(string[..<string.index(before: string.endIndex)])\"") + components.append("-b \"\(string[..<string.index(before: string.endIndex)])\"") #else - components.append("-b \"\(string.substring(to: string.characters.index(before: string.endIndex)))\"") + components.append("-b \"\(string.substring(to: string.characters.index(before: string.endIndex)))\"") #endif } \ No newline at end of file From 40c24514fe81e7787d4f62b607eee4daa4f83e9e Mon Sep 17 00:00:00 2001 From: kitasuke Date: Sun, 12 May 2019 23:11:24 +0900 Subject: [PATCH 2/4] Consolidate StringInterpolationExprSyntax to StringLiteralExprSyntax (cherry picked from commit 56f760e5ec2f315d48104ed12fde3ce10fa48b9e) --- Sources/SwiftSyntax/SyntaxFactory.swift.gyb | 13 +++++++++---- lit_tests/output/print_verify_tree.swift.withkind | 4 ++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Sources/SwiftSyntax/SyntaxFactory.swift.gyb b/Sources/SwiftSyntax/SyntaxFactory.swift.gyb index b4d32814d06..aa8c7ef7d59 100644 --- a/Sources/SwiftSyntax/SyntaxFactory.swift.gyb +++ b/Sources/SwiftSyntax/SyntaxFactory.swift.gyb @@ -199,10 +199,15 @@ public enum SyntaxFactory { public static func makeStringLiteralExpr(_ text: String, leadingTrivia: Trivia = [], trailingTrivia: Trivia = []) -> StringLiteralExprSyntax { - let literal = makeStringLiteral("\"\(text)\"", - leadingTrivia: leadingTrivia, - trailingTrivia: trailingTrivia) - return makeStringLiteralExpr(stringLiteral: literal) + let string = makeStringSegment(text, + leadingTrivia: leadingTrivia, + trailingTrivia: trailingTrivia) + let segment = makeStringSegment(content: string) + let segments = makeStringLiteralSegments([segment]) + let quote = makeStringQuoteToken() + return makeStringLiteralExpr(openQuote: quote, + segments: segments, + closeQuote: quote) } public static func makeVariableExpr(_ text: String, diff --git a/lit_tests/output/print_verify_tree.swift.withkind b/lit_tests/output/print_verify_tree.swift.withkind index 02d52fb4311..fab3f9c69f1 100644 --- a/lit_tests/output/print_verify_tree.swift.withkind +++ b/lit_tests/output/print_verify_tree.swift.withkind @@ -4,8 +4,8 @@ func foo() { #if swift(>=3.2) - components.append("-b \"\(string[..<string.index(before: string.endIndex)])\"") + components.append("-b \"\(string[..<string.index(before: string.endIndex)])\"") #else - components.append("-b \"\(string.substring(to: string.characters.index(before: string.endIndex)))\"") + components.append("-b \"\(string.substring(to: string.characters.index(before: string.endIndex)))\"") #endif } \ No newline at end of file From c21a00983bc3cd34822fba68cd569bedfad8106e Mon Sep 17 00:00:00 2001 From: kitasuke Date: Mon, 13 May 2019 01:05:35 +0900 Subject: [PATCH 3/4] Pass leading/trailing trivia to open/close quote (cherry picked from commit 66837202e5bb90fb56850162b1f9da753056d1fa) --- Sources/SwiftSyntax/SyntaxFactory.swift.gyb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Sources/SwiftSyntax/SyntaxFactory.swift.gyb b/Sources/SwiftSyntax/SyntaxFactory.swift.gyb index aa8c7ef7d59..23587cf08ad 100644 --- a/Sources/SwiftSyntax/SyntaxFactory.swift.gyb +++ b/Sources/SwiftSyntax/SyntaxFactory.swift.gyb @@ -204,10 +204,11 @@ public enum SyntaxFactory { trailingTrivia: trailingTrivia) let segment = makeStringSegment(content: string) let segments = makeStringLiteralSegments([segment]) - let quote = makeStringQuoteToken() - return makeStringLiteralExpr(openQuote: quote, + let openQuote = makeStringQuoteToken(leadingTrivia: leadingTrivia) + let closeQuote = makeStringQuoteToken(trailingTrivia: trailingTrivia) + return makeStringLiteralExpr(openQuote: openQuote, segments: segments, - closeQuote: quote) + closeQuote: closeQuote) } public static func makeVariableExpr(_ text: String, From 97497dce23701004928740f4fd997963df393ad2 Mon Sep 17 00:00:00 2001 From: Jan Svoboda Date: Wed, 15 May 2019 00:36:38 +0200 Subject: [PATCH 4/4] [libSyntax] Represent raw string delimiters (cherry picked from commit a085c5b90644fe7a1031e95e92d83f764d1a253c) --- Sources/SwiftSyntax/SyntaxFactory.swift.gyb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Sources/SwiftSyntax/SyntaxFactory.swift.gyb b/Sources/SwiftSyntax/SyntaxFactory.swift.gyb index 23587cf08ad..6662faa9e29 100644 --- a/Sources/SwiftSyntax/SyntaxFactory.swift.gyb +++ b/Sources/SwiftSyntax/SyntaxFactory.swift.gyb @@ -206,9 +206,11 @@ public enum SyntaxFactory { let segments = makeStringLiteralSegments([segment]) let openQuote = makeStringQuoteToken(leadingTrivia: leadingTrivia) let closeQuote = makeStringQuoteToken(trailingTrivia: trailingTrivia) - return makeStringLiteralExpr(openQuote: openQuote, + return makeStringLiteralExpr(openDelimiter: nil, + openQuote: openQuote, segments: segments, - closeQuote: closeQuote) + closeQuote: closeQuote, + closeDelimiter: nil) } public static func makeVariableExpr(_ text: String,