File tree Expand file tree Collapse file tree
Tests/PrincipleMacrosTests/Parameters Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -20,19 +20,26 @@ extension DeclBuilder {
2020
2121 public var inheritedAccessControlLevel : TokenSyntax ? {
2222 let settings = settings. accessControlLevel
23- return basicDeclaration. accessControlLevel (
23+ return basicDeclaration. inlinableAccessControlLevel (
2424 inheritedBy: settings. inheritingDeclaration,
2525 maxAllowed: settings. maxAllowed
2626 )
2727 }
28+ }
29+
30+ extension DeclBuilder {
2831
2932 public var inheritedGlobalActorIsolation : GlobalActorIsolation ? {
30- if let preferred = settings. preferredGlobalActorIsolation {
31- return preferred
33+ if let explicit = settings. explicitGlobalActorIsolation {
34+ return explicit
3235 }
33- if let inferredType = basicDeclaration. globalActor? . attributeName. trimmed {
34- return . isolated( trimmedType: inferredType )
36+ if let inherited = basicDeclaration. globalActor? . attributeName {
37+ return . isolated( trimmedType: inherited . trimmed )
3538 }
3639 return . nonisolated
3740 }
41+
42+ public var inheritedGlobalActorAttribute : AttributeSyntax ? {
43+ inheritedGlobalActorIsolation? . inlinableAttribute
44+ }
3845}
Original file line number Diff line number Diff line change @@ -11,14 +11,14 @@ import SwiftSyntax
1111public struct DeclBuilderSettings {
1212
1313 public var accessControlLevel : AccessControlLevel
14- public var preferredGlobalActorIsolation : GlobalActorIsolation ?
14+ public var explicitGlobalActorIsolation : GlobalActorIsolation ?
1515
1616 public init (
1717 accessControlLevel: AccessControlLevel ,
18- preferredGlobalActorIsolation : GlobalActorIsolation ? = nil
18+ explicitGlobalActorIsolation : GlobalActorIsolation ? = nil
1919 ) {
2020 self . accessControlLevel = accessControlLevel
21- self . preferredGlobalActorIsolation = preferredGlobalActorIsolation
21+ self . explicitGlobalActorIsolation = explicitGlobalActorIsolation
2222 }
2323}
2424
Original file line number Diff line number Diff line change @@ -22,18 +22,18 @@ extension TypeDeclBuilder {
2222
2323extension TypeDeclBuilder {
2424
25- public var trimmedTypeName : TypeSyntax {
25+ public var trimmedType : TypeSyntax {
2626 switch TypeDeclBuilderContext . current {
27- case let . extension( extendedType ) :
28- extendedType . trimmed
27+ case let . extension( trimmedType ) :
28+ trimmedType
2929 case . declaration:
3030 " \( typeDeclaration. name. trimmed) "
3131 }
3232 }
3333
3434 public func buildExtension( of extendedType: some TypeSyntaxProtocol ) throws -> MemberBlockSyntax {
3535 try TypeDeclBuilderContext . $current. withValue (
36- . extension( TypeSyntax ( extendedType) ) ,
36+ . extension( trimmedType : TypeSyntax ( extendedType. trimmed ) ) ,
3737 operation: {
3838 try MemberBlockSyntax (
3939 members: MemberBlockItemListSyntax (
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ import SwiftSyntax
1111internal enum TypeDeclBuilderContext {
1212
1313 case declaration
14- case `extension`( TypeSyntax )
14+ case `extension`( trimmedType : TypeSyntax )
1515}
1616
1717extension TypeDeclBuilderContext {
Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ extension WithModifiersSyntax {
4343
4444extension WithModifiersSyntax {
4545
46- public func accessControlLevel (
46+ public func inlinableAccessControlLevel (
4747 inheritedBy inheritingDeclaration: InheritingDeclaration ,
4848 maxAllowed: Keyword
4949 ) -> TokenSyntax ? {
Original file line number Diff line number Diff line change @@ -15,19 +15,18 @@ public enum GlobalActorIsolation: Hashable {
1515
1616 public var trimmedType : TypeSyntax ? {
1717 switch self {
18- case let . isolated( type ) :
19- type
18+ case let . isolated( trimmedType ) :
19+ trimmedType
2020 case . nonisolated:
2121 nil
2222 }
2323 }
2424
25- public var trimmedAttribute : AttributeSyntax ? {
25+ public var inlinableAttribute : AttributeSyntax ? {
2626 guard let trimmedType else {
2727 return nil
2828 }
29- return AttributeSyntax (
30- attributeName: trimmedType
31- )
29+ let attribute = AttributeSyntax ( attributeName: trimmedType)
30+ return attribute. withTrailingSpace
3231 }
3332}
Original file line number Diff line number Diff line change @@ -100,7 +100,7 @@ extension ParameterExtractorTests {
100100 func testIsolatedPreferredGlobalActorExtraction( isolation: String ) throws {
101101 let extractor = try makeExtractor ( from: " #MyMacro(isolation: \( raw: isolation) .self) " )
102102 let extracted = try extractor. preferredGlobalActorIsolation ( withLabel: " isolation " )
103- #expect( extracted? . trimmedAttribute ? . description == " @ \( isolation) " )
103+ #expect( extracted? . trimmedType ? . description == isolation)
104104 }
105105
106106 @Test
You can’t perform that action at this time.
0 commit comments