Skip to content

Commit

Permalink
Fix indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Wang committed Oct 27, 2024
1 parent 55d21b6 commit 1ed6ae2
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 43 deletions.
20 changes: 10 additions & 10 deletions Sources/MMIOMacros/Macros/Arguments/BitRange.swift
Original file line number Diff line number Diff line change
Expand Up @@ -204,15 +204,15 @@ extension ErrorDiagnostic {
}

extension Array where Element == BitRange {
var isOverlapped: Bool {
guard count > 1 else { return false }
let sorted = map { $0.canonicalizedClosedRange }
.sorted(by: { $0.lowerBound < $1.lowerBound })
for i in 0..<(sorted.count - 1) {
if sorted[i].upperBound >= sorted[i+1].lowerBound {
return true
}
}
return false
var isOverlapped: Bool {
guard count > 1 else { return false }
let sorted = map { $0.canonicalizedClosedRange }
.sorted(by: { $0.lowerBound < $1.lowerBound })
for i in 0..<(sorted.count - 1) {
if sorted[i].upperBound >= sorted[i+1].lowerBound {
return true
}
}
return false
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,39 +12,39 @@ import SwiftSyntax
import SwiftSyntaxMacros

extension DeclGroupSyntax {
func allBitRanges(
with context: MacroContext<some ParsableMacro, some MacroExpansionContext>
) throws -> [BitRange] {
let attributeNames = [
"ReadOnly",
"ReadWrite",
"Reserved",
"WriteOnly",
]
return try memberBlock.members
func allBitRanges(
with context: MacroContext<some ParsableMacro, some MacroExpansionContext>
) throws -> [BitRange] {
let attributeNames = [
"ReadOnly",
"ReadWrite",
"Reserved",
"WriteOnly",
]
return try memberBlock.members
.compactMap {
VariableDeclSyntax($0.decl)?.attributes
.compactMap {
VariableDeclSyntax($0.decl)?.attributes
.compactMap {
AttributeSyntax($0)
}
.filter {
attributeNames.contains(IdentifierTypeSyntax($0.attributeName)?.name.text ?? "" )
}
.compactMap {
LabeledExprListSyntax($0.arguments)
}
AttributeSyntax($0)
}
.flatMap({ $0 }) // All the LabeledExprLists in interest
.reduce(into: [BitRange](), { partialResult, labeledExprList in
var bits = false
for labeledExpr in labeledExprList {
if let label = labeledExpr.label {
bits = label.text == "bits"
}
if bits {
partialResult.append(try BitRange(expression: labeledExpr.expression, in: context))
}
}
})
}
.filter {
attributeNames.contains(IdentifierTypeSyntax($0.attributeName)?.name.text ?? "" )
}
.compactMap {
LabeledExprListSyntax($0.arguments)
}
}
.flatMap({ $0 }) // All the LabeledExprLists in interest
.reduce(into: [BitRange](), { partialResult, labeledExprList in
var bits = false
for labeledExpr in labeledExprList {
if let label = labeledExpr.label {
bits = label.text == "bits"
}
if bits {
partialResult.append(try BitRange(expression: labeledExpr.expression, in: context))
}
}
})
}
}

0 comments on commit 1ed6ae2

Please sign in to comment.