nixd
Toggle main menu visibility
Loading...
Searching...
No Matches
libnixf
src
Basic
JSONDiagnostic.cpp
Go to the documentation of this file.
1
#include "
nixf/Basic/JSONDiagnostic.h
"
2
#include "
nixf/Basic/Diagnostic.h
"
3
#include "
nixf/Basic/Range.h
"
4
5
using namespace
nixf
;
6
using
nlohmann::json;
7
8
void
nixf::to_json
(json &R,
const
LexerCursor
&LC) {
9
R = json{
10
{
"line"
, LC.
line
()},
11
{
"column"
, LC.
column
()},
12
{
"offset"
, LC.
offset
()},
13
};
14
}
15
16
void
nixf::to_json
(json &R,
const
LexerCursorRange
&LCR) {
17
R = json{
18
{
"lCur"
, LCR.
lCur
()},
19
{
"rCur"
, LCR.
rCur
()},
20
};
21
}
22
23
void
nixf::to_json
(json &R,
const
PartialDiagnostic
&PD) {
24
R = json{
25
{
"args"
, PD.
args
()},
26
{
"tag"
, PD.
tags
()},
27
{
"range"
, PD.
range
()},
28
};
29
}
30
31
void
nixf::to_json
(json &R,
const
Diagnostic
&D) {
32
to_json
(R,
static_cast<
const
PartialDiagnostic
&
>
(D));
33
R[
"kind"
] = D.
kind
();
34
R[
"severity"
] =
Diagnostic::severity
(D.
kind
());
35
R[
"message"
] = D.
message
();
36
R[
"sname"
] = D.
sname
();
37
R[
"notes"
] = D.
notes
();
38
R[
"fixes"
] = D.
fixes
();
39
}
40
41
void
nixf::to_json
(json &R,
const
Note
&N) {
42
to_json
(R,
static_cast<
const
PartialDiagnostic
&
>
(N));
43
R[
"kind"
] = N.
kind
();
44
R[
"sname"
] = N.
sname
();
45
R[
"message"
] = N.
message
();
46
}
47
48
void
nixf::to_json
(json &R,
const
Fix
&F) {
49
R = json{
50
{
"edits"
, F.
edits
()},
51
{
"message"
, F.
message
()},
52
};
53
}
54
55
void
nixf::to_json
(json &R,
const
TextEdit
&D) {
56
R = json{
57
{
"range"
, D.
oldRange
()},
58
{
"newText"
, D.
newText
()},
59
};
60
}
Diagnostic.h
JSONDiagnostic.h
Provide jsonified diagnostic, for other languages/structured output.
Range.h
nixf::Diagnostic::message
static const char * message(DiagnosticKind Kind)
nixf::Diagnostic::kind
DiagnosticKind kind() const
Definition
Diagnostic.h:176
nixf::Diagnostic::sname
static const char * sname(DiagnosticKind Kind)
nixf::Diagnostic::fixes
const std::vector< Fix > & fixes() const
Definition
Diagnostic.h:207
nixf::Diagnostic::notes
const std::vector< Note > & notes() const
Definition
Diagnostic.h:201
nixf::Diagnostic::severity
static Severity severity(DiagnosticKind Kind)
nixf::Fix
Definition
Diagnostic.h:57
nixf::Fix::edits
const std::vector< TextEdit > & edits() const
Definition
Diagnostic.h:70
nixf::Fix::message
const std::string & message() const
Definition
Diagnostic.h:71
nixf::LexerCursorRange
Definition
Range.h:105
nixf::LexerCursorRange::lCur
LexerCursor lCur() const
Definition
Range.h:116
nixf::LexerCursorRange::rCur
LexerCursor rCur() const
Definition
Range.h:117
nixf::LexerCursor
A point in the source file.
Definition
Range.h:57
nixf::LexerCursor::column
int64_t column() const
Column number, starting from 0.
Definition
Range.h:96
nixf::LexerCursor::offset
std::size_t offset() const
Offset in the source file, starting from 0.
Definition
Range.h:102
nixf::LexerCursor::line
int64_t line() const
Line number, starting from 0.
Definition
Range.h:93
nixf::Note
Definition
Diagnostic.h:114
nixf::Note::kind
NoteKind kind() const
Definition
Diagnostic.h:135
nixf::Note::sname
static const char * sname(NoteKind Kind)
Definition
Diagnostic.cpp:27
nixf::Note::message
static const char * message(NoteKind Kind)
Definition
Diagnostic.cpp:39
nixf::PartialDiagnostic
Definition
Diagnostic.h:79
nixf::PartialDiagnostic::args
const std::vector< std::string > & args() const
Definition
Diagnostic.h:92
nixf::PartialDiagnostic::tags
const std::vector< DiagnosticTag > & tags() const
Definition
Diagnostic.h:98
nixf::PartialDiagnostic::range
LexerCursorRange range() const
Definition
Diagnostic.h:100
nixf::TextEdit
Definition
Diagnostic.h:25
nixf::TextEdit::newText
std::string_view newText() const
Definition
Diagnostic.h:54
nixf::TextEdit::oldRange
LexerCursorRange oldRange() const
Definition
Diagnostic.h:53
Diagnostic
Definition
Diagnostic.cpp.py:1
nixf
Definition
Diagnostic.h:19
nixf::to_json
void to_json(nlohmann::json &R, const LexerCursor &LC)
Generated by
1.17.0