Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
Aleph::Diagnostic_Engine Class Reference

Diagnostic accumulator and renderer. More...

#include <ah-diagnostics.H>

Collaboration diagram for Aleph::Diagnostic_Engine:
[legend]

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
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ Diagnostic_Engine()

Aleph::Diagnostic_Engine::Diagnostic_Engine ( const Source_Manager &  sm)
inlineexplicitnoexcept

Constructs an engine bound to sm.

Definition at line 257 of file ah-diagnostics.H.

Member Function Documentation

◆ append_diagnostic()

size_t Aleph::Diagnostic_Engine::append_diagnostic ( const Diagnostic_Severity  severity,
const Source_Span &  span,
const std::string &  msg 
)
inlineprivate

◆ clear()

void Aleph::Diagnostic_Engine::clear ( )
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().

◆ error()

◆ error_count()

size_t Aleph::Diagnostic_Engine::error_count ( ) const
inlinenoexcept

Returns the number of error and fatal diagnostics.

Definition at line 308 of file ah-diagnostics.H.

References errors.

Referenced by TEST(), TEST(), and TEST().

◆ fatal()

Diagnostic_Builder Aleph::Diagnostic_Engine::fatal ( const Source_Span &  span,
const std::string &  msg 
)
inline

Starts a fatal diagnostic.

Definition at line 278 of file ah-diagnostics.H.

References append_diagnostic(), Diagnostic_Builder, and Aleph::Fatal.

◆ first_primary_label()

const Diagnostic_Label * Aleph::Diagnostic_Engine::first_primary_label ( const Diagnostic &  diag) const
inlineprivatenoexcept

Definition at line 192 of file ah-diagnostics.H.

References Aleph::and, and Aleph::Primary.

Referenced by render_plain().

◆ get()

const Diagnostic & Aleph::Diagnostic_Engine::get ( const size_t  i) const
inline

Returns diagnostic i.

Definition at line 294 of file ah-diagnostics.H.

References ah_out_of_range_error_unless, and diags.

Referenced by TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), and TEST().

◆ has_errors()

◆ note()

Diagnostic_Builder Aleph::Diagnostic_Engine::note ( const Source_Span &  span,
const std::string &  msg 
)
inline

Starts a note diagnostic.

Definition at line 286 of file ah-diagnostics.H.

References append_diagnostic(), Diagnostic_Builder, and Aleph::Note.

◆ render_label_snippet()

◆ render_plain()

◆ render_secondary_labels()

void Aleph::Diagnostic_Engine::render_secondary_labels ( std::ostream &  out,
const Diagnostic &  diag 
) const
inlineprivate

◆ severity_string()

static const char * Aleph::Diagnostic_Engine::severity_string ( const Diagnostic_Severity  severity)
inlinestaticprivate

Definition at line 158 of file ah-diagnostics.H.

References Aleph::Error, Aleph::Fatal, Aleph::Note, and Aleph::Warning.

Referenced by render_plain().

◆ size()

size_t Aleph::Diagnostic_Engine::size ( ) const
inlinenoexcept

Returns the number of stored diagnostics.

Definition at line 302 of file ah-diagnostics.H.

References diags.

Referenced by main(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), and TEST().

◆ warning()

Diagnostic_Builder Aleph::Diagnostic_Engine::warning ( const Source_Span &  span,
const std::string &  msg 
)
inline

Starts a warning diagnostic.

Definition at line 270 of file ah-diagnostics.H.

References append_diagnostic(), Diagnostic_Builder, and Aleph::Warning.

Referenced by TEST(), TEST(), and TEST().

◆ warning_count()

size_t Aleph::Diagnostic_Engine::warning_count ( ) const
inlinenoexcept

Returns the number of warnings.

Definition at line 314 of file ah-diagnostics.H.

References warnings.

Referenced by TEST(), TEST(), and TEST().

Friends And Related Symbol Documentation

◆ Diagnostic_Builder

Definition at line 361 of file ah-diagnostics.H.

Referenced by error(), fatal(), note(), and warning().

Member Data Documentation

◆ diags

DynArray<Diagnostic> Aleph::Diagnostic_Engine::diags
private

◆ errors

size_t Aleph::Diagnostic_Engine::errors = 0
private

Definition at line 155 of file ah-diagnostics.H.

Referenced by append_diagnostic(), clear(), error_count(), and has_errors().

◆ sources

const Source_Manager* Aleph::Diagnostic_Engine::sources = nullptr
private

Definition at line 153 of file ah-diagnostics.H.

Referenced by render_label_snippet(), and render_secondary_labels().

◆ warnings

size_t Aleph::Diagnostic_Engine::warnings = 0
private

Definition at line 156 of file ah-diagnostics.H.

Referenced by append_diagnostic(), clear(), and warning_count().


The documentation for this class was generated from the following file: