-
-
Notifications
You must be signed in to change notification settings - Fork 387
[Feature] Add action to autorequire undefined globals #2177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
See |
Improved eq error message in test/code_action/init.lua Uses core.diagnostics.undefined-global
|
I added a testcase, and used the I also don't use diagnostic messages anymore to determine if a global is undefined, so that I can add the The undefined-global function is marked as async, but the code-action function is not. Can I safely add a |
Greate, thank you!
There is currently no such function. You can do the following:
---@class vm.node
---@field package _undefined_global? boolean
function api.isUndefinedGlobal(src)
local node = vm.compileNode(src)
if node._undefined_global == nil then
node._undefined_global = checkIsUndefinedGlobal(src)
end
return node._undefined_global
end
Yes, all code is executed within a coroutine during testing. (Translated by ChatGPT) |
|
I've moved the undefined global check into |
Resolve member naming
|
Fixed formatting (I dont know how that happened) |
|
Nice work, thank you! |
I attempted to implement #1938.

This is how it looks in action:
How to make this less of a hack?
lua-language-server/script/core/code-action.lua
Lines 730 to 739 in 62d4d35
How to add tests? I suppose they should go somewhere here:
lua-language-server/test/code_action/init.lua
Line 158 in 62d4d35
But how do I create the stubs for other modules?