Skip to content

Commit e5069f1

Browse files
committed
Rename AttributeRemover initializer to init(removingWhere:) instead of init(where:) and added documentation
1 parent b91459c commit e5069f1

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

Sources/SwiftSyntaxMacroExpansion/MacroSystem.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,11 @@ public class AttributeRemover: SyntaxRewriter {
390390

391391
var triviaToAttachToNextToken: Trivia = Trivia()
392392

393-
public init(where predicate: @escaping (AttributeSyntax) -> Bool) {
393+
/// Initializes an attribute remover with a given predicate to determine which attributes to remove.
394+
///
395+
/// - Parameter predicate: A closure that determines whether a given `AttributeSyntax` should be removed.
396+
/// If this closure returns `true` for an attribute, that attribute will be removed.
397+
public init(removingWhere predicate: @escaping (AttributeSyntax) -> Bool) {
394398
self.predicate = predicate
395399
}
396400

@@ -574,7 +578,7 @@ private class MacroApplication<Context: MacroExpansionContext>: SyntaxRewriter {
574578

575579
let attributesToRemove = self.macroAttributes(attachedTo: visitedNode).map(\.attributeNode)
576580

577-
return AttributeRemover(where: { attributesToRemove.contains($0) }).rewrite(visitedNode)
581+
return AttributeRemover(removingWhere: { attributesToRemove.contains($0) }).rewrite(visitedNode)
578582
}
579583

580584
return nil

Tests/SwiftSyntaxMacroExpansionTest/AttributeRemoverTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ fileprivate func assertSyntaxRemovingTestAttributes(
2525
let attributeToRemove = AttributeSyntax(stringLiteral: "@Test")
2626

2727
let reducedSource = AttributeRemover(
28-
where: { $0.trimmedDescription == attributeToRemove.trimmedDescription }
28+
removingWhere: { $0.trimmedDescription == attributeToRemove.trimmedDescription }
2929
)
3030
.rewrite(
3131
Parser.parse(source: originalSource)

0 commit comments

Comments
 (0)