mirror of
https://github.com/nicklockwood/SwiftFormat.git
synced 2026-05-17 10:30:35 +00:00
Ensure enumNamespaces excludes structs with attributes
This commit is contained in:
+3
-3
@@ -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),
|
||||
|
||||
@@ -1028,7 +1028,7 @@ class SyntaxTests: RulesTests {
|
||||
func testEnumNamespacesNotAppliedIfMacro() {
|
||||
let input = """
|
||||
@FooBar
|
||||
final class Foo {
|
||||
struct Foo {
|
||||
static let = "A"
|
||||
}
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user