mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
CommonSyntaxTest: Fix info messages being colored as errors
This commit is contained in:
parent
81b5387a9f
commit
7857562a3b
@ -52,6 +52,7 @@ static constexpr char const* BLUE_BACKGROUND = "\033[44m";
|
||||
static constexpr char const* MAGENTA_BACKGROUND = "\033[45m";
|
||||
static constexpr char const* CYAN_BACKGROUND = "\033[46m";
|
||||
static constexpr char const* WHITE_BACKGROUND = "\033[47m";
|
||||
static constexpr char const* GRAY_BACKGROUND = "\033[100m";
|
||||
|
||||
// 256-bit-colors (incomplete set)
|
||||
static constexpr char const* RED_BACKGROUND_256 = "\033[48;5;160m";
|
||||
|
@ -114,11 +114,18 @@ void CommonSyntaxTest::printSource(ostream& _stream, string const& _linePrefix,
|
||||
{
|
||||
assert(static_cast<size_t>(error.locationStart) <= source.length());
|
||||
assert(static_cast<size_t>(error.locationEnd) <= source.length());
|
||||
bool isWarning = (error.type == Error::Type::Warning);
|
||||
for (int i = error.locationStart; i < error.locationEnd; i++)
|
||||
if (isWarning)
|
||||
if (error.type == Error::Type::Info)
|
||||
{
|
||||
if (sourceFormatting[static_cast<size_t>(i)] == util::formatting::RESET)
|
||||
sourceFormatting[static_cast<size_t>(i)] = util::formatting::GRAY_BACKGROUND;
|
||||
}
|
||||
else if (error.type == Error::Type::Warning)
|
||||
{
|
||||
if (
|
||||
sourceFormatting[static_cast<size_t>(i)] == util::formatting::RESET ||
|
||||
sourceFormatting[static_cast<size_t>(i)] == util::formatting::GRAY_BACKGROUND
|
||||
)
|
||||
sourceFormatting[static_cast<size_t>(i)] = util::formatting::ORANGE_BACKGROUND_256;
|
||||
}
|
||||
else
|
||||
@ -192,7 +199,11 @@ void CommonSyntaxTest::printErrorList(
|
||||
for (auto const& error: _errorList)
|
||||
{
|
||||
{
|
||||
util::AnsiColorized scope(_stream, _formatted, {BOLD, (error.type == Error::Type::Warning) ? YELLOW : RED});
|
||||
util::AnsiColorized scope(
|
||||
_stream,
|
||||
_formatted,
|
||||
{BOLD, error.type == Error::Type::Info ? WHITE : (error.type == Error::Type::Warning ? YELLOW : RED)}
|
||||
);
|
||||
_stream << _linePrefix << Error::formatErrorType(error.type);
|
||||
if (error.errorId.has_value())
|
||||
_stream << ' ' << error.errorId->error;
|
||||
|
Loading…
Reference in New Issue
Block a user