Closed jjvbsag closed 1 year ago
@jjvbsag, the checker is cached, but the cache is interpreter-specific:
and "luacheck" .. (ide:GetInterpreter():GetFileName() or "")
When the interpreter is changed, is should run create_checker()
again; does this not happen for you (it does happen for me)?
:-) But: The interpreter in the projects is all the same, just the target runtime and available lua libs (on embedded arm-hosts) differ from project to project. And I want luacheck to verify, only existing functions are called.
Are you saying that the cache should also check for Project path? That may work. Can you try this patch:
diff --git a/src/editor/inspect.lua b/src/editor/inspect.lua
index 76e95e29..f0a6a9ec 100644
--- a/src/editor/inspect.lua
+++ b/src/editor/inspect.lua
@@ -280,7 +280,7 @@ local checkers = {}
local function warnings_from_string(...)
local checktype = (ide.config.staticanalyzer.luacheck
-- luacheck globals depend on the interpreter, so create different checkers if needed
- and "luacheck" .. (ide:GetInterpreter():GetFileName() or "")
+ and "luacheck" .. (ide:GetInterpreter():GetFileName() or "") .. (ide:GetProject() or "")
or "luainspect")
if not checkers[checktype] then checkers[checktype] = create_checker() end
return checkers[checktype](...)
@pkulchenko : Did not help in my special case (well at least it doesnt crash ZBS :smiley: ). But this may also be my fault, because I load the luacheck options inside (project specific) Package:onProjectLoad()
using
local path=self.fpath:match("(.*[\\/])").."luacheck-options.lua"
local luacheck_options=dofile(path)
ide.config.staticanalyzer.luacheck={options=luacheck_options}
do you see any conflicts with this code?
The patch is not going to help in your case, but that's a quite special case, so I'm not sure if it needs to be handled. I guess, you'll have to reload your settings from OnProjectLoad
and OnInterpreterLoad
events. It will then detect the change with this patch in place (as long as you update ide.config.staticanalyzer.luacheck
values).
BTW, it should work with staticanalyzer.luacheck={options=luacheck_options}
, as you shouldn't need to specify ide.config
prefix (as far as I remember).
@pkulchenko Ok, I wasn't aware of the OnInterpreterLoad
event. I will try.
As it is really a special case and I assume not relevant for anybody else, I will close this issue.
Thank you for your support.
@jjvbsag, your case may be quite specific, but I still think that adding .. (ide:GetProject() or "")
may be worth it.
Can you tell me what exactly you do? I'm curious why switching the project is not detected even when you add the patch shown above. It should reset the value if either the interpreter or the project changed, which is what happens in your case, right?
@pkulchenko Yes, I also believe ide:GetProject() does not harm.
To be honest, I'm still fighting with luacheck to be verbose with relevant errors and shut up with nonerelevant. In our embedded project there are a lot of preloaded modules, which define either global objects with lot of methods and also a bunch of globally available functions. Now I try to prepare luacheck options to know all of them, which is a hassle. But in the meantime I managed to use luacheck with my luacheck-options.lua module from shell, so turnaround-time by Close-ZBS, Reopen-ZBS is not an issue any more.
Once more, thanks for your support.
@jjvbsag, BTW, there is ID.RESTART
item that can be associated with a shortcut or a toolbar/menu item to add a one-click IDE reload. It should save the configuration and unsaved editor tabs as well.
I use https://github.com/pkulchenko/ZeroBranePackage/blob/master/projectsettings.lua to have different settings for different project. Now I wanted to use
staticanalyzer.luacheck = {options = {...}}
do define project specific globals and conditions.But the checker is cached in ZeroBraneStudio/src/editor/inspect.lua line 279 fff
and then never updated again, if the project is changed. I always have to restart zbs