From aeeb72fab8e49a9d6f420ac827b6ed688c338943 Mon Sep 17 00:00:00 2001 From: Richard Piazza Date: Sat, 6 Jun 2026 15:18:43 -0500 Subject: [PATCH] @MainActor Attribute on Key Hierarchy Extensions --- Sources/TranslationCatalogIO/KeyHierarchy+Syntax.swift | 1 + Sources/TranslationCatalogIO/KeyHierarchy.swift | 1 + Tests/TranslationCatalogTests/DeepKeyHierarchyTests.swift | 8 ++++---- .../ShallowKeyHierarchyTests.swift | 8 ++++---- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Sources/TranslationCatalogIO/KeyHierarchy+Syntax.swift b/Sources/TranslationCatalogIO/KeyHierarchy+Syntax.swift index afad259..55bf0f7 100644 --- a/Sources/TranslationCatalogIO/KeyHierarchy+Syntax.swift +++ b/Sources/TranslationCatalogIO/KeyHierarchy+Syntax.swift @@ -37,6 +37,7 @@ public extension KeyHierarchy { ExtensionDeclSyntax( leadingTrivia: .newlines(2), + attributes: AttributeListSyntax([.attribute("@MainActor")]), extendedType: TypeSyntax(stringLiteral: "LocalizedStringKey") ) { let hierarchy = self diff --git a/Sources/TranslationCatalogIO/KeyHierarchy.swift b/Sources/TranslationCatalogIO/KeyHierarchy.swift index 34612c8..e2a76e1 100644 --- a/Sources/TranslationCatalogIO/KeyHierarchy.swift +++ b/Sources/TranslationCatalogIO/KeyHierarchy.swift @@ -22,6 +22,7 @@ public struct KeyHierarchy { "continue", "for", "in", + "import", "self", ] diff --git a/Tests/TranslationCatalogTests/DeepKeyHierarchyTests.swift b/Tests/TranslationCatalogTests/DeepKeyHierarchyTests.swift index 393a9e2..d54005c 100644 --- a/Tests/TranslationCatalogTests/DeepKeyHierarchyTests.swift +++ b/Tests/TranslationCatalogTests/DeepKeyHierarchyTests.swift @@ -400,7 +400,7 @@ struct DeepKeyHierarchyTests { #expect(syntax == """ import SwiftUI - extension LocalizedStringKey { + @MainActor extension LocalizedStringKey { enum Payment { @@ -472,7 +472,7 @@ struct DeepKeyHierarchyTests { #expect(syntax == """ import SwiftUI - extension LocalizedStringKey { + @MainActor extension LocalizedStringKey { enum PaymentMethod { @@ -538,7 +538,7 @@ struct DeepKeyHierarchyTests { #expect(syntax == """ import SwiftUI - extension LocalizedStringKey { + @MainActor extension LocalizedStringKey { enum Payment { @@ -586,7 +586,7 @@ struct DeepKeyHierarchyTests { #expect(syntax == """ import SwiftUI - extension LocalizedStringKey { + @MainActor extension LocalizedStringKey { enum PaymentMethod { /// Are you sure you want to delete this payment method? diff --git a/Tests/TranslationCatalogTests/ShallowKeyHierarchyTests.swift b/Tests/TranslationCatalogTests/ShallowKeyHierarchyTests.swift index e40dbf1..a9bbf14 100644 --- a/Tests/TranslationCatalogTests/ShallowKeyHierarchyTests.swift +++ b/Tests/TranslationCatalogTests/ShallowKeyHierarchyTests.swift @@ -282,7 +282,7 @@ struct ShallowKeyHierarchyTests { #expect(syntax == """ import SwiftUI - extension LocalizedStringKey { + @MainActor extension LocalizedStringKey { /// Hello World! static let greeting: LocalizedStringKey = "GREETING" @@ -327,7 +327,7 @@ struct ShallowKeyHierarchyTests { #expect(syntax == """ import SwiftUI - extension LocalizedStringKey { + @MainActor extension LocalizedStringKey { /// Hello World! static let greeting: LocalizedStringKey = "GREETING" @@ -375,7 +375,7 @@ struct ShallowKeyHierarchyTests { #expect(syntax == """ import SwiftUI - extension LocalizedStringKey { + @MainActor extension LocalizedStringKey { /// Lingua static let applicationName: LocalizedStringKey = "APPLICATION_NAME" /// Hello World! @@ -410,7 +410,7 @@ struct ShallowKeyHierarchyTests { #expect(syntax == """ import SwiftUI - extension LocalizedStringKey { + @MainActor extension LocalizedStringKey { /// Lingua static let applicationName: LocalizedStringKey = "APPLICATION_NAME" /// Hello World!