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

Function diagnose_file

CodeFormatLib/src/CodeFormatLib.cpp:410–441  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

408}
409
410int diagnose_file(lua_State *L) {
411 int top = lua_gettop(L);
412
413 if (top < 2) {
414 return 0;
415 }
416
417 if (lua_isstring(L, 1) && lua_isstring(L, 2)) {
418 try {
419 std::string filename = lua_tostring(L, 1);
420 std::string text = lua_tostring(L, 2);
421 auto diagnosticResult = LuaCodeFormat::GetInstance().Diagnostic(filename, std::move(text));
422 if (diagnosticResult.Type == ResultType::Err) {
423 lua_pushboolean(L, false);
424 return 1;
425 }
426
427 auto &diagnostics = diagnosticResult.Data;
428 lua_pushboolean(L, true);
429 PushDiagnosticToLua(L, diagnostics);
430
431 return 2;
432 } catch (std::exception &e) {
433 std::string err = e.what();
434 lua_settop(L, top);
435 lua_pushboolean(L, false);
436 lua_pushlstring(L, err.c_str(), err.size());
437 return 2;
438 }
439 }
440 return 0;
441}
442
443int set_default_config(lua_State *L) {
444 int top = lua_gettop(L);

Callers

nothing calls this directly

Calls 9

lua_gettopFunction · 0.85
lua_isstringFunction · 0.85
lua_pushbooleanFunction · 0.85
PushDiagnosticToLuaFunction · 0.85
lua_settopFunction · 0.85
lua_pushlstringFunction · 0.85
DiagnosticMethod · 0.45
whatMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected