-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDeclBuilder.swift
More file actions
45 lines (36 loc) · 1.15 KB
/
Copy pathDeclBuilder.swift
File metadata and controls
45 lines (36 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//
// DeclBuilder.swift
// PrincipleMacros
//
// Created by Kamil Strzelecki on 26/01/2025.
// Copyright © 2025 Kamil Strzelecki. All rights reserved.
//
import SwiftSyntax
public protocol DeclBuilder {
var basicDeclaration: any BasicDeclSyntax { get }
var settings: DeclBuilderSettings { get }
func build() throws -> [DeclSyntax]
}
extension DeclBuilder {
public var inheritedAccessControlLevel: TokenSyntax? {
let settings = settings.accessControlLevel
return basicDeclaration.inlinableAccessControlLevel(
inheritedBy: settings.inheritingDeclaration,
maxAllowed: settings.maxAllowed
)
}
}
extension DeclBuilder {
public var inheritedGlobalActorIsolation: GlobalActorIsolation? {
if let explicit = settings.explicitGlobalActorIsolation {
return explicit
}
if let inherited = basicDeclaration.globalActor?.attributeName {
return .isolated(trimmedType: inherited.trimmed)
}
return .nonisolated
}
public var inheritedGlobalActorAttribute: AttributeSyntax? {
inheritedGlobalActorIsolation?.inlinableAttribute
}
}