-
-
Notifications
You must be signed in to change notification settings - Fork 33
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
Unknown references through addon namespaces #31
Comments
This is indeed a pretty glaring issue. The addon namespace appears to be properly supported by IntelliJ EmmyLua but not in Sumneko's implementation. As in you can only define it once with file1.lua ---@class ns
local _, ns = ...
ns.test = "banana" file2.lua ---@type ns
local _, ns = ...
ns.hello = "world" file3.lua ---@type ns
local _, ns = ...
print(ns.test)
print(ns.hello) I will need to make an issue for Sumneko to support this behavior. |
Thanks for looking into it & for letting Sumneko know! |
I'll paste the solution Sumneko gave: using
---@class ns
local _, ns = ...
ns.foo = "bar"
---@class ns
local _, ns = ...
ns.fruit = "banana" |
Edit:
@Ketho I see you've closed the issue while I was writing up this reply. When you got the time, could you please take a look at my write-up below since I can't seem to be able to get it working again for me with my code. 😁 Glad to see there's a solution, but I have to follow up on Sumneko's response with a question here: File 1: --Addon identifier name, namespace table
local addonNameSpace, ns = ...
--Version string
ns.WidgetToolsVersion = "1.4"
--Global WidgetTools table containing toolbox subtables for each respective WidgetTools version (WidgetToolbox["version_string"])
if not WidgetToolbox then WidgetToolbox = {} end
--Create the global reference subtable for the current version
if not WidgetToolbox[ns.WidgetToolsVersion] then
--Create Toolbox
WidgetToolbox[ns.WidgetToolsVersion] = {}
---Dump an object and its contents to the in-game chat
---@param object any Object to dump out
WidgetToolbox[ns.WidgetToolsVersion].Dump = function(object)
--Stuff..
end
--More stuff..
end File 2: --Addon name, namespace
local addonNameSpace, ns = ...
local _, addon = GetAddOnInfo(addonNameSpace)
--WidgetTools reference
local wt = WidgetToolbox[ns.WidgetToolsVersion]
wt.Dump() As is, wt.Dump() is unknown. I don't quite know how to get the annotations from Dump's definition from one file to the other through the subtable at the version key within the global table. By adding File 1: ---Create Toolbox
---@class WidgetToolbox
---@field Dump function (Even if I put something here, it doesn't show - but I'd want the details annotations to appear including @param, @return and more)
WidgetToolbox[ns.WidgetToolsVersion] = {} File 2: ---WidgetTools reference
---@class WidgetToolbox
local wt = WidgetToolbox[ns.WidgetToolsVersion] Previously, in Sumneko's Lua version 2.6.8, I'd see this (even without having any I could just revert to 2.6.8 and continue using that, but what my question is, how could I restore this functionality for the structure I built? (It might be overengineered but I have good reasons to have built the toolbox like this and it's been working for me quite well.) |
I honestly have no idea, this is way over my head. That would be a question for Sumneko, and I suppose you would have to keep using 2.6.8 otherwise. |
Hey!
I'm communicating between different files of my addons through the provided addon namespaces. Previously, annotations and references were pulled through the namespace so I could Ctrl+click to jump to a function shared in the namespace from one file to another or I could see the EmmyLua annotation on a function defined in another file for instance.
More specifically, I use a global table shared between addons, which contains subtables with version keys. A specific key is shared in the addon namespace so all files of the addon can access the specific subtable of that global table with that key (if multiple addons are on the same version, they can access the same subtable with the identical key - that's the idea in a nutshell).
Now, this functionality is broken. I'm not sure if it was broken by the main Lua extension of sumneko or WoW API specifically.
Example:
Code in file 1:
Code in file 2:
Annotation and jump to definition doesn't work when it's through the namespace table:
Annotation and jump to definition does work when it's global (as it did previously with the namespace as well):
It might be related to this issue, I'm not sure: #28 (comment)
The text was updated successfully, but these errors were encountered: