Repository: apple/swift-syntax (swift)

Issue:
Possible bug with inserting extra space between string literal and dot symbol
### Description

Not sure if this is bug or I'm doing some not allowed operation but please take a look.

let's consider such small macro 
```swift
import SwiftCompilerPlugin
import SwiftSyntax
import SwiftSyntaxBuilder
import SwiftSyntaxMacros
import SwiftDiagnostics

public struct TestMacro: PeerMacro {
    public static func expansion(
        of node: SwiftSyntax.AttributeSyntax,
        providingPeersOf declaration: some SwiftSyntax.DeclSyntaxProtocol,
        in context: some SwiftSyntaxMacros.MacroExpansionContext
    ) throws -> [SwiftSyntax.DeclSyntax] {

        guard let declaration = declaration.as(FunctionDeclSyntax.self) else {
            fatalError()
        }
        let body = declaration.body!.statements
        return ["""
                func test1() {
                    \(raw: body)
                }
                """]
    }
}

@main
struct MyMacro: CompilerPlugin {
    let providingMacros: [Macro.Type] = [
        TestMacro.self,
    ]
}
```
and when using in this example
```swift
import MyMacro

struct Struct {
    @TestMacro
    func method() {
        let x = 100
        "Swift Macro".lowercased()
        let y = 123.byteSwapped
    }
}
```
macro is expanded to this code
```swift
func test1() {

        let x = 100
        "Swift Macro" .lowercased()
        let y = 123.byteSwapped
}
```
There is extra space after string literal `Swift Macro` and before `.lowercased()`. As you can notice for int literal in next line  it is working fine.

swift-syntax 509.0.2

Here is link to full macro project.
https://github.com/mkowalski87/swift-macro-issue

### Steps to Reproduce

_No response_

Pull request:
Fixes https://github.com/apple/swift-syntax/issues/2344 
rdar://118176218

Patch:
diff --git a/Sources/SwiftBasicFormat/BasicFormat.swift b/Sources/SwiftBasicFormat/BasicFormat.swift
index 30c4e55c9d9..0f2dd3ac793 100644
--- a/Sources/SwiftBasicFormat/BasicFormat.swift
+++ b/Sources/SwiftBasicFormat/BasicFormat.swift
@@ -331,8 +331,11 @@ open class BasicFormat: SyntaxRewriter {
       (.rawStringPoundDelimiter, .multilineStringQuote),  // opening raw string delimiter should never be separate by a space
       (.rawStringPoundDelimiter, .singleQuote),  // opening raw string delimiter should never be separate by a space
       (.rawStringPoundDelimiter, .stringQuote),  // opening raw string delimiter should never be separate by a space
+      (.rawStringPoundDelimiter, .period),  // opening raw string delimiter should never be separate by a space
       (.regexLiteralPattern, _),
+      (.regexPoundDelimiter, .period),  // #/myRegex/#.someMember
       (.regexSlash, .regexPoundDelimiter),  // closing extended regex delimiter should never be separate by a space
+      (.regexSlash, .period),  // /myRegex/.someMember
       (.rightAngle, .leftParen),  // func foo<T>(x: T)
       (.rightAngle, .period),  // Foo<T>.bar
       (.rightBrace, .leftParen),  // { return 1 }()
@@ -341,6 +344,7 @@ open class BasicFormat: SyntaxRewriter {
       (.rightSquare, .period),  // myArray[1].someProperty
       (.singleQuote, .rawStringPoundDelimiter),  // closing raw string delimiter should never be separate by a space
       (.stringQuote, .rawStringPoundDelimiter),  // closing raw string delimiter should never be separate by a space
+      (.stringQuote, .period),  // "test".lowercased
       (.stringSegment, _),
       (_, .comma),
       (_, .ellipsis),


Test patch:
diff --git a/Tests/SwiftBasicFormatTest/BasicFormatTests.swift b/Tests/SwiftBasicFormatTest/BasicFormatTests.swift
index 7dd65b7cc2b..36af3190256 100644
--- a/Tests/SwiftBasicFormatTest/BasicFormatTests.swift
+++ b/Tests/SwiftBasicFormatTest/BasicFormatTests.swift
@@ -538,4 +538,32 @@ final class BasicFormatTest: XCTestCase {
       expected: "Foo<T>.bar"
     )
   }
+
+  func testPeriodAfterStringLiteral() {
+    let source = """
+      "test".lowercased()
+      """
+    assertFormatted(source: source, expected: source)
+  }
+
+  func testPeriodAfterRawStringLiteral() {
+    let source = """
+      #"test"#.lowercased()
+      """
+    assertFormatted(source: source, expected: source)
+  }
+
+  func testPeriodAfterRegexLiteral() {
+    let source = """
+      /test/.something
+      """
+    assertFormatted(source: source, expected: source)
+  }
+
+  func testPeriodAfterRawRegexLiteral() {
+    let source = """
+      /test/.something
+      """
+    assertFormatted(source: source, expected: source)
+  }
 }