hoshi-lang dev
Yet another programming language
Loading...
Searching...
No Matches
DiagnosticEngine Class Reference

#include <diagnosticEngine.h>

Public Types

enum class  Mode { Immediate , Collect }
 

Public Member Functions

 DiagnosticEngine ()
 
 DiagnosticEngine (Mode mode)
 
void report (const Diagnostic &diag)
 
void report (yoi::indexT line, yoi::indexT col, const std::string &msg, DiagnosticSeverity severity=DiagnosticSeverity::Error, DiagnosticCategory category=DiagnosticCategory::Generic)
 
bool hasErrors () const
 
bool hasWarnings () const
 
size_t errorCount () const
 
size_t warningCount () const
 
const std::vector< Diagnostic > & getDiagnostics () const
 
void clear ()
 
void setMode (Mode mode)
 
Mode getMode () const
 
void setCurrentFilePath (const yoi::wstr &path)
 Set the file path for diagnostics reported via the convenience overload.
 
const yoi::wstrgetCurrentFilePath () const
 
void setCategorySeverity (const std::string &label, DiagnosticSeverity severity)
 
DiagnosticSeverity getCategorySeverity (const std::string &label) const
 Get the effective severity for a legacy category label.
 
yoi::wstr getLineHint (const yoi::wstr &file, yoi::indexT line, yoi::indexT col) const
 

Private Member Functions

void initDefaultCategorySeverity ()
 

Private Attributes

Mode m_mode
 
yoi::wstr m_currentFilePath
 
std::vector< Diagnosticm_diagnostics
 
std::mutex m_mutex
 
std::map< std::string, DiagnosticSeveritym_categorySeverityOverrides
 

Detailed Description

Definition at line 16 of file diagnosticEngine.h.

Member Enumeration Documentation

◆ Mode

enum class Mode
strong
Enumerator
Immediate 
Collect 

Definition at line 18 of file diagnosticEngine.h.

Constructor & Destructor Documentation

◆ DiagnosticEngine() [1/2]

Definition at line 12 of file diagnosticEngine.cpp.

References DiagnosticEngine::initDefaultCategorySeverity().

Here is the call graph for this function:

◆ DiagnosticEngine() [2/2]

DiagnosticEngine ( Mode  mode)
explicit

Definition at line 17 of file diagnosticEngine.cpp.

References DiagnosticEngine::initDefaultCategorySeverity().

Here is the call graph for this function:

Member Function Documentation

◆ clear()

void clear ( )

Definition at line 109 of file diagnosticEngine.cpp.

References DiagnosticEngine::m_diagnostics, and DiagnosticEngine::m_mutex.

Referenced by DocumentStore::reparseDocument().

Here is the caller graph for this function:

◆ errorCount()

size_t errorCount ( ) const

◆ getCategorySeverity()

DiagnosticSeverity getCategorySeverity ( const std::string &  label) const

Get the effective severity for a legacy category label.

Definition at line 134 of file diagnosticEngine.cpp.

References DiagnosticEngine::m_categorySeverityOverrides, and yoi::Warning.

◆ getCurrentFilePath()

const yoi::wstr & getCurrentFilePath ( ) const

Definition at line 126 of file diagnosticEngine.cpp.

References DiagnosticEngine::m_currentFilePath.

◆ getDiagnostics()

const std::vector< Diagnostic > & getDiagnostics ( ) const

Definition at line 103 of file diagnosticEngine.cpp.

References DiagnosticEngine::m_diagnostics.

Referenced by DocumentStore::reparseDocument().

Here is the caller graph for this function:

◆ getLineHint()

yoi::wstr getLineHint ( const yoi::wstr file,
yoi::indexT  line,
yoi::indexT  col 
) const

Read the source file and produce a line with a caret pointing to the error. line and col are 1-based.

Definition at line 143 of file diagnosticEngine.cpp.

References yoi::string2wstring(), and yoi::wstring2string().

Referenced by DiagnosticEngine::report().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getMode()

DiagnosticEngine::Mode getMode ( ) const

Definition at line 118 of file diagnosticEngine.cpp.

References DiagnosticEngine::m_mode.

◆ hasErrors()

bool hasErrors ( ) const

◆ hasWarnings()

bool hasWarnings ( ) const

◆ initDefaultCategorySeverity()

void initDefaultCategorySeverity ( )
private

Definition at line 22 of file diagnosticEngine.cpp.

References yoi::Error, DiagnosticEngine::m_categorySeverityOverrides, and yoi::Warning.

Referenced by DiagnosticEngine::DiagnosticEngine(), and DiagnosticEngine::DiagnosticEngine().

Here is the caller graph for this function:

◆ report() [1/2]

void report ( const Diagnostic diag)

Record a diagnostic. In Immediate mode with Error severity, throws std::runtime_error after recording.

Definition at line 32 of file diagnosticEngine.cpp.

References Diagnostic::column, yoi::Error, DiagnosticEngine::getLineHint(), DiagnosticEngine::Immediate, Diagnostic::line, DiagnosticEngine::m_diagnostics, DiagnosticEngine::m_mode, DiagnosticEngine::m_mutex, Diagnostic::message, Diagnostic::severity, Diagnostic::sourceFile, and yoi::wstring2string().

Referenced by yoi::panic(), DiagnosticEngine::report(), and yoi::warning().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ report() [2/2]

void report ( yoi::indexT  line,
yoi::indexT  col,
const std::string &  msg,
DiagnosticSeverity  severity = DiagnosticSeverity::Error,
DiagnosticCategory  category = DiagnosticCategory::Generic 
)

Convenience overload: constructs a Diagnostic from components. line and col are 0-based (as received from the lexer/parser). They are stored as 1-based in the Diagnostic.

Definition at line 56 of file diagnosticEngine.cpp.

References DiagnosticEngine::m_currentFilePath, and DiagnosticEngine::report().

Here is the call graph for this function:

◆ setCategorySeverity()

void setCategorySeverity ( const std::string &  label,
DiagnosticSeverity  severity 
)

Map a legacy exception_categories label to a severity override. Labels: "INTERNAL", "UCRT_NOT_FOUND", "ELYSIA_RUNTIME_NOT_FOUND", "NULLABLE_VALUE_SUPPLY_TO_RAW", "MODULE_NOT_MODIFIED"

Definition at line 130 of file diagnosticEngine.cpp.

References DiagnosticEngine::m_categorySeverityOverrides.

◆ setCurrentFilePath()

void setCurrentFilePath ( const yoi::wstr path)

Set the file path for diagnostics reported via the convenience overload.

Definition at line 122 of file diagnosticEngine.cpp.

References DiagnosticEngine::m_currentFilePath.

Referenced by DocumentStore::reparseDocument().

Here is the caller graph for this function:

◆ setMode()

void setMode ( Mode  mode)

Definition at line 114 of file diagnosticEngine.cpp.

References DiagnosticEngine::m_mode.

◆ warningCount()

size_t warningCount ( ) const

Member Data Documentation

◆ m_categorySeverityOverrides

std::map<std::string, DiagnosticSeverity> m_categorySeverityOverrides
private

◆ m_currentFilePath

◆ m_diagnostics

◆ m_mode

Mode m_mode
private

◆ m_mutex


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