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

Function spell_analysis

CodeFormatLib/src/CodeFormatLib.cpp:570–613  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

568}
569
570int spell_analysis(lua_State *L) {
571 int top = lua_gettop(L);
572
573 if (top < 2) {
574 return 0;
575 }
576
577 if (lua_isstring(L, 1) && lua_isstring(L, 2)) {
578 try {
579 std::string filename = lua_tostring(L, 1);
580 std::string text = lua_tostring(L, 2);
581
582 CodeSpellChecker::CustomDictionary tempDict;
583
584 if (top == 3 && lua_istable(L, 3)) {
585 lua_pushnil(L);
586 while (lua_next(L, -2) != 0) {
587 auto value = luaToString(L, -1);
588 tempDict.insert(value);
589 lua_pop(L, 1);
590 }
591 }
592
593 auto spellResult = LuaCodeFormat::GetInstance().SpellCheck(filename, std::move(text), tempDict);
594 if (spellResult.Type == ResultType::Err) {
595 lua_pushboolean(L, false);
596 return 1;
597 }
598
599 auto &diagnostics = spellResult.Data;
600 lua_pushboolean(L, true);
601 PushDiagnosticToLua(L, diagnostics);
602
603 return 2;
604 } catch (std::exception &e) {
605 std::string err = e.what();
606 lua_settop(L, top);
607 lua_pushboolean(L, false);
608 lua_pushlstring(L, err.c_str(), err.size());
609 return 2;
610 }
611 }
612 return 0;
613}
614
615InfoNode CreateFromLua(InfoTree &t, lua_State *L) {
616 if (lua_istable(L, -1)) {

Callers

nothing calls this directly

Calls 13

lua_gettopFunction · 0.85
lua_isstringFunction · 0.85
lua_pushnilFunction · 0.85
lua_nextFunction · 0.85
luaToStringFunction · 0.85
lua_pushbooleanFunction · 0.85
PushDiagnosticToLuaFunction · 0.85
lua_settopFunction · 0.85
lua_pushlstringFunction · 0.85
insertMethod · 0.45
SpellCheckMethod · 0.45
whatMethod · 0.45

Tested by

no test coverage detected