Skip to content

Commit 5ebcebd

Browse files
committed
Format code
1 parent 3e56ebf commit 5ebcebd

File tree

5 files changed

+35
-27
lines changed

5 files changed

+35
-27
lines changed

CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/SyntaxCollectionsFile.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ let syntaxCollectionsFile = SourceFileSyntax(leadingTrivia: generateCopyrightHea
3838
for node in SYNTAX_NODES where node.isSyntaxCollection {
3939
let documentation =
4040
node.description.map { "/// " + $0 }
41-
?? """
42-
/// `\(node.name)` represents a collection of one or more
43-
/// `\(node.collectionElement)` nodes. \(node.name) behaves
44-
/// as a regular Swift collection, and has accessors that return new
45-
/// versions of the collection with different children.
46-
"""
41+
?? """
42+
/// `\(node.name)` represents a collection of one or more
43+
/// `\(node.collectionElement)` nodes. \(node.name) behaves
44+
/// as a regular Swift collection, and has accessors that return new
45+
/// versions of the collection with different children.
46+
"""
4747

4848
try! StructDeclSyntax(
4949
"""

Sources/SwiftDiagnostics/DiagnosticsFormatter.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ public struct DiagnosticsFormatter {
5353
/// Print given diagnostics for a given syntax tree on the command line
5454
func annotatedSource<SyntaxType: SyntaxProtocol>(
5555
fileName: String?,
56-
tree: SyntaxType, diags: [Diagnostic],
56+
tree: SyntaxType,
57+
diags: [Diagnostic],
5758
indentString: String,
5859
suffixText: [(AbsolutePosition, String)]
5960
) -> String {
@@ -124,7 +125,7 @@ public struct DiagnosticsFormatter {
124125

125126
// add indentation
126127
annotatedSource.append(indentString)
127-
128+
128129
// print the source line
129130
annotatedSource.append("\(linePrefix)\(annotatedLine.sourceString)")
130131

@@ -168,7 +169,8 @@ public struct DiagnosticsFormatter {
168169

169170
/// Print given diagnostics for a given syntax tree on the command line
170171
public func annotatedSource<SyntaxType: SyntaxProtocol>(
171-
tree: SyntaxType, diags: [Diagnostic]
172+
tree: SyntaxType,
173+
diags: [Diagnostic]
172174
) -> String {
173175
return annotatedSource(
174176
fileName: nil,

Sources/SwiftDiagnostics/GroupedDiagnostics.swift

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public struct GroupedDiagnostics {
4949
/// source file IDs.
5050
var rootIndexes: [SourceFileSyntax: SourceFileID] = [:]
5151

52-
public init() { }
52+
public init() {}
5353

5454
/// Add a new source file to the set of grouped diagnostics.
5555
///
@@ -106,7 +106,8 @@ public struct GroupedDiagnostics {
106106
/// - knownSourceFileID: the source file into which this diagnostic goes,
107107
/// if known.
108108
public mutating func addDiagnostic(
109-
_ diagnostic: Diagnostic, in knownSourceFileID: SourceFileID? = nil
109+
_ diagnostic: Diagnostic,
110+
in knownSourceFileID: SourceFileID? = nil
110111
) {
111112
guard let sourceFileID = knownSourceFileID ?? findSourceFileContaining(diagnostic.node) else {
112113
// Drop the diagnostic on the floor.
@@ -175,13 +176,14 @@ extension GroupedDiagnostics {
175176
}
176177

177178
// Render the buffer.
178-
return prefixString + formatter.annotatedSource(
179-
fileName: isRoot ? sourceFile.displayName : nil,
180-
tree: sourceFile.tree,
181-
diags: sourceFile.diagnostics,
182-
indentString: indentString,
183-
suffixText: childSources
184-
) + suffixString
179+
return prefixString
180+
+ formatter.annotatedSource(
181+
fileName: isRoot ? sourceFile.displayName : nil,
182+
tree: sourceFile.tree,
183+
diags: sourceFile.diagnostics,
184+
indentString: indentString,
185+
suffixText: childSources
186+
) + suffixString
185187
}
186188
}
187189

Tests/SwiftDiagnosticsTest/GroupDiagnosticsFormatterTests.swift

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ extension GroupedDiagnostics {
3535
_ markedSource: String,
3636
displayName: String,
3737
parent: (SourceFileID, AbsolutePosition)? = nil,
38-
extraDiagnostics: [String : (String, DiagnosticSeverity)] = [:]
38+
extraDiagnostics: [String: (String, DiagnosticSeverity)] = [:]
3939
) -> (SourceFileID, [String: AbsolutePosition]) {
4040
// Parse the source file and produce parser diagnostics.
4141
let (markers, source) = extractMarkers(markedSource)
@@ -85,7 +85,7 @@ final class GroupedDiagnosticsFormatterTests: XCTestCase {
8585
print("hello"
8686
""",
8787
displayName: "main.swift",
88-
extraDiagnostics: ["0️⃣" : ("in expansion of macro 'myAssert' here", .note)]
88+
extraDiagnostics: ["0️⃣": ("in expansion of macro 'myAssert' here", .note)]
8989
)
9090
let inExpansionNotePos = mainSourceMarkers["0️⃣"]!
9191

@@ -101,14 +101,16 @@ final class GroupedDiagnosticsFormatterTests: XCTestCase {
101101
displayName: "#myAssert",
102102
parent: (mainSourceID, inExpansionNotePos),
103103
extraDiagnostics: [
104-
"0️⃣" : ("no matching operator '==' for types 'Double' and 'Int'", .error)
104+
"0️⃣": ("no matching operator '==' for types 'Double' and 'Int'", .error)
105105
]
106106
)
107107

108108
let formatter = DiagnosticsFormatter()
109109
let annotated = formatter.annotateSources(in: group)
110110
print(annotated)
111-
AssertStringsEqualWithDiff(annotated, """
111+
AssertStringsEqualWithDiff(
112+
annotated,
113+
"""
112114
=== main.swift ===
113115
1 │ let pi = 3.14159
114116
2 │ #myAssert(pi == 3)
@@ -139,7 +141,7 @@ final class GroupedDiagnosticsFormatterTests: XCTestCase {
139141
print("hello"
140142
""",
141143
displayName: "main.swift",
142-
extraDiagnostics: ["0️⃣" : ("in expansion of macro 'myAssert' here", .note)]
144+
extraDiagnostics: ["0️⃣": ("in expansion of macro 'myAssert' here", .note)]
143145
)
144146
let inExpansionNotePos = mainSourceMarkers["0️⃣"]!
145147

@@ -155,7 +157,7 @@ final class GroupedDiagnosticsFormatterTests: XCTestCase {
155157
displayName: "#myAssert",
156158
parent: (mainSourceID, inExpansionNotePos),
157159
extraDiagnostics: [
158-
"0️⃣" : ("in expansion of macro 'invertedEqualityCheck' here", .note)
160+
"0️⃣": ("in expansion of macro 'invertedEqualityCheck' here", .note)
159161
]
160162
)
161163
let inInnerExpansionNotePos = outerExpansionSourceMarkers["0️⃣"]!
@@ -168,14 +170,16 @@ final class GroupedDiagnosticsFormatterTests: XCTestCase {
168170
displayName: "#invertedEqualityCheck",
169171
parent: (outerExpansionSourceID, inInnerExpansionNotePos),
170172
extraDiagnostics: [
171-
"0️⃣" : ("no matching operator '==' for types 'Double' and 'Int'", .error)
173+
"0️⃣": ("no matching operator '==' for types 'Double' and 'Int'", .error)
172174
]
173175
)
174176

175177
let formatter = DiagnosticsFormatter()
176178
let annotated = formatter.annotateSources(in: group)
177179
print(annotated)
178-
AssertStringsEqualWithDiff(annotated, """
180+
AssertStringsEqualWithDiff(
181+
annotated,
182+
"""
179183
=== main.swift ===
180184
1 │ let pi = 3.14159
181185
2 │ #myAssert(pi == 3)

Tests/SwiftParserTest/translated/StringLiteralEofTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ final class StringLiteralEofTests: XCTestCase {
105105
foo
106106
\(<#expression#>)"""
107107
"""##
108-
// FIXME: The closing delimiter should be put on the new line
108+
// FIXME: The closing delimiter should be put on the new line
109109
)
110110
}
111111

0 commit comments

Comments
 (0)