-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathObservationSuppressedMacro.swift
More file actions
45 lines (36 loc) · 1.18 KB
/
Copy pathObservationSuppressedMacro.swift
File metadata and controls
45 lines (36 loc) · 1.18 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
//
// ObservationSuppressedMacro.swift
// Relay
//
// Created by Kamil Strzelecki on 01/12/2025.
// Copyright © 2025 Kamil Strzelecki. All rights reserved.
//
import SwiftSyntaxMacros
public enum ObservationSuppressedMacro {
static let attribute: AttributeSyntax = "@ObservationSuppressed"
}
extension ObservationSuppressedMacro: PeerMacro {
public static func expansion(
of _: AttributeSyntax,
providingPeersOf _: some DeclSyntaxProtocol,
in _: some MacroExpansionContext
) -> [DeclSyntax] {
[]
}
}
extension Property {
var isStoredObservationTracked: Bool {
kind == .stored
&& mutability == .mutable
&& underlying.typeScopeSpecifier == nil
&& underlying.overrideSpecifier == nil
&& !underlying.attributes.contains(like: ObservationIgnoredMacro.attribute)
&& !underlying.attributes.contains(like: ObservationSuppressedMacro.attribute)
}
}
extension FunctionDeclSyntax {
var isObservationTracked: Bool {
!attributes.contains(like: ObservationIgnoredMacro.attribute)
&& !attributes.contains(like: ObservationSuppressedMacro.attribute)
}
}