|
hoshi-lang dev
Yet another programming language
|
#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::wstr & | getCurrentFilePath () 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< Diagnostic > | m_diagnostics |
| std::mutex | m_mutex |
| std::map< std::string, DiagnosticSeverity > | m_categorySeverityOverrides |
Definition at line 16 of file diagnosticEngine.h.
|
strong |
| Enumerator | |
|---|---|
| Immediate | |
| Collect | |
Definition at line 18 of file diagnosticEngine.h.
| DiagnosticEngine | ( | ) |
Definition at line 12 of file diagnosticEngine.cpp.
References DiagnosticEngine::initDefaultCategorySeverity().

|
explicit |
Definition at line 17 of file diagnosticEngine.cpp.
References DiagnosticEngine::initDefaultCategorySeverity().

| void clear | ( | ) |
Definition at line 109 of file diagnosticEngine.cpp.
References DiagnosticEngine::m_diagnostics, and DiagnosticEngine::m_mutex.
Referenced by DocumentStore::reparseDocument().

| size_t errorCount | ( | ) | const |
Definition at line 83 of file diagnosticEngine.cpp.
References yoi::Error, DiagnosticEngine::m_diagnostics, and DiagnosticEngine::m_mutex.
| 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.
| const yoi::wstr & getCurrentFilePath | ( | ) | const |
Definition at line 126 of file diagnosticEngine.cpp.
References DiagnosticEngine::m_currentFilePath.
| const std::vector< Diagnostic > & getDiagnostics | ( | ) | const |
Definition at line 103 of file diagnosticEngine.cpp.
References DiagnosticEngine::m_diagnostics.
Referenced by DocumentStore::reparseDocument().

| 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().


| DiagnosticEngine::Mode getMode | ( | ) | const |
Definition at line 118 of file diagnosticEngine.cpp.
References DiagnosticEngine::m_mode.
| bool hasErrors | ( | ) | const |
Definition at line 65 of file diagnosticEngine.cpp.
References yoi::Error, DiagnosticEngine::m_diagnostics, and DiagnosticEngine::m_mutex.
| bool hasWarnings | ( | ) | const |
Definition at line 74 of file diagnosticEngine.cpp.
References DiagnosticEngine::m_diagnostics, DiagnosticEngine::m_mutex, and yoi::Warning.
|
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().

| 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().


| 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().

| 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.
| 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().

| void setMode | ( | Mode | mode | ) |
Definition at line 114 of file diagnosticEngine.cpp.
References DiagnosticEngine::m_mode.
| size_t warningCount | ( | ) | const |
Definition at line 93 of file diagnosticEngine.cpp.
References DiagnosticEngine::m_diagnostics, DiagnosticEngine::m_mutex, and yoi::Warning.
|
private |
Definition at line 81 of file diagnosticEngine.h.
Referenced by DiagnosticEngine::getCategorySeverity(), DiagnosticEngine::initDefaultCategorySeverity(), and DiagnosticEngine::setCategorySeverity().
|
private |
Definition at line 78 of file diagnosticEngine.h.
Referenced by DiagnosticEngine::getCurrentFilePath(), DiagnosticEngine::report(), and DiagnosticEngine::setCurrentFilePath().
|
private |
Definition at line 79 of file diagnosticEngine.h.
Referenced by DiagnosticEngine::clear(), DiagnosticEngine::errorCount(), DiagnosticEngine::getDiagnostics(), DiagnosticEngine::hasErrors(), DiagnosticEngine::hasWarnings(), DiagnosticEngine::report(), and DiagnosticEngine::warningCount().
|
private |
Definition at line 77 of file diagnosticEngine.h.
Referenced by DiagnosticEngine::getMode(), DiagnosticEngine::report(), and DiagnosticEngine::setMode().
|
mutableprivate |
Definition at line 80 of file diagnosticEngine.h.
Referenced by DiagnosticEngine::clear(), DiagnosticEngine::errorCount(), DiagnosticEngine::hasErrors(), DiagnosticEngine::hasWarnings(), DiagnosticEngine::report(), and DiagnosticEngine::warningCount().