Skip to content

Commit ddcb0db

Browse files
committed
Cleanup.
1 parent e9eddf8 commit ddcb0db

File tree

5 files changed

+35
-44
lines changed

5 files changed

+35
-44
lines changed

Sources/DiffableTextKit/Models/Attribute.swift

Lines changed: 20 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -18,50 +18,22 @@
1818
/// - Note: The easiest way to unformat text is to exclude symbols marked as virtual.
1919
///
2020
public struct Attribute: OptionSet {
21-
22-
//=------------------------------------------------------------------------=
23-
// MARK: State
24-
//=------------------------------------------------------------------------=
25-
26-
public let rawValue: UInt8
27-
28-
//=------------------------------------------------------------------------=
29-
// MARK: Initializers
30-
//=------------------------------------------------------------------------=
31-
32-
@inlinable public init(rawValue: UInt8) {
33-
self.rawValue = rawValue
34-
}
35-
}
36-
37-
//=----------------------------------------------------------------------------=
38-
// MARK: Singular
39-
//=----------------------------------------------------------------------------=
40-
41-
public extension Attribute {
4221

4322
//=------------------------------------------------------------------------=
4423
// MARK: Instances
4524
//=------------------------------------------------------------------------=
4625

4726
/// Signifies that the symbol is not real and should not be parsed.
48-
static let virtual = Self(rawValue: 1 << 0)
27+
public static let virtual = Self(rawValue: 1 << 0)
4928

5029
/// Signifies that the symbol should be ignored when it is inserted.
51-
static let insertable = Self(rawValue: 1 << 1)
30+
public static let insertable = Self(rawValue: 1 << 1)
5231

5332
/// Signifies that the symbol should be ignored when it is removed.
54-
static let removable = Self(rawValue: 1 << 2)
33+
public static let removable = Self(rawValue: 1 << 2)
5534

5635
/// Signifies that the symbol has no interactive size and should be passed through.
57-
static let passthrough = Self(rawValue: 1 << 3)
58-
}
59-
60-
//=----------------------------------------------------------------------------=
61-
// MARK: Composites
62-
//=----------------------------------------------------------------------------=
63-
64-
public extension Attribute {
36+
public static let passthrough = Self(rawValue: 1 << 3)
6537

6638
//=------------------------------------------------------------------------=
6739
// MARK: Instances
@@ -71,13 +43,27 @@ public extension Attribute {
7143
///
7244
/// It contains no attributes.
7345
///
74-
static let content = Self([])
46+
public static let content = Self([])
7547

7648
/// A formatting attribute describing formatting characters.
7749
///
7850
/// It contains: virtual, insertable, removable, passthrough.
7951
///
80-
static let phantom = Self([.virtual, .insertable, .removable, .passthrough])
52+
public static let phantom = Self([.virtual, .insertable, .removable, .passthrough])
53+
54+
//=------------------------------------------------------------------------=
55+
// MARK: State
56+
//=------------------------------------------------------------------------=
57+
58+
public let rawValue: UInt8
59+
60+
//=------------------------------------------------------------------------=
61+
// MARK: Initializers
62+
//=------------------------------------------------------------------------=
63+
64+
@inlinable public init(rawValue: UInt8) {
65+
self.rawValue = rawValue
66+
}
8167
}
8268

8369
//=----------------------------------------------------------------------------=

Sources/DiffableTextKit/Models/Changes.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public struct Changes: OptionSet {
3333
//=------------------------------------------------------------------------=
3434

3535
@inlinable @inline(__always)
36-
public init(rawValue: UInt8 = 0) {
36+
public init(rawValue: UInt8) {
3737
self.rawValue = rawValue
3838
}
3939
}

Sources/DiffableTextKit/Models/Commit.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ public struct Commit<Value> {
2626
//=------------------------------------------------------------------------=
2727

2828
@inlinable public init(_ value: Value, _ snapshot: Snapshot) {
29-
self.value = value
30-
self.snapshot = snapshot
29+
self.value = value; self.snapshot = snapshot
3130
}
3231

3332
//=------------------------------------------------------------------------=

Sources/DiffableTextKit/Models/Position.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public struct Position<Offset: DiffableTextKit.Offset>: Comparable {
2727
// MARK: Initializers
2828
//=------------------------------------------------------------------------=
2929

30-
@inlinable public init(_ offset: Int = 0) {
30+
@inlinable public init(_ offset: Int) {
3131
self.offset = offset
3232
}
3333

Sources/DiffableTextKit/Models/Symbol.swift

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,31 +37,37 @@ public struct Symbol: Equatable {
3737
// MARK: Initializers
3838
//=------------------------------------------------------------------------=
3939

40-
@inlinable @inline(__always) public static func content(_ character: Character) -> Self {
40+
@inlinable @inline(__always)
41+
public static func content(_ character: Character) -> Self {
4142
Self(character, as: .content)
4243
}
4344

44-
@inlinable @inline(__always) public static func phantom(_ character: Character) -> Self {
45+
@inlinable @inline(__always)
46+
public static func phantom(_ character: Character) -> Self {
4547
Self(character, as: .phantom)
4648
}
4749

4850
//=------------------------------------------------------------------------=
4951
// MARK: Accessors
5052
//=------------------------------------------------------------------------=
5153

52-
@inlinable @inline(__always) public var virtual: Bool {
54+
@inlinable @inline(__always)
55+
public var virtual: Bool {
5356
self.attribute.contains(.virtual)
5457
}
5558

56-
@inlinable @inline(__always) public var nonvirtual: Bool {
59+
@inlinable @inline(__always)
60+
public var nonvirtual: Bool {
5761
self.attribute.contains(.virtual) == false
5862
}
5963

60-
@inlinable @inline(__always) public func contains(_ character: Character) -> Bool {
64+
@inlinable @inline(__always)
65+
public func contains(_ character: Character) -> Bool {
6166
self.character == character
6267
}
6368

64-
@inlinable @inline(__always) public func contains(_ attribute: Attribute) -> Bool {
69+
@inlinable @inline(__always)
70+
public func contains(_ attribute: Attribute) -> Bool {
6571
self.attribute.contains(attribute)
6672
}
6773
}

0 commit comments

Comments
 (0)