|
19 | 19 | #include <test/CommonSyntaxTest.h>
|
20 | 20 | #include <test/Common.h>
|
21 | 21 | #include <test/TestCase.h>
|
| 22 | + |
| 23 | +#include <liblangutil/SourceReferenceFormatter.h> |
| 24 | + |
22 | 25 | #include <libsolutil/CommonIO.h>
|
23 | 26 | #include <libsolutil/StringUtils.h>
|
| 27 | + |
24 | 28 | #include <boost/algorithm/string.hpp>
|
25 | 29 | #include <boost/algorithm/string/predicate.hpp>
|
26 | 30 | #include <boost/test/unit_test.hpp>
|
27 | 31 | #include <boost/throw_exception.hpp>
|
| 32 | + |
28 | 33 | #include <fstream>
|
29 | 34 | #include <memory>
|
30 | 35 | #include <stdexcept>
|
@@ -116,21 +121,17 @@ void CommonSyntaxTest::printSource(ostream& _stream, string const& _linePrefix,
|
116 | 121 | assert(static_cast<size_t>(error.locationStart) <= source.length());
|
117 | 122 | assert(static_cast<size_t>(error.locationEnd) <= source.length());
|
118 | 123 | for (int i = error.locationStart; i < error.locationEnd; i++)
|
119 |
| - if (error.type == Error::Type::Info) |
120 |
| - { |
121 |
| - if (sourceFormatting[static_cast<size_t>(i)] == util::formatting::RESET) |
122 |
| - sourceFormatting[static_cast<size_t>(i)] = util::formatting::GRAY_BACKGROUND; |
123 |
| - } |
124 |
| - else if (error.type == Error::Type::Warning) |
125 |
| - { |
126 |
| - if ( |
127 |
| - sourceFormatting[static_cast<size_t>(i)] == util::formatting::RESET || |
128 |
| - sourceFormatting[static_cast<size_t>(i)] == util::formatting::GRAY_BACKGROUND |
129 |
| - ) |
130 |
| - sourceFormatting[static_cast<size_t>(i)] = util::formatting::ORANGE_BACKGROUND_256; |
131 |
| - } |
132 |
| - else |
133 |
| - sourceFormatting[static_cast<size_t>(i)] = util::formatting::RED_BACKGROUND; |
| 124 | + { |
| 125 | + char const*& cellFormat = sourceFormatting[static_cast<size_t>(i)]; |
| 126 | + char const* infoBgColor = SourceReferenceFormatter::errorHighlightColor(Error::Severity::Info); |
| 127 | + |
| 128 | + if ( |
| 129 | + (error.type != Error::Type::Warning && error.type != Error::Type::Info) || |
| 130 | + (error.type == Error::Type::Warning && (cellFormat == RESET || cellFormat == infoBgColor)) || |
| 131 | + (error.type == Error::Type::Info && cellFormat == RESET) |
| 132 | + ) |
| 133 | + cellFormat = SourceReferenceFormatter::errorHighlightColor(Error::errorSeverity(error.type)); |
| 134 | + } |
134 | 135 | }
|
135 | 136 |
|
136 | 137 | _stream << _linePrefix << sourceFormatting.front() << source.front();
|
@@ -200,7 +201,7 @@ void CommonSyntaxTest::printErrorList(
|
200 | 201 | util::AnsiColorized scope(
|
201 | 202 | _stream,
|
202 | 203 | _formatted,
|
203 |
| - {BOLD, error.type == Error::Type::Info ? WHITE : (error.type == Error::Type::Warning ? YELLOW : RED)} |
| 204 | + {BOLD, SourceReferenceFormatter::errorTextColor(Error::errorSeverity(error.type))} |
204 | 205 | );
|
205 | 206 | _stream << _linePrefix << Error::formatErrorType(error.type);
|
206 | 207 | if (error.errorId.has_value())
|
|
0 commit comments