Sources/OrgCore/Semantic/SemanticSettings.swift

bba622a330741075866a63f110953d34a9235a04
orgstar/Sources/OrgCore/Semantic/SemanticSettings.swift

47 lines · 1570 bytes

 1/// App-wide settings that change what a document means without changing how it parses.
 2public struct SemanticSettings: Sendable, Equatable {
 3    public enum PropertyInheritance: Sendable, Equatable {
 4        /// org's default: properties apply only to their own heading.
 5        case none
 6        case all
 7        /// Upper-cased property keys that inherit.
 8        case only(Set<String>)
 9    }
10
11    public var tagInheritance: Bool
12    public var tagsExcludedFromInheritance: Set<String>
13    public var propertyInheritance: PropertyInheritance
14
15    public init(
16        tagInheritance: Bool = true,
17        tagsExcludedFromInheritance: Set<String> = [],
18        propertyInheritance: PropertyInheritance = .none
19    ) {
20        self.tagInheritance = tagInheritance
21        self.tagsExcludedFromInheritance = tagsExcludedFromInheritance
22        self.propertyInheritance = propertyInheritance
23    }
24
25    public static let `default` = SemanticSettings()
26}
27
28/// Where a resolved value came from.
29public enum ValueSource: Sendable, Equatable {
30    case defaults
31    /// A file-level keyword such as `#+FILETAGS` or `#+PROPERTY`.
32    case file
33    /// A heading, by index into `DocumentModel.headings`.
34    case heading(Int)
35    /// The element itself: a `#+HEADER` line or a block's begin line.
36    case element
37}
38
39public struct Resolved<Value: Sendable & Equatable>: Sendable, Equatable {
40    public let value: Value
41    public let source: ValueSource
42
43    public init(_ value: Value, _ source: ValueSource) {
44        self.value = value
45        self.source = source
46    }
47}
Keyboard shortcuts

Global

⌘K
Command palette & jump
/
Focus search
?
Show this help
g d
Dashboard
g e
Explore repositories
g n
Notifications

Repository & editor

t
Find file in repository
y
Copy immutable SHA permalink
g c
Code tab
g i
Issues tab
g m
Merge requests tab
g b
Builds tab
⌘↵
Submit active form