Ensure enumNamespaces excludes structs with attributes

This commit is contained in:
Nick Lockwood
2024-03-06 19:47:40 +00:00
parent f96163080f
commit 29cf62fd87
2 changed files with 4 additions and 4 deletions
+3 -3
View File
@@ -956,9 +956,7 @@ public struct _FormatRules {
// exit for class as protocol conformance
formatter.last(.nonSpaceOrCommentOrLinebreak, before: i) != .delimiter(":"),
// exit if not closed for extension
formatter.modifiersForDeclaration(at: i, contains: "final"),
// exit if has attribute(s)
!formatter.modifiersForDeclaration(at: i, contains: { $1.hasPrefix("@") })
formatter.modifiersForDeclaration(at: i, contains: "final")
else {
return
}
@@ -966,6 +964,8 @@ public struct _FormatRules {
guard let braceIndex = formatter.index(of: .startOfScope("{"), after: i),
// exit if import statement
formatter.last(.nonSpaceOrCommentOrLinebreak, before: i) != .keyword("import"),
// exit if has attribute(s)
!formatter.modifiersForDeclaration(at: i, contains: { $1.hasPrefix("@") }),
// exit if type is conforming any other types
!formatter.tokens[i ... braceIndex].contains(.delimiter(":")),
let endIndex = formatter.index(of: .endOfScope("}"), after: braceIndex),
+1 -1
View File
@@ -1028,7 +1028,7 @@ class SyntaxTests: RulesTests {
func testEnumNamespacesNotAppliedIfMacro() {
let input = """
@FooBar
final class Foo {
struct Foo {
static let = "A"
}
"""