Tencent / LuaHelper

LuaHelper is a High-performance lua VSCode plugin, Language Server Protocol for lua.
Other
617 stars 93 forks source link

关于一个单例类方法跳转的问题 #116

Open 1156022152 opened 2 years ago

1156022152 commented 2 years ago

单例类内部这样定义:XXXData.Instance = self 外部调用:XXXData.Instance:GetRoleLv() 期望是跳转到 GetRoleLv() 方法定义处,但实际总是会跳转到 Instance 定义处。

wyqcghs commented 1 year ago

加上---@type 注解就能解决这个问题

1156022152 commented 1 year ago

在方法定义前一行加 ---@type XXXData 似乎无效

wyqcghs commented 1 year ago

在方法定义前一行加 ---@type XXXData 似乎无效

建议先看一下 注解功能 的相关文档 https://github.com/Tencent/LuaHelper/blob/master/docs/manual/annotate.md

wyqcghs commented 1 year ago

在方法定义前一行加 ---@type XXXData 似乎无效

建议先看一下 注解功能 的相关文档 https://github.com/Tencent/LuaHelper/blob/master/docs/manual/annotate.md

先用 ---@class 注解标记 xxxData 再用 ---@type 注解把 xxxData.Instance 标记为对应的类型就可以了。

1156022152 commented 1 year ago

在方法定义前一行加 ---@type XXXData 似乎无效

建议先看一下 注解功能 的相关文档 https://github.com/Tencent/LuaHelper/blob/master/docs/manual/annotate.md

先用 ---@Class 注解标记 xxxData 再用 ---@type 注解把 xxxData.Instance 标记为对应的类型就可以了。 ok

1156022152 commented 1 year ago

在方法定义前一行加 ---@type XXXData 似乎无效

建议先看一下 注解功能 的相关文档 https://github.com/Tencent/LuaHelper/blob/master/docs/manual/annotate.md

先用 ---@Class 注解标记 xxxData 再用 ---@type 注解把 xxxData.Instance 标记为对应的类型就可以了。

---@class XXXData ---@type XXXData.Instance @property typy XXXData.Instance:GetRoleLv() 这样标记还是跳不到GetRoleLv定义的地方

wyqcghs commented 1 year ago

在方法定义前一行加 ---@type XXXData 似乎无效

建议先看一下 注解功能 的相关文档 https://github.com/Tencent/LuaHelper/blob/master/docs/manual/annotate.md

先用 ---@Class 注解标记 xxxData 再用 ---@type 注解把 xxxData.Instance 标记为对应的类型就可以了。

---@Class XXXData ---@type XXXData.Instance @Property typy XXXData.Instance:GetRoleLv() 这样标记还是跳不到GetRoleLv定义的地方

能贴一下你是怎么使用的吗?或者提供一个示例代码文件?我这样使用是可以正常跳转的

1156022152 commented 1 year ago

在方法定义前一行加 ---@type XXXData 似乎无效

建议先看一下 注解功能 的相关文档 https://github.com/Tencent/LuaHelper/blob/master/docs/manual/annotate.md

先用 ---@Class 注解标记 xxxData 再用 ---@type 注解把 xxxData.Instance 标记为对应的类型就可以了。

---@Class XXXData ---@type XXXData.Instance @Property typy XXXData.Instance:GetRoleLv() 这样标记还是跳不到GetRoleLv定义的地方

能贴一下你是怎么使用的吗?或者提供一个示例代码文件?我这样使用是可以正常跳转的

好,晚一些我弄一个示例文件,因为是内网暂时不太方便,谢谢解答