Rename SourceReferenceFormatterHuman.

This commit is contained in:
chriseth 2020-12-01 14:22:15 +01:00
parent 4044817255
commit c193ce6c07
25 changed files with 64 additions and 64 deletions

View File

@ -19,8 +19,8 @@ set(sources
SourceLocation.cpp
SourceReferenceExtractor.cpp
SourceReferenceExtractor.h
SourceReferenceFormatterHuman.cpp
SourceReferenceFormatterHuman.h
SourceReferenceFormatter.cpp
SourceReferenceFormatter.h
Token.cpp
Token.h
UndefMacros.h

View File

@ -19,7 +19,7 @@
* Formatting functions for errors referencing positions and locations in the source.
*/
#include <liblangutil/SourceReferenceFormatterHuman.h>
#include <liblangutil/SourceReferenceFormatter.h>
#include <liblangutil/Scanner.h>
#include <liblangutil/Exceptions.h>
#include <libsolutil/UTF8.h>
@ -46,42 +46,42 @@ std::string replaceNonTabs(std::string_view _utf8Input, char _filler)
}
AnsiColorized SourceReferenceFormatterHuman::normalColored() const
AnsiColorized SourceReferenceFormatter::normalColored() const
{
return AnsiColorized(m_stream, m_colored, {WHITE});
}
AnsiColorized SourceReferenceFormatterHuman::frameColored() const
AnsiColorized SourceReferenceFormatter::frameColored() const
{
return AnsiColorized(m_stream, m_colored, {BOLD, BLUE});
}
AnsiColorized SourceReferenceFormatterHuman::errorColored() const
AnsiColorized SourceReferenceFormatter::errorColored() const
{
return AnsiColorized(m_stream, m_colored, {BOLD, RED});
}
AnsiColorized SourceReferenceFormatterHuman::messageColored() const
AnsiColorized SourceReferenceFormatter::messageColored() const
{
return AnsiColorized(m_stream, m_colored, {BOLD, WHITE});
}
AnsiColorized SourceReferenceFormatterHuman::secondaryColored() const
AnsiColorized SourceReferenceFormatter::secondaryColored() const
{
return AnsiColorized(m_stream, m_colored, {BOLD, CYAN});
}
AnsiColorized SourceReferenceFormatterHuman::highlightColored() const
AnsiColorized SourceReferenceFormatter::highlightColored() const
{
return AnsiColorized(m_stream, m_colored, {YELLOW});
}
AnsiColorized SourceReferenceFormatterHuman::diagColored() const
AnsiColorized SourceReferenceFormatter::diagColored() const
{
return AnsiColorized(m_stream, m_colored, {BOLD, YELLOW});
}
void SourceReferenceFormatterHuman::printSourceLocation(SourceReference const& _ref)
void SourceReferenceFormatter::printSourceLocation(SourceReference const& _ref)
{
if (_ref.sourceName.empty())
return; // Nothing we can print here
@ -152,7 +152,7 @@ void SourceReferenceFormatterHuman::printSourceLocation(SourceReference const& _
}
}
void SourceReferenceFormatterHuman::printExceptionInformation(SourceReferenceExtractor::Message const& _msg)
void SourceReferenceFormatter::printExceptionInformation(SourceReferenceExtractor::Message const& _msg)
{
// exception header line
errorColored() << _msg.category;
@ -172,12 +172,12 @@ void SourceReferenceFormatterHuman::printExceptionInformation(SourceReferenceExt
m_stream << '\n';
}
void SourceReferenceFormatterHuman::printExceptionInformation(util::Exception const& _exception, std::string const& _category)
void SourceReferenceFormatter::printExceptionInformation(util::Exception const& _exception, std::string const& _category)
{
printExceptionInformation(SourceReferenceExtractor::extract(_exception, _category));
}
void SourceReferenceFormatterHuman::printErrorInformation(Error const& _error)
void SourceReferenceFormatter::printErrorInformation(Error const& _error)
{
printExceptionInformation(SourceReferenceExtractor::extract(_error));
}

View File

@ -34,10 +34,10 @@ namespace solidity::langutil
{
struct SourceLocation;
class SourceReferenceFormatterHuman
class SourceReferenceFormatter
{
public:
SourceReferenceFormatterHuman(std::ostream& _stream, bool _colored, bool _withErrorIds):
SourceReferenceFormatter(std::ostream& _stream, bool _colored, bool _withErrorIds):
m_stream(_stream), m_colored(_colored), m_withErrorIds(_withErrorIds)
{}
@ -55,7 +55,7 @@ public:
)
{
std::ostringstream errorOutput;
SourceReferenceFormatterHuman formatter(errorOutput, _colored, _withErrorIds);
SourceReferenceFormatter formatter(errorOutput, _colored, _withErrorIds);
formatter.printExceptionInformation(_exception, _name);
return errorOutput.str();
}

View File

@ -45,7 +45,7 @@
#include <liblangutil/ErrorReporter.h>
#include <liblangutil/Scanner.h>
#include <liblangutil/SourceReferenceFormatterHuman.h>
#include <liblangutil/SourceReferenceFormatter.h>
#include <boost/algorithm/string/replace.hpp>
@ -460,7 +460,7 @@ void CompilerContext::appendInlineAssembly(
_assembly + "\n"
"------------------ Errors: ----------------\n";
for (auto const& error: errorReporter.errors())
message += SourceReferenceFormatterHuman::formatErrorInformation(*error);
message += SourceReferenceFormatter::formatErrorInformation(*error);
message += "-------------------------------------------\n";
solAssert(false, message);

View File

@ -37,7 +37,7 @@
#include <libsolutil/Whiskers.h>
#include <libsolutil/StringUtils.h>
#include <liblangutil/SourceReferenceFormatterHuman.h>
#include <liblangutil/SourceReferenceFormatter.h>
#include <boost/range/adaptor/map.hpp>
@ -60,7 +60,7 @@ pair<string, string> IRGenerator::run(
{
string errorMessage;
for (auto const& error: asmStack.errors())
errorMessage += langutil::SourceReferenceFormatterHuman::formatErrorInformation(*error);
errorMessage += langutil::SourceReferenceFormatter::formatErrorInformation(*error);
solAssert(false, ir + "\n\nInvalid IR generated:\n" + errorMessage + "\n");
}
asmStack.optimize();

View File

@ -27,7 +27,7 @@
#include <libyul/AssemblyStack.h>
#include <libyul/Exceptions.h>
#include <libyul/optimiser/Suite.h>
#include <liblangutil/SourceReferenceFormatterHuman.h>
#include <liblangutil/SourceReferenceFormatter.h>
#include <libevmasm/Instruction.h>
#include <libsmtutil/Exceptions.h>
#include <libsolutil/JSON.h>
@ -118,7 +118,7 @@ Json::Value formatErrorWithException(
{
string message;
// TODO: consider enabling color
string formattedMessage = SourceReferenceFormatterHuman::formatExceptionInformation(_exception, _type);
string formattedMessage = SourceReferenceFormatter::formatExceptionInformation(_exception, _type);
if (string const* description = boost::get_error_info<util::errinfo_comment>(_exception))
message = ((_message.length() > 0) ? (_message + ":") : "") + *description;

View File

@ -39,7 +39,7 @@
#include <liblangutil/ErrorReporter.h>
#include <liblangutil/Scanner.h>
#include <liblangutil/SourceReferenceFormatterHuman.h>
#include <liblangutil/SourceReferenceFormatter.h>
// The following headers are generated from the
// yul files placed in libyul/backends/wasm/polyfill.
@ -97,7 +97,7 @@ Object EVMToEwasmTranslator::run(Object const& _object)
message += ret.toString(&WasmDialect::instance());
message += "----------------------------------\n";
for (auto const& err: errors)
message += langutil::SourceReferenceFormatterHuman::formatErrorInformation(*err);
message += langutil::SourceReferenceFormatter::formatErrorInformation(*err);
yulAssert(false, message);
}
@ -131,7 +131,7 @@ void EVMToEwasmTranslator::parsePolyfill()
{
string message;
for (auto const& err: errors)
message += langutil::SourceReferenceFormatterHuman::formatErrorInformation(*err);
message += langutil::SourceReferenceFormatter::formatErrorInformation(*err);
yulAssert(false, message);
}

View File

@ -45,7 +45,7 @@
#include <liblangutil/Exceptions.h>
#include <liblangutil/Scanner.h>
#include <liblangutil/SourceReferenceFormatterHuman.h>
#include <liblangutil/SourceReferenceFormatter.h>
#include <libsmtutil/Exceptions.h>
@ -1447,7 +1447,7 @@ bool CommandLineInterface::processInput()
m_compiler = make_unique<CompilerStack>(fileReader);
SourceReferenceFormatterHuman formatter(serr(false), m_coloredOutput, m_withErrorIds);
SourceReferenceFormatter formatter(serr(false), m_coloredOutput, m_withErrorIds);
try
{
@ -1872,7 +1872,7 @@ bool CommandLineInterface::assemble(
for (auto const& sourceAndStack: assemblyStacks)
{
auto const& stack = sourceAndStack.second;
SourceReferenceFormatterHuman formatter(serr(false), m_coloredOutput, m_withErrorIds);
SourceReferenceFormatter formatter(serr(false), m_coloredOutput, m_withErrorIds);
for (auto const& error: stack.errors())
{

View File

@ -20,7 +20,7 @@
#include <test/libsolidity/ASTJSONTest.h>
#include <test/Common.h>
#include <libsolutil/AnsiColorized.h>
#include <liblangutil/SourceReferenceFormatterHuman.h>
#include <liblangutil/SourceReferenceFormatter.h>
#include <libsolidity/ast/ASTJsonConverter.h>
#include <libsolidity/interface/CompilerStack.h>
#include <boost/algorithm/string.hpp>
@ -141,7 +141,7 @@ TestCase::TestResult ASTJSONTest::run(ostream& _stream, string const& _linePrefi
if (!c.compile(CompilerStack::State::Parsed))
{
SourceReferenceFormatterHuman formatter(_stream, _formatted, false);
SourceReferenceFormatter formatter(_stream, _formatted, false);
for (auto const& error: c.errors())
formatter.printErrorInformation(*error);
return TestResult::FatalError;
@ -167,7 +167,7 @@ TestCase::TestResult ASTJSONTest::run(ostream& _stream, string const& _linePrefi
if (m_expectation.empty())
return resultsMatch ? TestResult::Success : TestResult::Failure;
SourceReferenceFormatterHuman formatter(_stream, _formatted, false);
SourceReferenceFormatter formatter(_stream, _formatted, false);
for (auto const& error: c.errors())
formatter.printErrorInformation(*error);
return TestResult::FatalError;

View File

@ -24,7 +24,7 @@
#include <test/Common.h>
#include <libsolidity/interface/CompilerStack.h>
#include <liblangutil/SourceReferenceFormatterHuman.h>
#include <liblangutil/SourceReferenceFormatter.h>
#include <libsolidity/ast/AST.h>
@ -149,7 +149,7 @@ string AnalysisFramework::formatErrors() const
string AnalysisFramework::formatError(Error const& _error) const
{
return SourceReferenceFormatterHuman::formatErrorInformation(_error);
return SourceReferenceFormatter::formatErrorInformation(_error);
}
ContractDefinition const* AnalysisFramework::retrieveContractByName(SourceUnit const& _source, string const& _name)

View File

@ -20,7 +20,7 @@
#include <test/Common.h>
#include <libsolutil/CommonIO.h>
#include <libsolutil/JSON.h>
#include <liblangutil/SourceReferenceFormatterHuman.h>
#include <liblangutil/SourceReferenceFormatter.h>
#include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/predicate.hpp>
#include <boost/filesystem.hpp>
@ -119,7 +119,7 @@ TestCase::TestResult GasTest::run(ostream& _stream, string const& _linePrefix, b
if (!compiler().parseAndAnalyze() || !compiler().compile())
{
SourceReferenceFormatterHuman formatter(_stream, _formatted, false);
SourceReferenceFormatter formatter(_stream, _formatted, false);
for (auto const& error: compiler().errors())
formatter.printErrorInformation(*error);
return TestResult::FatalError;

View File

@ -30,7 +30,7 @@
#include <liblangutil/Scanner.h>
#include <liblangutil/Exceptions.h>
#include <liblangutil/SourceReferenceFormatterHuman.h>
#include <liblangutil/SourceReferenceFormatter.h>
#include <libevmasm/Assembly.h>
@ -81,7 +81,7 @@ std::optional<Error> parseAndReturnFirstError(
{
string errors;
for (auto const& err: stack.errors())
errors += SourceReferenceFormatterHuman::formatErrorInformation(*err);
errors += SourceReferenceFormatter::formatErrorInformation(*err);
BOOST_FAIL("Found more than one error:\n" + errors);
}
error = e;

View File

@ -26,7 +26,7 @@
#include <boost/test/framework.hpp>
#include <test/libsolidity/SolidityExecutionFramework.h>
#include <liblangutil/Exceptions.h>
#include <liblangutil/SourceReferenceFormatterHuman.h>
#include <liblangutil/SourceReferenceFormatter.h>
using namespace solidity;
using namespace solidity::test;
@ -62,7 +62,7 @@ bytes SolidityExecutionFramework::multiSourceCompileContract(
for (auto const& error: m_compiler.errors())
if (error->type() == langutil::Error::Type::CodeGenerationError)
BOOST_THROW_EXCEPTION(*error);
langutil::SourceReferenceFormatterHuman formatter(std::cerr, true, false);
langutil::SourceReferenceFormatter formatter(std::cerr, true, false);
for (auto const& error: m_compiler.errors())
formatter.printErrorInformation(*error);

View File

@ -23,7 +23,7 @@
#include <test/Common.h>
#include <liblangutil/SourceReferenceFormatterHuman.h>
#include <liblangutil/SourceReferenceFormatter.h>
#include <libyul/optimiser/Disambiguator.h>
#include <libyul/AsmParser.h>
@ -55,7 +55,7 @@ Dialect const& defaultDialect(bool _yul)
void yul::test::printErrors(ErrorList const& _errors)
{
SourceReferenceFormatterHuman formatter(cout, true, false);
SourceReferenceFormatter formatter(cout, true, false);
for (auto const& error: _errors)
formatter.printErrorInformation(*error);

View File

@ -31,7 +31,7 @@
#include <libyul/Object.h>
#include <liblangutil/ErrorReporter.h>
#include <liblangutil/SourceReferenceFormatterHuman.h>
#include <liblangutil/SourceReferenceFormatter.h>
#include <libsolutil/AnsiColorized.h>
@ -116,7 +116,7 @@ string EwasmTranslationTest::interpret()
void EwasmTranslationTest::printErrors(ostream& _stream, ErrorList const& _errors)
{
SourceReferenceFormatterHuman formatter(_stream, true, false);
SourceReferenceFormatter formatter(_stream, true, false);
for (auto const& error: _errors)
formatter.printErrorInformation(*error);

View File

@ -24,7 +24,7 @@
#include <libevmasm/Instruction.h>
#include <liblangutil/SourceReferenceFormatterHuman.h>
#include <liblangutil/SourceReferenceFormatter.h>
#include <boost/algorithm/string.hpp>
@ -96,7 +96,7 @@ TestCase::TestResult ObjectCompilerTest::run(ostream& _stream, string const& _li
void ObjectCompilerTest::printErrors(ostream& _stream, ErrorList const& _errors)
{
SourceReferenceFormatterHuman formatter(_stream, true, false);
SourceReferenceFormatter formatter(_stream, true, false);
for (auto const& error: _errors)
formatter.printErrorInformation(*error);

View File

@ -28,7 +28,7 @@
#include <libyul/AsmAnalysisInfo.h>
#include <liblangutil/ErrorReporter.h>
#include <liblangutil/SourceReferenceFormatterHuman.h>
#include <liblangutil/SourceReferenceFormatter.h>
#include <libsolutil/AnsiColorized.h>
@ -104,7 +104,7 @@ string YulInterpreterTest::interpret()
void YulInterpreterTest::printErrors(ostream& _stream, ErrorList const& _errors)
{
SourceReferenceFormatterHuman formatter(_stream, true, false);
SourceReferenceFormatter formatter(_stream, true, false);
for (auto const& error: _errors)
formatter.printErrorInformation(*error);

View File

@ -73,7 +73,7 @@
#include <libyul/AsmAnalysis.h>
#include <libyul/AssemblyStack.h>
#include <libyul/CompilabilityChecker.h>
#include <liblangutil/SourceReferenceFormatterHuman.h>
#include <liblangutil/SourceReferenceFormatter.h>
#include <liblangutil/ErrorReporter.h>
#include <liblangutil/Scanner.h>
@ -496,7 +496,7 @@ void YulOptimizerTest::updateContext()
void YulOptimizerTest::printErrors(ostream& _stream, ErrorList const& _errors)
{
SourceReferenceFormatterHuman formatter(_stream, true, false);
SourceReferenceFormatter formatter(_stream, true, false);
for (auto const& error: _errors)
formatter.printErrorInformation(*error);

View File

@ -1,7 +1,7 @@
#include <test/tools/ossfuzz/abiV2FuzzerCommon.h>
#include <liblangutil/Exceptions.h>
#include <liblangutil/SourceReferenceFormatterHuman.h>
#include <liblangutil/SourceReferenceFormatter.h>
using namespace solidity::test::abiv2fuzzer;
@ -24,7 +24,7 @@ solidity::bytes SolidityCompilationFramework::compileContract(
m_compiler.setOptimiserSettings(_optimization);
if (!m_compiler.compile())
{
langutil::SourceReferenceFormatterHuman formatter(std::cerr, false, false);
langutil::SourceReferenceFormatter formatter(std::cerr, false, false);
for (auto const& error: m_compiler.errors())
formatter.printExceptionInformation(

View File

@ -28,7 +28,7 @@
#include <libyul/Exceptions.h>
#include <liblangutil/EVMVersion.h>
#include <liblangutil/SourceReferenceFormatterHuman.h>
#include <liblangutil/SourceReferenceFormatter.h>
#include <test/tools/ossfuzz/yulFuzzerCommon.h>
@ -44,7 +44,7 @@ namespace
{
void printErrors(ostream& _stream, ErrorList const& _errors)
{
SourceReferenceFormatterHuman formatter(_stream, false, false);
SourceReferenceFormatter formatter(_stream, false, false);
for (auto const& error: _errors)
formatter.printExceptionInformation(

View File

@ -30,7 +30,7 @@
#include <libyul/AsmParser.h>
#include <libyul/AsmPrinter.h>
#include <libyul/Object.h>
#include <liblangutil/SourceReferenceFormatterHuman.h>
#include <liblangutil/SourceReferenceFormatter.h>
#include <libyul/optimiser/Disambiguator.h>
#include <libyul/optimiser/OptimiserStep.h>
@ -64,7 +64,7 @@ class YulOpti
public:
void printErrors()
{
SourceReferenceFormatterHuman formatter(cerr, true, false);
SourceReferenceFormatter formatter(cerr, true, false);
for (auto const& error: m_errors)
formatter.printErrorInformation(*error);

View File

@ -31,7 +31,7 @@
#include <liblangutil/Exceptions.h>
#include <liblangutil/ErrorReporter.h>
#include <liblangutil/EVMVersion.h>
#include <liblangutil/SourceReferenceFormatterHuman.h>
#include <liblangutil/SourceReferenceFormatter.h>
#include <libsolutil/CommonIO.h>
#include <libsolutil/CommonData.h>
@ -58,7 +58,7 @@ namespace
void printErrors(ErrorList const& _errors)
{
for (auto const& error: _errors)
SourceReferenceFormatterHuman(cout, true, false).printErrorInformation(*error);
SourceReferenceFormatter(cout, true, false).printErrorInformation(*error);
}
pair<shared_ptr<Block>, shared_ptr<AsmAnalysisInfo>> parse(string const& _source)

View File

@ -18,7 +18,7 @@
#include <tools/solidityUpgrade/SourceUpgrade.h>
#include <liblangutil/Exceptions.h>
#include <liblangutil/SourceReferenceFormatterHuman.h>
#include <liblangutil/SourceReferenceFormatter.h>
#include <libsolidity/ast/AST.h>
@ -397,7 +397,7 @@ void SourceUpgrade::applyChange(
void SourceUpgrade::printErrors() const
{
auto formatter = make_unique<langutil::SourceReferenceFormatterHuman>(cout, true, false);
auto formatter = make_unique<langutil::SourceReferenceFormatter>(cout, true, false);
for (auto const& error: m_compiler->errors())
if (error->type() != langutil::Error::Type::Warning)

View File

@ -18,7 +18,7 @@
#include <tools/solidityUpgrade/UpgradeChange.h>
#include <liblangutil/SourceReferenceExtractor.h>
#include <liblangutil/SourceReferenceFormatterHuman.h>
#include <liblangutil/SourceReferenceFormatter.h>
using namespace std;
using namespace solidity;
@ -37,7 +37,7 @@ void UpgradeChange::apply()
void UpgradeChange::log(bool const _shorten) const
{
stringstream os;
SourceReferenceFormatterHuman formatter{os, true, false};
SourceReferenceFormatter formatter{os, true, false};
string start = to_string(m_location.start);
string end = to_string(m_location.end);

View File

@ -20,7 +20,7 @@
#include <liblangutil/CharStream.h>
#include <liblangutil/ErrorReporter.h>
#include <liblangutil/SourceReferenceFormatterHuman.h>
#include <liblangutil/SourceReferenceFormatter.h>
#include <libyul/AsmAnalysis.h>
#include <libyul/AsmAnalysisInfo.h>
@ -59,7 +59,7 @@ ostream& operator<<(ostream& _stream, Program const& _program);
ostream& std::operator<<(ostream& _outputStream, ErrorList const& _errors)
{
SourceReferenceFormatterHuman formatter(_outputStream, true, false);
SourceReferenceFormatter formatter(_outputStream, true, false);
for (auto const& error: _errors)
formatter.printErrorInformation(*error);