Enable LSP debug logging, expand language feature support, and fix GUI rendering issues.
- Added `--debug` CLI flag to control LSP debug logging and corresponding environment setting. - Extended LSP capabilities with basic hover, completion, and definition feature support. - Removed redundant `NoScrollWithMouse` flag, resolving inconsistencies in GUI scrolling behavior. - Refined variable usage and type consistency across LSP and rendering modules. - Updated `LspManager` for improved buffer handling and server diagnostics integration.
This commit is contained in:
@@ -98,6 +98,9 @@ enum class CommandId {
|
||||
// Syntax highlighting
|
||||
Syntax, // ":syntax on|off|reload"
|
||||
SetOption, // generic ":set key=value" (v1: filetype=<lang>)
|
||||
// LSP
|
||||
LspHover,
|
||||
LspGotoDefinition,
|
||||
};
|
||||
|
||||
|
||||
|
||||
6
Editor.h
6
Editor.h
@@ -450,6 +450,12 @@ public:
|
||||
}
|
||||
|
||||
|
||||
// LSP helpers: trigger hover/definition at current cursor in current buffer
|
||||
bool LspHoverAtCursor();
|
||||
|
||||
bool LspGotoDefinitionAtCursor();
|
||||
|
||||
|
||||
// LSP: notify buffer saved (used by commands)
|
||||
void NotifyBufferSaved(Buffer *buf);
|
||||
|
||||
|
||||
@@ -47,7 +47,6 @@ GUIRenderer::Draw(Editor &ed)
|
||||
|
||||
ImGuiWindowFlags flags = ImGuiWindowFlags_NoTitleBar
|
||||
| ImGuiWindowFlags_NoScrollbar
|
||||
| ImGuiWindowFlags_NoScrollWithMouse
|
||||
| ImGuiWindowFlags_NoResize
|
||||
| ImGuiWindowFlags_NoMove
|
||||
| ImGuiWindowFlags_NoCollapse
|
||||
@@ -60,7 +59,7 @@ GUIRenderer::Draw(Editor &ed)
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(6.f, 6.f));
|
||||
|
||||
ImGui::Begin("kte", nullptr, flags);
|
||||
ImGui::Begin("kte", nullptr, flags | ImGuiWindowFlags_NoScrollWithMouse);
|
||||
|
||||
const Buffer *buf = ed.CurrentBuffer();
|
||||
if (!buf) {
|
||||
@@ -69,7 +68,7 @@ GUIRenderer::Draw(Editor &ed)
|
||||
const auto &lines = buf->Rows();
|
||||
// Reserve space for status bar at bottom
|
||||
ImGui::BeginChild("scroll", ImVec2(0, -ImGui::GetFrameHeightWithSpacing()), false,
|
||||
ImGuiWindowFlags_HorizontalScrollbar | ImGuiWindowFlags_NoScrollWithMouse);
|
||||
ImGuiWindowFlags_HorizontalScrollbar);
|
||||
// Detect click-to-move inside this scroll region
|
||||
ImVec2 list_origin = ImGui::GetCursorScreenPos();
|
||||
float scroll_y = ImGui::GetScrollY();
|
||||
@@ -109,13 +108,13 @@ GUIRenderer::Draw(Editor &ed)
|
||||
}
|
||||
// If user scrolled, update buffer offsets accordingly
|
||||
if (prev_scroll_y >= 0.0f && scroll_y != prev_scroll_y) {
|
||||
if (Buffer *mbuf = const_cast<Buffer *>(buf)) {
|
||||
if (auto mbuf = const_cast<Buffer *>(buf)) {
|
||||
mbuf->SetOffsets(static_cast<std::size_t>(std::max(0L, scroll_top)),
|
||||
mbuf->Coloffs());
|
||||
}
|
||||
}
|
||||
if (prev_scroll_x >= 0.0f && scroll_x != prev_scroll_x) {
|
||||
if (Buffer *mbuf = const_cast<Buffer *>(buf)) {
|
||||
if (auto mbuf = const_cast<Buffer *>(buf)) {
|
||||
mbuf->SetOffsets(mbuf->Rowoffs(),
|
||||
static_cast<std::size_t>(std::max(0L, scroll_left)));
|
||||
}
|
||||
@@ -162,11 +161,13 @@ GUIRenderer::Draw(Editor &ed)
|
||||
buf->Highlighter()->PrefetchViewport(*buf, fr, rc, buf->Version());
|
||||
}
|
||||
}
|
||||
// Handle mouse click before rendering to avoid dependent on drawn items
|
||||
// Handle mouse click before rendering to avoid dependency on drawn items
|
||||
if (ImGui::IsWindowHovered() && ImGui::IsMouseClicked(ImGuiMouseButton_Left)) {
|
||||
ImVec2 mp = ImGui::GetIO().MousePos;
|
||||
// Compute viewport-relative row so (0) is top row of the visible area
|
||||
float vy_f = (mp.y - list_origin.y - scroll_y) / row_h;
|
||||
// Note: list_origin is already in the scrolled space of the child window,
|
||||
// so we must NOT subtract scroll_y again (would double-apply).
|
||||
float vy_f = (mp.y - list_origin.y) / row_h;
|
||||
long vy = static_cast<long>(vy_f);
|
||||
if (vy < 0)
|
||||
vy = 0;
|
||||
@@ -190,8 +191,9 @@ GUIRenderer::Draw(Editor &ed)
|
||||
by = 0;
|
||||
}
|
||||
|
||||
// Compute desired pixel X inside the viewport content (subtract horizontal scroll)
|
||||
float px = (mp.x - list_origin.x - scroll_x);
|
||||
// Compute desired pixel X inside the viewport content.
|
||||
// list_origin is already scrolled; do not subtract scroll_x here.
|
||||
float px = (mp.x - list_origin.x);
|
||||
if (px < 0.0f)
|
||||
px = 0.0f;
|
||||
|
||||
@@ -255,10 +257,10 @@ GUIRenderer::Draw(Editor &ed)
|
||||
for (std::size_t i = rowoffs; i < lines.size(); ++i) {
|
||||
// Capture the screen position before drawing the line
|
||||
ImVec2 line_pos = ImGui::GetCursorScreenPos();
|
||||
std::string line = static_cast<std::string>(lines[i]);
|
||||
auto line = static_cast<std::string>(lines[i]);
|
||||
|
||||
// Expand tabs to spaces with width=8 and apply horizontal scroll offset
|
||||
const std::size_t tabw = 8;
|
||||
constexpr std::size_t tabw = 8;
|
||||
std::string expanded;
|
||||
expanded.reserve(line.size() + 16);
|
||||
std::size_t rx_abs_draw = 0; // rendered column for drawing
|
||||
@@ -275,7 +277,7 @@ GUIRenderer::Draw(Editor &ed)
|
||||
for (auto it = std::sregex_iterator(line.begin(), line.end(), rx);
|
||||
it != std::sregex_iterator(); ++it) {
|
||||
const auto &m = *it;
|
||||
std::size_t sx = static_cast<std::size_t>(m.position());
|
||||
auto sx = static_cast<std::size_t>(m.position());
|
||||
std::size_t ex = sx + static_cast<std::size_t>(m.length());
|
||||
hl_src_ranges.emplace_back(sx, ex);
|
||||
}
|
||||
@@ -318,8 +320,8 @@ GUIRenderer::Draw(Editor &ed)
|
||||
continue; // fully left of view
|
||||
std::size_t vx0 = (rx_start > coloffs_now) ? (rx_start - coloffs_now) : 0;
|
||||
std::size_t vx1 = rx_end - coloffs_now;
|
||||
ImVec2 p0 = ImVec2(line_pos.x + static_cast<float>(vx0) * space_w, line_pos.y);
|
||||
ImVec2 p1 = ImVec2(line_pos.x + static_cast<float>(vx1) * space_w,
|
||||
auto p0 = ImVec2(line_pos.x + static_cast<float>(vx0) * space_w, line_pos.y);
|
||||
auto p1 = ImVec2(line_pos.x + static_cast<float>(vx1) * space_w,
|
||||
line_pos.y + line_h);
|
||||
// Choose color: current match stronger
|
||||
bool is_current = has_current && sx == cur_x && ex == cur_end;
|
||||
@@ -347,7 +349,7 @@ GUIRenderer::Draw(Editor &ed)
|
||||
const kte::LineHighlight &lh = buf->Highlighter()->GetLine(
|
||||
*buf, static_cast<int>(i), buf->Version());
|
||||
// Helper to convert a src column to expanded rx position
|
||||
auto src_to_rx_full = [&](std::size_t sidx) -> std::size_t {
|
||||
auto src_to_rx_full = [&](const std::size_t sidx) -> std::size_t {
|
||||
std::size_t rx = 0;
|
||||
for (std::size_t k = 0; k < sidx && k < line.size(); ++k) {
|
||||
rx += (line[k] == '\t') ? (tabw - (rx % tabw)) : 1;
|
||||
@@ -369,12 +371,14 @@ GUIRenderer::Draw(Editor &ed)
|
||||
if (vx1 <= vx0)
|
||||
continue;
|
||||
ImU32 col = ImGui::GetColorU32(kte::SyntaxInk(sp.kind));
|
||||
ImVec2 p = ImVec2(line_pos.x + static_cast<float>(vx0) * space_w, line_pos.y);
|
||||
auto p = ImVec2(line_pos.x + static_cast<float>(vx0) * space_w, line_pos.y);
|
||||
ImGui::GetWindowDrawList()->AddText(
|
||||
p, col, expanded.c_str() + vx0, expanded.c_str() + vx1);
|
||||
}
|
||||
// We drew text via draw list (no layout advance). Manually advance the cursor to the next line.
|
||||
ImGui::SetCursorScreenPos(ImVec2(line_pos.x, line_pos.y + line_h));
|
||||
// We drew text via draw list (no layout advance). Advance by the same amount
|
||||
// ImGui uses between lines (line height + spacing) so hit-testing (which
|
||||
// divides by row_h) aligns with drawing.
|
||||
ImGui::SetCursorScreenPos(ImVec2(line_pos.x, line_pos.y + row_h));
|
||||
} else {
|
||||
// No syntax: draw as one run
|
||||
ImGui::TextUnformatted(expanded.c_str());
|
||||
@@ -417,7 +421,7 @@ GUIRenderer::Draw(Editor &ed)
|
||||
ImGui::GetWindowDrawList()->AddRectFilled(p0, p1, bg_col);
|
||||
// If a prompt is active, replace the entire status bar with the prompt text
|
||||
if (ed.PromptActive()) {
|
||||
std::string label = ed.PromptLabel();
|
||||
const std::string &label = ed.PromptLabel();
|
||||
std::string ptext = ed.PromptText();
|
||||
auto kind = ed.CurrentPromptKind();
|
||||
if (kind == Editor::PromptKind::OpenFile || kind == Editor::PromptKind::SaveAs ||
|
||||
@@ -466,8 +470,8 @@ GUIRenderer::Draw(Editor &ed)
|
||||
float ratio = tail_sz.x / avail_px;
|
||||
size_t skip = ratio > 1.5f
|
||||
? std::min(tail.size() - start,
|
||||
(size_t) std::max<size_t>(
|
||||
1, (size_t) (tail.size() / 4)))
|
||||
static_cast<size_t>(std::max<size_t>(
|
||||
1, tail.size() / 4)))
|
||||
: 1;
|
||||
start += skip;
|
||||
std::string candidate = tail.substr(start);
|
||||
@@ -524,8 +528,7 @@ GUIRenderer::Draw(Editor &ed)
|
||||
left += " ";
|
||||
// Insert buffer position prefix "[x/N] " before filename
|
||||
{
|
||||
std::size_t total = ed.BufferCount();
|
||||
if (total > 0) {
|
||||
if (std::size_t total = ed.BufferCount(); total > 0) {
|
||||
std::size_t idx1 = ed.CurrentBufferIndex() + 1; // 1-based for display
|
||||
left += "[";
|
||||
left += std::to_string(static_cast<unsigned long long>(idx1));
|
||||
@@ -539,7 +542,7 @@ GUIRenderer::Draw(Editor &ed)
|
||||
left += " *";
|
||||
// Append total line count as "<n>L"
|
||||
{
|
||||
unsigned long lcount = static_cast<unsigned long>(buf->Rows().size());
|
||||
auto lcount = buf->Rows().size();
|
||||
left += " ";
|
||||
left += std::to_string(lcount);
|
||||
left += "L";
|
||||
@@ -625,9 +628,9 @@ GUIRenderer::Draw(Editor &ed)
|
||||
ImGuiViewport *vp2 = ImGui::GetMainViewport();
|
||||
|
||||
// Desired size, min size, and margins
|
||||
const ImVec2 want(800.0f, 500.0f);
|
||||
const ImVec2 min_sz(240.0f, 160.0f);
|
||||
const float margin = 20.0f; // space from viewport edges
|
||||
constexpr ImVec2 want(800.0f, 500.0f);
|
||||
constexpr ImVec2 min_sz(240.0f, 160.0f);
|
||||
constexpr float margin = 20.0f; // space from viewport edges
|
||||
|
||||
// Compute the maximum allowed size (viewport minus margins) and make sure it's not negative
|
||||
ImVec2 max_sz(std::max(32.0f, vp2->Size.x - 2.0f * margin),
|
||||
|
||||
@@ -38,18 +38,48 @@ map_key_to_command(const int ch,
|
||||
MEVENT ev{};
|
||||
if (getmouse(&ev) == OK) {
|
||||
// Mouse wheel → map to MoveUp/MoveDown one line per wheel notch
|
||||
unsigned long wheel_up_mask = 0;
|
||||
unsigned long wheel_dn_mask = 0;
|
||||
#ifdef BUTTON4_PRESSED
|
||||
if (ev.bstate & (BUTTON4_PRESSED | BUTTON4_RELEASED | BUTTON4_CLICKED)) {
|
||||
out = {true, CommandId::MoveUp, "", 0};
|
||||
return true;
|
||||
}
|
||||
wheel_up_mask |= BUTTON4_PRESSED;
|
||||
#endif
|
||||
#ifdef BUTTON4_RELEASED
|
||||
wheel_up_mask |= BUTTON4_RELEASED;
|
||||
#endif
|
||||
#ifdef BUTTON4_CLICKED
|
||||
wheel_up_mask |= BUTTON4_CLICKED;
|
||||
#endif
|
||||
#ifdef BUTTON4_DOUBLE_CLICKED
|
||||
wheel_up_mask |= BUTTON4_DOUBLE_CLICKED;
|
||||
#endif
|
||||
#ifdef BUTTON4_TRIPLE_CLICKED
|
||||
wheel_up_mask |= BUTTON4_TRIPLE_CLICKED;
|
||||
#endif
|
||||
#ifdef BUTTON5_PRESSED
|
||||
if (ev.bstate & (BUTTON5_PRESSED | BUTTON5_RELEASED | BUTTON5_CLICKED)) {
|
||||
out = {true, CommandId::MoveDown, "", 0};
|
||||
wheel_dn_mask |= BUTTON5_PRESSED;
|
||||
#endif
|
||||
#ifdef BUTTON5_RELEASED
|
||||
wheel_dn_mask |= BUTTON5_RELEASED;
|
||||
#endif
|
||||
#ifdef BUTTON5_CLICKED
|
||||
wheel_dn_mask |= BUTTON5_CLICKED;
|
||||
#endif
|
||||
#ifdef BUTTON5_DOUBLE_CLICKED
|
||||
wheel_dn_mask |= BUTTON5_DOUBLE_CLICKED;
|
||||
#endif
|
||||
#ifdef BUTTON5_TRIPLE_CLICKED
|
||||
wheel_dn_mask |= BUTTON5_TRIPLE_CLICKED;
|
||||
#endif
|
||||
if (wheel_up_mask && (ev.bstate & wheel_up_mask)) {
|
||||
// Prefer viewport scrolling for wheel: page up
|
||||
out = {true, CommandId::PageUp, "", 0};
|
||||
return true;
|
||||
}
|
||||
if (wheel_dn_mask && (ev.bstate & wheel_dn_mask)) {
|
||||
// Prefer viewport scrolling for wheel: page down
|
||||
out = {true, CommandId::PageDown, "", 0};
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
// React to left button click/press
|
||||
if (ev.bstate & (BUTTON1_CLICKED | BUTTON1_PRESSED | BUTTON1_RELEASED)) {
|
||||
char buf[64];
|
||||
|
||||
403
ext/json.h
403
ext/json.h
@@ -1216,30 +1216,30 @@ JSON_HEDLEY_SUNPRO_VERSION_CHECK(8, 0, 0) || \
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444")
|
||||
#elif JSON_HEDLEY_GCC_VERSION_CHECK(4, 3, 0)
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
|
||||
#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
|
||||
#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15, 0, 0)
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:4996))
|
||||
#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
|
||||
#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10)
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444")
|
||||
#elif \
|
||||
JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
|
||||
(JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
|
||||
JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
|
||||
(JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
|
||||
JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
|
||||
(JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
|
||||
JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
|
||||
(JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
|
||||
JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
|
||||
JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
|
||||
JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
|
||||
JSON_HEDLEY_TI_VERSION_CHECK(15, 12, 0) || \
|
||||
(JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4, 8, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
|
||||
JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5, 2, 0) || \
|
||||
(JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
|
||||
JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 4, 0) || \
|
||||
(JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 0, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
|
||||
JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 3, 0) || \
|
||||
(JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 2, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
|
||||
JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7, 5, 0) || \
|
||||
JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || \
|
||||
JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0)
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1291,1718")
|
||||
#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && !defined(__cplusplus)
|
||||
#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 13, 0) && !defined(__cplusplus)
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,E_DEPRECATED_ATT,E_DEPRECATED_ATT_MESS)")
|
||||
#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && defined(__cplusplus)
|
||||
#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 13, 0) && defined(__cplusplus)
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,symdeprecated,symdeprecated2)")
|
||||
#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
|
||||
#elif JSON_HEDLEY_IAR_VERSION_CHECK(8, 0, 0)
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress=Pe1444,Pe1215")
|
||||
#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0)
|
||||
#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2, 90, 0)
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warn(disable:2241)")
|
||||
#else
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
|
||||
@@ -1258,19 +1258,19 @@ JSON_HEDLEY_SUNPRO_VERSION_CHECK(8, 0, 0) || \
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 1675")
|
||||
#elif JSON_HEDLEY_GCC_VERSION_CHECK(4, 3, 0)
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("GCC diagnostic ignored \"-Wunknown-pragmas\"")
|
||||
#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
|
||||
#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15, 0, 0)
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:4068))
|
||||
#elif \
|
||||
JSON_HEDLEY_TI_VERSION_CHECK(16,9,0) || \
|
||||
JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \
|
||||
JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
|
||||
JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0)
|
||||
JSON_HEDLEY_TI_VERSION_CHECK(16, 9, 0) || \
|
||||
JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8, 0, 0) || \
|
||||
JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || \
|
||||
JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 3, 0)
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163")
|
||||
#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0)
|
||||
#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8, 0, 0)
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163")
|
||||
#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
|
||||
#elif JSON_HEDLEY_IAR_VERSION_CHECK(8, 0, 0)
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress=Pe161")
|
||||
#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
|
||||
#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10)
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 161")
|
||||
#else
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
|
||||
@@ -1283,26 +1283,26 @@ JSON_HEDLEY_SUNPRO_VERSION_CHECK(8, 0, 0) || \
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("clang diagnostic ignored \"-Wunknown-attributes\"")
|
||||
#elif JSON_HEDLEY_GCC_VERSION_CHECK(4, 6, 0)
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
|
||||
#elif JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0)
|
||||
#elif JSON_HEDLEY_INTEL_VERSION_CHECK(17, 0, 0)
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("warning(disable:1292)")
|
||||
#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
|
||||
#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021, 1, 0)
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:1292))
|
||||
#elif JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,0)
|
||||
#elif JSON_HEDLEY_MSVC_VERSION_CHECK(19, 0, 0)
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:5030))
|
||||
#elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0)
|
||||
#elif JSON_HEDLEY_PGI_VERSION_CHECK(20, 7, 0)
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097,1098")
|
||||
#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
|
||||
#elif JSON_HEDLEY_PGI_VERSION_CHECK(17, 10, 0)
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097")
|
||||
#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)
|
||||
#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 14, 0) && defined(__cplusplus)
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("error_messages(off,attrskipunsup)")
|
||||
#elif \
|
||||
JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \
|
||||
JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \
|
||||
JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0)
|
||||
JSON_HEDLEY_TI_VERSION_CHECK(18, 1, 0) || \
|
||||
JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8, 3, 0) || \
|
||||
JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0)
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1173")
|
||||
#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
|
||||
#elif JSON_HEDLEY_IAR_VERSION_CHECK(8, 0, 0)
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress=Pe1097")
|
||||
#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
|
||||
#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10)
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097")
|
||||
#else
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
|
||||
@@ -1328,9 +1328,9 @@ JSON_HEDLEY_SUNPRO_VERSION_CHECK(8, 0, 0) || \
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("clang diagnostic ignored \"-Wunused-function\"")
|
||||
#elif JSON_HEDLEY_GCC_VERSION_CHECK(3, 4, 0)
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("GCC diagnostic ignored \"-Wunused-function\"")
|
||||
#elif JSON_HEDLEY_MSVC_VERSION_CHECK(1,0,0)
|
||||
#elif JSON_HEDLEY_MSVC_VERSION_CHECK(1, 0, 0)
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION __pragma(warning(disable:4505))
|
||||
#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
|
||||
#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10)
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("diag_suppress 3142")
|
||||
#else
|
||||
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION
|
||||
@@ -1635,7 +1635,7 @@ JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || \
|
||||
JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0) || \
|
||||
JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10)
|
||||
#define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(__printf__, string_idx, first_to_check)))
|
||||
#elif JSON_HEDLEY_PELLES_VERSION_CHECK(6,0,0)
|
||||
#elif JSON_HEDLEY_PELLES_VERSION_CHECK(6, 0, 0)
|
||||
#define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __declspec(vaformat(printf,string_idx,first_to_check))
|
||||
#else
|
||||
#define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check)
|
||||
@@ -1679,21 +1679,21 @@ JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10)
|
||||
# define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect (!!(expr), 0 )
|
||||
#elif \
|
||||
(JSON_HEDLEY_HAS_BUILTIN(__builtin_expect) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \
|
||||
JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \
|
||||
JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
|
||||
(JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \
|
||||
JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
|
||||
JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
|
||||
JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
|
||||
JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \
|
||||
JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \
|
||||
JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \
|
||||
JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
|
||||
JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
|
||||
JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
|
||||
JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,27) || \
|
||||
JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \
|
||||
JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
|
||||
JSON_HEDLEY_GCC_VERSION_CHECK(3, 0, 0) || \
|
||||
JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \
|
||||
(JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 15, 0) && defined(__cplusplus)) || \
|
||||
JSON_HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || \
|
||||
JSON_HEDLEY_IBM_VERSION_CHECK(10, 1, 0) || \
|
||||
JSON_HEDLEY_TI_VERSION_CHECK(15, 12, 0) || \
|
||||
JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4, 7, 0) || \
|
||||
JSON_HEDLEY_TI_CL430_VERSION_CHECK(3, 1, 0) || \
|
||||
JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 1, 0) || \
|
||||
JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6, 1, 0) || \
|
||||
JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || \
|
||||
JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0) || \
|
||||
JSON_HEDLEY_TINYC_VERSION_CHECK(0, 9, 27) || \
|
||||
JSON_HEDLEY_CRAY_VERSION_CHECK(8, 1, 0) || \
|
||||
JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10)
|
||||
# define JSON_HEDLEY_PREDICT(expr, expected, probability) \
|
||||
(((probability) >= 0.9) ? __builtin_expect((expr), (expected)) : (JSON_HEDLEY_STATIC_CAST(void, expected), (expr)))
|
||||
# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) \
|
||||
@@ -1742,11 +1742,11 @@ JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || \
|
||||
JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0) || \
|
||||
JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10)
|
||||
#define JSON_HEDLEY_MALLOC __attribute__((__malloc__))
|
||||
#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
|
||||
#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 10, 0)
|
||||
#define JSON_HEDLEY_MALLOC _Pragma("returns_new_memory")
|
||||
#elif \
|
||||
JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
|
||||
JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
|
||||
JSON_HEDLEY_MSVC_VERSION_CHECK(14, 0, 0) || \
|
||||
JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021, 1, 0)
|
||||
#define JSON_HEDLEY_MALLOC __declspec(restrict)
|
||||
#else
|
||||
#define JSON_HEDLEY_MALLOC
|
||||
@@ -1776,13 +1776,13 @@ JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0) || \
|
||||
JSON_HEDLEY_PGI_VERSION_CHECK(17, 10, 0) || \
|
||||
JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10)
|
||||
# define JSON_HEDLEY_PURE __attribute__((__pure__))
|
||||
#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
|
||||
#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 10, 0)
|
||||
# define JSON_HEDLEY_PURE _Pragma("does_not_write_global_data")
|
||||
#elif defined(__cplusplus) && \
|
||||
( \
|
||||
JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \
|
||||
JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0) || \
|
||||
JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) \
|
||||
JSON_HEDLEY_TI_CL430_VERSION_CHECK(2, 0, 1) || \
|
||||
JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4, 0, 0) || \
|
||||
JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) \
|
||||
)
|
||||
# define JSON_HEDLEY_PURE _Pragma("FUNC_IS_PURE;")
|
||||
#else
|
||||
@@ -1814,7 +1814,7 @@ JSON_HEDLEY_PGI_VERSION_CHECK(17, 10, 0) || \
|
||||
JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10)
|
||||
#define JSON_HEDLEY_CONST __attribute__((__const__))
|
||||
#elif \
|
||||
JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
|
||||
JSON_HEDLEY_SUNPRO_VERSION_CHECK(5, 10, 0)
|
||||
#define JSON_HEDLEY_CONST _Pragma("no_side_effect")
|
||||
#else
|
||||
#define JSON_HEDLEY_CONST JSON_HEDLEY_PURE
|
||||
@@ -1900,20 +1900,20 @@ JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10) || \
|
||||
JSON_HEDLEY_IAR_VERSION_CHECK(8, 10, 0)
|
||||
# define JSON_HEDLEY_ALWAYS_INLINE __attribute__((__always_inline__)) JSON_HEDLEY_INLINE
|
||||
#elif \
|
||||
JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \
|
||||
JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
|
||||
JSON_HEDLEY_MSVC_VERSION_CHECK(12, 0, 0) || \
|
||||
JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021, 1, 0)
|
||||
# define JSON_HEDLEY_ALWAYS_INLINE __forceinline
|
||||
#elif defined(__cplusplus) && \
|
||||
( \
|
||||
JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
|
||||
JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
|
||||
JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
|
||||
JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
|
||||
JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
|
||||
JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) \
|
||||
JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5, 2, 0) || \
|
||||
JSON_HEDLEY_TI_CL430_VERSION_CHECK(4, 3, 0) || \
|
||||
JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6, 4, 0) || \
|
||||
JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6, 1, 0) || \
|
||||
JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || \
|
||||
JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0) \
|
||||
)
|
||||
# define JSON_HEDLEY_ALWAYS_INLINE _Pragma("FUNC_ALWAYS_INLINE;")
|
||||
#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
|
||||
#elif JSON_HEDLEY_IAR_VERSION_CHECK(8, 0, 0)
|
||||
# define JSON_HEDLEY_ALWAYS_INLINE _Pragma("inline=forced")
|
||||
#else
|
||||
# define JSON_HEDLEY_ALWAYS_INLINE JSON_HEDLEY_INLINE
|
||||
@@ -1944,18 +1944,18 @@ JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10) || \
|
||||
JSON_HEDLEY_IAR_VERSION_CHECK(8, 10, 0)
|
||||
#define JSON_HEDLEY_NEVER_INLINE __attribute__((__noinline__))
|
||||
#elif \
|
||||
JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
|
||||
JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
|
||||
JSON_HEDLEY_MSVC_VERSION_CHECK(13, 10, 0) || \
|
||||
JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021, 1, 0)
|
||||
#define JSON_HEDLEY_NEVER_INLINE __declspec(noinline)
|
||||
#elif JSON_HEDLEY_PGI_VERSION_CHECK(10,2,0)
|
||||
#elif JSON_HEDLEY_PGI_VERSION_CHECK(10, 2, 0)
|
||||
#define JSON_HEDLEY_NEVER_INLINE _Pragma("noinline")
|
||||
#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus)
|
||||
#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6, 0, 0) && defined(__cplusplus)
|
||||
#define JSON_HEDLEY_NEVER_INLINE _Pragma("FUNC_CANNOT_INLINE;")
|
||||
#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
|
||||
#elif JSON_HEDLEY_IAR_VERSION_CHECK(8, 0, 0)
|
||||
#define JSON_HEDLEY_NEVER_INLINE _Pragma("inline=never")
|
||||
#elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0)
|
||||
#elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3, 2, 0)
|
||||
#define JSON_HEDLEY_NEVER_INLINE __attribute((noinline))
|
||||
#elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0)
|
||||
#elif JSON_HEDLEY_PELLES_VERSION_CHECK(9, 0, 0)
|
||||
#define JSON_HEDLEY_NEVER_INLINE __declspec(noinline)
|
||||
#else
|
||||
#define JSON_HEDLEY_NEVER_INLINE
|
||||
@@ -2009,9 +2009,9 @@ JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \
|
||||
JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10)
|
||||
#define JSON_HEDLEY_NO_THROW __attribute__((__nothrow__))
|
||||
#elif \
|
||||
JSON_HEDLEY_MSVC_VERSION_CHECK(13,1,0) || \
|
||||
JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
|
||||
JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0)
|
||||
JSON_HEDLEY_MSVC_VERSION_CHECK(13, 1, 0) || \
|
||||
JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021, 1, 0) || \
|
||||
JSON_HEDLEY_ARM_VERSION_CHECK(4, 1, 0)
|
||||
#define JSON_HEDLEY_NO_THROW __declspec(nothrow)
|
||||
#else
|
||||
#define JSON_HEDLEY_NO_THROW
|
||||
@@ -2025,7 +2025,7 @@ JSON_HEDLEY_HAS_ATTRIBUTE(fallthrough) || \
|
||||
JSON_HEDLEY_GCC_VERSION_CHECK(7, 0, 0) || \
|
||||
JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1, 25, 10)
|
||||
#define JSON_HEDLEY_FALL_THROUGH __attribute__((__fallthrough__))
|
||||
#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(clang,fallthrough)
|
||||
#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(clang, fallthrough)
|
||||
#define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[clang::fallthrough]])
|
||||
#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(fallthrough)
|
||||
#define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[fallthrough]])
|
||||
@@ -2223,11 +2223,11 @@ JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021, 1, 0)
|
||||
JSON_HEDLEY_GCC_VERSION_CHECK(4, 4, 0) || \
|
||||
JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0)
|
||||
# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message msg)
|
||||
#elif JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0)
|
||||
#elif JSON_HEDLEY_CRAY_VERSION_CHECK(5, 0, 0)
|
||||
# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(_CRI message msg)
|
||||
#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
|
||||
#elif JSON_HEDLEY_IAR_VERSION_CHECK(8, 0, 0)
|
||||
# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg))
|
||||
#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,0,0)
|
||||
#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2, 0, 0)
|
||||
# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg))
|
||||
#else
|
||||
# define JSON_HEDLEY_MESSAGE(msg)
|
||||
@@ -2248,8 +2248,8 @@ JSON_HEDLEY_PGI_VERSION_CHECK(18, 4, 0) || \
|
||||
JSON_HEDLEY_INTEL_VERSION_CHECK(13, 0, 0)
|
||||
# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(GCC warning msg)
|
||||
#elif \
|
||||
JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \
|
||||
JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
|
||||
JSON_HEDLEY_MSVC_VERSION_CHECK(15, 0, 0) || \
|
||||
JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021, 1, 0)
|
||||
# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(message(msg))
|
||||
#else
|
||||
# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_MESSAGE(msg)
|
||||
@@ -3035,7 +3035,7 @@ operator<(const value_t lhs, const value_t rhs) noexcept
|
||||
const auto r_index = static_cast<std::size_t>(rhs);
|
||||
#if JSON_HAS_THREE_WAY_COMPARISON
|
||||
if (l_index < order.size() && r_index < order.size()) {
|
||||
return order[l_index] <=> order[r_index]; // *NOPAD*
|
||||
return order[l_index] <= > order[r_index]; // *NOPAD*
|
||||
}
|
||||
return std::partial_ordering::unordered;
|
||||
#else
|
||||
@@ -3052,7 +3052,7 @@ operator<(const value_t lhs, const value_t rhs) noexcept
|
||||
inline bool
|
||||
operator<(const value_t lhs, const value_t rhs) noexcept
|
||||
{
|
||||
return std::is_lt(lhs <=> rhs); // *NOPAD*
|
||||
return std::is_lt(lhs <= > rhs); // *NOPAD*
|
||||
}
|
||||
#endif
|
||||
} // namespace detail
|
||||
@@ -3187,6 +3187,7 @@ NLOHMANN_JSON_NAMESPACE_END
|
||||
#include <type_traits> // conditional, enable_if, false_type, integral_constant, is_constructible, is_integral, is_same, remove_cv, remove_reference, true_type
|
||||
|
||||
|
||||
|
||||
#include <utility> // index_sequence, make_index_sequence, index_sequence_for
|
||||
|
||||
// #include <nlohmann/detail/macro_scope.hpp>
|
||||
@@ -3400,10 +3401,10 @@ template<typename T, typename = void>
|
||||
struct iterator_traits {};
|
||||
|
||||
template<typename T>
|
||||
struct iterator_traits<T, enable_if_t < !std::is_pointer<T>::value>
|
||||
>
|
||||
:
|
||||
iterator_types<T> {};
|
||||
struct iterator_traits<T, enable_if_t<!std::is_pointer<T>::value>
|
||||
>
|
||||
:
|
||||
iterator_types<T> {};
|
||||
|
||||
template<typename T>
|
||||
struct iterator_traits<T *, enable_if_t<std::is_object<T>::value> > {
|
||||
@@ -3636,14 +3637,13 @@ struct is_getable {
|
||||
};
|
||||
|
||||
template<typename BasicJsonType, typename T>
|
||||
struct has_from_json<BasicJsonType, T, enable_if_t < !is_basic_json<T>::value>
|
||||
>
|
||||
{
|
||||
struct has_from_json<BasicJsonType, T, enable_if_t<!is_basic_json<T>::value>
|
||||
> {
|
||||
using serializer = typename BasicJsonType::template json_serializer<T, void>;
|
||||
|
||||
static constexpr bool value =
|
||||
is_detected_exact<void, from_json_function, serializer,
|
||||
const BasicJsonType&, T&>::value;
|
||||
const BasicJsonType &, T &>::value;
|
||||
};
|
||||
|
||||
// This trait checks if JSONSerializer<T>::from_json(json const&) exists
|
||||
@@ -3652,14 +3652,13 @@ template<typename BasicJsonType, typename T, typename = void>
|
||||
struct has_non_default_from_json : std::false_type {};
|
||||
|
||||
template<typename BasicJsonType, typename T>
|
||||
struct has_non_default_from_json<BasicJsonType, T, enable_if_t < !is_basic_json<T>::value>
|
||||
>
|
||||
{
|
||||
struct has_non_default_from_json<BasicJsonType, T, enable_if_t<!is_basic_json<T>::value>
|
||||
> {
|
||||
using serializer = typename BasicJsonType::template json_serializer<T, void>;
|
||||
|
||||
static constexpr bool value =
|
||||
is_detected_exact<T, from_json_function, serializer,
|
||||
const BasicJsonType&>::value;
|
||||
const BasicJsonType &>::value;
|
||||
};
|
||||
|
||||
// This trait checks if BasicJsonType::json_serializer<T>::to_json exists
|
||||
@@ -3668,13 +3667,12 @@ template<typename BasicJsonType, typename T, typename = void>
|
||||
struct has_to_json : std::false_type {};
|
||||
|
||||
template<typename BasicJsonType, typename T>
|
||||
struct has_to_json<BasicJsonType, T, enable_if_t < !is_basic_json<T>::value>
|
||||
>
|
||||
{
|
||||
struct has_to_json<BasicJsonType, T, enable_if_t<!is_basic_json<T>::value>
|
||||
> {
|
||||
using serializer = typename BasicJsonType::template json_serializer<T, void>;
|
||||
|
||||
static constexpr bool value =
|
||||
is_detected_exact<void, to_json_function, serializer, BasicJsonType&,
|
||||
is_detected_exact<void, to_json_function, serializer, BasicJsonType &,
|
||||
T>::value;
|
||||
};
|
||||
|
||||
@@ -3895,10 +3893,9 @@ struct is_compatible_object_type_impl : std::false_type {};
|
||||
template<typename BasicJsonType, typename CompatibleObjectType>
|
||||
struct is_compatible_object_type_impl<
|
||||
BasicJsonType, CompatibleObjectType,
|
||||
enable_if_t < is_detected<mapped_type_t, CompatibleObjectType>::value &&
|
||||
enable_if_t<is_detected<mapped_type_t, CompatibleObjectType>::value &&
|
||||
is_detected<key_type_t, CompatibleObjectType>::value>
|
||||
>
|
||||
{
|
||||
> {
|
||||
using object_t = typename BasicJsonType::object_t;
|
||||
|
||||
// macOS's is_constructible does not play well with nonesuch...
|
||||
@@ -3920,10 +3917,9 @@ struct is_constructible_object_type_impl : std::false_type {};
|
||||
template<typename BasicJsonType, typename ConstructibleObjectType>
|
||||
struct is_constructible_object_type_impl<
|
||||
BasicJsonType, ConstructibleObjectType,
|
||||
enable_if_t < is_detected<mapped_type_t, ConstructibleObjectType>::value &&
|
||||
enable_if_t<is_detected<mapped_type_t, ConstructibleObjectType>::value &&
|
||||
is_detected<key_type_t, ConstructibleObjectType>::value>
|
||||
>
|
||||
{
|
||||
> {
|
||||
using object_t = typename BasicJsonType::object_t;
|
||||
|
||||
static constexpr bool value =
|
||||
@@ -3932,14 +3928,14 @@ struct is_constructible_object_type_impl<
|
||||
std::is_copy_assignable<ConstructibleObjectType>::value) &&
|
||||
(is_constructible<typename ConstructibleObjectType::key_type,
|
||||
typename object_t::key_type>::value &&
|
||||
std::is_same <
|
||||
std::is_same<
|
||||
typename object_t::mapped_type,
|
||||
typename ConstructibleObjectType::mapped_type >::value)) ||
|
||||
typename ConstructibleObjectType::mapped_type>::value)) ||
|
||||
(has_from_json<BasicJsonType,
|
||||
typename ConstructibleObjectType::mapped_type>::value ||
|
||||
has_non_default_from_json <
|
||||
has_non_default_from_json<
|
||||
BasicJsonType,
|
||||
typename ConstructibleObjectType::mapped_type >::value);
|
||||
typename ConstructibleObjectType::mapped_type>::value);
|
||||
};
|
||||
|
||||
template<typename BasicJsonType, typename ConstructibleObjectType>
|
||||
@@ -3975,17 +3971,16 @@ struct is_compatible_array_type_impl : std::false_type {};
|
||||
template<typename BasicJsonType, typename CompatibleArrayType>
|
||||
struct is_compatible_array_type_impl<
|
||||
BasicJsonType, CompatibleArrayType,
|
||||
enable_if_t <
|
||||
enable_if_t<
|
||||
is_detected<iterator_t, CompatibleArrayType>::value &&
|
||||
is_iterator_traits<iterator_traits<detected_t<iterator_t, CompatibleArrayType> > >::value &&
|
||||
// special case for types like std::filesystem::path whose iterator's value_type are themselves
|
||||
// c.f. https://github.com/nlohmann/json/pull/3073
|
||||
!std::is_same<CompatibleArrayType, detected_t<range_value_t, CompatibleArrayType> >::value>
|
||||
>
|
||||
{
|
||||
> {
|
||||
static constexpr bool value =
|
||||
is_constructible<BasicJsonType,
|
||||
range_value_t<CompatibleArrayType>>::value;
|
||||
range_value_t<CompatibleArrayType> >::value;
|
||||
};
|
||||
|
||||
template<typename BasicJsonType, typename CompatibleArrayType>
|
||||
@@ -4005,22 +4000,23 @@ struct is_constructible_array_type_impl<
|
||||
template<typename BasicJsonType, typename ConstructibleArrayType>
|
||||
struct is_constructible_array_type_impl<
|
||||
BasicJsonType, ConstructibleArrayType,
|
||||
enable_if_t < !std::is_same<ConstructibleArrayType,
|
||||
enable_if_t<!std::is_same<ConstructibleArrayType,
|
||||
typename BasicJsonType::value_type>::value &&
|
||||
!is_compatible_string_type<BasicJsonType, ConstructibleArrayType>::value &&
|
||||
is_default_constructible<ConstructibleArrayType>::value &&
|
||||
(std::is_move_assignable<ConstructibleArrayType>::value ||
|
||||
std::is_copy_assignable<ConstructibleArrayType>::value) &&
|
||||
is_detected<iterator_t, ConstructibleArrayType>::value &&
|
||||
is_iterator_traits<iterator_traits<detected_t<iterator_t, ConstructibleArrayType> > >::value &&
|
||||
is_iterator_traits<iterator_traits<detected_t<iterator_t, ConstructibleArrayType> > >::value
|
||||
&&
|
||||
is_detected<range_value_t, ConstructibleArrayType>::value &&
|
||||
// special case for types like std::filesystem::path whose iterator's value_type are themselves
|
||||
// c.f. https://github.com/nlohmann/json/pull/3073
|
||||
!std::is_same<ConstructibleArrayType, detected_t<range_value_t, ConstructibleArrayType> >::value &&
|
||||
!std::is_same<ConstructibleArrayType, detected_t<range_value_t,
|
||||
ConstructibleArrayType> >::value &&
|
||||
is_complete_type<
|
||||
detected_t<range_value_t, ConstructibleArrayType> >::value>
|
||||
>
|
||||
{
|
||||
> {
|
||||
using value_type = range_value_t<ConstructibleArrayType>;
|
||||
|
||||
static constexpr bool value =
|
||||
@@ -4028,9 +4024,9 @@ struct is_constructible_array_type_impl<
|
||||
typename BasicJsonType::array_t::value_type>::value ||
|
||||
has_from_json<BasicJsonType,
|
||||
value_type>::value ||
|
||||
has_non_default_from_json <
|
||||
has_non_default_from_json<
|
||||
BasicJsonType,
|
||||
value_type >::value;
|
||||
value_type>::value;
|
||||
};
|
||||
|
||||
template<typename BasicJsonType, typename ConstructibleArrayType>
|
||||
@@ -4044,11 +4040,10 @@ struct is_compatible_integer_type_impl : std::false_type {};
|
||||
template<typename RealIntegerType, typename CompatibleNumberIntegerType>
|
||||
struct is_compatible_integer_type_impl<
|
||||
RealIntegerType, CompatibleNumberIntegerType,
|
||||
enable_if_t < std::is_integral<RealIntegerType>::value &&
|
||||
enable_if_t<std::is_integral<RealIntegerType>::value &&
|
||||
std::is_integral<CompatibleNumberIntegerType>::value &&
|
||||
!std::is_same<bool, CompatibleNumberIntegerType>::value>
|
||||
>
|
||||
{
|
||||
> {
|
||||
// is there an assert somewhere on overflows?
|
||||
using RealLimits = std::numeric_limits<RealIntegerType>;
|
||||
using CompatibleLimits = std::numeric_limits<CompatibleNumberIntegerType>;
|
||||
@@ -4071,9 +4066,8 @@ struct is_compatible_type_impl : std::false_type {};
|
||||
template<typename BasicJsonType, typename CompatibleType>
|
||||
struct is_compatible_type_impl<
|
||||
BasicJsonType, CompatibleType,
|
||||
enable_if_t < is_complete_type<CompatibleType>::value>
|
||||
>
|
||||
{
|
||||
enable_if_t<is_complete_type<CompatibleType>::value>
|
||||
> {
|
||||
static constexpr bool value =
|
||||
has_to_json<BasicJsonType, CompatibleType>::value;
|
||||
};
|
||||
@@ -4127,15 +4121,15 @@ struct is_comparable : std::false_type {};
|
||||
// is_json_pointer_of can be removed once the deprecated function has been
|
||||
// removed.
|
||||
template<typename Compare, typename A, typename B>
|
||||
struct is_comparable<Compare, A, B, enable_if_t < !is_json_pointer_of<A, B>::value
|
||||
struct is_comparable<Compare, A, B, enable_if_t<!is_json_pointer_of<A, B>::value
|
||||
&& std::is_constructible<decltype(std::declval<Compare>()(
|
||||
std::declval<A>(), std::declval<B>()))>::value
|
||||
&& std::is_constructible<decltype(std::declval<Compare>()(
|
||||
std::declval<B>(), std::declval<A>()))>::value
|
||||
>
|
||||
>
|
||||
:
|
||||
std::true_type {};
|
||||
>
|
||||
>
|
||||
:
|
||||
std::true_type {};
|
||||
|
||||
template<typename T>
|
||||
using detect_is_transparent = typename T::is_transparent;
|
||||
@@ -4835,7 +4829,8 @@ namespace std_fs = std::experimental::filesystem;
|
||||
NLOHMANN_JSON_NAMESPACE_END
|
||||
#elif JSON_HAS_FILESYSTEM
|
||||
#include <filesystem> // NOLINT(build/c++17)
|
||||
NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail {
|
||||
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||
namespace detail {
|
||||
namespace std_fs = std::filesystem;
|
||||
} // namespace detail
|
||||
NLOHMANN_JSON_NAMESPACE_END
|
||||
@@ -4947,12 +4942,9 @@ template<
|
||||
enable_if_t<
|
||||
std::is_assignable<StringType &, const typename BasicJsonType::string_t>::value
|
||||
&& is_detected_exact<typename BasicJsonType::string_t::value_type, value_type_t, StringType>::value
|
||||
&& !std::is_same < typename BasicJsonType::string_t, StringType>::value
|
||||
&&!is_json_ref<StringType>::value, int>
|
||||
|
||||
|
||||
=
|
||||
0
|
||||
&& !std::is_same<typename BasicJsonType::string_t, StringType>::value
|
||||
&& !is_json_ref<StringType>::value, int> =
|
||||
0
|
||||
>
|
||||
inline void
|
||||
from_json(const BasicJsonType &j, StringType &s)
|
||||
@@ -5191,20 +5183,20 @@ from_json_inplace_array_impl(BasicJsonType &&j,
|
||||
template<typename BasicJsonType, typename T, std::size_t N>
|
||||
auto
|
||||
from_json(BasicJsonType &&j, identity_tag<std::array<T, N> > tag)
|
||||
-> decltype(from_json_inplace_array_impl(std::forward<BasicJsonType>(j), tag, make_index_sequence < N > {}
|
||||
-> decltype(from_json_inplace_array_impl(std::forward<BasicJsonType>(j), tag, make_index_sequence<N>{}
|
||||
|
||||
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
{
|
||||
if (JSON_HEDLEY_UNLIKELY(!j.is_array()))
|
||||
{
|
||||
if (JSON_HEDLEY_UNLIKELY(!j.is_array())) {
|
||||
JSON_THROW(type_error::create(302, concat("type must be array, but is ", j.type_name()), &j));
|
||||
}
|
||||
|
||||
return from_json_inplace_array_impl(std::forward<BasicJsonType>(j), tag, make_index_sequence<N> {});
|
||||
return from_json_inplace_array_impl(std::forward<BasicJsonType>(j), tag, make_index_sequence<N>{});
|
||||
}
|
||||
|
||||
|
||||
template<typename BasicJsonType>
|
||||
inline void
|
||||
from_json(const BasicJsonType &j, typename BasicJsonType::binary_t &bin)
|
||||
@@ -5328,7 +5320,7 @@ std::tuple<Args...>
|
||||
from_json_tuple_impl(BasicJsonType &&j, identity_tag<std::tuple<Args...> > /*unused*/, priority_tag<2> /*unused*/)
|
||||
{
|
||||
return from_json_tuple_impl_base<BasicJsonType, Args...>(std::forward<BasicJsonType>(j),
|
||||
index_sequence_for < Args...> {});
|
||||
index_sequence_for<Args...>{});
|
||||
}
|
||||
|
||||
|
||||
@@ -5337,7 +5329,7 @@ inline void
|
||||
from_json_tuple_impl(BasicJsonType &&j, std::tuple<Args...> &t, priority_tag<3> /*unused*/)
|
||||
{
|
||||
t = from_json_tuple_impl_base<BasicJsonType, Args...>(std::forward<BasicJsonType>(j),
|
||||
index_sequence_for < Args...> {});
|
||||
index_sequence_for<Args...>{});
|
||||
}
|
||||
|
||||
|
||||
@@ -5356,11 +5348,8 @@ from_json(BasicJsonType &&j, TupleRelated &&t)
|
||||
|
||||
|
||||
template<typename BasicJsonType, typename Key, typename Value, typename Compare, typename Allocator,
|
||||
typename = enable_if_t<!std::is_constructible <
|
||||
typename BasicJsonType::string_t, Key>::value>
|
||||
|
||||
|
||||
>
|
||||
typename = enable_if_t<!std::is_constructible<
|
||||
typename BasicJsonType::string_t, Key>::value> >
|
||||
inline void
|
||||
from_json(const BasicJsonType &j, std::map<Key, Value, Compare, Allocator> &m)
|
||||
{
|
||||
@@ -5378,11 +5367,8 @@ from_json(const BasicJsonType &j, std::map<Key, Value, Compare, Allocator> &m)
|
||||
|
||||
|
||||
template<typename BasicJsonType, typename Key, typename Value, typename Hash, typename KeyEqual, typename Allocator,
|
||||
typename = enable_if_t<!std::is_constructible <
|
||||
typename BasicJsonType::string_t, Key>::value>
|
||||
|
||||
|
||||
>
|
||||
typename = enable_if_t<!std::is_constructible<
|
||||
typename BasicJsonType::string_t, Key>::value> >
|
||||
inline void
|
||||
from_json(const BasicJsonType &j, std::unordered_map<Key, Value, Hash, KeyEqual, Allocator> &m)
|
||||
{
|
||||
@@ -5407,13 +5393,13 @@ from_json(const BasicJsonType &j, std_fs::path &p)
|
||||
JSON_THROW(type_error::create(302, concat("type must be string, but is ", j.type_name()), &j));
|
||||
}
|
||||
const auto &s = *j.template get_ptr<const typename BasicJsonType::string_t *>();
|
||||
// Checking for C++20 standard or later can be insufficient in case the
|
||||
// library support for char8_t is either incomplete or was disabled
|
||||
// altogether. Use the __cpp_lib_char8_t feature test instead.
|
||||
// Checking for C++20 standard or later can be insufficient in case the
|
||||
// library support for char8_t is either incomplete or was disabled
|
||||
// altogether. Use the __cpp_lib_char8_t feature test instead.
|
||||
#if defined(__cpp_lib_char8_t) && (__cpp_lib_char8_t >= 201907L)
|
||||
p= std_fs::path (std::u8string_view(reinterpret_cast<const char8_t *>(s.data()), s.size()));
|
||||
p = std_fs::path(std::u8string_view(reinterpret_cast<const char8_t *>(s.data()), s.size()));
|
||||
#else
|
||||
p= std_fs::u8path (s); // accepts UTF-8 encoded std::string in C++17, deprecated in C++20
|
||||
p = std_fs::u8path(s); // accepts UTF-8 encoded std::string in C++17, deprecated in C++20
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
@@ -5437,6 +5423,7 @@ namespace // NOLINT(cert-dcl59-cpp,fuchsia-header-anon-namespaces,google-build-n
|
||||
{
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
JSON_INLINE_VARIABLE constexpr const auto &from_json = // NOLINT(misc-definitions-in-headers)
|
||||
detail::static_const<detail::from_json_fn>::value;
|
||||
@@ -5748,7 +5735,7 @@ class tuple_element<N, ::nlohmann::detail::iteration_proxy_value<IteratorType> >
|
||||
{
|
||||
public:
|
||||
using type = decltype(
|
||||
get < N > (std::declval<
|
||||
get<N>(std::declval<
|
||||
::nlohmann::detail::iteration_proxy_value<IteratorType> >()));
|
||||
};
|
||||
#if defined(__clang__)
|
||||
@@ -6043,11 +6030,8 @@ to_json(BasicJsonType &j, const BoolRef &b) noexcept
|
||||
|
||||
|
||||
template<typename BasicJsonType, typename CompatibleString,
|
||||
enable_if_t<std::is_constructible < typename BasicJsonType::string_t, CompatibleString>::value, int>
|
||||
|
||||
|
||||
=
|
||||
0
|
||||
enable_if_t<std::is_constructible<typename BasicJsonType::string_t, CompatibleString>::value, int> =
|
||||
0
|
||||
>
|
||||
inline void
|
||||
to_json(BasicJsonType &j, const CompatibleString &s)
|
||||
@@ -6122,13 +6106,10 @@ template<typename BasicJsonType, typename CompatibleArrayType,
|
||||
CompatibleArrayType>::value &&
|
||||
!is_compatible_object_type<BasicJsonType, CompatibleArrayType>::value &&
|
||||
!is_compatible_string_type<BasicJsonType, CompatibleArrayType>::value &&
|
||||
!std::is_same < typename BasicJsonType::binary_t, CompatibleArrayType>::value &&
|
||||
!std::is_same<typename BasicJsonType::binary_t, CompatibleArrayType>::value &&
|
||||
!is_basic_json<CompatibleArrayType>::value,
|
||||
int>
|
||||
|
||||
|
||||
=
|
||||
0
|
||||
int> =
|
||||
0
|
||||
>
|
||||
inline void
|
||||
to_json(BasicJsonType &j, const CompatibleArrayType &arr)
|
||||
@@ -6182,15 +6163,13 @@ to_json(BasicJsonType &j, typename BasicJsonType::object_t &&obj)
|
||||
|
||||
template<
|
||||
typename BasicJsonType, typename T, std::size_t N,
|
||||
enable_if_t<!std::is_constructible < typename BasicJsonType::string_t,
|
||||
enable_if_t<!std::is_constructible<typename BasicJsonType::string_t,
|
||||
const T(&)[N]>::value, // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays)
|
||||
int>
|
||||
|
||||
|
||||
=
|
||||
0
|
||||
int> =
|
||||
0
|
||||
>
|
||||
inline void to_json(BasicJsonType & j, const T(&arr)[N]) // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays)
|
||||
inline void
|
||||
to_json(BasicJsonType &j, const T (&arr)[N]) // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays)
|
||||
{
|
||||
external_constructor<value_t::array>::construct(j, arr);
|
||||
}
|
||||
@@ -6219,7 +6198,7 @@ template<typename BasicJsonType, typename Tuple, std::size_t... Idx>
|
||||
inline void
|
||||
to_json_tuple_impl(BasicJsonType &j, const Tuple &t, index_sequence<Idx...> /*unused*/)
|
||||
{
|
||||
j = {std::get < Idx > (t)...};
|
||||
j = {std::get<Idx>(t)...};
|
||||
}
|
||||
|
||||
|
||||
@@ -6236,9 +6215,8 @@ template<typename BasicJsonType, typename T, enable_if_t<is_constructible_tuple<
|
||||
inline void
|
||||
to_json(BasicJsonType &j, const T &t)
|
||||
{
|
||||
to_json_tuple_impl(j, t, make_index_sequence < std::tuple_size<T>::value > {}
|
||||
)
|
||||
;
|
||||
to_json_tuple_impl(j, t, make_index_sequence<std::tuple_size<T>::value>{}
|
||||
);
|
||||
}
|
||||
|
||||
#if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM
|
||||
@@ -6280,6 +6258,7 @@ namespace // NOLINT(cert-dcl59-cpp,fuchsia-header-anon-namespaces,google-build-n
|
||||
{
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
JSON_INLINE_VARIABLE constexpr const auto &to_json = // NOLINT(misc-definitions-in-headers)
|
||||
detail::static_const<detail::to_json_fn>::value;
|
||||
@@ -7015,14 +6994,14 @@ struct is_iterator_of_multibyte {
|
||||
};
|
||||
|
||||
template<typename IteratorType>
|
||||
struct iterator_input_adapter_factory<IteratorType, enable_if_t < is_iterator_of_multibyte<IteratorType>::value>
|
||||
>
|
||||
{
|
||||
struct iterator_input_adapter_factory<IteratorType, enable_if_t<is_iterator_of_multibyte<IteratorType>::value>
|
||||
> {
|
||||
using iterator_type = IteratorType;
|
||||
using char_type = typename std::iterator_traits<iterator_type>::value_type;
|
||||
using base_adapter_type = iterator_input_adapter<iterator_type>;
|
||||
using adapter_type = wide_string_input_adapter<base_adapter_type, char_type>;
|
||||
|
||||
|
||||
static adapter_type create(IteratorType first, IteratorType last)
|
||||
{
|
||||
return adapter_type(base_adapter_type(std::move(first), std::move(last)));
|
||||
@@ -7155,10 +7134,10 @@ public:
|
||||
|
||||
template<class IteratorType,
|
||||
typename std::enable_if<
|
||||
std::is_same < typename iterator_traits<IteratorType>::iterator_category,
|
||||
std::is_same<typename iterator_traits<IteratorType>::iterator_category,
|
||||
std::random_access_iterator_tag>::value,
|
||||
int>
|
||||
::type=
|
||||
::type =
|
||||
0
|
||||
>
|
||||
span_input_adapter(IteratorType first, IteratorType last)
|
||||
@@ -8594,7 +8573,7 @@ public:
|
||||
for (const auto c: token_string) {
|
||||
if (static_cast<unsigned char>(c) <= '\x1F') {
|
||||
// escape control characters
|
||||
std::array < char, 9 > cs{{}};
|
||||
std::array<char, 9> cs{{}};
|
||||
static_cast<void>((std::snprintf)(cs.data(), cs.size(), "<U+%.4X>", static_cast<unsigned char>(c))); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg)
|
||||
result += cs.data();
|
||||
} else {
|
||||
@@ -10240,7 +10219,7 @@ private:
|
||||
|
||||
default: // anything else is not supported (yet)
|
||||
{
|
||||
std::array < char, 3 > cr{{}};
|
||||
std::array<char, 3> cr{{}};
|
||||
static_cast<void>((std::snprintf)(cr.data(), cr.size(), "%.2hhX", static_cast<unsigned char>(element_type))); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg)
|
||||
const std::string cr_str{cr.data()};
|
||||
return sax->parse_error(element_type_parse_position, cr_str,
|
||||
@@ -12704,6 +12683,7 @@ private:
|
||||
} else {
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
auto *ptr = reinterpret_cast<std::uint8_t *>(&number);
|
||||
for (std::size_t i = 0; i < sz / 2; ++i) {
|
||||
@@ -12835,7 +12815,7 @@ private:
|
||||
*/
|
||||
std::string get_token_string() const
|
||||
{
|
||||
std::array < char, 3 > cr{{}};
|
||||
std::array<char, 3> cr{{}};
|
||||
static_cast<void>((std::snprintf)(cr.data(), cr.size(), "%.2hhX", static_cast<unsigned char>(current))); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg)
|
||||
return std::string{cr.data()};
|
||||
}
|
||||
@@ -13735,7 +13715,7 @@ class iter_impl // NOLINT(cppcoreguidelines-special-member-functions,hicpp-speci
|
||||
// superficial check for the LegacyBidirectionalIterator named requirement
|
||||
static_assert(std::is_base_of<std::bidirectional_iterator_tag, std::bidirectional_iterator_tag>::value
|
||||
&& std::is_base_of<std::bidirectional_iterator_tag,
|
||||
typename std::iterator_traits < typename array_t::iterator>::iterator_category > ::value,
|
||||
typename std::iterator_traits<typename array_t::iterator>::iterator_category>::value,
|
||||
"basic_json iterator assumes array and object type iterators satisfy the LegacyBidirectionalIterator named requirement.")
|
||||
;
|
||||
|
||||
@@ -15460,7 +15440,7 @@ public:
|
||||
|
||||
/// @brief 3-way compares two JSON pointers
|
||||
template<typename RefStringTypeRhs>
|
||||
std::strong_ordering operator<=>(const json_pointer<RefStringTypeRhs> &rhs) const noexcept // *NOPAD*
|
||||
std::strong_ordering operator<=>(const json_pointer<RefStringTypeRhs> &rhs) constnoexcept // *NOPAD*
|
||||
{
|
||||
return reference_tokens <=> rhs.reference_tokens; // *NOPAD*
|
||||
}
|
||||
@@ -19299,9 +19279,9 @@ private:
|
||||
int> = 0>
|
||||
void dump_integer(NumberType x)
|
||||
{
|
||||
static constexpr std::array<std::array < char, 2>
|
||||
static constexpr std::array<std::array<char, 2>
|
||||
,
|
||||
100 > digits_to_99
|
||||
100> digits_to_99
|
||||
{
|
||||
{
|
||||
{{'0', '0'}}, {{'0', '1'}}, {{'0', '2'}}, {{'0', '3'}}, {{'0', '4'}}, {{'0', '5'}},
|
||||
@@ -20577,6 +20557,7 @@ private:
|
||||
}));
|
||||
|
||||
|
||||
|
||||
}
|
||||
JSON_CATCH(...) {} // LCOV_EXCL_LINE
|
||||
#endif
|
||||
@@ -20698,12 +20679,11 @@ public:
|
||||
|
||||
/// @brief create a null object
|
||||
/// @sa https://json.nlohmann.me/api/basic_json/basic_json/
|
||||
basic_json (std::nullptr_t =
|
||||
basic_json(std::nullptr_t =
|
||||
nullptr
|
||||
)
|
||||
noexcept // NOLINT(bugprone-exception-escape)
|
||||
:
|
||||
basic_json (value_t::null)
|
||||
: basic_json(value_t::null)
|
||||
{
|
||||
assert_invariant();
|
||||
}
|
||||
@@ -23653,6 +23633,7 @@ public:
|
||||
{
|
||||
|
||||
|
||||
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wfloat-equal"
|
||||
@@ -23685,7 +23666,7 @@ public:
|
||||
|
||||
/// @brief comparison: 3-way
|
||||
/// @sa https://json.nlohmann.me/api/basic_json/operator_spaceship/
|
||||
std::partial_ordering operator<=>(const_reference rhs) const noexcept // *NOPAD*
|
||||
std::partial_ordering operator<=>(const_reference rhs) constnoexcept // *NOPAD*
|
||||
{
|
||||
const_reference lhs = *this;
|
||||
// default_result is used if we cannot compare values. In that case,
|
||||
@@ -23700,7 +23681,7 @@ public:
|
||||
/// @sa https://json.nlohmann.me/api/basic_json/operator_spaceship/
|
||||
template<typename ScalarType>
|
||||
requires std::is_scalar_v<ScalarType>
|
||||
std::partial_ordering operator<=>(ScalarType rhs) const noexcept // *NOPAD*
|
||||
std::partial_ordering operator<=>(ScalarType rhs) constnoexcept // *NOPAD*
|
||||
{
|
||||
return *this <=> basic_json(rhs); // *NOPAD*
|
||||
}
|
||||
@@ -25336,7 +25317,7 @@ operator"" _json(const char *s, std::size_t n)
|
||||
}
|
||||
|
||||
#if defined(__cpp_char8_t)
|
||||
JSON_HEDLEY_NON_NULL(1)
|
||||
JSON_HEDLEY_NON_NULL (1)
|
||||
inline nlohmann::json
|
||||
operator""_json(const char8_t *s, std::size_t n)
|
||||
{
|
||||
@@ -25401,7 +25382,7 @@ struct less<::nlohmann::detail::value_t>
|
||||
::nlohmann::detail::value_t rhs) const noexcept
|
||||
{
|
||||
#if JSON_HAS_THREE_WAY_COMPARISON
|
||||
return std::is_lt(lhs <=> rhs); // *NOPAD*
|
||||
return std::is_lt(lhs <= > rhs); // *NOPAD*
|
||||
#else
|
||||
return ::nlohmann::detail::operator<(lhs, rhs);
|
||||
#endif
|
||||
@@ -25416,8 +25397,8 @@ struct less<::nlohmann::detail::value_t>
|
||||
NLOHMANN_BASIC_JSON_TPL_DECLARATION
|
||||
inline void
|
||||
swap(nlohmann::NLOHMANN_BASIC_JSON_TPL &j1, nlohmann::NLOHMANN_BASIC_JSON_TPL &j2) noexcept( // NOLINT(readability-inconsistent-declaration-parameter-name, cert-dcl58-cpp)
|
||||
is_nothrow_move_constructible<nlohmann::NLOHMANN_BASIC_JSON_TPL>::value && // NOLINT(misc-redundant-expression,cppcoreguidelines-noexcept-swap,performance-noexcept-swap)
|
||||
is_nothrow_move_assignable<nlohmann::NLOHMANN_BASIC_JSON_TPL>::value)
|
||||
is_nothrow_move_constructible<nlohmann::NLOHMANN_BASIC_JSON_TPL >::value && // NOLINT(misc-redundant-expression,cppcoreguidelines-noexcept-swap,performance-noexcept-swap)
|
||||
is_nothrow_move_assignable<nlohmann::NLOHMANN_BASIC_JSON_TPL >::value)
|
||||
{
|
||||
j1.swap(j2);
|
||||
}
|
||||
|
||||
@@ -14,10 +14,11 @@
|
||||
#include "Diagnostic.h"
|
||||
|
||||
namespace kte::lsp {
|
||||
// Callback types (stubs for future phases)
|
||||
using CompletionCallback = std::function<void()>;
|
||||
using HoverCallback = std::function<void()>;
|
||||
using LocationCallback = std::function<void()>;
|
||||
// Callback types for initial language features
|
||||
// If error is non-empty, the result may be default-constructed/empty
|
||||
using CompletionCallback = std::function<void(const CompletionList & result, const std::string & error)>;
|
||||
using HoverCallback = std::function<void(const HoverResult & result, const std::string & error)>;
|
||||
using LocationCallback = std::function<void(const std::vector<Location> & result, const std::string & error)>;
|
||||
|
||||
class LspClient {
|
||||
public:
|
||||
@@ -39,7 +40,7 @@ public:
|
||||
|
||||
virtual void didSave(const std::string &uri) = 0;
|
||||
|
||||
// Language Features (not yet implemented)
|
||||
// Language Features (initial)
|
||||
virtual void completion(const std::string &, Position,
|
||||
CompletionCallback) {}
|
||||
|
||||
|
||||
@@ -371,7 +371,27 @@ LspManager::requestHover(Buffer *buffer, Position pos, HoverCallback callback)
|
||||
lsp_debug_file("hover pos convert: L%d C%d -> L%d C%d", pos.line, pos.character, p16.line,
|
||||
p16.character);
|
||||
}
|
||||
client->hover(uri, p16, std::move(callback));
|
||||
// Wrap the callback to convert any returned range from UTF-16 (wire) -> UTF-8 (editor)
|
||||
HoverCallback wrapped = [this, uri, provider, cb = std::move(callback)](const HoverResult &res16,
|
||||
const std::string &err) {
|
||||
if (!cb)
|
||||
return;
|
||||
if (!res16.range.has_value()) {
|
||||
cb(res16, err);
|
||||
return;
|
||||
}
|
||||
HoverResult res8 = res16;
|
||||
res8.range = toUtf8(uri, *res16.range, provider);
|
||||
if (debug_) {
|
||||
const auto &r16 = *res16.range;
|
||||
const auto &r8 = *res8.range;
|
||||
lsp_debug_file("hover range convert: L%d %d-%d -> L%d %d-%d",
|
||||
r16.start.line, r16.start.character, r16.end.character,
|
||||
r8.start.line, r8.start.character, r8.end.character);
|
||||
}
|
||||
cb(res8, err);
|
||||
};
|
||||
client->hover(uri, p16, std::move(wrapped));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -396,7 +416,29 @@ LspManager::requestDefinition(Buffer *buffer, Position pos, LocationCallback cal
|
||||
lsp_debug_file("definition pos convert: L%d C%d -> L%d C%d", pos.line, pos.character, p16.line,
|
||||
p16.character);
|
||||
}
|
||||
client->definition(uri, p16, std::move(callback));
|
||||
// Wrap callback to convert Location ranges from UTF-16 (wire) -> UTF-8 (editor)
|
||||
LocationCallback wrapped = [this, uri, provider, cb = std::move(callback)](
|
||||
const std::vector<Location> &locs16,
|
||||
const std::string &err) {
|
||||
if (!cb)
|
||||
return;
|
||||
std::vector<Location> locs8;
|
||||
locs8.reserve(locs16.size());
|
||||
for (const auto &l: locs16) {
|
||||
Location x = l;
|
||||
x.range = toUtf8(uri, l.range, provider);
|
||||
if (debug_) {
|
||||
lsp_debug_file("definition range convert: L%d %d-%d -> L%d %d-%d",
|
||||
l.range.start.line, l.range.start.character,
|
||||
l.range.end.character,
|
||||
x.range.start.line, x.range.start.character,
|
||||
x.range.end.character);
|
||||
}
|
||||
locs8.push_back(std::move(x));
|
||||
}
|
||||
cb(locs8, err);
|
||||
};
|
||||
client->definition(uri, p16, std::move(wrapped));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -483,6 +483,8 @@ LspProcessClient::handleIncoming(const std::string &json)
|
||||
const auto itParams = j.find("params");
|
||||
if (debug_ &&itParams
|
||||
|
||||
|
||||
|
||||
!=
|
||||
j.end() && itParams->is_object()
|
||||
)
|
||||
@@ -662,9 +664,46 @@ LspProcessClient::completion(const std::string &uri, Position pos, CompletionCal
|
||||
params["position"]["line"] = pos.line;
|
||||
params["position"]["character"] = pos.character;
|
||||
sendRequest("textDocument/completion", params,
|
||||
[cb = std::move(cb)](const nlohmann::json &/*result*/, const nlohmann::json * /*error*/) {
|
||||
[cb = std::move(cb)](const nlohmann::json &result, const nlohmann::json *error) {
|
||||
CompletionList out{};
|
||||
std::string err;
|
||||
if (error) {
|
||||
if (auto itMsg = error->find("message");
|
||||
itMsg != error->end() && itMsg->is_string())
|
||||
err = itMsg->get<std::string>();
|
||||
else
|
||||
err = "LSP error";
|
||||
} else {
|
||||
auto parseItem = [](const nlohmann::json &j) -> CompletionItem {
|
||||
CompletionItem it{};
|
||||
if (auto il = j.find("label"); il != j.end() && il->is_string())
|
||||
it.label = il->get<std::string>();
|
||||
if (auto idt = j.find("detail"); idt != j.end() && idt->is_string())
|
||||
it.detail = idt->get<std::string>();
|
||||
if (auto ins = j.find("insertText"); ins != j.end() && ins->is_string())
|
||||
it.insertText = ins->get<std::string>();
|
||||
return it;
|
||||
};
|
||||
if (result.is_array()) {
|
||||
for (const auto &ji: result) {
|
||||
if (ji.is_object())
|
||||
out.items.push_back(parseItem(ji));
|
||||
}
|
||||
} else if (result.is_object()) {
|
||||
if (auto ii = result.find("isIncomplete");
|
||||
ii != result.end() && ii->is_boolean())
|
||||
out.isIncomplete = ii->get<bool>();
|
||||
if (auto itms = result.find("items");
|
||||
itms != result.end() && itms->is_array()) {
|
||||
for (const auto &ji: *itms) {
|
||||
if (ji.is_object())
|
||||
out.items.push_back(parseItem(ji));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (cb)
|
||||
cb();
|
||||
cb(out, err);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -677,9 +716,67 @@ LspProcessClient::hover(const std::string &uri, Position pos, HoverCallback cb)
|
||||
params["position"]["line"] = pos.line;
|
||||
params["position"]["character"] = pos.character;
|
||||
sendRequest("textDocument/hover", params,
|
||||
[cb = std::move(cb)](const nlohmann::json &/*result*/, const nlohmann::json * /*error*/) {
|
||||
[cb = std::move(cb)](const nlohmann::json &result, const nlohmann::json *error) {
|
||||
HoverResult out{};
|
||||
std::string err;
|
||||
if (error) {
|
||||
if (auto itMsg = error->find("message");
|
||||
itMsg != error->end() && itMsg->is_string())
|
||||
err = itMsg->get<std::string>();
|
||||
else
|
||||
err = "LSP error";
|
||||
} else if (!result.is_null()) {
|
||||
auto appendText = [&](const std::string &s) {
|
||||
if (!out.contents.empty())
|
||||
out.contents.push_back('\n');
|
||||
out.contents += s;
|
||||
};
|
||||
if (result.is_object()) {
|
||||
if (auto itC = result.find("contents"); itC != result.end()) {
|
||||
if (itC->is_string()) {
|
||||
appendText(itC->get<std::string>());
|
||||
} else if (itC->is_object()) {
|
||||
if (auto itV = itC->find("value");
|
||||
itV != itC->end() && itV->is_string())
|
||||
appendText(itV->get<std::string>());
|
||||
} else if (itC->is_array()) {
|
||||
for (const auto &el: *itC) {
|
||||
if (el.is_string())
|
||||
appendText(el.get<std::string>());
|
||||
else if (el.is_object()) {
|
||||
if (auto itV = el.find("value");
|
||||
itV != el.end() && itV->is_string())
|
||||
appendText(itV->get<std::string>());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (auto itR = result.find("range");
|
||||
itR != result.end() && itR->is_object()) {
|
||||
Range r{};
|
||||
if (auto s = itR->find("start");
|
||||
s != itR->end() && s->is_object()) {
|
||||
if (auto il = s->find("line");
|
||||
il != s->end() && il->is_number_integer())
|
||||
r.start.line = *il;
|
||||
if (auto ic = s->find("character");
|
||||
ic != s->end() && ic->is_number_integer())
|
||||
r.start.character = *ic;
|
||||
}
|
||||
if (auto e = itR->find("end"); e != itR->end() && e->is_object()) {
|
||||
if (auto il = e->find("line");
|
||||
il != e->end() && il->is_number_integer())
|
||||
r.end.line = *il;
|
||||
if (auto ic = e->find("character");
|
||||
ic != e->end() && ic->is_number_integer())
|
||||
r.end.character = *ic;
|
||||
}
|
||||
out.range = r;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (cb)
|
||||
cb();
|
||||
cb(out, err);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -692,9 +789,77 @@ LspProcessClient::definition(const std::string &uri, Position pos, LocationCallb
|
||||
params["position"]["line"] = pos.line;
|
||||
params["position"]["character"] = pos.character;
|
||||
sendRequest("textDocument/definition", params,
|
||||
[cb = std::move(cb)](const nlohmann::json &/*result*/, const nlohmann::json * /*error*/) {
|
||||
[cb = std::move(cb)](const nlohmann::json &result, const nlohmann::json *error) {
|
||||
std::vector<Location> out;
|
||||
std::string err;
|
||||
auto parseRange = [](const nlohmann::json &jr) -> Range {
|
||||
Range r{};
|
||||
if (!jr.is_object())
|
||||
return r;
|
||||
if (auto s = jr.find("start"); s != jr.end() && s->is_object()) {
|
||||
if (auto il = s->find("line"); il != s->end() && il->is_number_integer())
|
||||
r.start.line = *il;
|
||||
if (auto ic = s->find("character");
|
||||
ic != s->end() && ic->is_number_integer())
|
||||
r.start.character = *ic;
|
||||
}
|
||||
if (auto e = jr.find("end"); e != jr.end() && e->is_object()) {
|
||||
if (auto il = e->find("line"); il != e->end() && il->is_number_integer())
|
||||
r.end.line = *il;
|
||||
if (auto ic = e->find("character");
|
||||
ic != e->end() && e->is_number_integer())
|
||||
r.end.character = *ic;
|
||||
}
|
||||
return r;
|
||||
};
|
||||
auto pushLocObj = [&](const nlohmann::json &jo) {
|
||||
Location loc{};
|
||||
if (auto iu = jo.find("uri"); iu != jo.end() && iu->is_string())
|
||||
loc.uri = iu->get<std::string>();
|
||||
if (auto ir = jo.find("range"); ir != jo.end())
|
||||
loc.range = parseRange(*ir);
|
||||
out.push_back(std::move(loc));
|
||||
};
|
||||
if (error) {
|
||||
if (auto itMsg = error->find("message");
|
||||
itMsg != error->end() && itMsg->is_string())
|
||||
err = itMsg->get<std::string>();
|
||||
else
|
||||
err = "LSP error";
|
||||
} else if (!result.is_null()) {
|
||||
if (result.is_object()) {
|
||||
if (result.contains("uri") && result.contains("range")) {
|
||||
pushLocObj(result);
|
||||
} else if (result.contains("targetUri")) {
|
||||
Location loc{};
|
||||
if (auto tu = result.find("targetUri");
|
||||
tu != result.end() && tu->is_string())
|
||||
loc.uri = tu->get<std::string>();
|
||||
if (auto tr = result.find("targetRange"); tr != result.end())
|
||||
loc.range = parseRange(*tr);
|
||||
out.push_back(std::move(loc));
|
||||
}
|
||||
} else if (result.is_array()) {
|
||||
for (const auto &el: result) {
|
||||
if (el.is_object()) {
|
||||
if (el.contains("uri")) {
|
||||
pushLocObj(el);
|
||||
} else if (el.contains("targetUri")) {
|
||||
Location loc{};
|
||||
if (auto tu = el.find("targetUri");
|
||||
tu != el.end() && tu->is_string())
|
||||
loc.uri = tu->get<std::string>();
|
||||
if (auto tr = el.find("targetRange");
|
||||
tr != el.end())
|
||||
loc.range = parseRange(*tr);
|
||||
out.push_back(std::move(loc));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (cb)
|
||||
cb();
|
||||
cb(out, err);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,28 @@ struct TextDocumentContentChangeEvent {
|
||||
std::optional<Range> range; // if not set, represents full document change
|
||||
std::string text; // new text for the given range
|
||||
};
|
||||
|
||||
// Minimal feature result types for phase 1
|
||||
struct CompletionItem {
|
||||
std::string label;
|
||||
std::optional<std::string> detail; // optional extra info
|
||||
std::optional<std::string> insertText; // if present, use instead of label
|
||||
};
|
||||
|
||||
struct CompletionList {
|
||||
bool isIncomplete = false;
|
||||
std::vector<CompletionItem> items;
|
||||
};
|
||||
|
||||
struct HoverResult {
|
||||
std::string contents; // concatenated plaintext/markdown for now
|
||||
std::optional<Range> range; // optional range
|
||||
};
|
||||
|
||||
struct Location {
|
||||
std::string uri;
|
||||
Range range;
|
||||
};
|
||||
} // namespace kte::lsp
|
||||
|
||||
#endif // KTE_LSP_TYPES_H
|
||||
24
main.cc
24
main.cc
@@ -30,6 +30,7 @@ PrintUsage(const char *prog)
|
||||
std::cerr << "Usage: " << prog << " [OPTIONS] [files]\n"
|
||||
<< "Options:\n"
|
||||
<< " -c, --chdir DIR Change working directory before opening files\n"
|
||||
<< " -d, --debug Enable LSP debug logging\n"
|
||||
<< " -g, --gui Use GUI frontend (if built)\n"
|
||||
<< " -t, --term Use terminal (ncurses) frontend [default]\n"
|
||||
<< " -h, --help Show this help and exit\n"
|
||||
@@ -43,11 +44,6 @@ main(const int argc, const char *argv[])
|
||||
Editor editor;
|
||||
// Wire up LSP manager (no diagnostic UI yet; frontends may provide later)
|
||||
kte::lsp::LspManager lspMgr(&editor, nullptr);
|
||||
// Enable LSP debug logging if KTE_LSP_DEBUG is set
|
||||
if (const char *dbg = std::getenv("KTE_LSP_DEBUG"); dbg && *dbg) {
|
||||
lspMgr.setDebugLogging(true);
|
||||
std::fprintf(stderr, "[kte][lsp] debug logging enabled via KTE_LSP_DEBUG\n");
|
||||
}
|
||||
editor.SetLspManager(&lspMgr);
|
||||
|
||||
// CLI parsing using getopt_long
|
||||
@@ -55,11 +51,13 @@ main(const int argc, const char *argv[])
|
||||
bool req_term = false;
|
||||
bool show_help = false;
|
||||
bool show_version = false;
|
||||
bool lsp_debug = false;
|
||||
|
||||
std::string nwd;
|
||||
|
||||
static struct option long_opts[] = {
|
||||
{"chdir", required_argument, nullptr, 'c'},
|
||||
{"debug", no_argument, nullptr, 'd'},
|
||||
{"gui", no_argument, nullptr, 'g'},
|
||||
{"term", no_argument, nullptr, 't'},
|
||||
{"help", no_argument, nullptr, 'h'},
|
||||
@@ -69,11 +67,14 @@ main(const int argc, const char *argv[])
|
||||
|
||||
int opt;
|
||||
int long_index = 0;
|
||||
while ((opt = getopt_long(argc, const_cast<char *const *>(argv), "c:gthV", long_opts, &long_index)) != -1) {
|
||||
while ((opt = getopt_long(argc, const_cast<char *const *>(argv), "c:dgthV", long_opts, &long_index)) != -1) {
|
||||
switch (opt) {
|
||||
case 'c':
|
||||
nwd = optarg;
|
||||
break;
|
||||
case 'd':
|
||||
lsp_debug = true;
|
||||
break;
|
||||
case 'g':
|
||||
req_gui = true;
|
||||
break;
|
||||
@@ -106,6 +107,16 @@ main(const int argc, const char *argv[])
|
||||
(void) req_term; // suppress unused warning when GUI is not compiled in
|
||||
#endif
|
||||
|
||||
// Apply LSP debug setting strictly based on -d flag
|
||||
lspMgr.setDebugLogging(lsp_debug);
|
||||
if (lsp_debug) {
|
||||
// Ensure LSP subprocess client picks up debug via environment
|
||||
::setenv("KTE_LSP_DEBUG", "1", 1);
|
||||
} else {
|
||||
// Prevent environment from enabling debug implicitly
|
||||
::unsetenv("KTE_LSP_DEBUG");
|
||||
}
|
||||
|
||||
// Determine frontend
|
||||
#if !defined(KTE_BUILD_GUI)
|
||||
if (req_gui) {
|
||||
@@ -122,6 +133,7 @@ main(const int argc, const char *argv[])
|
||||
} else {
|
||||
|
||||
|
||||
|
||||
// Default depends on build target: kge defaults to GUI, kte to terminal
|
||||
#if defined(KTE_DEFAULT_GUI)
|
||||
use_gui = true;
|
||||
|
||||
Reference in New Issue
Block a user