Generalize existing functions for indenting and prefixing

This commit is contained in:
Kamil Śliwak
2023-09-29 23:03:14 +02:00
parent c6b04df78c
commit 996e9cacd0
12 changed files with 89 additions and 73 deletions
+1 -15
View File
@@ -30,8 +30,6 @@
#include <libsolutil/StringUtils.h>
#include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <range/v3/view/transform.hpp>
@@ -40,18 +38,6 @@ using namespace solidity::langutil;
using namespace solidity::util;
using namespace solidity::yul;
namespace
{
std::string indent(std::string const& _input)
{
if (_input.empty())
return _input;
return boost::replace_all_copy(" " + _input, "\n", "\n ");
}
}
std::string Data::toString(Dialect const*, DebugInfoSelection const&, CharStreamProvider const*) const
{
return "data \"" + name.str() + "\" hex\"" + util::toHex(data) + "\"";
@@ -86,7 +72,7 @@ std::string Object::toString(
for (auto const& obj: subObjects)
inner += "\n" + obj->toString(_dialect, _debugInfoSelection, _soliditySourceProvider);
return useSrcComment + "object \"" + name.str() + "\" {\n" + indent(inner) + "\n}";
return useSrcComment + "object \"" + name.str() + "\" {\n" + indent(inner, true /* _indentEmptyLines */) + "\n}";
}
Json::Value Data::toJson() const