-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support to dump subset of children and superclass nodes
- Loading branch information
Showing
4 changed files
with
356 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
/// Implement this protocol to include superclass nodes | ||
public protocol CustomDumpIncludeSuperclass {} | ||
|
||
/// Implement this protocol to ignore dumping child nodes | ||
/// | ||
/// Using this protocol will make the type ignore the children completly and only print out the type name. | ||
/// This can be useful when something is irrelevant | ||
public protocol CustomDumpIgnoreChildNodes {} | ||
|
||
/// Properties to include child nodes. By default all child nodes are included but when this is implemented, only the values passed will be included in the dump | ||
/// | ||
/// ``` | ||
/// struct Human { | ||
/// let name = "Jimmy" | ||
/// } | ||
/// | ||
/// struct User: CustomDumpIncludedChildNodesProvider { | ||
/// static var includedNodes: [String]? { | ||
/// [ | ||
/// "name", | ||
/// "email", | ||
/// "friends", | ||
/// ] | ||
/// } | ||
/// let name = "John" | ||
/// let email = "[email protected]" | ||
/// let age = 97 | ||
/// let friends = [ | ||
/// "James", | ||
/// "Lilly", | ||
/// "Peter", | ||
/// "Remus", | ||
/// ] | ||
/// let human = Human() | ||
/// } | ||
/// ``` | ||
/// The dump for this will produce | ||
/// ``` | ||
/// User( | ||
/// name: "John", | ||
/// email: "[email protected]", | ||
/// friends: [ | ||
/// [0]: "James", | ||
/// [1]: "Lilly", | ||
/// [2]: "Peter", | ||
/// [3]: "Remus" | ||
/// ] | ||
/// ) | ||
/// ``` | ||
public protocol CustomDumpIncludedChildNodesProvider { | ||
/// Which nodes to include in the dump | ||
static var includedNodes: [String]? { get } | ||
} | ||
|
||
/// Properties to exclude child nodes. This can be helpful when one or more fields are not relevant | ||
/// | ||
/// ``` | ||
/// struct Human { | ||
/// let name = "Jimmy" | ||
/// } | ||
/// | ||
/// struct User: CustomDumpExcludedChildNodesProvider { | ||
/// static var excludedNodes: [String] { | ||
/// [ | ||
/// "age", | ||
/// "friends" | ||
/// ] | ||
/// } | ||
/// let name = "John" | ||
/// let email = "[email protected]" | ||
/// let age = 97 | ||
/// let friends = [ | ||
/// "James", | ||
/// "Lilly", | ||
/// "Peter", | ||
/// "Remus", | ||
/// ] | ||
/// let human = Human() | ||
/// } | ||
/// ``` | ||
/// The dump for this will produce | ||
/// ``` | ||
/// User( | ||
/// name: "John", | ||
/// email: "[email protected]", | ||
/// friends: [ | ||
/// [0]: "James", | ||
/// [1]: "Lilly", | ||
/// [2]: "Peter", | ||
/// [3]: "Remus" | ||
/// ] | ||
/// ) | ||
/// ``` | ||
public protocol CustomDumpExcludedChildNodesProvider { | ||
/// Which nodes to exclude from the dump | ||
static var excludedNodes: [String] { get } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.