Closed
Description
Description
In the SyntaxRewriter
implementation, I noticed that many visit
methods are written in the following format:
open func visit(_ node: AttributeListSyntax) -> AttributeListSyntax {
return Syntax(visitChildren(node)).cast(AttributeListSyntax.self)
}
Since the node
argument is already of type AttributeListSyntax
, and the visitChildren(node)
method returns the same type, the type casting using .cast(AttributeListSyntax.self)
appears to be redundant and unnecessary.
Suggested Improvement:
Consider refactoring the generated visit
methods to remove this redundant type casting and Syntax
wrapping. The improved version would look like:
open func visit(_ node: AttributeListSyntax) -> AttributeListSyntax {
return visitChildren(node)
}
This simplification would make the codebase cleaner, more readable, and reduce potential points of failure.