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
/// A collection of string literal segments representing both plain text and interpolated expressions.
1401
+
///
1402
+
/// This collection is used to represent the contents of string literals, including both static text segments and interpolated expressions.
1403
+
/// For example, in the string literal `"Hello \(name)"`, the collection would contain a string segment for `"Hello "` followed by an expression segment for `\(name)`.
1404
+
///
1405
+
/// ```swift
1406
+
/// let segments = StringLiteralSegmentListSyntax([
/// A literal text segment inside a string literal.
1440
+
///
1441
+
/// This case represents static text content like `"Hello "` in `"Hello \(name)"`.
1442
+
///
1411
1443
/// - SeeAlso: ``ExpressionSegmentSyntax``
1412
1444
case stringSegment(StringSegmentSyntax)
1413
-
/// An interpolated expression inside a string literal.
1414
-
///
1445
+
1446
+
/// An interpolated expression segment inside a string literal.
1447
+
///
1448
+
/// This case represents interpolated expressions like `\(name)` in `"Hello \(name)"`.
1449
+
///
1415
1450
/// - SeeAlso: ``StringSegmentSyntax``
1416
1451
case expressionSegment(ExpressionSegmentSyntax)
1417
1452
@@ -1424,14 +1459,59 @@ public struct StringLiteralSegmentListSyntax: SyntaxCollection, SyntaxHashable {
1424
1459
}
1425
1460
}
1426
1461
1462
+
/// Creates a new Element wrapping a string segment.
1463
+
///
1464
+
/// This initializer is used when adding literal text content to a string literal. The string segment should be created using `.stringSegment()` to ensure proper formatting.
1465
+
///
1466
+
/// Example from warning macro:
1467
+
/// ```swift
1468
+
/// let element = StringLiteralSegmentListSyntax.Element(
/// - node: The syntax node to attempt to convert into an element. Must be either a StringSegmentSyntax or ExpressionSegmentSyntax.
1435
1515
publicinit?(_ node: __shared someSyntaxProtocol){
1436
1516
iflet node = node.as(StringSegmentSyntax.self){
1437
1517
self=.stringSegment(node)
@@ -1493,6 +1573,23 @@ public struct StringLiteralSegmentListSyntax: SyntaxCollection, SyntaxHashable {
1493
1573
1494
1574
publiclet_syntaxNode:Syntax
1495
1575
1576
+
/// Creates a list of string literal segments from an array of elements.
1577
+
///
1578
+
/// Used to create lists that represent both plain text and interpolated expressions in a string literal. Common in macros where you need to create or modify string literals.
0 commit comments