-
Notifications
You must be signed in to change notification settings - Fork 31
update #539
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
update #539
Conversation
Is this really a good idea? Seems like all locations should be returned. Perhaps you can sort the results instead? |
So I sorted the The compromise is that if there is a matching |
Alternatively, we can enable this behavior when the number of declarations exceeds a specified threshold. This behavior is enabled because, in practice, some functions may have a large number of declarations with the same name. A typical example is |
In the example: ---@class T
---@field func fun(a:Goto1) # 1
---@field func fun(a:Goto2) # 2
---@field func fun(a:Goto3) # 3
local T = {}
function T:func(a)
end
---@type T
local t
t.func(Goto1)
t.fu<??>nc(Goto2)
t.func(Goto3) I would expect the locations returned would be the function definition and the matching However if the argument type isn't known (e.g. is |
The current behavior of jumping to definition is similar, but it's important to note that if the actual definition is inherited from a parent class, it will not appear here. Regarding definitions inherited from parent classes, I've observed that |
When defining classes, so far I mostly inherit from abstract classes, and not from any that implements definitions. What is the most standard way to do that in Lua? I assume the subclass definition would need to explicitly call the parent class? If so then it's probably ok to not go to the parent definition. I'm not sure though. |
d090a84
to
54ff123
Compare
crates/emmylua_code_analysis/src/compilation/analyzer/doc/type_def_tags.rs
Outdated
Show resolved
Hide resolved
@lewis6991 |
Usually something like: --- @class Class
local Class = {}
Class.__index = Class
function Class:method()
end
function Class.new(arg1, arg2)
return setmetatable({
arg1 = arg1,
arg2 = arg2,
}, Class)
end We don't have any formats for classes that inherit other classes because I don't know how to do it. |
Generally speaking, it is achieved through several specific functions to centralize definition and instantiation. Then this feature is not useful to you; currently, it only provides hints when ---@overload is present. |
```lua -- test.lua local function test() end return { test = test, } ``` ```lua local t = require("test") local test = t.test -- 找到 test = test, test() -- 找到 local function test() ```
导入模块的返回值是类定义时使用类名, 其他则使用文件名
```lua local export = {} ---@enum MapName export.MapName = { A = 1, B = 2, } return export ``` ```lua mapn -- 自动完成会提示导入 ```
No description provided.