|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Diagnostic accumulator and renderer. More...
#include <ah-diagnostics.H>
Public Member Functions | |
| Diagnostic_Engine (const Source_Manager &sm) noexcept | |
Constructs an engine bound to sm. | |
| Diagnostic_Builder | error (const Source_Span &span, const std::string &msg) |
| Starts an error diagnostic. | |
| Diagnostic_Builder | warning (const Source_Span &span, const std::string &msg) |
| Starts a warning diagnostic. | |
| Diagnostic_Builder | fatal (const Source_Span &span, const std::string &msg) |
| Starts a fatal diagnostic. | |
| Diagnostic_Builder | note (const Source_Span &span, const std::string &msg) |
| Starts a note diagnostic. | |
| const Diagnostic & | get (const size_t i) const |
Returns diagnostic i. | |
| size_t | size () const noexcept |
| Returns the number of stored diagnostics. | |
| size_t | error_count () const noexcept |
| Returns the number of error and fatal diagnostics. | |
| size_t | warning_count () const noexcept |
| Returns the number of warnings. | |
| bool | has_errors () const noexcept |
| Returns whether any error or fatal diagnostic was emitted. | |
| void | clear () noexcept |
| Removes all accumulated diagnostics and resets counters. | |
| void | render_plain (std::ostream &out) const |
| Renders all diagnostics as deterministic plain text. | |
Private Member Functions | |
| size_t | append_diagnostic (const Diagnostic_Severity severity, const Source_Span &span, const std::string &msg) |
| const Diagnostic_Label * | first_primary_label (const Diagnostic &diag) const noexcept |
| void | render_label_snippet (std::ostream &out, const Diagnostic_Label &label) const |
| void | render_secondary_labels (std::ostream &out, const Diagnostic &diag) const |
Static Private Member Functions | |
| static const char * | severity_string (const Diagnostic_Severity severity) |
Private Attributes | |
| const Source_Manager * | sources = nullptr |
| DynArray< Diagnostic > | diags |
| size_t | errors = 0 |
| size_t | warnings = 0 |
Friends | |
| class | Diagnostic_Builder |
Diagnostic accumulator and renderer.
Diagnostics are appended through convenience entry points such as error() and warning(). The engine keeps counters by severity and renders plain text snippets using its associated Source_Manager.
Definition at line 151 of file ah-diagnostics.H.
|
inlineexplicitnoexcept |
Constructs an engine bound to sm.
Definition at line 257 of file ah-diagnostics.H.
|
inlineprivate |
Definition at line 171 of file ah-diagnostics.H.
References Aleph::blossom_maximum_cardinality_matching(), diags, Aleph::Error, errors, Aleph::Fatal, Aleph::Source_Span::is_valid(), Aleph::Diagnostic::labels, Aleph::Diagnostic::message, Aleph::Primary, Aleph::Diagnostic::severity, Aleph::Warning, and warnings.
|
inlinenoexcept |
Removes all accumulated diagnostics and resets counters.
Definition at line 326 of file ah-diagnostics.H.
References diags, errors, and warnings.
Referenced by Aleph::Compiler_Driver::clear(), Aleph::Compiler_Line_Frontend::clear(), Aleph::Compiler_MVP_Frontend::clear(), and TEST().
|
inline |
Starts an error diagnostic.
Definition at line 262 of file ah-diagnostics.H.
References append_diagnostic(), Diagnostic_Builder, and Aleph::Error.
Referenced by Aleph::compiler_emit_module_name_resolution_diagnostic(), Aleph::Compiler_Driver::emit_driver_diagnostic(), Aleph::Compiler_MVP_Frontend::emit_driver_diagnostic(), Aleph::Compiler_Line_Frontend::emit_error(), Aleph::Compiler_Typed_Semantic_Analyzer::emit_error(), Aleph::Compiler_Lexer::emit_error(), Aleph::Compiler_Parser::emit_error(), Aleph::Compiler_Parser_Stream::emit_error(), Aleph::Compiler_Semantic_Analyzer::emit_error(), main(), Aleph::Interpreter_Runtime::runtime_error(), TEST(), TEST(), TEST(), and TEST().
|
inlinenoexcept |
|
inline |
Starts a fatal diagnostic.
Definition at line 278 of file ah-diagnostics.H.
References append_diagnostic(), Diagnostic_Builder, and Aleph::Fatal.
|
inlineprivatenoexcept |
Definition at line 192 of file ah-diagnostics.H.
References Aleph::and, and Aleph::Primary.
Referenced by render_plain().
|
inline |
|
inlinenoexcept |
Returns whether any error or fatal diagnostic was emitted.
Definition at line 320 of file ah-diagnostics.H.
References errors.
Referenced by Aleph::Compiler_Line_Frontend::analyze(), Aleph::Compiler_MVP_Frontend::analyze(), main(), Aleph::Compiler_Driver::ok(), Aleph::Compiler_MVP_Frontend::parse(), Aleph::Compiler_Driver::parse_registered_sources(), Aleph::Compiler_Line_Frontend::parse_source_file(), Aleph::Compiler_Driver::resolve_import_order(), Aleph::Compiler_Line_Frontend::resolve_import_order(), Aleph::Compiler_MVP_Frontend::resolve_import_order(), Aleph::Compiler_Driver::run_typed_semantics(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), and Aleph::Compiler_Line_Frontend::validate_top_level_calls().
|
inline |
Starts a note diagnostic.
Definition at line 286 of file ah-diagnostics.H.
References append_diagnostic(), Diagnostic_Builder, and Aleph::Note.
|
inlineprivate |
Definition at line 211 of file ah-diagnostics.H.
References Aleph::Source_Manager::begin_position(), Aleph::blossom_maximum_cardinality_matching(), Aleph::Source_Span::is_valid(), Aleph::Source_Snippet::line, Aleph::Diagnostic_Label::message, out, Aleph::Source_Manager::snippet(), sources, and Aleph::Diagnostic_Label::span.
Referenced by render_plain().
|
inline |
Renders all diagnostics as deterministic plain text.
Definition at line 334 of file ah-diagnostics.H.
References Aleph::blossom_maximum_cardinality_matching(), diags, first_primary_label(), out, render_label_snippet(), render_secondary_labels(), and severity_string().
Referenced by Aleph::Compiler_Driver::diagnostics_text(), Aleph::Compiler_Generic_Driver::diagnostics_text(), Aleph::Compiler_MVP_Frontend::diagnostics_text(), main(), Aleph::Compiler_Driver::record_diagnostics_artifact(), Aleph::Compiler_Generic_Driver::record_diagnostics_artifact(), TEST(), TEST(), TEST(), and TEST().
|
inlineprivate |
Definition at line 237 of file ah-diagnostics.H.
References Aleph::Source_Manager::begin_position(), Aleph::blossom_maximum_cardinality_matching(), Aleph::Diagnostic::labels, out, Aleph::Secondary, sources, and Aleph::Source_Position::to_string().
Referenced by render_plain().
|
inlinestaticprivate |
Definition at line 158 of file ah-diagnostics.H.
References Aleph::Error, Aleph::Fatal, Aleph::Note, and Aleph::Warning.
Referenced by render_plain().
|
inlinenoexcept |
|
inline |
Starts a warning diagnostic.
Definition at line 270 of file ah-diagnostics.H.
References append_diagnostic(), Diagnostic_Builder, and Aleph::Warning.
|
inlinenoexcept |
|
friend |
|
private |
Definition at line 154 of file ah-diagnostics.H.
Referenced by append_diagnostic(), clear(), Aleph::Diagnostic_Builder::diag(), get(), render_plain(), and size().
|
private |
Definition at line 155 of file ah-diagnostics.H.
Referenced by append_diagnostic(), clear(), error_count(), and has_errors().
|
private |
Definition at line 153 of file ah-diagnostics.H.
Referenced by render_label_snippet(), and render_secondary_labels().
|
private |
Definition at line 156 of file ah-diagnostics.H.
Referenced by append_diagnostic(), clear(), and warning_count().