37# include <gtest/gtest.h>
53 const auto where =
sm.span(
id, 8, 9);
56 .
note(
"parser recovered at ';'")
57 .
help(
"insert an expression after '='")
64 const auto & diag = dx.
get(0);
66 EXPECT_EQ(diag.message,
"expected expression");
68 EXPECT_EQ(diag.labels.access(0).kind, Diagnostic_Label_Kind::Primary);
80 dx.
warning(
sm.span(
id, 8, 9),
"use before declaration")
82 .
secondary(
sm.span(
id, 15, 16),
"symbol declared here")
89 const auto & diag = dx.
get(0);
91 EXPECT_EQ(diag.labels.access(1).kind, Diagnostic_Label_Kind::Secondary);
101 dx.
error(
sm.span(
id, 8, 9),
"expected expression")
103 .
note(
"parser recovered at ';'")
104 .
help(
"insert an expression after '='")
107 std::ostringstream
out;
109 const std::string text =
out.str();
111 EXPECT_NE(text.find(
"error[E001]: expected expression"), std::string::npos);
112 EXPECT_NE(text.find(
"main.aw:1:9"), std::string::npos);
113 EXPECT_NE(text.find(
"1 | let x = ;"), std::string::npos);
114 EXPECT_NE(text.find(
"^"), std::string::npos);
115 EXPECT_NE(text.find(
"note: parser recovered at ';'"), std::string::npos);
116 EXPECT_NE(text.find(
"help: insert an expression after '='"), std::string::npos);
126 dx.
warning(
sm.span(
id, 0, 3),
"call target is unresolved")
129 dx.
error(
sm.span(
id, 3, 4),
"expected ')'")
133 std::ostringstream a;
134 std::ostringstream b;
Plain-text diagnostic engine for compiler-style tooling.
size_t size_t int32_t * out
Diagnostic_Builder & code(const std::string &value)
Sets the stable diagnostic code.
size_t emit() const noexcept
Finalizes the builder and returns the diagnostic index.
Diagnostic_Builder & help(const std::string &msg)
Appends a help line.
Diagnostic_Builder & secondary(const Source_Span &span, const std::string &msg)
Adds a secondary label.
Diagnostic_Builder & note(const std::string &msg)
Appends a note line.
Diagnostic accumulator and renderer.
size_t warning_count() const noexcept
Returns the number of warnings.
void clear() noexcept
Removes all accumulated diagnostics and resets counters.
void render_plain(std::ostream &out) const
Renders all diagnostics as deterministic plain text.
bool has_errors() const noexcept
Returns whether any error or fatal diagnostic was emitted.
Diagnostic_Builder warning(const Source_Span &span, const std::string &msg)
Starts a warning diagnostic.
const Diagnostic & get(const size_t i) const
Returns diagnostic i.
size_t error_count() const noexcept
Returns the number of error and fatal diagnostics.
Diagnostic_Builder error(const Source_Span &span, const std::string &msg)
Starts an error diagnostic.
size_t size() const noexcept
Returns the number of stored diagnostics.
Stores source files and resolves offsets into human-readable data.
Source_File_Id add_virtual_file(const std::string &name, const std::string &text)
Registers an in-memory source file.
size_t blossom_maximum_cardinality_matching(const GT &g, DynDlist< typename GT::Arc * > &matching, SA sa=SA())
Alias of compute_maximum_cardinality_general_matching().
Main namespace for Aleph-w library functions.