MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / PushDiagnosticToLua

Function PushDiagnosticToLua

CodeFormatLib/src/CodeFormatLib.cpp:344–408  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

342}
343
344void PushDiagnosticToLua(lua_State *L, std::vector<LuaDiagnosticInfo> &diagnosticInfos) {
345 int count = 1;
346 lua_newtable(L);
347 for (auto &diagnosticInfo: diagnosticInfos) {
348 // 诊断信息表
349 lua_newtable(L);
350
351 //message
352 {
353 lua_pushstring(L, "message");
354 lua_pushlstring(L, diagnosticInfo.Message.c_str(), diagnosticInfo.Message.size());
355 lua_rawset(L, -3);
356
357 lua_pushstring(L, "type");
358 lua_pushstring(L, GetDiagnosisString(diagnosticInfo.Type).c_str());
359 lua_rawset(L, -3);
360
361 // data
362 if (!diagnosticInfo.Data.empty()) {
363 lua_pushstring(L, "data");
364 lua_pushlstring(L, diagnosticInfo.Data.c_str(), diagnosticInfo.Data.size());
365 lua_rawset(L, -3);
366 }
367 }
368
369 // range
370 {
371 lua_pushstring(L, "range");
372 //range table
373 lua_newtable(L);
374
375 lua_pushstring(L, "start");
376 // start table
377 lua_newtable(L);
378 lua_pushstring(L, "line");
379 lua_pushinteger(L, diagnosticInfo.Start.Line);
380 lua_rawset(L, -3);
381
382 lua_pushstring(L, "character");
383 lua_pushinteger(L, diagnosticInfo.Start.Col);
384 lua_rawset(L, -3);
385
386 lua_rawset(L, -3);// set start = {}
387
388 lua_pushstring(L, "end");
389 // end table
390 lua_newtable(L);
391 lua_pushstring(L, "line");
392 lua_pushinteger(L, diagnosticInfo.End.Line);
393 lua_rawset(L, -3);
394
395 lua_pushstring(L, "character");
396 lua_pushinteger(L, diagnosticInfo.End.Col);
397 lua_rawset(L, -3);
398
399 lua_rawset(L, -3);// set end = {}
400
401 lua_rawset(L, -3);// set range = {}

Callers 3

diagnose_fileFunction · 0.85
spell_analysisFunction · 0.85
name_style_analysisFunction · 0.85

Calls 8

lua_pushstringFunction · 0.85
lua_pushlstringFunction · 0.85
lua_rawsetFunction · 0.85
GetDiagnosisStringFunction · 0.85
lua_pushintegerFunction · 0.85
lua_rawsetiFunction · 0.85
sizeMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected