Skip to content

Commit 1ed6ae2

Browse files
author
Tim Wang
committed
Fix indentation
1 parent 55d21b6 commit 1ed6ae2

File tree

2 files changed

+43
-43
lines changed

2 files changed

+43
-43
lines changed

Sources/MMIOMacros/Macros/Arguments/BitRange.swift

+10-10
Original file line numberDiff line numberDiff line change
@@ -204,15 +204,15 @@ extension ErrorDiagnostic {
204204
}
205205

206206
extension Array where Element == BitRange {
207-
var isOverlapped: Bool {
208-
guard count > 1 else { return false }
209-
let sorted = map { $0.canonicalizedClosedRange }
210-
.sorted(by: { $0.lowerBound < $1.lowerBound })
211-
for i in 0..<(sorted.count - 1) {
212-
if sorted[i].upperBound >= sorted[i+1].lowerBound {
213-
return true
214-
}
215-
}
216-
return false
207+
var isOverlapped: Bool {
208+
guard count > 1 else { return false }
209+
let sorted = map { $0.canonicalizedClosedRange }
210+
.sorted(by: { $0.lowerBound < $1.lowerBound })
211+
for i in 0..<(sorted.count - 1) {
212+
if sorted[i].upperBound >= sorted[i+1].lowerBound {
213+
return true
214+
}
217215
}
216+
return false
217+
}
218218
}

Sources/MMIOMacros/SwiftSyntaxExtensions/DeclGroupSyntax+BitRange.swift

+33-33
Original file line numberDiff line numberDiff line change
@@ -12,39 +12,39 @@ import SwiftSyntax
1212
import SwiftSyntaxMacros
1313

1414
extension DeclGroupSyntax {
15-
func allBitRanges(
16-
with context: MacroContext<some ParsableMacro, some MacroExpansionContext>
17-
) throws -> [BitRange] {
18-
let attributeNames = [
19-
"ReadOnly",
20-
"ReadWrite",
21-
"Reserved",
22-
"WriteOnly",
23-
]
24-
return try memberBlock.members
15+
func allBitRanges(
16+
with context: MacroContext<some ParsableMacro, some MacroExpansionContext>
17+
) throws -> [BitRange] {
18+
let attributeNames = [
19+
"ReadOnly",
20+
"ReadWrite",
21+
"Reserved",
22+
"WriteOnly",
23+
]
24+
return try memberBlock.members
25+
.compactMap {
26+
VariableDeclSyntax($0.decl)?.attributes
2527
.compactMap {
26-
VariableDeclSyntax($0.decl)?.attributes
27-
.compactMap {
28-
AttributeSyntax($0)
29-
}
30-
.filter {
31-
attributeNames.contains(IdentifierTypeSyntax($0.attributeName)?.name.text ?? "" )
32-
}
33-
.compactMap {
34-
LabeledExprListSyntax($0.arguments)
35-
}
28+
AttributeSyntax($0)
3629
}
37-
.flatMap({ $0 }) // All the LabeledExprLists in interest
38-
.reduce(into: [BitRange](), { partialResult, labeledExprList in
39-
var bits = false
40-
for labeledExpr in labeledExprList {
41-
if let label = labeledExpr.label {
42-
bits = label.text == "bits"
43-
}
44-
if bits {
45-
partialResult.append(try BitRange(expression: labeledExpr.expression, in: context))
46-
}
47-
}
48-
})
49-
}
30+
.filter {
31+
attributeNames.contains(IdentifierTypeSyntax($0.attributeName)?.name.text ?? "" )
32+
}
33+
.compactMap {
34+
LabeledExprListSyntax($0.arguments)
35+
}
36+
}
37+
.flatMap({ $0 }) // All the LabeledExprLists in interest
38+
.reduce(into: [BitRange](), { partialResult, labeledExprList in
39+
var bits = false
40+
for labeledExpr in labeledExprList {
41+
if let label = labeledExpr.label {
42+
bits = label.text == "bits"
43+
}
44+
if bits {
45+
partialResult.append(try BitRange(expression: labeledExpr.expression, in: context))
46+
}
47+
}
48+
})
49+
}
5050
}

0 commit comments

Comments
 (0)