Skip to content

Commit 0db13de

Browse files
committed
Enable NoBlockComments and remove existing block comments.
1 parent 3390fcf commit 0db13de

File tree

13 files changed

+58
-62
lines changed

13 files changed

+58
-62
lines changed

.swift-format

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"rules": {
1111
"AlwaysUseLowerCamelCase": false,
1212
"AmbiguousTrailingClosureOverload": false,
13-
"NoBlockComments": false,
13+
"NoBlockComments": true,
1414
"OrderedImports": true,
1515
"UseLetInEveryBoundCaseVariable": false,
1616
"UseSynthesizedInitializer": true

CodeGeneration/Sources/SyntaxSupport/Child.swift

+5-7
Original file line numberDiff line numberDiff line change
@@ -187,13 +187,11 @@ public class Child: NodeChoiceConvertible {
187187
} else if choices.allSatisfy(\.isKeyword) {
188188
return .keyword
189189
} else {
190-
/*
191-
FIXME: Technically, returning `.unknown` is not correct here.
192-
The old string-based implementation returned "Token" to ensure that `tokenKind` is not nil
193-
and that `isToken` computed-property will return true, but the value "Token" had never been
194-
used in other cases. We should try to remove this computed property altogether in the issue:
195-
https://github.com/swiftlang/swift-syntax/issues/2010
196-
*/
190+
// FIXME: Technically, returning `.unknown` is not correct here.
191+
// The old string-based implementation returned "Token" to ensure that `tokenKind` is not nil
192+
// and that `isToken` computed-property will return true, but the value "Token" had never been
193+
// used in other cases. We should try to remove this computed property altogether in the issue:
194+
// https://github.com/swiftlang/swift-syntax/issues/2010
197195
return .unknown
198196
}
199197
default:

Sources/SwiftCompilerPluginMessageHandling/JSON/JSONDecoding.swift

+38-44
Original file line numberDiff line numberDiff line change
@@ -35,50 +35,44 @@ func decodeFromJSON<T: Decodable>(json: UnsafeBufferPointer<UInt8>) throws -> T
3535
}
3636
}
3737

38-
/*
39-
JSONMap is inspired by swift-foundation's JSONMap.
40-
41-
For JSON payload such as:
42-
43-
```
44-
{"foo": [-1.3, true], "barz": 42}
45-
```
46-
47-
will be scanned by 'JSONScanner' into a map like:
48-
49-
```
50-
<OM> == Object Marker
51-
<AM> == Array Marker
52-
<SS> == Simple String (a variant of String that can has no escapes and can be passed directly to a UTF-8 parser)
53-
<NM> == Number Marker
54-
<TL> == NULL Marker
55-
map: [
56-
0: <OM>, -- object marker
57-
1: 17, | `- number of *map* elements this object occupies
58-
2: <SS>, | --- key 1: 'foo'
59-
3: <int_ptr>, | | |- pointer in the payload
60-
4: 3, | | `- length
61-
5: <AM>, | --- value 1: array
62-
6: 6, | | `- number of *map* elements this array occupies
63-
7: <NM>, | | -- arr elm 1: '-1.3'
64-
8: <int_ptr>, | | |
65-
9: 4, | | |
66-
10: <TL>, | | -- arr elm 2: 'true'
67-
11: <SS>, | --- key 2: 'barz'
68-
12: <int_ptr>, | |
69-
13: 4, | |
70-
14: <NM> | --- value 2: '42'
71-
15: <int_ptr>, | |
72-
16: 2, | |
73-
]
74-
```
75-
To decode '<root>.barz' value:
76-
1. Index 0 indicates it's a object.
77-
2. Parse a key string at index 2, which is "foo", not a match for "barz"
78-
3. Skip the key and the value by advancing the index by 'mapSize' of them, 3 and 6.
79-
4. Parse a key string at index 11, matching "barz"
80-
5. Parse a value number at the pointer of index 15, length at index 16
81-
*/
38+
// JSONMap is inspired by swift-foundation's JSONMap.
39+
// For JSON payload such as:
40+
// ```
41+
// {"foo": [-1.3, true], "barz": 42}
42+
// ```
43+
// will be scanned by 'JSONScanner' into a map like:
44+
// ```
45+
// <OM> == Object Marker
46+
// <AM> == Array Marker
47+
// <SS> == Simple String (a variant of String that can has no escapes and can be passed directly to a UTF-8 parser)
48+
// <NM> == Number Marker
49+
// <TL> == NULL Marker
50+
// map: [
51+
// 0: <OM>, -- object marker
52+
// 1: 17, | `- number of *map* elements this object occupies
53+
// 2: <SS>, | --- key 1: 'foo'
54+
// 3: <int_ptr>, | | |- pointer in the payload
55+
// 4: 3, | | `- length
56+
// 5: <AM>, | --- value 1: array
57+
// 6: 6, | | `- number of *map* elements this array occupies
58+
// 7: <NM>, | | -- arr elm 1: '-1.3'
59+
// 8: <int_ptr>, | | |
60+
// 9: 4, | | |
61+
// 10: <TL>, | | -- arr elm 2: 'true'
62+
// 11: <SS>, | --- key 2: 'barz'
63+
// 12: <int_ptr>, | |
64+
// 13: 4, | |
65+
// 14: <NM> | --- value 2: '42'
66+
// 15: <int_ptr>, | |
67+
// 16: 2, | |
68+
// ]
69+
// ```
70+
// To decode '<root>.barz' value:
71+
// 1. Index 0 indicates it's a object.
72+
// 2. Parse a key string at index 2, which is "foo", not a match for "barz"
73+
// 3. Skip the key and the value by advancing the index by 'mapSize' of them, 3 and 6.
74+
// 4. Parse a key string at index 11, matching "barz"
75+
// 5. Parse a value number at the pointer of index 15, length at index 16
8276

