You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodesQRS.swift
+36-7Lines changed: 36 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -2277,16 +2277,31 @@ public struct StringLiteralExprSyntax: ExprSyntaxProtocol, SyntaxHashable, _Leaf
2277
2277
2278
2278
// MARK: - StringSegmentSyntax
2279
2279
2280
-
/// A literal segment inside a string segment.
2281
-
///
2282
-
/// - SeeAlso: ``ExpressionSegmentSyntax``
2280
+
/// A string literal segment that represents plain text content within a string literal expression.
2281
+
///
2282
+
/// Used to construct string literals programmatically, especially in macros that need to generate or manipulate string content. For example, in a string literal `"Hello \(name)"`, the `"Hello "` part would be represented by a `StringSegmentSyntax`.
2283
+
///
2284
+
/// Creating a string segment requires special attention to use `.stringSegment()` for the content token to ensure proper formatting. For example, when creating a simple string segment:
2285
+
/// ```swift
2286
+
/// let segment = StringSegmentSyntax(content: .stringSegment("Hello World"))
2287
+
/// ```
2288
+
///
2289
+
/// This type is commonly used in macros for:
2290
+
/// - Creating and validating string literals at compile time (e.g., URL validation)
2291
+
/// - Building string-based error messages and diagnostics
2292
+
/// - Generating code that contains string literals
2293
+
/// - Constructing string interpolations
2294
+
///
2295
+
/// Important: When creating a string segment from a string literal, always use `.stringSegment(string)` rather than just passing the string directly. Using the raw string will create an identifier token instead of a string segment token, which can lead to formatting issues.
2296
+
///
2297
+
/// - SeeAlso: ``ExpressionSegmentSyntax`` for segments containing string interpolations
/// - leadingTrivia: Trivia to be prepended to the leading trivia of the node’s first token. If the node is empty, there is no token to attach the trivia to and the parameter is ignored.
2304
-
/// - trailingTrivia: Trivia to be appended to the trailing trivia of the node’s last token. If the node is empty, there is no token to attach the trivia to and the parameter is ignored.
2329
+
/// - leadingTrivia: Trivia to be prepended to the leading trivia of the node's first token. If the node is empty, there is no token to attach the trivia to and the parameter is ignored.
2330
+
/// - unexpectedBeforeContent: Used internally by swift-syntax to handle malformed source code. When creating string segments programmatically, you should pass nil.
2331
+
/// - content: The string content token, created using `.stringSegment("your string")`
2332
+
/// - unexpectedAfterContent: Used internally by swift-syntax to handle malformed source code. When creating string segments programmatically, you should pass nil.
2333
+
/// - trailingTrivia: Trivia to be appended to the trailing trivia of the node's last token. If the node is empty, there is no token to attach the trivia to and the parameter is ignored.
0 commit comments