Diagnostic: Replace 'info' with 'note'
Change-Id: Icde015422882bad9a1427d5480718c822a28fd6a Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/45242 Commit-Queue: Ben Clayton <bclayton@google.com> Reviewed-by: David Neto <dneto@google.com>
This commit is contained in:
parent
399b88845c
commit
512bdf1612
|
@ -25,7 +25,7 @@ namespace tint {
|
||||||
namespace diag {
|
namespace diag {
|
||||||
|
|
||||||
/// Severity is an enumerator of diagnostic severities.
|
/// Severity is an enumerator of diagnostic severities.
|
||||||
enum class Severity { Info, Warning, Error, InternalCompilerError, Fatal };
|
enum class Severity { Note, Warning, Error, InternalCompilerError, Fatal };
|
||||||
|
|
||||||
/// @return true iff `a` is more than, or of equal severity to `b`
|
/// @return true iff `a` is more than, or of equal severity to `b`
|
||||||
inline bool operator>=(Severity a, Severity b) {
|
inline bool operator>=(Severity a, Severity b) {
|
||||||
|
@ -97,6 +97,17 @@ class List {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// adds the note message with the given Source to the end of this list.
|
||||||
|
/// @param note_msg the note message
|
||||||
|
/// @param source the source of the note diagnostic
|
||||||
|
void add_note(const std::string& note_msg, const Source& source) {
|
||||||
|
diag::Diagnostic error{};
|
||||||
|
error.severity = diag::Severity::Note;
|
||||||
|
error.source = source;
|
||||||
|
error.message = note_msg;
|
||||||
|
add(std::move(error));
|
||||||
|
}
|
||||||
|
|
||||||
/// adds the error message without a source to the end of this list.
|
/// adds the error message without a source to the end of this list.
|
||||||
/// @param err_msg the error message
|
/// @param err_msg the error message
|
||||||
void add_error(const std::string& err_msg) {
|
void add_error(const std::string& err_msg) {
|
||||||
|
|
|
@ -26,8 +26,8 @@ namespace {
|
||||||
|
|
||||||
const char* to_str(Severity severity) {
|
const char* to_str(Severity severity) {
|
||||||
switch (severity) {
|
switch (severity) {
|
||||||
case Severity::Info:
|
case Severity::Note:
|
||||||
return "info";
|
return "note";
|
||||||
case Severity::Warning:
|
case Severity::Warning:
|
||||||
return "warning";
|
return "warning";
|
||||||
case Severity::Error:
|
case Severity::Error:
|
||||||
|
@ -172,7 +172,7 @@ void Formatter::format(const Diagnostic& diag, State& state) const {
|
||||||
|
|
||||||
Color severity_color = Color::kDefault;
|
Color severity_color = Color::kDefault;
|
||||||
switch (diag.severity) {
|
switch (diag.severity) {
|
||||||
case Severity::Info:
|
case Severity::Note:
|
||||||
break;
|
break;
|
||||||
case Severity::Warning:
|
case Severity::Warning:
|
||||||
severity_color = Color::kYellow;
|
severity_color = Color::kYellow;
|
||||||
|
|
|
@ -31,7 +31,7 @@ the snail says ???
|
||||||
class DiagFormatterTest : public testing::Test {
|
class DiagFormatterTest : public testing::Test {
|
||||||
public:
|
public:
|
||||||
Source::File file{"file.name", content};
|
Source::File file{"file.name", content};
|
||||||
Diagnostic diag_info{Severity::Info,
|
Diagnostic diag_note{Severity::Note,
|
||||||
Source{Source::Range{Source::Location{1, 14}}, &file},
|
Source{Source::Range{Source::Location{1, 14}}, &file},
|
||||||
"purr"};
|
"purr"};
|
||||||
Diagnostic diag_warn{Severity::Warning,
|
Diagnostic diag_warn{Severity::Warning,
|
||||||
|
@ -49,7 +49,7 @@ class DiagFormatterTest : public testing::Test {
|
||||||
|
|
||||||
TEST_F(DiagFormatterTest, Simple) {
|
TEST_F(DiagFormatterTest, Simple) {
|
||||||
Formatter fmt{{false, false, false, false}};
|
Formatter fmt{{false, false, false, false}};
|
||||||
auto got = fmt.format(List{diag_info, diag_warn, diag_err});
|
auto got = fmt.format(List{diag_note, diag_warn, diag_err});
|
||||||
auto* expect = R"(1:14: purr
|
auto* expect = R"(1:14: purr
|
||||||
2:14: grrr
|
2:14: grrr
|
||||||
3:16 abc123: hiss)";
|
3:16 abc123: hiss)";
|
||||||
|
@ -58,7 +58,7 @@ TEST_F(DiagFormatterTest, Simple) {
|
||||||
|
|
||||||
TEST_F(DiagFormatterTest, SimpleNewlineAtEnd) {
|
TEST_F(DiagFormatterTest, SimpleNewlineAtEnd) {
|
||||||
Formatter fmt{{false, false, false, true}};
|
Formatter fmt{{false, false, false, true}};
|
||||||
auto got = fmt.format(List{diag_info, diag_warn, diag_err});
|
auto got = fmt.format(List{diag_note, diag_warn, diag_err});
|
||||||
auto* expect = R"(1:14: purr
|
auto* expect = R"(1:14: purr
|
||||||
2:14: grrr
|
2:14: grrr
|
||||||
3:16 abc123: hiss
|
3:16 abc123: hiss
|
||||||
|
@ -68,7 +68,7 @@ TEST_F(DiagFormatterTest, SimpleNewlineAtEnd) {
|
||||||
|
|
||||||
TEST_F(DiagFormatterTest, SimpleNoSource) {
|
TEST_F(DiagFormatterTest, SimpleNoSource) {
|
||||||
Formatter fmt{{false, false, false, false}};
|
Formatter fmt{{false, false, false, false}};
|
||||||
Diagnostic diag{Severity::Info, Source{}, "no source!"};
|
Diagnostic diag{Severity::Note, Source{}, "no source!"};
|
||||||
auto got = fmt.format(List{diag});
|
auto got = fmt.format(List{diag});
|
||||||
auto* expect = "no source!";
|
auto* expect = "no source!";
|
||||||
ASSERT_EQ(expect, got);
|
ASSERT_EQ(expect, got);
|
||||||
|
@ -76,7 +76,7 @@ TEST_F(DiagFormatterTest, SimpleNoSource) {
|
||||||
|
|
||||||
TEST_F(DiagFormatterTest, WithFile) {
|
TEST_F(DiagFormatterTest, WithFile) {
|
||||||
Formatter fmt{{true, false, false, false}};
|
Formatter fmt{{true, false, false, false}};
|
||||||
auto got = fmt.format(List{diag_info, diag_warn, diag_err});
|
auto got = fmt.format(List{diag_note, diag_warn, diag_err});
|
||||||
auto* expect = R"(file.name:1:14: purr
|
auto* expect = R"(file.name:1:14: purr
|
||||||
file.name:2:14: grrr
|
file.name:2:14: grrr
|
||||||
file.name:3:16 abc123: hiss)";
|
file.name:3:16 abc123: hiss)";
|
||||||
|
@ -85,8 +85,8 @@ file.name:3:16 abc123: hiss)";
|
||||||
|
|
||||||
TEST_F(DiagFormatterTest, WithSeverity) {
|
TEST_F(DiagFormatterTest, WithSeverity) {
|
||||||
Formatter fmt{{false, true, false, false}};
|
Formatter fmt{{false, true, false, false}};
|
||||||
auto got = fmt.format(List{diag_info, diag_warn, diag_err});
|
auto got = fmt.format(List{diag_note, diag_warn, diag_err});
|
||||||
auto* expect = R"(1:14 info: purr
|
auto* expect = R"(1:14 note: purr
|
||||||
2:14 warning: grrr
|
2:14 warning: grrr
|
||||||
3:16 error abc123: hiss)";
|
3:16 error abc123: hiss)";
|
||||||
ASSERT_EQ(expect, got);
|
ASSERT_EQ(expect, got);
|
||||||
|
@ -94,7 +94,7 @@ TEST_F(DiagFormatterTest, WithSeverity) {
|
||||||
|
|
||||||
TEST_F(DiagFormatterTest, WithLine) {
|
TEST_F(DiagFormatterTest, WithLine) {
|
||||||
Formatter fmt{{false, false, true, false}};
|
Formatter fmt{{false, false, true, false}};
|
||||||
auto got = fmt.format(List{diag_info, diag_warn, diag_err});
|
auto got = fmt.format(List{diag_note, diag_warn, diag_err});
|
||||||
auto* expect = R"(1:14: purr
|
auto* expect = R"(1:14: purr
|
||||||
the cat says meow
|
the cat says meow
|
||||||
^
|
^
|
||||||
|
@ -112,8 +112,8 @@ the snake says quack
|
||||||
|
|
||||||
TEST_F(DiagFormatterTest, BasicWithFileSeverityLine) {
|
TEST_F(DiagFormatterTest, BasicWithFileSeverityLine) {
|
||||||
Formatter fmt{{true, true, true, false}};
|
Formatter fmt{{true, true, true, false}};
|
||||||
auto got = fmt.format(List{diag_info, diag_warn, diag_err});
|
auto got = fmt.format(List{diag_note, diag_warn, diag_err});
|
||||||
auto* expect = R"(file.name:1:14 info: purr
|
auto* expect = R"(file.name:1:14 note: purr
|
||||||
the cat says meow
|
the cat says meow
|
||||||
^
|
^
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue