Skip to content

Commit d2d5dc3

Browse files
committed
updating the doc for hasAttribute
1 parent 8019514 commit d2d5dc3

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Sources/SwiftFormat/Core/WithAttributesSyntax+Convenience.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
import SwiftSyntax
1414

1515
extension WithAttributesSyntax {
16-
/// Indicates whether the node has attribute with the given `name`.
16+
/// Indicates whether the node has attribute with the given `name` and `module`.
17+
/// The `module` is only considered if the attribute is written as `@Module.Attribute`.
1718
///
1819
/// - Parameter name: The name of the attribute to lookup.
1920
/// - Parameter module: The module name to lookup the attribute in.
@@ -22,10 +23,11 @@ extension WithAttributesSyntax {
2223
attributes.contains { attribute in
2324
let attributeName = attribute.as(AttributeSyntax.self)?.attributeName
2425
if let identifier = attributeName?.as(IdentifierTypeSyntax.self) {
26+
// @Attribute syntax
2527
return identifier.name.text == name
2628
}
27-
// support @Module.Attribute syntax as well
2829
if let memberType = attributeName?.as(MemberTypeSyntax.self) {
30+
// @Module.Attribute syntax
2931
return memberType.name.text == name
3032
&& memberType.baseType.as(IdentifierTypeSyntax.self)?.name.text == module
3133
}

0 commit comments

Comments
 (0)