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
@@ -110,6 +113,25 @@ let basicFormatFile = SourceFileSyntax(leadingTrivia: generateCopyrightHeader(fo
110
113
"""
111
114
)
112
115
116
+
DeclSyntax(
117
+
"""
118
+
/// If this returns `true`, ``BasicFormat`` will not wrap `node` to a new line. This can be used to e.g. keep string interpolation segments on a single line.
119
+
/// - Parameter node: the node that is being visited
120
+
/// - Returns: returns true if newline should be omitted
121
+
open func shouldOmitNewline(_ node: TokenSyntax) -> Bool {
Copy file name to clipboardExpand all lines: Sources/SwiftBasicFormat/Trivia+Indented.swift
+17-7Lines changed: 17 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -13,25 +13,35 @@
13
13
import SwiftSyntax
14
14
15
15
extensionTrivia{
16
-
func indented(indentation:TriviaPiece)->Trivia{
16
+
/// Makes sure each newline of this trivia is followed by `indentation`. If this is not the case, the existing indentation is extended to `indentation`.
17
+
/// `isOnNewline` determines whether the trivia starts on a new line. If this is the case, the function makes sure that the returned trivia starts with `indentation`.
@@ -71,6 +74,21 @@ open class BasicFormat: SyntaxRewriter {
71
74
return rewritten
72
75
}
73
76
77
+
/// If this returns `true`, ``BasicFormat`` will not wrap `node` to a new line. This can be used to e.g. keep string interpolation segments on a single line.
78
+
/// - Parameter node: the node that is being visited
79
+
/// - Returns: returns true if newline should be omitted
0 commit comments