31 : OldRange(OldRange), NewText(std::move(NewText)) {
32 assert(OldRange.
lCur() != OldRange.
rCur() || !this->NewText.empty());
36 return {{P, P}, std::move(NewText)};
40 return {RemovingRange,
""};
47 [[nodiscard]]
bool isRemoval()
const {
return NewText.empty(); }
50 return OldRange.
lCur() == OldRange.
rCur();
54 [[nodiscard]] std::string_view
newText()
const {
return NewText; }
58 std::vector<TextEdit> Edits;
62 Fix(std::vector<TextEdit> Edits, std::string Message)
63 : Edits(std::move(Edits)), Message(std::move(Message)) {}
66 Edits.emplace_back(std::move(Edit));
70 [[nodiscard]]
const std::vector<TextEdit> &
edits()
const {
return Edits; }
71 [[nodiscard]]
const std::string &
message()
const {
return Message; }
81 [[nodiscard]]
virtual const char *
message()
const = 0;
86 Args.emplace_back(std::move(Var));
90 [[nodiscard]] std::string
format()
const;
92 [[nodiscard]]
const std::vector<std::string> &
args()
const {
return Args; }
94 std::vector<std::string> &
args() {
return Args; }
98 [[nodiscard]]
const std::vector<DiagnosticTag> &
tags()
const {
return Tags; }
108 std::vector<DiagnosticTag> Tags;
109 std::vector<std::string> Args;
118#define DIAG_NOTE(SNAME, CNAME, MESSAGE) NK_##CNAME,
127 args().push_back(Var);
171#include "DiagnosticEnum.h"
176 [[nodiscard]] DiagnosticKind
kind()
const {
return Kind; };
180 [[nodiscard]]
static const char *
message(DiagnosticKind Kind);
189 [[nodiscard]]
static const char *
sname(DiagnosticKind Kind);
192 [[nodiscard]]
static std::optional<Diagnostic::DiagnosticKind>
198 return Notes.emplace_back(Kind, Range);
201 [[nodiscard]]
const std::vector<Note> &
notes()
const {
return Notes; }
204 return Fixes.emplace_back(
Fix{{}, std::move(Message)});
207 [[nodiscard]]
const std::vector<Fix> &
fixes()
const {
return Fixes; }
212 std::vector<Note> Notes;
213 std::vector<Fix> Fixes;
static std::optional< Diagnostic::DiagnosticKind > parseKind(std::string_view SName)
Parse diagnostic "cname" to diagnostic id.
@ DS_Fatal
shouldn't eval the code, e.g. parsing error.
@ DS_Error
trigger an error in nix, but we can recover & eval the code.
Diagnostic(DiagnosticKind Kind, LexerCursorRange Range)
Internal kind.
Note & note(Note::NoteKind Kind, LexerCursorRange Range)
virtual const char * sname() const
static const char * message(DiagnosticKind Kind)
DiagnosticKind kind() const
Fix & fix(std::string Message)
const char * message() const override
static const char * sname(DiagnosticKind Kind)
const std::vector< Fix > & fixes() const
const std::vector< Note > & notes() const
static Severity severity(DiagnosticKind Kind)
Fix(std::vector< TextEdit > Edits, std::string Message)
const std::vector< TextEdit > & edits() const
const std::string & message() const
Fix & edit(TextEdit Edit)
A point in the source file.
const char * message() const override
PartialDiagnostic & operator<<(const T &Var)
Note(NoteKind Kind, LexerCursorRange Range)
virtual const char * sname() const
void tag(DiagnosticTag Tag)
PartialDiagnostic()=default
PartialDiagnostic(LexerCursorRange Range)
std::vector< std::string > & args()
virtual const char * message() const =0
virtual ~PartialDiagnostic()=default
const std::vector< std::string > & args() const
const std::vector< DiagnosticTag > & tags() const
std::string format() const
PartialDiagnostic & operator<<(std::string Var)
LexerCursorRange range() const
std::string_view newText() const
LexerCursorRange oldRange() const
static TextEdit mkRemoval(LexerCursorRange RemovingRange)
static TextEdit mkInsertion(LexerCursor P, std::string NewText)
TextEdit(LexerCursorRange OldRange, std::string NewText)