Fabric: Improved prettyprinting of TreeMutationInstruction

Summary:
@public
Quite trivial... and nice.

Reviewed By: mdvacca

Differential Revision: D8709951

fbshipit-source-id: 63e53eb85361fe3a0a0ecd7f21bf4c7db049d5bf
This commit is contained in:
Valentin Shergin
2018-07-06 14:34:38 -07:00
committed by Facebook Github Bot
parent de09fd53bd
commit e0e9c1549e
2 changed files with 17 additions and 1 deletions

View File

@@ -150,6 +150,21 @@ std::string TreeMutationInstruction::getDebugName() const {
}
};
std::string TreeMutationInstruction::getDebugValue() const {
switch (type_) {
case Creation:
return "[*" + folly::to<std::string>(newChildNode_->getTag()) + "]";
case Deletion:
return "[~" + folly::to<std::string>(oldChildNode_->getTag()) + "]";
case Insertion:
return "[" + folly::to<std::string>(newChildNode_->getTag()) + "->" + folly::to<std::string>(parentNode_->getTag()) + "]";
case Removal:
return "[" + folly::to<std::string>(oldChildNode_->getTag()) + "<~" + folly::to<std::string>(parentNode_->getTag()) + "]";
case Replacement:
return "[=" + folly::to<std::string>(oldChildNode_->getTag()) + "]";
}
};
SharedDebugStringConvertibleList TreeMutationInstruction::getDebugProps() const {
DebugStringConvertibleOptions options = {.maximumDepth = 1, .format = false};
@@ -176,7 +191,7 @@ SharedDebugStringConvertibleList TreeMutationInstruction::getDebugProps() const
};
case Replacement:
return SharedDebugStringConvertibleList {
std::make_shared<DebugStringConvertibleItem>("parentNode", parentNode_->getDebugDescription(options)),
std::make_shared<DebugStringConvertibleItem>("parentNode", parentNode_ ? parentNode_->getDebugDescription(options) : "nullptr"),
std::make_shared<DebugStringConvertibleItem>("oldChildNode", oldChildNode_->getDebugDescription(options)),
std::make_shared<DebugStringConvertibleItem>("newChildNode", newChildNode_->getDebugDescription(options)),
std::make_shared<DebugStringConvertibleItem>("index", folly::to<std::string>(index_))

View File

@@ -96,6 +96,7 @@ public:
#pragma mark - DebugStringConvertible
std::string getDebugName() const override;
std::string getDebugValue() const override;
SharedDebugStringConvertibleList getDebugProps() const override;
private: