| 304 | } |
| 305 | |
| 306 | int update_config(lua_State *L) { |
| 307 | int top = lua_gettop(L); |
| 308 | |
| 309 | if (top < 3) { |
| 310 | return 0; |
| 311 | } |
| 312 | |
| 313 | if (lua_isinteger(L, 1) && lua_isstring(L, 2) && lua_isstring(L, 3)) { |
| 314 | try { |
| 315 | auto type = static_cast<UpdateType>(lua_tointeger(L, 1)); |
| 316 | std::string workspaceUri = lua_tostring(L, 2); |
| 317 | std::string configPath = lua_tostring(L, 3); |
| 318 | switch (type) { |
| 319 | case UpdateType::Created: |
| 320 | case UpdateType::Changed: { |
| 321 | LuaCodeFormat::GetInstance().UpdateCodeStyle(workspaceUri, configPath); |
| 322 | break; |
| 323 | } |
| 324 | case UpdateType::Deleted: { |
| 325 | LuaCodeFormat::GetInstance().RemoveCodeStyle(workspaceUri); |
| 326 | break; |
| 327 | } |
| 328 | } |
| 329 | |
| 330 | lua_pushboolean(L, true); |
| 331 | return 1; |
| 332 | } catch (std::exception &e) { |
| 333 | std::string err = e.what(); |
| 334 | lua_settop(L, top); |
| 335 | lua_pushboolean(L, false); |
| 336 | lua_pushlstring(L, err.c_str(), err.size()); |
| 337 | return 2; |
| 338 | } |
| 339 | } |
| 340 | |
| 341 | return 0; |
| 342 | } |
| 343 | |
| 344 | void PushDiagnosticToLua(lua_State *L, std::vector<LuaDiagnosticInfo> &diagnosticInfos) { |
| 345 | int count = 1; |
nothing calls this directly
no test coverage detected