8377
private struct JSONMap {
8478
enum Descriptor: Int {

Sources/SwiftCompilerPluginMessageHandling/PluginMacroExpansionContext.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ class SourceManager {
129129

130130
var node = syntaxRegistry.get(source: syntaxInfo.source, kind: syntaxInfo.kind)
131131
if let operatorTable {
132-
node = operatorTable.foldAll(node, errorHandler: { _ in /*ignore*/ })
132+
node = operatorTable.foldAll(node, errorHandler: { _ in }) // ignore
133133
}
134134

135135
// Copy the location info from the plugin message.

Sources/SwiftCompilerPluginMessageHandling/StandardIOMessageConnection.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public struct StandardIOMessageConnection: MessageConnection {
102102
while ptr != endPtr {
103103
switch write(outputFileDescriptor, ptr, numericCast(endPtr - ptr)) {
104104
case -1: throw IOError.systemError(function: "write(_:_:_:)", errno: _errno)
105-
case 0: throw IOError.systemError(function: "write", errno: 0) /* unreachable */
105+
case 0: throw IOError.systemError(function: "write", errno: 0) // unreachable
106106
case let n: ptr += Int(n)
107107
}
108108
}

Sources/SwiftLibraryPluginProvider/LibraryPluginProvider.swift

+5-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,11 @@ private func _findAnyType(_ moduleName: String, _ typeName: String) -> Any.Type?
151151
// actual symbol name doesn't match with it. i.e. We don't need to perform
152152
// punycode encodings or word substitutions.
153153
// FIXME: This is process global. Can we limit it to a specific .dylib ?
154-
for suffix in [ /*struct*/"V", /*enum*/ "O", /*class*/ "C"] {
154+
for suffix in [
155+
"V", // struct
156+
"O", // enum
157+
"C", // class
158+
] {
155159
let mangled = "\(moduleName.utf8.count)\(moduleName)\(typeName.utf8.count)\(typeName)\(suffix)"
156160
if let type = _typeByName(mangled) {
157161
return type

Sources/SwiftSyntax/Documentation.docc/Resources/Formatter.step2.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ import Foundation
2323
}
2424

2525
func formatImports(in file: String) -> SourceFileSyntax {
26-
/* Formatter here */
26+
// Formatter here
2727
}
2828
}

Sources/SwiftSyntax/Documentation.docc/Resources/Formatter.step3.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ import SwiftSyntax
2525
}
2626

2727
func formatImports(in file: String) -> SourceFileSyntax {
28-
/* Formatter here */
28+
// Formatter here
2929
}
3030
}

Sources/SwiftSyntax/Documentation.docc/Resources/Formatter.step4.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import SwiftSyntax
2626

2727
func formatImports(in file: String) -> SourceFileSyntax {
2828
let sourceFile = Parser.parse(source: file)
29-
/* format source file */
29+
// format source file
3030
return sourceFile
3131
}
3232
}

Sources/SwiftSyntax/Documentation.docc/Resources/Formatter.step5.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,6 @@ import SwiftSyntax
3636
}
3737

3838
func classifyItems(in file: SourceFileSyntax) -> [Item] {
39-
/* Classify items here */
39+
// Classify items here
4040
}
4141
}

Sources/SwiftSyntax/SyntaxArena.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ public class ParsingSyntaxArena: SyntaxArena {
202202
public func internSourceBuffer(_ buffer: UnsafeBufferPointer<UInt8>) -> UnsafeBufferPointer<UInt8> {
203203
let allocated = allocator.allocate(
204204
UInt8.self,
205-
count: buffer.count + /* for NULL */ 1
205+
count: buffer.count + 1 // +1 for NULL
206206
)
207207
precondition(sourceBuffer.baseAddress == nil, "SourceBuffer should only be set once.")
208208
_ = allocated.initialize(from: buffer)

Sources/SwiftSyntaxMacroExpansion/BasicMacroExpansionContext.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ extension BasicMacroExpansionContext {
119119
/// Fold all operators in `node` and associated the ``KnownSourceFile``
120120
/// information of `node` with the original new, folded tree.
121121
func foldAllOperators(of node: some SyntaxProtocol, with operatorTable: OperatorTable) -> Syntax {
122-
let folded = operatorTable.foldAll(node, errorHandler: { _ in /*ignore*/ })
122+
let folded = operatorTable.foldAll(node, errorHandler: { _ in }) // ignore
123123
if let originalSourceFile = node.root.as(SourceFileSyntax.self),
124124
let newSourceFile = folded.root.as(SourceFileSyntax.self)
125125
{

Sources/SwiftSyntaxMacroExpansion/MacroSystem.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1443,7 +1443,7 @@ private extension SyntaxProtocol {
14431443
if let basicContext = context as? BasicMacroExpansionContext {
14441444
folded = basicContext.foldAllOperators(of: self, with: operatorTable)
14451445
} else {
1446-
folded = operatorTable.foldAll(self, errorHandler: { _ in /*ignore*/ })
1446+
folded = operatorTable.foldAll(self, errorHandler: { _ in }) // ignore
14471447
}
14481448
} else {
14491449
folded = Syntax(self)

0 commit comments

Comments
 (0)