19namespace neograph::program {
21enum class CompilePhase {
32enum class DiagnosticSeverity { Error, Warning, Note };
35 std::uint64_t byte_begin = 0;
36 std::uint64_t byte_end = 0;
37 std::uint32_t line_begin = 1;
38 std::uint32_t column_begin = 1;
39 std::uint32_t line_end = 1;
40 std::uint32_t column_end = 1;
42 bool operator==(
const SourceSpan&)
const =
default;
45struct SourceCoordinate {
46 std::string source_id;
47 std::string json_pointer;
48 std::optional<SourceSpan> span;
50 bool operator==(
const SourceCoordinate&)
const =
default;
74struct DiagnosticSuggestion {
76 std::vector<SuggestionEdit> edits;
83 SourceCoordinate coordinate;
94 std::vector<LabelledCoordinate> related;
95 std::vector<DiagnosticSuggestion> suggestions;
101 CompilePhase phase = CompilePhase::Source;
103 DiagnosticSeverity severity = DiagnosticSeverity::Error;
104 SourceCoordinate primary;
107 std::vector<SourceCoordinate> related;
109 std::optional<DiagnosticHelp> help;
117NEOGRAPH_PROGRAM_API std::string_view to_string(CompilePhase phase)
noexcept;
118NEOGRAPH_PROGRAM_API std::string_view to_string(DiagnosticSeverity severity)
noexcept;
120NEOGRAPH_PROGRAM_API CompilePhase compile_phase_from_string(std::string_view value);
121NEOGRAPH_PROGRAM_API DiagnosticSeverity diagnostic_severity_from_string(std::string_view value);
123suggestion_applicability_from_string(std::string_view value);
136 std::string_view right,
137 std::size_t limit = 2);
141 std::string_view unknown,
const std::vector<std::string>& declared);
146NEOGRAPH_PROGRAM_API
void to_json(json& value,
const SourceSpan& span);
147NEOGRAPH_PROGRAM_API
void from_json(
const json& value, SourceSpan& span);
148NEOGRAPH_PROGRAM_API
void to_json(json& value,
const SourceCoordinate& coordinate);
149NEOGRAPH_PROGRAM_API
void from_json(
const json& value, SourceCoordinate& coordinate);
150NEOGRAPH_PROGRAM_API
void to_json(json& value,
const DiagnosticHelp& help);
151NEOGRAPH_PROGRAM_API
void from_json(
const json& value,
DiagnosticHelp& help);
153NEOGRAPH_PROGRAM_API
void to_json(json& value,
const Diagnostic& diagnostic);
154NEOGRAPH_PROGRAM_API
void from_json(
const json& value, Diagnostic& diagnostic);
163 const Diagnostic& diagnostic()
const noexcept;
166 Diagnostic diagnostic_;
NEOGRAPH_API export/import macro for shared-library builds.
Marks an exception type as a configuration or definition verdict.
A Program diagnostic raised at runtime.
Marker for exceptions that are configuration or definition verdicts (#364).
constexpr std::size_t MAX_RETURNED_DIAGNOSTICS
At most this many diagnostics are returned, plus the truncation note.
NEOGRAPH_PROGRAM_API Diagnostic sealed_diagnostic(Diagnostic diagnostic)
The copy that is sealed into a bundle: the same diagnostic without help.
NEOGRAPH_PROGRAM_API std::vector< std::string > diagnostic_name_candidates(std::string_view unknown, const std::vector< std::string > &declared)
Names within distance 2 of unknown, nearest first, then by byte order.
NEOGRAPH_PROGRAM_API std::string diagnostic_doc_link(std::string_view code)
The documentation link for a diagnostic code: its own entry in docs/diagnostics.md,...
constexpr std::string_view DIAGNOSTICS_TRUNCATED_CODE
Code of the note that replaces returned diagnostics past the cap.
SuggestionApplicability
How safely a tool may apply a suggestion without review.
@ Machine
The edits are the fix; apply them as given.
@ Placeholder
The edits contain a value the author must fill in.
@ Maybe
A likely fix; review it first. The default.
NEOGRAPH_PROGRAM_API std::size_t diagnostic_name_distance(std::string_view left, std::string_view right, std::size_t limit=2)
Damerau-Levenshtein (optimal string alignment) distance, counted in bytes.
Thin C++ RAII wrapper around yyjson with nlohmann-compatible API.
Self-repair help for one diagnostic.
std::string doc
Repository-relative documentation link, e.g. "docs/diagnostics.md#p_core_e15".
std::vector< std::string > candidates
Declared names close to an unknown one (Damerau distance <= 2), nearest first.
A secondary location with a one-line label ("also referenced here").
One edit of a suggestion, as an RFC 6902 JSON Patch operation on the Program document the compiler pa...