hoshi-lang dev
Yet another programming language
Loading...
Searching...
No Matches
diagnosticEngine.h
Go to the documentation of this file.
1//
2// Created for hoshi-lang LSP readiness refactoring.
3//
4
5#ifndef HOSHI_LANG_DIAGNOSTIC_ENGINE_H
6#define HOSHI_LANG_DIAGNOSTIC_ENGINE_H
7
8#include <map>
9#include <mutex>
10#include <string>
11#include <vector>
12#include "diagnostic.h"
13
14namespace yoi {
15
17public:
18 enum class Mode {
19 Immediate, // Error severity throws immediately (current CLI behavior)
20 Collect // Accumulate all diagnostics; throw only on checkAbort()
21 };
22
24 explicit DiagnosticEngine(Mode mode);
25
26 // ---- Core reporting ----
27
30 void report(const Diagnostic &diag);
31
35 void report(yoi::indexT line, yoi::indexT col,
36 const std::string &msg,
39
40 // ---- Query API ----
41
42 bool hasErrors() const;
43 bool hasWarnings() const;
44 size_t errorCount() const;
45 size_t warningCount() const;
46 const std::vector<Diagnostic> &getDiagnostics() const;
47 void clear();
48
49 // ---- Mode control ----
50
51 void setMode(Mode mode);
52 Mode getMode() const;
53
54 // ---- File path ----
55
57 void setCurrentFilePath(const yoi::wstr &path);
58 const yoi::wstr &getCurrentFilePath() const;
59
60 // ---- Category severity overrides ----
61
65 void setCategorySeverity(const std::string &label, DiagnosticSeverity severity);
66
68 DiagnosticSeverity getCategorySeverity(const std::string &label) const;
69
70 // ---- Source line hint ----
71
74 yoi::wstr getLineHint(const yoi::wstr &file, yoi::indexT line, yoi::indexT col) const;
75
76private:
79 std::vector<Diagnostic> m_diagnostics;
80 mutable std::mutex m_mutex;
81 std::map<std::string, DiagnosticSeverity> m_categorySeverityOverrides;
82
84};
85
86} // namespace yoi
87
88#endif // HOSHI_LANG_DIAGNOSTIC_ENGINE_H
const std::vector< Diagnostic > & getDiagnostics() const
yoi::wstr getLineHint(const yoi::wstr &file, yoi::indexT line, yoi::indexT col) const
const yoi::wstr & getCurrentFilePath() const
void setCurrentFilePath(const yoi::wstr &path)
Set the file path for diagnostics reported via the convenience overload.
void setCategorySeverity(const std::string &label, DiagnosticSeverity severity)
void report(const Diagnostic &diag)
DiagnosticSeverity getCategorySeverity(const std::string &label) const
Get the effective severity for a legacy category label.
std::map< std::string, DiagnosticSeverity > m_categorySeverityOverrides
std::vector< Diagnostic > m_diagnostics
DiagnosticCategory
Definition diagnostic.h:21
DiagnosticSeverity
Definition diagnostic.h:14
std::wstring wstr
Definition def.hpp:51
uint64_t indexT
Definition def.hpp:54