mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Make --pretty-json work with Standard JSON output
This commit is contained in:
committed by
Kamil Śliwak
parent
7041b87c3b
commit
9bbeea58c8
@@ -1420,7 +1420,7 @@ string StandardCompiler::compile(string const& _input) noexcept
|
||||
try
|
||||
{
|
||||
if (!util::jsonParseStrict(_input, input, &errors))
|
||||
return util::jsonCompactPrint(formatFatalError("JSONError", errors));
|
||||
return util::jsonPrint(formatFatalError("JSONError", errors), m_jsonPrintingFormat);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
@@ -1433,7 +1433,7 @@ string StandardCompiler::compile(string const& _input) noexcept
|
||||
|
||||
try
|
||||
{
|
||||
return util::jsonCompactPrint(output);
|
||||
return util::jsonPrint(output, m_jsonPrintingFormat);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <libsolidity/interface/CompilerStack.h>
|
||||
#include <libsolutil/JSON.h>
|
||||
|
||||
#include <optional>
|
||||
#include <utility>
|
||||
@@ -46,8 +47,10 @@ public:
|
||||
/// Creates a new StandardCompiler.
|
||||
/// @param _readFile callback used to read files for import statements. Must return
|
||||
/// and must not emit exceptions.
|
||||
explicit StandardCompiler(ReadCallback::Callback _readFile = ReadCallback::Callback()):
|
||||
m_readFile(std::move(_readFile))
|
||||
explicit StandardCompiler(ReadCallback::Callback _readFile = ReadCallback::Callback(),
|
||||
util::JsonFormat const& _format = {}):
|
||||
m_readFile(std::move(_readFile)),
|
||||
m_jsonPrintingFormat(std::move(_format))
|
||||
{
|
||||
}
|
||||
|
||||
@@ -91,6 +94,8 @@ private:
|
||||
Json::Value compileYul(InputsAndSettings _inputsAndSettings);
|
||||
|
||||
ReadCallback::Callback m_readFile;
|
||||
|
||||
util::JsonFormat m_jsonPrintingFormat;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user